From c6899f16389458766904d8d913054f09076e06dd Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 3 Dec 2019 20:24:38 +0100 Subject: Replace QVariant::type with QVariant::userType as type is going to be deprecated. This change was done automatically with the help of clazy. In addition, ColumnRoleMetadata was changed to take an int instead of a QVariant::Type Change-Id: Ibc02d7b52e7d931a56c19fdebc4788b5e6df2a39 Reviewed-by: Lars Knoll --- src/qmlmodels/qqmladaptormodel.cpp | 6 +++--- src/qmlmodels/qqmldelegatemodel.cpp | 2 +- src/qmlmodels/qqmllistaccessor.cpp | 4 ++-- src/qmlmodels/qqmllistmodel.cpp | 26 ++++++++++++++------------ 4 files changed, 20 insertions(+), 18 deletions(-) (limited to 'src/qmlmodels') diff --git a/src/qmlmodels/qqmladaptormodel.cpp b/src/qmlmodels/qqmladaptormodel.cpp index cf0d8fbb2f..fbb85327a7 100644 --- a/src/qmlmodels/qqmladaptormodel.cpp +++ b/src/qmlmodels/qqmladaptormodel.cpp @@ -367,10 +367,10 @@ QV4::ReturnedValue QQmlDMCachedModelData::set_property(const QV4::FunctionObject QQmlDMCachedModelData *modelData = static_cast(o->d()->item); if (!modelData->cachedData.isEmpty()) { if (modelData->cachedData.count() > 1) { - modelData->cachedData[propertyId] = scope.engine->toVariant(argv[0], QVariant::Invalid); + modelData->cachedData[propertyId] = scope.engine->toVariant(argv[0], QMetaType::UnknownType); QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), propertyId, nullptr); } else if (modelData->cachedData.count() == 1) { - modelData->cachedData[0] = scope.engine->toVariant(argv[0], QVariant::Invalid); + modelData->cachedData[0] = scope.engine->toVariant(argv[0], QMetaType::UnknownType); QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), 0, nullptr); QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), 1, nullptr); } @@ -601,7 +601,7 @@ public: if (!argc) return v4->throwTypeError(); - static_cast(o->d()->item)->setModelData(v4->toVariant(argv[0], QVariant::Invalid)); + static_cast(o->d()->item)->setModelData(v4->toVariant(argv[0], QMetaType::UnknownType)); return QV4::Encode::undefined(); } diff --git a/src/qmlmodels/qqmldelegatemodel.cpp b/src/qmlmodels/qqmldelegatemodel.cpp index 7ad53eeb6c..3a3903965c 100644 --- a/src/qmlmodels/qqmldelegatemodel.cpp +++ b/src/qmlmodels/qqmldelegatemodel.cpp @@ -2011,7 +2011,7 @@ bool QQmlDelegateModelPrivate::insert(Compositor::insert_iterator &before, const propertyName = it.nextPropertyNameAsString(v); if (propertyName->isNull()) break; - cacheItem->setValue(propertyName->toQStringNoThrow(), scope.engine->toVariant(v, QVariant::Invalid)); + cacheItem->setValue(propertyName->toQStringNoThrow(), scope.engine->toVariant(v, QMetaType::UnknownType)); } cacheItem->groups = groups | Compositor::UnresolvedFlag | Compositor::CacheFlag; diff --git a/src/qmlmodels/qqmllistaccessor.cpp b/src/qmlmodels/qqmllistaccessor.cpp index 46a11e2bc2..c450c616e7 100644 --- a/src/qmlmodels/qqmllistaccessor.cpp +++ b/src/qmlmodels/qqmllistaccessor.cpp @@ -76,11 +76,11 @@ void QQmlListAccessor::setList(const QVariant &v, QQmlEngine *engine) if (!d.isValid()) { m_type = Invalid; - } else if (d.userType() == QVariant::StringList) { + } else if (d.userType() == QMetaType::QStringList) { m_type = StringList; } else if (d.userType() == QMetaType::QVariantList) { m_type = VariantList; - } else if (d.canConvert(QVariant::Int)) { + } else if (d.canConvert(QMetaType::Int)) { // Here we have to check for an upper limit, because down the line code might (well, will) // allocate memory depending on the number of elements. The upper limit cannot be INT_MAX: // QVector> something; diff --git a/src/qmlmodels/qqmllistmodel.cpp b/src/qmlmodels/qqmllistmodel.cpp index f79910204a..fe8fba0cca 100644 --- a/src/qmlmodels/qqmllistmodel.cpp +++ b/src/qmlmodels/qqmllistmodel.cpp @@ -219,14 +219,14 @@ const ListLayout::Role *ListLayout::getRoleOrCreate(const QString &key, const QV { Role::DataType type; - switch (data.type()) { - case QVariant::Double: type = Role::Number; break; - case QVariant::Int: type = Role::Number; break; - case QVariant::Bool: type = Role::Bool; break; - case QVariant::String: type = Role::String; break; - case QVariant::Map: type = Role::VariantMap; break; - case QVariant::DateTime: type = Role::DateTime; break; - case QVariant::UserType: { + switch (data.userType()) { + case QMetaType::Double: type = Role::Number; break; + case QMetaType::Int: type = Role::Number; break; + case QMetaType::Bool: type = Role::Bool; break; + case QMetaType::QString: type = Role::String; break; + case QMetaType::QVariantMap: type = Role::VariantMap; break; + case QMetaType::QDateTime: type = Role::DateTime; break; + default: { if (data.userType() == qMetaTypeId() && data.value().isCallable()) { type = Role::Function; @@ -235,12 +235,14 @@ const ListLayout::Role *ListLayout::getRoleOrCreate(const QString &key, const QV && data.value()->isTranslationBinding()) { type = Role::String; break; - } else { + } else if (data.userType() >= QMetaType::User) { type = Role::List; break; + } else { + type = Role::Invalid; + break; } } - default: type = Role::Invalid; break; } if (type == Role::Invalid) { @@ -1740,7 +1742,7 @@ void DynamicRoleModelNode::updateValues(const QVariantMap &object, QVector if (value.userType() == qMetaTypeId()) value = value.value().toVariant(); - if (value.type() == QVariant::List) { + if (value.userType() == QMetaType::QVariantList) { QQmlListModel *subModel = QQmlListModel::createWithOwner(m_owner); QVariantList subArray = value.toList(); @@ -1803,7 +1805,7 @@ void DynamicRoleModelNodeMetaObject::propertyWritten(int index) if (v.userType() == qMetaTypeId()) v= v.value().toVariant(); - if (v.type() == QVariant::List) { + if (v.userType() == QMetaType::QVariantList) { QQmlListModel *subModel = QQmlListModel::createWithOwner(parentModel); QVariantList subArray = v.toList(); -- cgit v1.2.3 From 0ced82a8cf8472a79b08db05d441caf778ac9131 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 17 Jan 2020 10:32:49 +0100 Subject: Drop all the .2 from import directories No one is going to import version 1 of those anymore, and we will be able to export multiple major versions from the same plugin in Qt6. Change-Id: Icb2b80d349498f0e7c14d27ebba76f3d100d85e8 Reviewed-by: Fabian Kosmale Reviewed-by: Shawn Rutledge --- src/qmlmodels/qmlmodels.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/qmlmodels') diff --git a/src/qmlmodels/qmlmodels.pro b/src/qmlmodels/qmlmodels.pro index 6abc5bf186..d3a7495599 100644 --- a/src/qmlmodels/qmlmodels.pro +++ b/src/qmlmodels/qmlmodels.pro @@ -64,7 +64,7 @@ qtConfig(qml-delegate-model) { } QMLTYPES_FILENAME = plugins.qmltypes -QMLTYPES_INSTALL_DIR = $$[QT_INSTALL_QML]/QtQml/Models.2 +QMLTYPES_INSTALL_DIR = $$[QT_INSTALL_QML]/QtQml/Models QML_IMPORT_NAME = QtQml.Models IMPORT_VERSION = 2.15 CONFIG += qmltypes install_qmltypes install_metatypes -- cgit v1.2.3