aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>2015-03-05 12:30:58 +0100
committerGabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>2015-03-05 14:04:24 +0000
commit7b29a983fa794291ff8ec7f580d4c03969ebe34b (patch)
treef4bb3c6461c5666863e545b976c8cd0aaf37ce0e
parentadaa3fc546ed831ec69a019c1e0ef48d9e69eb12 (diff)
Work around QPersistentModelIndex being a built-in meta-type
This is a temporary work-around and will be removed once I63d733d1eb66aa61691e7afce27fe7372a83ac00 is merged in qtbase. Change-Id: I6cfcf1ddc2c9d408c26c171be865d40141de7fa0 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
-rw-r--r--src/qml/qml/qqmlvaluetype.cpp30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/qml/qml/qqmlvaluetype.cpp b/src/qml/qml/qqmlvaluetype.cpp
index 1528ebda37..d3142af75e 100644
--- a/src/qml/qml/qqmlvaluetype.cpp
+++ b/src/qml/qml/qqmlvaluetype.cpp
@@ -58,6 +58,30 @@ struct QQmlValueTypeFactoryImpl
QMutex mutex;
};
+
+namespace {
+// This should be removed once the QPersistentModelIndex as built-in type is merged in qtbase
+#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
+#error Please, someone remove this. QPersistentModelIndex should be a built-in meta-type by now.
+#else
+template <typename T, bool builtin = QMetaTypeId2<T>::IsBuiltIn>
+struct QPMIConvertersRegistrer {
+ void registerConverters()
+ {
+ }
+};
+
+template <typename T> struct QPMIConvertersRegistrer<T, false> {
+ void registerConverters()
+ {
+ qRegisterMetaType<QPersistentModelIndex>();
+ QMetaType::registerConverter<QModelIndex, QPersistentModelIndex>(&QQmlModelIndexValueType::toPersistentModelIndex);
+ QMetaType::registerConverter<QPersistentModelIndex, QModelIndex>(&QQmlPersistentModelIndexValueType::toModelIndex);
+ }
+};
+#endif
+}
+
QQmlValueTypeFactoryImpl::QQmlValueTypeFactoryImpl()
{
for (unsigned int ii = 0; ii < QVariant::UserType; ++ii)
@@ -65,11 +89,11 @@ QQmlValueTypeFactoryImpl::QQmlValueTypeFactoryImpl()
// See types wrapped in qqmlmodelindexvaluetype_p.h
qRegisterMetaType<QModelIndexList>();
- qRegisterMetaType<QPersistentModelIndex>();
qRegisterMetaType<QItemSelectionRange>();
qRegisterMetaType<QItemSelection>();
- QMetaType::registerConverter<QModelIndex, QPersistentModelIndex>(&QQmlModelIndexValueType::toPersistentModelIndex);
- QMetaType::registerConverter<QPersistentModelIndex, QModelIndex>(&QQmlPersistentModelIndexValueType::toModelIndex);
+
+ QPMIConvertersRegistrer<QPersistentModelIndex> conv;
+ conv.registerConverters();
}
QQmlValueTypeFactoryImpl::~QQmlValueTypeFactoryImpl()