diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-02-13 15:54:14 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-03-20 08:05:04 +0000 |
commit | d2fd8010d3d3a6493df1a848c342db40555b4c1f (patch) | |
tree | e1209b4d472396330d8a486b359faae58483e6bf /src/qmltest | |
parent | 80920a3012239644ac0aba8c37a9a05e22e34b5a (diff) |
Support QRegularExpression on the same level as QRegExp
QRegularExpression is the recommended way to do regular expressions
nowadays. Support assignment of JavaScript regular expressions to
QRegularExpression properties of QObjects and the other way around.
QJSValue::toVariant() will create a QRegularExpression from a JavaScript
RegExp by default now.
[ChangeLog][QtQml][Important Behavior Changes] QRegularExpression is now
supported the same way QRegExp is in QML. QJSValue::toVariant() creates
a QRegularExpression variant rather than a QRegExp one from a JavaScript
regular expression now.
Fixes: QTBUG-73429
Change-Id: I301a02771cd17903406c2bc5c7aaeca6cce629f0
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qmltest')
-rw-r--r-- | src/qmltest/quicktestresult.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/qmltest/quicktestresult.cpp b/src/qmltest/quicktestresult.cpp index 4dbec585c4..49552e1901 100644 --- a/src/qmltest/quicktestresult.cpp +++ b/src/qmltest/quicktestresult.cpp @@ -62,7 +62,9 @@ #include <QtCore/qdebug.h> #include <QtCore/QUrl> #include <QtCore/QDir> +#if QT_CONFIG(regularexpression) #include <QtCore/qregularexpression.h> +#endif #include <QtQuick/qquickwindow.h> #include <QtGui/qvector3d.h> #include <QtGui/qimagewriter.h> @@ -640,12 +642,9 @@ void QuickTestResult::warn(const QString &message, const QUrl &location, int lin void QuickTestResult::ignoreWarning(const QJSValue &message) { if (message.isRegExp()) { - // ### we should probably handle QRegularExpression conversion engine-side - QRegExp re = message.toVariant().toRegExp(); - QRegularExpression::PatternOptions opts = re.caseSensitivity() == - Qt::CaseInsensitive ? QRegularExpression::CaseInsensitiveOption : QRegularExpression::NoPatternOption; - QRegularExpression re2(re.pattern(), opts); - QTestLog::ignoreMessage(QtWarningMsg, re2); +#if QT_CONFIG(regularexpression) + QTestLog::ignoreMessage(QtWarningMsg, message.toVariant().toRegularExpression()); +#endif } else { QTestLog::ignoreMessage(QtWarningMsg, message.toString().toLatin1()); } |