diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2020-03-16 08:47:45 +0100 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2020-03-17 09:17:08 +0100 |
commit | cfcf88e259599131b344dbbe0372d3b03f7d35ec (patch) | |
tree | f85f84f7022b4590173c90efc290e2b617aa1fe6 /src | |
parent | dee55af0a5359bb3b57a89cf3065ffca9d8506da (diff) |
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 <lars.knoll@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/itemmodels/qabstractitemmodel.cpp | 14 | ||||
-rw-r--r-- | src/corelib/kernel/qmetatype.h | 9 | ||||
-rw-r--r-- | src/corelib/kernel/qvariant.cpp | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qvariant.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qplatformdialoghelper.cpp | 1 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowsdialoghelpers.cpp | 11 | ||||
-rw-r--r-- | src/widgets/dialogs/qfilesystemmodel.cpp | 4 |
7 files changed, 39 insertions, 4 deletions
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 <qdebug.h> #include <qvector.h> #include <qregexp.h> -#include <qregularexpression.h> +#if QT_CONFIG(regularexpression) +# include <qregularexpression.h> +#endif #include <qstack.h> #include <qbitarray.h> #include <qdatetime.h> @@ -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); diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 61f9a42850..6d34402177 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -111,6 +111,13 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId(); #define QT_FOR_EACH_STATIC_ITEMMODEL_CLASS(F) #endif +#if QT_CONFIG(regularexpression) +# define QT_FOR_EACH_STATIC_REGULAR_EXPRESSION(F) \ + F(QRegularExpression, 44, QRegularExpression) +#else +# define QT_FOR_EACH_STATIC_REGULAR_EXPRESSION(F) +#endif + #define QT_FOR_EACH_STATIC_CORE_CLASS(F)\ F(QChar, 7, QChar) \ F(QString, 10, QString) \ @@ -134,7 +141,7 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId(); QT_FOR_EACH_STATIC_EASINGCURVE(F) \ F(QUuid, 30, QUuid) \ F(QVariant, 41, QVariant) \ - F(QRegularExpression, 44, QRegularExpression) \ + QT_FOR_EACH_STATIC_REGULAR_EXPRESSION(F) \ F(QJsonValue, 45, QJsonValue) \ F(QJsonObject, 46, QJsonObject) \ F(QJsonArray, 47, QJsonArray) \ diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 7d93dde022..6d3c7b4831 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -3606,7 +3606,9 @@ bool QVariant::canConvert(int targetTypeId) const case QMetaType::QByteArray: case QMetaType::QDateTime: case QMetaType::QUrl: +#if QT_CONFIG(regularexpression) case QMetaType::QRegularExpression: +#endif case QMetaType::QUuid: case QMetaType::QVariantList: case QMetaType::QVariantMap: diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index cf95f12689..c519411fc1 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -161,7 +161,9 @@ class Q_CORE_EXPORT QVariant Point = QMetaType::QPoint, PointF = QMetaType::QPointF, RegExp = QMetaType::QRegExp, +#if QT_CONFIG(regularexpression) RegularExpression = QMetaType::QRegularExpression, +#endif Hash = QMetaType::QVariantHash, #if QT_CONFIG(easingcurve) EasingCurve = QMetaType::QEasingCurve, diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp index 5face96575..d2e079b57f 100644 --- a/src/gui/kernel/qplatformdialoghelper.cpp +++ b/src/gui/kernel/qplatformdialoghelper.cpp @@ -790,6 +790,7 @@ QStringList QPlatformFileDialogHelper::cleanFilterList(const QString &filter) f = match.captured(2); return f.split(QLatin1Char(' '), Qt::SkipEmptyParts); #else + Q_UNUSED(filter) return QStringList(); #endif } diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index b038e19689..ccc809413e 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -55,7 +55,9 @@ #include <QtGui/qcolor.h> #include <QtCore/qdebug.h> -#include <QtCore/qregularexpression.h> +#if QT_CONFIG(regularexpression) +# include <QtCore/qregularexpression.h> +#endif #include <QtCore/qtimer.h> #include <QtCore/qdir.h> #include <QtCore/qscopedpointer.h> @@ -1034,9 +1036,12 @@ static QList<FilterSpec> filterSpecs(const QStringList &filters, result.reserve(filters.size()); *totalStringLength = 0; +#if QT_CONFIG(regularexpression) const QRegularExpression filterSeparatorRE(QStringLiteral("[;\\s]+")); const QString separator = QStringLiteral(";"); Q_ASSERT(filterSeparatorRE.isValid()); +#endif + // Split filter specification as 'Texts (*.txt[;] *.doc)', '*.txt[;] *.doc' // into description and filters specification as '*.txt;*.doc' for (const QString &filterString : filters) { @@ -1049,7 +1054,11 @@ static QList<FilterSpec> filterSpecs(const QStringList &filters, filterString.mid(openingParenPos + 1, closingParenPos - openingParenPos - 1).trimmed(); if (filterSpec.filter.isEmpty()) filterSpec.filter += u'*'; +#if QT_CONFIG(regularexpression) filterSpec.filter.replace(filterSeparatorRE, separator); +#else + filterSpec.filter.replace(QLatin1Char(' '), QLatin1Char(';')); +#endif filterSpec.description = filterString; if (hideFilterDetails && openingParenPos != -1) { // Do not show pattern in description filterSpec.description.truncate(openingParenPos); diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index 4644f0f04e..6afdfa6eb9 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -1709,6 +1709,8 @@ void QFileSystemModel::setNameFilters(const QStringList &filters) d->nameFilters = filters; d->forceSort = true; d->delayedSort(); +#else + Q_UNUSED(filters) #endif } @@ -2158,6 +2160,8 @@ bool QFileSystemModelPrivate::passNameFilters(const QFileSystemNode *node) const } return false; } +#else + Q_UNUSED(node) #endif return true; } |