Add QModelIndex as a built-in metatype.

Change-Id: Ib87cfff8b4baee78189f3df5e20d2e1a00d690e1
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
This commit is contained in:
Stephen Kelly 2012-01-10 14:46:34 +01:00 committed by Qt by Nokia
parent a7f4139af0
commit 0fd8816340
5 changed files with 26 additions and 1 deletions

View File

@ -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: {

View File

@ -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,

View File

@ -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

View File

@ -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,

View File

@ -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()
{