diff options
author | Giuseppe D'Angelo <dangelog@gmail.com> | 2012-03-11 00:26:17 +0000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-14 10:53:24 +0100 |
commit | 08790636f2b19a6bab97e3462211bec5b2d23c45 (patch) | |
tree | 77e6dc5a9b79e4c0e3462c6bf345d0283cde144b /src/corelib/kernel/qvariant.cpp | |
parent | b8112c8526a6e261c6e00bdb4fe6ceef3876d01f (diff) |
QRegularExpression: QMetaType and QVariant support
Removed the Q_DECLARE_METATYPE in favour of first-class support
inside QMetaType and QVariant.
Change-Id: I904236822bfab967dc0fbd4d4cc2bcb68c741adc
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src/corelib/kernel/qvariant.cpp')
-rw-r--r-- | src/corelib/kernel/qvariant.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 8058a06117..e08f4ef53c 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -48,6 +48,7 @@ #include "qdatetime.h" #include "qeasingcurve.h" #include "qlist.h" +#include "qregularexpression.h" #include "qstring.h" #include "qstringlist.h" #include "qurl.h" @@ -106,6 +107,7 @@ struct TypeDefinition { #ifdef QT_BOOTSTRAPPED template<> struct TypeDefinition<QEasingCurve> { static const bool IsAvailable = false; }; template<> struct TypeDefinition<QModelIndex> { static const bool IsAvailable = false; }; +template<> struct TypeDefinition<QRegularExpression> { static const bool IsAvailable = false; }; #endif #ifdef QT_NO_GEOM_VARIANT template<> struct TypeDefinition<QRect> { static const bool IsAvailable = false; }; @@ -1028,6 +1030,7 @@ Q_CORE_EXPORT void QVariantPrivate::unregisterHandler(const int /* Modules::Name \value Rect a QRect \value RectF a QRectF \value RegExp a QRegExp + \value RegularExpression a QRegularExpression \value Region a QRegion \value Size a QSize \value SizeF a QSizeF @@ -1358,6 +1361,14 @@ QVariant::QVariant(const char *val) Constructs a new variant with the regexp value \a regExp. */ +/*! + \fn QVariant::QVariant(const QRegularExpression &re) + + \since 5.0 + + Constructs a new variant with the regular expression value \a re. +*/ + /*! \since 4.2 \fn QVariant::QVariant(Qt::GlobalColor color) @@ -1446,7 +1457,10 @@ QVariant::QVariant(const QUrl &u) { d.is_null = false; d.type = Url; v_construct QVariant::QVariant(const QLocale &l) { d.is_null = false; d.type = Locale; v_construct<QLocale>(&d, l); } #ifndef QT_NO_REGEXP QVariant::QVariant(const QRegExp ®Exp) { d.is_null = false; d.type = RegExp; v_construct<QRegExp>(&d, regExp); } -#endif +#ifndef QT_BOOTSTRAPPED +QVariant::QVariant(const QRegularExpression &re) { d.is_null = false; d.type = QMetaType::QRegularExpression; v_construct<QRegularExpression>(&d, re); } +#endif // QT_BOOTSTRAPPED +#endif // QT_NO_REGEXP QVariant::QVariant(Qt::GlobalColor color) { create(62, &color); } /*! @@ -2127,6 +2141,24 @@ QRegExp QVariant::toRegExp() const #endif /*! + \fn QRegularExpression QVariant::toRegularExpression() const + \since 5.0 + + Returns the variant as a QRegularExpression if the variant has type() \l + QRegularExpression; otherwise returns an empty QRegularExpression. + + \sa canConvert(), convert() +*/ +#ifndef QT_BOOTSTRAPPED +#ifndef QT_NO_REGEXP +QRegularExpression QVariant::toRegularExpression() const +{ + return qVariantToHelper<QRegularExpression>(d, handlerManager); +} +#endif +#endif + +/*! \fn QChar QVariant::toChar() const Returns the variant as a QChar if the variant has type() \l Char, |