diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/kernel/qmetatype.cpp | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qmetatype.h | 3 | ||||
-rw-r--r-- | src/corelib/kernel/qmetatype_p.h | 3 | ||||
-rw-r--r-- | src/corelib/kernel/qvariant.cpp | 58 | ||||
-rw-r--r-- | src/corelib/kernel/qvariant.h | 10 | ||||
-rw-r--r-- | src/corelib/text/qregexp.cpp | 12 | ||||
-rw-r--r-- | src/corelib/text/qregexp.h | 7 |
7 files changed, 39 insertions, 56 deletions
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index c34e442cdb..dfb6842d13 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -53,7 +53,6 @@ #include "quuid.h" #include "qvariant.h" #include "qdatastream.h" -#include "qregexp.h" #include "qmetatypeswitcher_p.h" #if QT_CONFIG(regularexpression) @@ -352,7 +351,6 @@ Q_GLOBAL_STATIC(QMetaTypeCustomRegistry, customTypeRegistry) \value QRect QRect \value QPoint QPoint \value QUrl QUrl - \value QRegExp QRegExp \value QRegularExpression QRegularExpression \value QDateTime QDateTime \value QPointF QPointF diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index eb81ac4c28..96133c13c5 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -137,7 +137,6 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId(); F(QLineF, 24, QLineF) \ F(QPoint, 25, QPoint) \ F(QPointF, 26, QPointF) \ - F(QRegExp, 27, QRegExp) \ QT_FOR_EACH_STATIC_EASINGCURVE(F) \ F(QUuid, 30, QUuid) \ F(QVariant, 41, QVariant) \ @@ -474,7 +473,7 @@ public: QChar = 7, QString = 10, QStringList = 11, QByteArray = 12, QBitArray = 13, QDate = 14, QTime = 15, QDateTime = 16, QUrl = 17, QLocale = 18, QRect = 19, QRectF = 20, QSize = 21, QSizeF = 22, - QLine = 23, QLineF = 24, QPoint = 25, QPointF = 26, QRegExp = 27, + QLine = 23, QLineF = 24, QPoint = 25, QPointF = 26, QEasingCurve = 29, QUuid = 30, QVariant = 41, QModelIndex = 42, QPersistentModelIndex = 50, QRegularExpression = 44, QJsonValue = 45, QJsonObject = 46, QJsonArray = 47, QJsonDocument = 48, diff --git a/src/corelib/kernel/qmetatype_p.h b/src/corelib/kernel/qmetatype_p.h index e4e2aa9e43..8e08d84ffd 100644 --- a/src/corelib/kernel/qmetatype_p.h +++ b/src/corelib/kernel/qmetatype_p.h @@ -164,9 +164,6 @@ template<> struct TypeDefinition<QLineF> { static const bool IsAvailable = false template<> struct TypeDefinition<QPoint> { static const bool IsAvailable = false; }; template<> struct TypeDefinition<QPointF> { static const bool IsAvailable = false; }; #endif -#ifdef QT_NO_REGEXP -template<> struct TypeDefinition<QRegExp> { static const bool IsAvailable = false; }; -#endif #if !QT_CONFIG(regularexpression) template<> struct TypeDefinition<QRegularExpression> { static const bool IsAvailable = false; }; #endif diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index c5cf6b9464..25b101d5e3 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -57,7 +57,6 @@ #include "qstringlist.h" #include "qurl.h" #include "qlocale.h" -#include "qregexp.h" #include "quuid.h" #if QT_CONFIG(itemmodel) #include "qabstractitemmodel.h" @@ -1681,7 +1680,6 @@ Q_CORE_EXPORT void QVariantPrivate::registerHandler(const int /* Modules::Names \value Quaternion a QQuaternion \value Rect a QRect \value RectF a QRectF - \value RegExp a QRegExp \value RegularExpression a QRegularExpression \value Region a QRegion \value Size a QSize @@ -2077,12 +2075,6 @@ QVariant::QVariant(const char *val) */ /*! - \fn QVariant::QVariant(const QRegExp ®Exp) - - Constructs a new variant with the regexp value \a regExp. -*/ - -/*! \fn QVariant::QVariant(const QRegularExpression &re) \since 5.0 @@ -2216,11 +2208,6 @@ QVariant::QVariant(const QUrl &u) QVariant::QVariant(const QLocale &l) : d(Locale) { v_construct<QLocale>(&d, l); } -#ifndef QT_NO_REGEXP -QVariant::QVariant(const QRegExp ®Exp) - : d(RegExp) -{ v_construct<QRegExp>(&d, regExp); } -#endif // QT_NO_REGEXP #if QT_CONFIG(regularexpression) QVariant::QVariant(const QRegularExpression &re) : d(RegularExpression) @@ -2262,7 +2249,7 @@ QVariant::QVariant(const QPersistentModelIndex &modelIndex) Note that return values in the ranges QVariant::Char through QVariant::RegExp and QVariant::Font through QVariant::Transform correspond to the values in the ranges QMetaType::QChar through - QMetaType::QRegExp and QMetaType::QFont through QMetaType::QQuaternion. + QMetaType::QRegularExpression and QMetaType::QFont through QMetaType::QQuaternion. Pay particular attention when working with char and QChar variants. Note that there is no QVariant constructor specifically @@ -2493,7 +2480,10 @@ void QVariant::load(QDataStream &s) qint8 is_null = false; if (s.version() >= QDataStream::Qt_4_2) s >> is_null; - if (typeId == QVariant::UserType) { + if (typeId == 27) { + // used to be QRegExp in Qt 4/5 + typeId = QMetaType::type("QRegExp"); + } else if (typeId == QVariant::UserType) { QByteArray name; s >> name; typeId = QMetaType::type(name.constData()); @@ -2532,9 +2522,11 @@ void QVariant::load(QDataStream &s) void QVariant::save(QDataStream &s) const { quint32 typeId = d.type().id(); - if (typeId >= QMetaType::User) + bool saveAsUserType = false; + if (typeId >= QMetaType::User) { typeId = QMetaType::User; - bool fakeUserType = false; + saveAsUserType = true; + } if (s.version() < QDataStream::Qt_4_0) { int i; for (i = 0; i <= MapFromThreeCount - 1; ++i) { @@ -2550,6 +2542,7 @@ void QVariant::save(QDataStream &s) const } else if (s.version() < QDataStream::Qt_5_0) { if (typeId == QMetaType::User) { typeId = 127; // QVariant::UserType had this value in Qt4 + saveAsUserType = true; } else if (typeId >= 128 - 97 && typeId <= LastCoreType) { // In Qt4 id == 128 was FirstExtCoreType. In Qt5 ExtCoreTypes set was merged to CoreTypes // by moving all ids down by 97. @@ -2566,15 +2559,22 @@ void QVariant::save(QDataStream &s) const } else if (typeId == QMetaType::QPolygonF || typeId == QMetaType::QUuid) { // These existed in Qt 4 only as a custom type typeId = 127; - fakeUserType = true; + saveAsUserType = true; + } + } + const char *typeName = nullptr; + if (saveAsUserType) { + typeName = QMetaType::typeName(d.type().id()); + if (!strcmp(typeName, "QRegExp")) { + typeId = 27; // QRegExp in Qt 4/5 + typeName = nullptr; } } s << typeId; if (s.version() >= QDataStream::Qt_4_2) s << qint8(d.is_null); - if (d.type().id() >= int(QVariant::UserType) || fakeUserType) { + if (typeName) s << QMetaType::typeName(userType()); - } if (!isValid()) { if (s.version() < QDataStream::Qt_5_0) @@ -2938,22 +2938,6 @@ QLocale QVariant::toLocale() const return qVariantToHelper<QLocale>(d, handlerManager); } -/*! - \fn QRegExp QVariant::toRegExp() const - \since 4.1 - - Returns the variant as a QRegExp if the variant has userType() - \l QMetaType::QRegExp; otherwise returns an empty QRegExp. - - \sa canConvert(int targetTypeId), convert() -*/ -#ifndef QT_NO_REGEXP -QRegExp QVariant::toRegExp() const -{ - return qVariantToHelper<QRegExp>(d, handlerManager); -} -#endif - #if QT_CONFIG(regularexpression) /*! \fn QRegularExpression QVariant::toRegularExpression() const @@ -3356,7 +3340,7 @@ static const quint32 qCanConvertMatrix[QMetaType::LastCoreType + 1] = /*QPointF*/ 1 << QMetaType::QPoint, -/*QRegExp*/ 0, +/*unused, was: QRegExp*/ 0, /*QHash*/ 0, diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index c519411fc1..d8ac0324ac 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -81,9 +81,6 @@ class QSize; class QSizeF; class QRect; class QRectF; -#ifndef QT_NO_REGEXP -class QRegExp; -#endif // QT_NO_REGEXP #if QT_CONFIG(regularexpression) class QRegularExpression; #endif // QT_CONFIG(regularexpression) @@ -160,7 +157,6 @@ class Q_CORE_EXPORT QVariant LineF = QMetaType::QLineF, Point = QMetaType::QPoint, PointF = QMetaType::QPointF, - RegExp = QMetaType::QRegExp, #if QT_CONFIG(regularexpression) RegularExpression = QMetaType::QRegularExpression, #endif @@ -252,9 +248,6 @@ class Q_CORE_EXPORT QVariant QVariant(const QRectF &rect); #endif QVariant(const QLocale &locale); -#ifndef QT_NO_REGEXP - QVariant(const QRegExp ®Exp); -#endif // QT_NO_REGEXP #if QT_CONFIG(regularexpression) QVariant(const QRegularExpression &re); #endif // QT_CONFIG(regularexpression) @@ -329,9 +322,6 @@ class Q_CORE_EXPORT QVariant QRectF toRectF() const; #endif QLocale toLocale() const; -#ifndef QT_NO_REGEXP - QRegExp toRegExp() const; -#endif // QT_NO_REGEXP #if QT_CONFIG(regularexpression) QRegularExpression toRegularExpression() const; #endif // QT_CONFIG(regularexpression) diff --git a/src/corelib/text/qregexp.cpp b/src/corelib/text/qregexp.cpp index 85086c7a40..9ae96a805e 100644 --- a/src/corelib/text/qregexp.cpp +++ b/src/corelib/text/qregexp.cpp @@ -4388,6 +4388,18 @@ bool QRegExp::exactMatch(const QString &str) const } } +/*! + Returns the regexp as a QVariant +*/ +QRegExp::operator QVariant() const +{ +QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED + QVariant v; + v.setValue(*this); + return v; +QT_WARNING_POP +} + // ### Qt 5: make non-const /*! Attempts to find a match in \a str from position \a offset (0 by diff --git a/src/corelib/text/qregexp.h b/src/corelib/text/qregexp.h index cf4aa0d32d..0c117fd17f 100644 --- a/src/corelib/text/qregexp.h +++ b/src/corelib/text/qregexp.h @@ -45,6 +45,7 @@ #ifndef QT_NO_REGEXP #include <QtCore/qstring.h> +#include <QtCore/qvariant.h> QT_BEGIN_NAMESPACE @@ -93,6 +94,8 @@ public: bool exactMatch(const QString &str) const; + operator QVariant() const; + int indexIn(const QString &str, int offset = 0, CaretMode caretMode = CaretAtZero) const; int lastIndexIn(const QString &str, int offset = -1, CaretMode caretMode = CaretAtZero) const; int matchedLength() const; @@ -130,8 +133,6 @@ private: QRegExpPrivate *priv; }; -Q_DECLARE_TYPEINFO(QRegExp, Q_MOVABLE_TYPE); - #ifndef QT_NO_DATASTREAM Q_CORE_EXPORT QDataStream &operator<<(QDataStream &out, const QRegExp ®Exp); Q_CORE_EXPORT QDataStream &operator>>(QDataStream &in, QRegExp ®Exp); @@ -143,6 +144,8 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QRegExp &); QT_END_NAMESPACE +Q_DECLARE_METATYPE(QRegExp) + #endif // QT_NO_REGEXP #endif // QREGEXP_H |