diff options
Diffstat (limited to 'src/quick/items/qquickdroparea.cpp')
-rw-r--r-- | src/quick/items/qquickdroparea.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/quick/items/qquickdroparea.cpp b/src/quick/items/qquickdroparea.cpp index fbbee31653..76be8cc261 100644 --- a/src/quick/items/qquickdroparea.cpp +++ b/src/quick/items/qquickdroparea.cpp @@ -43,7 +43,7 @@ #include <private/qv4arraybuffer_p.h> -#if QT_CONFIG(draganddrop) +#include <QtCore/qregularexpression.h> QT_BEGIN_NAMESPACE @@ -70,7 +70,7 @@ public: QStringList getKeys(const QMimeData *mimeData) const; QStringList keys; - QRegExp keyRegExp; + QRegularExpression keyRegExp; QPointF dragPosition; QQuickDropAreaDrag *drag; QPointer<QObject> source; @@ -157,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(); } @@ -231,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; @@ -619,5 +620,3 @@ void QQuickDropEvent::accept(QQmlV4Function *args) QT_END_NAMESPACE #include "moc_qquickdroparea_p.cpp" - -#endif // draganddrop |