aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlmodels/qqmllistmodel.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2019-12-03 20:24:38 +0100
committerOlivier Goffart <ogoffart@woboq.com>2020-01-17 11:31:35 +0100
commitc6899f16389458766904d8d913054f09076e06dd (patch)
treee24f942a01720775391ae04557e24a35839f7361 /src/qmlmodels/qqmllistmodel.cpp
parent9e674be4fb8c369873a009f58e3152a12d2c4cce (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/qqmllistmodel.cpp')
-rw-r--r--src/qmlmodels/qqmllistmodel.cpp26
1 files changed, 14 insertions, 12 deletions
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();