From 0fd8816340dab1fa12128ad8d20815472db10a95 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 10 Jan 2012 14:46:34 +0100 Subject: Add QModelIndex as a built-in metatype. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ib87cfff8b4baee78189f3df5e20d2e1a00d690e1 Reviewed-by: Jędrzej Nowacki --- src/corelib/kernel/qmetatype.cpp | 15 +++++++++++++++ src/corelib/kernel/qmetatype.h | 3 ++- src/corelib/kernel/qvariant.cpp | 5 +++++ src/corelib/kernel/qvariant.h | 1 + 4 files changed, 23 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 112dfe92e6..375c7b75bb 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -62,6 +62,7 @@ # include "qbitarray.h" # include "qurl.h" # include "qvariant.h" +# include "qabstractitemmodel.h" #endif #ifndef QT_NO_GEOM_VARIANT @@ -108,6 +109,7 @@ template<> struct TypeDefiniton { static const bool IsAvailable = fals template<> struct TypeDefiniton { static const bool IsAvailable = false; }; template<> struct TypeDefiniton { static const bool IsAvailable = false; }; template<> struct TypeDefiniton { static const bool IsAvailable = false; }; +template<> struct TypeDefiniton { static const bool IsAvailable = false; }; #endif #ifdef QT_NO_REGEXP template<> struct TypeDefiniton { static const bool IsAvailable = false; }; @@ -1124,6 +1126,10 @@ void *QMetaType::create(int type, const void *copy) #endif case QMetaType::QUuid: return new NS(QUuid)(*static_cast(copy)); +#ifndef QT_BOOTSTRAPPED + case QMetaType::QModelIndex: + return new NS(QModelIndex)(*static_cast(copy)); +#endif case QMetaType::Void: return 0; default: @@ -1223,6 +1229,10 @@ void *QMetaType::create(int type, const void *copy) #endif case QMetaType::QUuid: return new NS(QUuid); +#ifndef QT_BOOTSTRAPPED + case QMetaType::QModelIndex: + return new NS(QModelIndex); +#endif case QMetaType::Void: return 0; default: @@ -1393,6 +1403,11 @@ void QMetaType::destroy(int type, void *data) case QMetaType::QUuid: delete static_cast< NS(QUuid)* >(data); break; +#ifndef QT_BOOTSTRAPPED + case QMetaType::QModelIndex: + delete static_cast< NS(QModelIndex)* >(data); + break; +#endif case QMetaType::Void: break; default: { diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index ab0203e5e4..843044eee6 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -99,6 +99,7 @@ QT_MODULE(Core) F(QRegExp, 27, QRegExp) \ F(QEasingCurve, 29, QEasingCurve) \ F(QUuid, 30, QUuid) \ + F(QModelIndex, 31, QModelIndex) \ F(QVariant, 138, QVariant) \ #define QT_FOR_EACH_STATIC_CORE_POINTER(F)\ @@ -183,7 +184,7 @@ public: // these are merged with QVariant QT_FOR_EACH_STATIC_TYPE(QT_DEFINE_METATYPE_ID) - LastCoreType = QUuid, + LastCoreType = QModelIndex, FirstGuiType = QFont, LastGuiType = QPolygonF, FirstWidgetsType = QIcon, diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index e4894eccdf..72229c0e63 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -53,6 +53,9 @@ #include "qurl.h" #include "qlocale.h" #include "quuid.h" +#ifndef QT_BOOTSTRAPPED +#include "qabstractitemmodel.h" +#endif #include "private/qvariant_p.h" #include "qmetatype_p.h" @@ -102,6 +105,7 @@ struct TypeDefiniton { // Ignore these types, as incomplete #ifdef QT_BOOTSTRAPPED template<> struct TypeDefiniton { static const bool IsAvailable = false; }; +template<> struct TypeDefiniton { static const bool IsAvailable = false; }; #endif #ifdef QT_NO_GEOM_VARIANT template<> struct TypeDefiniton { static const bool IsAvailable = false; }; @@ -995,6 +999,7 @@ Q_CORE_EXPORT void QVariantPrivate::unregisterHandler(const int /* Modules::Name \value Double a double \value EasingCurve a QEasingCurve \value Uuid a QUuid + \value ModelIndex a QModelIndex \value Font a QFont \value Hash a QVariantHash \value Icon a QIcon diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 738e516b82..35c584fa51 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -124,6 +124,7 @@ class Q_CORE_EXPORT QVariant Hash = QMetaType::QVariantHash, EasingCurve = QMetaType::QEasingCurve, Uuid = QMetaType::QUuid, + ModelIndex = QMetaType::QModelIndex, LastCoreType = QMetaType::LastCoreType, Font = QMetaType::QFont, -- cgit v1.2.3