aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Gaist <samuel.gaist@idiap.ch>2018-12-02 22:53:43 +0100
committerMitch Curtis <mitch.curtis@qt.io>2018-12-04 08:05:18 +0000
commit98b6f8eee9affce6df8be137068e49f88becb9ce (patch)
treedda25edced0d8ad2276b69ed6c3586bb57770217
parentbbd6c9972206eccc4d2872be44db509ef716c351 (diff)
Port QQuickComboBox to QRegularExpression
This patch updates the QQuickComboBox code to use QRegularExpression in place of QRegExp which is to be considered deprecated. Change-Id: I6551fac80b071073e3cd09d2016ef99df510e8ff Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/quicktemplates2/qquickcombobox.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp
index 77abee07..1b6161c0 100644
--- a/src/quicktemplates2/qquickcombobox.cpp
+++ b/src/quicktemplates2/qquickcombobox.cpp
@@ -41,7 +41,7 @@
#include "qquickpopup_p_p.h"
#include "qquickdeferredexecute_p_p.h"
-#include <QtCore/qregexp.h>
+#include <QtCore/qregularexpression.h>
#include <QtCore/qabstractitemmodel.h>
#include <QtGui/qinputmethod.h>
#include <QtGui/qguiapplication.h>
@@ -573,6 +573,8 @@ int QQuickComboBoxPrivate::match(int start, const QString &text, Qt::MatchFlags
uint matchType = flags & 0x0F;
bool wrap = flags & Qt::MatchWrap;
Qt::CaseSensitivity cs = flags & Qt::MatchCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive;
+ QRegularExpression::PatternOptions options = flags & Qt::MatchCaseSensitive ? QRegularExpression::NoPatternOption
+ : QRegularExpression::CaseInsensitiveOption;
int from = start;
int to = q->count();
@@ -585,14 +587,19 @@ int QQuickComboBoxPrivate::match(int start, const QString &text, Qt::MatchFlags
if (t == text)
return idx;
break;
- case Qt::MatchRegExp:
- if (QRegExp(text, cs).exactMatch(t))
+ case Qt::MatchRegExp: {
+ QRegularExpression rx(QRegularExpression::anchoredPattern(text), options);
+ if (rx.match(t).hasMatch())
return idx;
break;
- case Qt::MatchWildcard:
- if (QRegExp(text, cs, QRegExp::Wildcard).exactMatch(t))
+ }
+ case Qt::MatchWildcard: {
+ QRegularExpression rx(QRegularExpression::anchoredPattern(QRegularExpression::wildcardToRegularExpression(text)),
+ options);
+ if (rx.match(t).hasMatch())
return idx;
break;
+ }
case Qt::MatchStartsWith:
if (t.startsWith(text, cs))
return idx;