aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlmodels
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-01-29 16:41:59 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-01-29 16:52:58 +0100
commitb684ba219493fb7b0108ae367d6d033aaa28053b (patch)
treef1fec8922da198e231416b50ef8f441ef6db065b /src/qmlmodels
parent97a5cf86345fd72cdff83c03664c19a8f5cdf79a (diff)
parent8354851b628ebae567a9125cbd0ba69268470c1b (diff)
Merge remote-tracking branch 'origin/dev' into wip/cmake
Conflicts: dependencies.yaml Change-Id: Ie3e9dc62031a85e5e81cbdf04694b95159d49fca
Diffstat (limited to 'src/qmlmodels')
-rw-r--r--src/qmlmodels/qmlmodels.pro2
-rw-r--r--src/qmlmodels/qqmladaptormodel.cpp6
-rw-r--r--src/qmlmodels/qqmldelegatemodel.cpp2
-rw-r--r--src/qmlmodels/qqmllistaccessor.cpp4
-rw-r--r--src/qmlmodels/qqmllistmodel.cpp26
5 files changed, 21 insertions, 19 deletions
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
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 1bbe9360bb..2c05b04429 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) {
@@ -1722,7 +1724,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();
@@ -1785,7 +1787,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();