From b8778ca03027266d5408a9d61a1ca5fa94ac07f7 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 18 Dec 2017 18:15:16 +0100 Subject: Add a feature for ListModel Change-Id: Ic7ae1f601084ec07fe9e500516eb7092818451aa Reviewed-by: Simon Hausmann --- src/qml/configure.json | 9 ++++++++- src/qml/jsruntime/qv4serialize.cpp | 10 ++++++++++ src/qml/qml/qqmlengine.cpp | 4 ++++ src/qml/types/qqmllistmodel_p.h | 2 ++ src/qml/types/qqmllistmodel_p_p.h | 2 ++ src/qml/types/qqmllistmodelworkeragent_p.h | 2 ++ src/qml/types/qqmlmodelsmodule.cpp | 4 ++++ src/qml/types/qquickworkerscript.cpp | 3 +++ src/qml/types/types.pri | 16 +++++++++++----- 9 files changed, 46 insertions(+), 6 deletions(-) (limited to 'src/qml') diff --git a/src/qml/configure.json b/src/qml/configure.json index 8e725fd374..f50c07b359 100644 --- a/src/qml/configure.json +++ b/src/qml/configure.json @@ -51,6 +51,12 @@ "purpose": "Supports mapping sequence types into QML.", "section": "QML", "output": [ "privateFeature" ] + }, + "qml-list-model": { + "label": "QML list model", + "purpose": "Provides the ListModel QML type.", + "section": "QML", + "output": [ "privateFeature" ] } }, @@ -60,7 +66,8 @@ "entries": [ "qml-network", "qml-debug", - "qml-sequence-object" + "qml-sequence-object", + "qml-list-model" ] } ] diff --git a/src/qml/jsruntime/qv4serialize.cpp b/src/qml/jsruntime/qv4serialize.cpp index 9bb226a1af..31b51cbfe3 100644 --- a/src/qml/jsruntime/qv4serialize.cpp +++ b/src/qml/jsruntime/qv4serialize.cpp @@ -40,8 +40,10 @@ #include "qv4serialize_p.h" #include +#if QT_CONFIG(qml_list_model) #include #include +#endif #include #include @@ -84,7 +86,9 @@ enum Type { WorkerNumber, WorkerDate, WorkerRegexp, +#if QT_CONFIG(qml_list_model) WorkerListModel, +#endif #if QT_CONFIG(qml_sequence_object) WorkerSequence #endif @@ -232,6 +236,7 @@ void Serialize::serialize(QByteArray &data, const QV4::Value &v, ExecutionEngine } else if (const QObjectWrapper *qobjectWrapper = v.as()) { // XXX TODO: Generalize passing objects between the main thread and worker scripts so // that others can trivially plug in their elements. +#if QT_CONFIG(qml_list_model) QQmlListModel *lm = qobject_cast(qobjectWrapper->object()); if (lm && lm->agent()) { QQmlListModelWorkerAgent *agent = lm->agent(); @@ -240,6 +245,9 @@ void Serialize::serialize(QByteArray &data, const QV4::Value &v, ExecutionEngine push(data, (void *)agent); return; } +#else + Q_UNUSED(qobjectWrapper); +#endif // No other QObject's are allowed to be sent push(data, valueheader(WorkerUndefined)); } else if (const Object *o = v.as()) { @@ -359,6 +367,7 @@ ReturnedValue Serialize::deserialize(const char *&data, ExecutionEngine *engine) data += ALIGN(length * sizeof(quint16)); return Encode(engine->newRegExpObject(pattern, flags)); } +#if QT_CONFIG(qml_list_model) case WorkerListModel: { void *ptr = popPtr(data); @@ -375,6 +384,7 @@ ReturnedValue Serialize::deserialize(const char *&data, ExecutionEngine *engine) agent->setEngine(engine); return rv->asReturnedValue(); } +#endif #if QT_CONFIG(qml_sequence_object) case WorkerSequence: { diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 80ec44e1e4..39ac767c2c 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -85,7 +85,9 @@ #if QT_CONFIG(animation) #include #endif +#if QT_CONFIG(qml_list_model) #include +#endif #include #include #include @@ -236,8 +238,10 @@ void QQmlEnginePrivate::registerBaseTypes(const char *uri, int versionMajor, int // These QtQuick types' implementation resides in the QtQml module void QQmlEnginePrivate::registerQtQuick2Types(const char *uri, int versionMajor, int versionMinor) { +#if QT_CONFIG(qml_list_model) qmlRegisterType(uri, versionMajor, versionMinor, "ListElement"); // Now in QtQml.Models, here for compatibility qmlRegisterCustomType(uri, versionMajor, versionMinor, "ListModel", new QQmlListModelParser); // Now in QtQml.Models, here for compatibility +#endif qmlRegisterType(uri, versionMajor, versionMinor, "WorkerScript"); qmlRegisterType(uri, versionMajor, versionMinor, "Package"); qmlRegisterType(uri, versionMajor, versionMinor, "VisualDataModel"); diff --git a/src/qml/types/qqmllistmodel_p.h b/src/qml/types/qqmllistmodel_p.h index cbb12caa20..147b845047 100644 --- a/src/qml/types/qqmllistmodel_p.h +++ b/src/qml/types/qqmllistmodel_p.h @@ -64,6 +64,8 @@ #include #include +QT_REQUIRE_CONFIG(qml_list_model); + QT_BEGIN_NAMESPACE diff --git a/src/qml/types/qqmllistmodel_p_p.h b/src/qml/types/qqmllistmodel_p_p.h index 81b9956ecb..01375da109 100644 --- a/src/qml/types/qqmllistmodel_p_p.h +++ b/src/qml/types/qqmllistmodel_p_p.h @@ -57,6 +57,8 @@ #include #include +QT_REQUIRE_CONFIG(qml_list_model); + QT_BEGIN_NAMESPACE diff --git a/src/qml/types/qqmllistmodelworkeragent_p.h b/src/qml/types/qqmllistmodelworkeragent_p.h index 761a467e89..6973f55426 100644 --- a/src/qml/types/qqmllistmodelworkeragent_p.h +++ b/src/qml/types/qqmllistmodelworkeragent_p.h @@ -59,6 +59,8 @@ #include +QT_REQUIRE_CONFIG(qml_list_model); + QT_BEGIN_NAMESPACE diff --git a/src/qml/types/qqmlmodelsmodule.cpp b/src/qml/types/qqmlmodelsmodule.cpp index a55d7af25d..872d7c059f 100644 --- a/src/qml/types/qqmlmodelsmodule.cpp +++ b/src/qml/types/qqmlmodelsmodule.cpp @@ -39,7 +39,9 @@ #include "qqmlmodelsmodule_p.h" #include +#if QT_CONFIG(qml_list_model) #include +#endif #include #include @@ -49,8 +51,10 @@ void QQmlModelsModule::defineModule() { const char uri[] = "QtQml.Models"; +#if QT_CONFIG(qml_list_model) qmlRegisterType(uri, 2, 1, "ListElement"); qmlRegisterCustomType(uri, 2, 1, "ListModel", new QQmlListModelParser); +#endif qmlRegisterType(uri, 2, 1, "DelegateModel"); qmlRegisterType(uri, 2, 9, "DelegateModel"); qmlRegisterType(uri, 2, 1, "DelegateModelGroup"); diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp index a9039cc4b9..85afcf915b 100644 --- a/src/qml/types/qquickworkerscript.cpp +++ b/src/qml/types/qquickworkerscript.cpp @@ -37,9 +37,12 @@ ** ****************************************************************************/ +#include "qtqmlglobal_p.h" #include "qquickworkerscript_p.h" +#if QT_CONFIG(qml_list_model) #include "qqmllistmodel_p.h" #include "qqmllistmodelworkeragent_p.h" +#endif #include #include diff --git a/src/qml/types/types.pri b/src/qml/types/types.pri index e85ab5982b..574e7c214d 100644 --- a/src/qml/types/types.pri +++ b/src/qml/types/types.pri @@ -2,8 +2,6 @@ SOURCES += \ $$PWD/qqmlbind.cpp \ $$PWD/qqmlconnections.cpp \ $$PWD/qqmldelegatemodel.cpp \ - $$PWD/qqmllistmodel.cpp \ - $$PWD/qqmllistmodelworkeragent.cpp \ $$PWD/qqmlmodelsmodule.cpp \ $$PWD/qqmlmodelindexvaluetype.cpp \ $$PWD/qqmlobjectmodel.cpp \ @@ -16,9 +14,6 @@ HEADERS += \ $$PWD/qqmlconnections_p.h \ $$PWD/qqmldelegatemodel_p.h \ $$PWD/qqmldelegatemodel_p_p.h \ - $$PWD/qqmllistmodel_p.h \ - $$PWD/qqmllistmodel_p_p.h \ - $$PWD/qqmllistmodelworkeragent_p.h \ $$PWD/qqmlmodelsmodule_p.h \ $$PWD/qqmlmodelindexvaluetype_p.h \ $$PWD/qqmlobjectmodel_p.h \ @@ -27,6 +22,17 @@ HEADERS += \ $$PWD/qqmlinstantiator_p.h \ $$PWD/qqmlinstantiator_p_p.h +qtConfig(qml-list-model) { + SOURCES += \ + $$PWD/qqmllistmodel.cpp \ + $$PWD/qqmllistmodelworkeragent.cpp + + HEADERS += \ + $$PWD/qqmllistmodel_p.h \ + $$PWD/qqmllistmodel_p_p.h \ + $$PWD/qqmllistmodelworkeragent_p.h +} + qtConfig(animation) { SOURCES += \ $$PWD/qqmltimer.cpp -- cgit v1.2.3