diff options
author | Samuel Gaist <samuel.gaist@idiap.ch> | 2018-07-25 09:23:28 +0200 |
---|---|---|
committer | Samuel Gaist <samuel.gaist@idiap.ch> | 2018-08-19 11:38:26 +0000 |
commit | bcd80eebf983a2b547662d7e0d67bc8624d1130f (patch) | |
tree | 248e569a21dc62ec8f2016c5efdde6d6afcf1e02 /src/widgets/dialogs | |
parent | 6228c0528ca5cea2f8c309c4f64e38eb729b04da (diff) |
Implement exact match expression builder for QRegularExpression
QRegularExpression doesn't offer a direct equivalent of QRegExp's exact
match.
There are several places in the Qt sources that use this feature. This
patch implements a small helper function that builds the expression as
recommended in the documentation and updates the related code.
[ChangeLog][Core][Tools] QRegularExpression now provides
anchoredPattern() which is a helper function to build regular
expressions used for exact matching.
Change-Id: Idbbf142c4c5cb9b62abf8229f4ce85fd4409e5d0
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r-- | src/widgets/dialogs/qfilesystemmodel.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index b67335822b..e4edd2f6ef 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -2032,10 +2032,8 @@ bool QFileSystemModelPrivate::passNameFilters(const QFileSystemNode *node) const : QRegularExpression::CaseInsensitiveOption; for (const auto &nameFilter : nameFilters) { - const QString wildcard = QLatin1String("\\A(?:") - + QRegularExpression::wildcardToRegularExpression(nameFilter) - + QLatin1String(")\\z"); - QRegularExpression rx(wildcard, options); + const QString wildcard = QRegularExpression::wildcardToRegularExpression(nameFilter); + QRegularExpression rx(QRegularExpression::anchoredPattern(wildcard), options); QRegularExpressionMatch match = rx.match(node->fileName); if (match.hasMatch()) return true; |