From 98b6f8eee9affce6df8be137068e49f88becb9ce Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sun, 2 Dec 2018 22:53:43 +0100 Subject: 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 --- src/quicktemplates2/qquickcombobox.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/quicktemplates2/qquickcombobox.cpp') 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 +#include #include #include #include @@ -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; -- cgit v1.2.3 From 69f02184a9a71f3a5e2dd1ada12367ddccd29787 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sat, 15 Dec 2018 14:19:11 +0100 Subject: QQuickComboBox: update QRegularExpression wildcard code Following the update of qtbase because of QTBUG-72539, the code using wildcardToRegularExpression must be updated as anchoredPattern is not needed anymore. Task-number: QTBUG-72539 Change-Id: I51c895560866079c9cc27fa076e29fa4546ecf8f Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickcombobox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/quicktemplates2/qquickcombobox.cpp') diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index 1b6161c0..ffdb7cc2 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -594,7 +594,7 @@ int QQuickComboBoxPrivate::match(int start, const QString &text, Qt::MatchFlags break; } case Qt::MatchWildcard: { - QRegularExpression rx(QRegularExpression::anchoredPattern(QRegularExpression::wildcardToRegularExpression(text)), + QRegularExpression rx(QRegularExpression::wildcardToRegularExpression(text), options); if (rx.match(t).hasMatch()) return idx; -- cgit v1.2.3