aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickdroparea.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-05-22 18:14:32 +0200
committerUlf Hermann <ulf.hermann@qt.io>2019-05-27 11:09:26 +0200
commit8733a8762c2db473d3a39d1f01c09156c04e3772 (patch)
tree751a8a376e3f8a298aea0d068f2197055f1c1e2f /src/quick/items/qquickdroparea.cpp
parent7d98307788dfe12d56a660df29c4451534e20f3c (diff)
QQuickDropArea: Use QRegularExpression rather than QRegExp
Task-number: QTBUG-72588 Change-Id: I943ada1bcf21b4affdd55a95e90be13d2a5bb454 Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/items/qquickdroparea.cpp')
-rw-r--r--src/quick/items/qquickdroparea.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/quick/items/qquickdroparea.cpp b/src/quick/items/qquickdroparea.cpp
index 4f6afb1863..f96d6b6244 100644
--- a/src/quick/items/qquickdroparea.cpp
+++ b/src/quick/items/qquickdroparea.cpp
@@ -43,6 +43,8 @@
#include <private/qv4arraybuffer_p.h>
+#include <QtCore/qregularexpression.h>
+
QT_BEGIN_NAMESPACE
QQuickDropAreaDrag::QQuickDropAreaDrag(QQuickDropAreaPrivate *d, QObject *parent)
@@ -68,7 +70,7 @@ public:
QStringList getKeys(const QMimeData *mimeData) const;
QStringList keys;
- QRegExp keyRegExp;
+ QRegularExpression keyRegExp;
QPointF dragPosition;
QQuickDropAreaDrag *drag;
QPointer<QObject> source;
@@ -155,13 +157,15 @@ void QQuickDropArea::setKeys(const QStringList &keys)
d->keys = keys;
if (keys.isEmpty()) {
- d->keyRegExp = QRegExp();
+ d->keyRegExp = QRegularExpression();
} else {
- QString pattern = QLatin1Char('(') + QRegExp::escape(keys.first());
+ QString pattern = QLatin1Char('(') + QRegularExpression::escape(keys.first());
for (int i = 1; i < keys.count(); ++i)
- pattern += QLatin1Char('|') + QRegExp::escape(keys.at(i));
+ pattern += QLatin1Char('|') + QRegularExpression::escape(keys.at(i));
pattern += QLatin1Char(')');
- d->keyRegExp = QRegExp(pattern.replace(QLatin1String("\\*"), QLatin1String(".+")));
+ d->keyRegExp = QRegularExpression(
+ QRegularExpression::anchoredPattern(pattern.replace(QLatin1String("\\*"),
+ QLatin1String(".+"))));
}
emit keysChanged();
}
@@ -229,12 +233,11 @@ void QQuickDropArea::dragMoveEvent(QDragMoveEvent *event)
bool QQuickDropAreaPrivate::hasMatchingKey(const QStringList &keys) const
{
- if (keyRegExp.isEmpty())
+ if (keyRegExp.pattern().isEmpty())
return true;
- QRegExp copy = keyRegExp;
for (const QString &key : keys) {
- if (copy.exactMatch(key))
+ if (key.contains(keyRegExp))
return true;
}
return false;