summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Kelly <stephen.kelly@kdab.com>2012-01-10 14:46:34 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-11 19:32:34 +0100
commit0fd8816340dab1fa12128ad8d20815472db10a95 (patch)
treecc38e018e062af2646862fae9beb907d588ba7a2
parenta7f4139af02d0ace2c0a408668a51505f1f964e4 (diff)
Add QModelIndex as a built-in metatype.
Change-Id: Ib87cfff8b4baee78189f3df5e20d2e1a00d690e1 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
-rw-r--r--src/corelib/kernel/qmetatype.cpp15
-rw-r--r--src/corelib/kernel/qmetatype.h3
-rw-r--r--src/corelib/kernel/qvariant.cpp5
-rw-r--r--src/corelib/kernel/qvariant.h1
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp3
5 files changed, 26 insertions, 1 deletions
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<QVariant> { static const bool IsAvailable = fals
template<> struct TypeDefiniton<QBitArray> { static const bool IsAvailable = false; };
template<> struct TypeDefiniton<QUrl> { static const bool IsAvailable = false; };
template<> struct TypeDefiniton<QEasingCurve> { static const bool IsAvailable = false; };
+template<> struct TypeDefiniton<QModelIndex> { static const bool IsAvailable = false; };
#endif
#ifdef QT_NO_REGEXP
template<> struct TypeDefiniton<QRegExp> { 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<const NS(QUuid)*>(copy));
+#ifndef QT_BOOTSTRAPPED
+ case QMetaType::QModelIndex:
+ return new NS(QModelIndex)(*static_cast<const NS(QModelIndex)*>(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<QEasingCurve> { static const bool IsAvailable = false; };
+template<> struct TypeDefiniton<QModelIndex> { static const bool IsAvailable = false; };
#endif
#ifdef QT_NO_GEOM_VARIANT
template<> struct TypeDefiniton<QRect> { 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,
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
index 475f190326..d5aa369a92 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
@@ -449,6 +449,9 @@ template<> struct TestValueFactory<QMetaType::QEasingCurve> {
template<> struct TestValueFactory<QMetaType::QUuid> {
static QUuid *create() { return new QUuid(); }
};
+template<> struct TestValueFactory<QMetaType::QModelIndex> {
+ static QModelIndex *create() { return new QModelIndex(); }
+};
template<> struct TestValueFactory<QMetaType::QRegExp> {
static QRegExp *create()
{