From cfcf88e259599131b344dbbe0372d3b03f7d35ec Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 16 Mar 2020 08:47:45 +0100 Subject: Fix compilation with -no-feature-regularexpression This -no-feature has probably not been tested for a while and seems to have rotted a bit, both some unprotected uses and some warnings on unused parameters. Change-Id: Ie20a06c78d3b4c36860dab49d6615eaa8ffc9077 Reviewed-by: Lars Knoll --- src/corelib/itemmodels/qabstractitemmodel.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/corelib/itemmodels') diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index a5df17e386..addeeafd45 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -46,7 +46,9 @@ #include #include #include -#include +#if QT_CONFIG(regularexpression) +# include +#endif #include #include #include @@ -2359,7 +2361,9 @@ QModelIndexList QAbstractItemModel::match(const QModelIndex &start, int role, bool wrap = flags & Qt::MatchWrap; bool allHits = (hits == -1); QString text; // only convert to a string if it is needed +#if QT_CONFIG(regularexpression) QRegularExpression rx; // only create it if needed +#endif const int column = start.column(); QModelIndex p = parent(start); int from = start.row(); @@ -2377,6 +2381,7 @@ QModelIndexList QAbstractItemModel::match(const QModelIndex &start, int role, if (value == v) result.append(idx); } else { // QString or regular expression based matching +#if QT_CONFIG(regularexpression) if (matchType == Qt::MatchRegularExpression) { if (rx.pattern().isEmpty()) { if (value.userType() == QMetaType::QRegularExpression) { @@ -2392,7 +2397,9 @@ QModelIndexList QAbstractItemModel::match(const QModelIndex &start, int role, rx.setPattern(QRegularExpression::wildcardToRegularExpression(value.toString())); if (cs == Qt::CaseInsensitive) rx.setPatternOptions(QRegularExpression::CaseInsensitiveOption); - } else { + } else +#endif + { if (text.isEmpty()) // lazy conversion text = value.toString(); } @@ -2405,12 +2412,15 @@ QModelIndexList QAbstractItemModel::match(const QModelIndex &start, int role, result.append(idx); break; #endif + +#if QT_CONFIG(regularexpression) case Qt::MatchRegularExpression: Q_FALLTHROUGH(); case Qt::MatchWildcard: if (t.contains(rx)) result.append(idx); break; +#endif case Qt::MatchStartsWith: if (t.startsWith(text, cs)) result.append(idx); -- cgit v1.2.3