diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2019-12-03 20:24:38 +0100 |
---|---|---|
committer | Olivier Goffart <ogoffart@woboq.com> | 2020-01-17 11:31:35 +0100 |
commit | c6899f16389458766904d8d913054f09076e06dd (patch) | |
tree | e24f942a01720775391ae04557e24a35839f7361 /src/qmlmodels | |
parent | 9e674be4fb8c369873a009f58e3152a12d2c4cce (diff) |
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 <lars.knoll@qt.io>
Diffstat (limited to 'src/qmlmodels')
-rw-r--r-- | src/qmlmodels/qqmladaptormodel.cpp | 6 | ||||
-rw-r--r-- | src/qmlmodels/qqmldelegatemodel.cpp | 2 | ||||
-rw-r--r-- | src/qmlmodels/qqmllistaccessor.cpp | 4 | ||||
-rw-r--r-- | src/qmlmodels/qqmllistmodel.cpp | 26 |
4 files changed, 20 insertions, 18 deletions
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<QQmlDMCachedModelData *>(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<QQmlDMListAccessorData *>(o->d()->item)->setModelData(v4->toVariant(argv[0], QVariant::Invalid)); + static_cast<QQmlDMListAccessorData *>(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<QPointer<QQuickItem>> 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<QJSValue>() && data.value<QJSValue>().isCallable()) { type = Role::Function; @@ -235,12 +235,14 @@ const ListLayout::Role *ListLayout::getRoleOrCreate(const QString &key, const QV && data.value<const QV4::CompiledData::Binding*>()->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<int> if (value.userType() == qMetaTypeId<QJSValue>()) value = value.value<QJSValue>().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<QJSValue>()) v= v.value<QJSValue>().toVariant(); - if (v.type() == QVariant::List) { + if (v.userType() == QMetaType::QVariantList) { QQmlListModel *subModel = QQmlListModel::createWithOwner(parentModel); QVariantList subArray = v.toList(); |