diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-09-27 01:00:58 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-09-27 13:08:12 +0200 |
commit | 1ce1e39b1c9334413473691a218ab4240fba01e1 (patch) | |
tree | 02a8ff6ab6c72cafa5cb45098bbfba4618fe83bc /src/qmlmodels | |
parent | 3cf5f0f6c3f1abe1d279ccae6c7563f14b31f41d (diff) | |
parent | cc1a604c704f848927b3fa0a97b0a50b0b79d2a4 (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
src/imports/folderlistmodel/plugin.cpp
src/imports/shapes/plugin.cpp
src/qml/qml/qqmlengine.cpp
src/qmlmodels/qqmlmodelsmodule.cpp
src/qmlworkerscript/qqmlworkerscriptmodule.cpp
src/quick/items/qquickitemsmodule.cpp
Change-Id: Ib9215a07aa95b5801ce3cb7287f7903926e8c838
Diffstat (limited to 'src/qmlmodels')
-rw-r--r-- | src/qmlmodels/qqmldelegatecomponent_p.h | 5 | ||||
-rw-r--r-- | src/qmlmodels/qqmldelegatemodel.cpp | 8 | ||||
-rw-r--r-- | src/qmlmodels/qqmldelegatemodel_p.h | 7 | ||||
-rw-r--r-- | src/qmlmodels/qqmlinstantiator_p.h | 2 | ||||
-rw-r--r-- | src/qmlmodels/qqmllistmodel_p.h | 10 | ||||
-rw-r--r-- | src/qmlmodels/qqmllistmodelworkeragent_p.h | 2 | ||||
-rw-r--r-- | src/qmlmodels/qqmlmodelsmodule.cpp | 29 | ||||
-rw-r--r-- | src/qmlmodels/qqmlmodelsmodule_p.h | 16 | ||||
-rw-r--r-- | src/qmlmodels/qqmlobjectmodel_p.h | 5 | ||||
-rw-r--r-- | src/qmlmodels/qqmltablemodel_p.h | 1 | ||||
-rw-r--r-- | src/qmlmodels/qqmltablemodelcolumn_p.h | 1 | ||||
-rw-r--r-- | src/qmlmodels/qquickpackage_p.h | 3 |
12 files changed, 67 insertions, 22 deletions
diff --git a/src/qmlmodels/qqmldelegatecomponent_p.h b/src/qmlmodels/qqmldelegatecomponent_p.h index 1d20f0327b..86ad04d2e3 100644 --- a/src/qmlmodels/qqmldelegatecomponent_p.h +++ b/src/qmlmodels/qqmldelegatecomponent_p.h @@ -64,6 +64,9 @@ class QQmlAdaptorModel; class Q_QMLMODELS_PRIVATE_EXPORT QQmlAbstractDelegateComponent : public QQmlComponent { Q_OBJECT + QML_NAMED_ELEMENT(AbstractDelegateComponent) + QML_UNCREATABLE("Cannot create instance of abstract class AbstractDelegateComponent.") + public: QQmlAbstractDelegateComponent(QObject *parent = nullptr); ~QQmlAbstractDelegateComponent() override; @@ -90,6 +93,7 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlDelegateChoice : public QObject Q_PROPERTY(int column READ column WRITE setColumn NOTIFY columnChanged) Q_PROPERTY(QQmlComponent* delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) Q_CLASSINFO("DefaultProperty", "delegate") + QML_NAMED_ELEMENT(DelegateChoice) public: QVariant roleValue() const; void setRoleValue(const QVariant &roleValue); @@ -126,6 +130,7 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlDelegateChooser : public QQmlAbstractDelega Q_PROPERTY(QString role READ role WRITE setRole NOTIFY roleChanged) Q_PROPERTY(QQmlListProperty<QQmlDelegateChoice> choices READ choices CONSTANT) Q_CLASSINFO("DefaultProperty", "choices") + QML_NAMED_ELEMENT(DelegateChooser) public: QString role() const { return m_role; } diff --git a/src/qmlmodels/qqmldelegatemodel.cpp b/src/qmlmodels/qqmldelegatemodel.cpp index e2a750a43a..55bf2ad783 100644 --- a/src/qmlmodels/qqmldelegatemodel.cpp +++ b/src/qmlmodels/qqmldelegatemodel.cpp @@ -932,6 +932,12 @@ void PropertyUpdater::breakBinding() void QQDMIncubationTask::initializeRequiredProperties(QQmlDelegateModelItem *modelItemToIncubate, QObject *object) { auto incubatorPriv = QQmlIncubatorPrivate::get(this); + QQmlData *d = QQmlData::get(object); + auto contextData = d ? d->context : nullptr; + if (contextData) { + contextData->hasExtraObject = true; + contextData->extraObject = modelItemToIncubate; + } if (incubatorPriv->hadRequiredProperties()) { if (incubatorPriv->requiredProperties().empty()) return; @@ -2271,6 +2277,8 @@ QQmlDelegateModelItem *QQmlDelegateModelItem::dataForObject(QObject *object) { QQmlData *d = QQmlData::get(object); QQmlContextData *context = d ? d->context : nullptr; + if (context && context->hasExtraObject) + return qobject_cast<QQmlDelegateModelItem *>(context->extraObject); for (context = context ? context->parent : nullptr; context; context = context->parent) { if (QQmlDelegateModelItem *cacheItem = qobject_cast<QQmlDelegateModelItem *>( context->contextObject)) { diff --git a/src/qmlmodels/qqmldelegatemodel_p.h b/src/qmlmodels/qqmldelegatemodel_p.h index 21eaef02e0..7492f2b77d 100644 --- a/src/qmlmodels/qqmldelegatemodel_p.h +++ b/src/qmlmodels/qqmldelegatemodel_p.h @@ -85,7 +85,11 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlDelegateModel : public QQmlInstanceModel, p Q_PROPERTY(QObject *parts READ parts CONSTANT) Q_PROPERTY(QVariant rootIndex READ rootIndex WRITE setRootIndex NOTIFY rootIndexChanged) Q_CLASSINFO("DefaultProperty", "delegate") + QML_NAMED_ELEMENT(DelegateModel) + QML_ADDED_IN_MINOR_VERSION(1) + QML_ATTACHED(QQmlDelegateModelAttached) Q_INTERFACES(QQmlParserStatus) + public: QQmlDelegateModel(); QQmlDelegateModel(QQmlContext *, QObject *parent=nullptr); @@ -163,6 +167,8 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlDelegateModelGroup : public QObject Q_PROPERTY(int count READ count NOTIFY countChanged) Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(bool includeByDefault READ defaultInclude WRITE setDefaultInclude NOTIFY defaultIncludeChanged) + QML_NAMED_ELEMENT(DelegateModelGroup) + QML_ADDED_IN_MINOR_VERSION(1) public: QQmlDelegateModelGroup(QObject *parent = nullptr); QQmlDelegateModelGroup(const QString &name, QQmlDelegateModel *model, int compositorType, QObject *parent = nullptr); @@ -240,7 +246,6 @@ public: QT_END_NAMESPACE QML_DECLARE_TYPE(QQmlDelegateModel) -QML_DECLARE_TYPEINFO(QQmlDelegateModel, QML_HAS_ATTACHED_PROPERTIES) QML_DECLARE_TYPE(QQmlDelegateModelGroup) #endif // QQMLDATAMODEL_P_H diff --git a/src/qmlmodels/qqmlinstantiator_p.h b/src/qmlmodels/qqmlinstantiator_p.h index 87accc304f..9f6d816d18 100644 --- a/src/qmlmodels/qqmlinstantiator_p.h +++ b/src/qmlmodels/qqmlinstantiator_p.h @@ -72,6 +72,8 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlInstantiator : public QObject, public QQmlP Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) Q_PROPERTY(QObject *object READ object NOTIFY objectChanged) Q_CLASSINFO("DefaultProperty", "delegate") + QML_NAMED_ELEMENT(Instantiator) + QML_ADDED_IN_MINOR_VERSION(1) public: QQmlInstantiator(QObject *parent = nullptr); diff --git a/src/qmlmodels/qqmllistmodel_p.h b/src/qmlmodels/qqmllistmodel_p.h index 10d67c1c6f..dc5063eb97 100644 --- a/src/qmlmodels/qqmllistmodel_p.h +++ b/src/qmlmodels/qqmllistmodel_p.h @@ -83,6 +83,7 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlListModel : public QAbstractListModel Q_PROPERTY(int count READ count NOTIFY countChanged) Q_PROPERTY(bool dynamicRoles READ dynamicRoles WRITE setDynamicRoles) Q_PROPERTY(QObject *agent READ agent CONSTANT REVISION(14)) + QML_NAMED_ELEMENT(ListModel) public: QQmlListModel(QObject *parent=nullptr); @@ -171,7 +172,8 @@ private: // ### FIXME class QQmlListElement : public QObject { -Q_OBJECT + Q_OBJECT + QML_NAMED_ELEMENT(ListElement) }; class QQmlListModelParser : public QQmlCustomParser @@ -201,6 +203,12 @@ private: QString listElementTypeName; }; +template<> +inline QQmlCustomParser *qmlCreateCustomParser<QQmlListModel>() +{ + return new QQmlListModelParser; +} + QT_END_NAMESPACE QML_DECLARE_TYPE(QQmlListModel) diff --git a/src/qmlmodels/qqmllistmodelworkeragent_p.h b/src/qmlmodels/qqmllistmodelworkeragent_p.h index 1ef27cea3f..f65909dcec 100644 --- a/src/qmlmodels/qqmllistmodelworkeragent_p.h +++ b/src/qmlmodels/qqmllistmodelworkeragent_p.h @@ -56,6 +56,7 @@ #include <QEvent> #include <QMutex> #include <QWaitCondition> +#include <QtQml/qqml.h> #include <private/qv4engine_p.h> @@ -71,6 +72,7 @@ class QQmlListModelWorkerAgent : public QObject Q_OBJECT Q_PROPERTY(int count READ count) Q_PROPERTY(QV4::ExecutionEngine *engine READ engine WRITE setEngine NOTIFY engineChanged) + QML_ANONYMOUS public: QQmlListModelWorkerAgent(QQmlListModel *); diff --git a/src/qmlmodels/qqmlmodelsmodule.cpp b/src/qmlmodels/qqmlmodelsmodule.cpp index 4b753fe49a..7ed8561558 100644 --- a/src/qmlmodels/qqmlmodelsmodule.cpp +++ b/src/qmlmodels/qqmlmodelsmodule.cpp @@ -40,16 +40,15 @@ #include "qqmlmodelsmodule_p.h" #include <private/qtqmlmodelsglobal_p.h> -#if QT_CONFIG(itemmodel) -#include <QtCore/qitemselectionmodel.h> -#endif #if QT_CONFIG(qml_list_model) #include <private/qqmllistmodel_p.h> +#include <private/qqmllistmodelworkeragent_p.h> #endif #if QT_CONFIG(qml_delegate_model) #include <private/qqmldelegatemodel_p.h> #include <private/qqmldelegatecomponent_p.h> #include <private/qquickpackage_p.h> +#include <private/qqmlcomponentattached_p.h> #endif #if QT_CONFIG(qml_object_model) #include <private/qqmlobjectmodel_p.h> @@ -67,24 +66,20 @@ void QQmlModelsModule::defineModule() const char uri[] = "QtQml.Models"; #if QT_CONFIG(qml_list_model) - qmlRegisterType<QQmlListElement>(uri, 2, 0, "ListElement"); - qmlRegisterCustomType<QQmlListModel>(uri, 2, 0, "ListModel", new QQmlListModelParser); + qmlRegisterTypesAndRevisions<QQmlListElement, QQmlListModel, QQmlListModelWorkerAgent>(uri, 2); #endif #if QT_CONFIG(qml_delegate_model) + // TODO: Get rid of these. It's called DelegateModel and DelegateModelGroup these days. qmlRegisterType<QQmlDelegateModel>(uri, 2, 0, "VisualDataModel"); qmlRegisterType<QQmlDelegateModelGroup>(uri, 2, 0, "VisualDataGroup"); - qmlRegisterType<QQmlDelegateModel>(uri, 2, 1, "DelegateModel"); - qmlRegisterType<QQmlDelegateModelGroup>(uri, 2, 1, "DelegateModelGroup"); - qmlRegisterType<QQuickPackage>(uri, 2, 0, "Package"); + + qmlRegisterTypesAndRevisions<QQmlDelegateModel, QQmlDelegateModelGroup, QQuickPackage>(uri, 2); #endif #if QT_CONFIG(qml_object_model) - qmlRegisterType<QQmlObjectModel>(uri, 2, 1, "ObjectModel"); - qmlRegisterType<QQmlObjectModel,3>(uri, 2, 3, "ObjectModel"); - qmlRegisterType<QQmlInstantiator>(uri, 2, 1, "Instantiator"); - qmlRegisterAnonymousType<QQmlInstanceModel>(uri, 2); + qmlRegisterTypesAndRevisions<QQmlObjectModel, QQmlInstantiator, QQmlInstanceModel>(uri, 2); #endif #if QT_CONFIG(itemmodel) - qmlRegisterType<QItemSelectionModel>(uri, 2, 2, "ItemSelectionModel"); + qmlRegisterTypesAndRevisions<QItemSelectionModelForeign>(uri, 2); #endif } @@ -93,13 +88,11 @@ void QQmlModelsModule::defineLabsModule() const char uri[] = "Qt.labs.qmlmodels"; #if QT_CONFIG(qml_delegate_model) - qmlRegisterUncreatableType<QQmlAbstractDelegateComponent>(uri, 1, 0, "AbstractDelegateComponent", QQmlAbstractDelegateComponent::tr("Cannot create instance of abstract class AbstractDelegateComponent.")); - qmlRegisterType<QQmlDelegateChooser>(uri, 1, 0, "DelegateChooser"); - qmlRegisterType<QQmlDelegateChoice>(uri, 1, 0, "DelegateChoice"); + qmlRegisterTypesAndRevisions< + QQmlAbstractDelegateComponent, QQmlDelegateChooser, QQmlDelegateChoice>(uri, 1); #endif #if QT_CONFIG(qml_table_model) - qmlRegisterType<QQmlTableModel>(uri, 1, 0, "TableModel"); - qmlRegisterType<QQmlTableModelColumn>(uri, 1, 0, "TableModelColumn"); + qmlRegisterTypesAndRevisions<QQmlTableModel, QQmlTableModelColumn>(uri, 1); #endif } diff --git a/src/qmlmodels/qqmlmodelsmodule_p.h b/src/qmlmodels/qqmlmodelsmodule_p.h index f63052b682..c697b08bf7 100644 --- a/src/qmlmodels/qqmlmodelsmodule_p.h +++ b/src/qmlmodels/qqmlmodelsmodule_p.h @@ -51,6 +51,12 @@ // We mean it. // +#include <QtQml/qqml.h> + +#if QT_CONFIG(itemmodel) +#include <QtCore/qitemselectionmodel.h> +#endif + #include <private/qtqmlmodelsglobal_p.h> QT_BEGIN_NAMESPACE @@ -62,6 +68,16 @@ public: static void defineLabsModule(); }; +#if QT_CONFIG(itemmodel) +struct QItemSelectionModelForeign +{ + Q_GADGET + QML_FOREIGN(QItemSelectionModel) + QML_NAMED_ELEMENT(ItemSelectionModel) + QML_ADDED_IN_MINOR_VERSION(2) +}; +#endif + QT_END_NAMESPACE #endif diff --git a/src/qmlmodels/qqmlobjectmodel_p.h b/src/qmlmodels/qqmlobjectmodel_p.h index 78a5615ae2..0aa818d724 100644 --- a/src/qmlmodels/qqmlobjectmodel_p.h +++ b/src/qmlmodels/qqmlobjectmodel_p.h @@ -69,6 +69,7 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlInstanceModel : public QObject Q_OBJECT Q_PROPERTY(int count READ count NOTIFY countChanged) + QML_ANONYMOUS public: virtual ~QQmlInstanceModel() {} @@ -113,6 +114,9 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlObjectModel : public QQmlInstanceModel Q_PROPERTY(QQmlListProperty<QObject> children READ children NOTIFY childrenChanged DESIGNABLE false) Q_CLASSINFO("DefaultProperty", "children") + QML_NAMED_ELEMENT(ObjectModel) + QML_ADDED_IN_MINOR_VERSION(1) + QML_ATTACHED(QQmlObjectModelAttached) public: QQmlObjectModel(QObject *parent=nullptr); @@ -191,6 +195,5 @@ QT_END_NAMESPACE QML_DECLARE_TYPE(QQmlInstanceModel) QML_DECLARE_TYPE(QQmlObjectModel) -QML_DECLARE_TYPEINFO(QQmlObjectModel, QML_HAS_ATTACHED_PROPERTIES) #endif // QQMLINSTANCEMODEL_P_H diff --git a/src/qmlmodels/qqmltablemodel_p.h b/src/qmlmodels/qqmltablemodel_p.h index b3c0cc2848..4b667e1073 100644 --- a/src/qmlmodels/qqmltablemodel_p.h +++ b/src/qmlmodels/qqmltablemodel_p.h @@ -72,6 +72,7 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlTableModel : public QAbstractTableModel, pu Q_PROPERTY(QQmlListProperty<QQmlTableModelColumn> columns READ columns CONSTANT FINAL) Q_INTERFACES(QQmlParserStatus) Q_CLASSINFO("DefaultProperty", "columns") + QML_NAMED_ELEMENT(TableModel) public: QQmlTableModel(QObject *parent = nullptr); diff --git a/src/qmlmodels/qqmltablemodelcolumn_p.h b/src/qmlmodels/qqmltablemodelcolumn_p.h index 0b6478ce38..33f32ccb68 100644 --- a/src/qmlmodels/qqmltablemodelcolumn_p.h +++ b/src/qmlmodels/qqmltablemodelcolumn_p.h @@ -96,6 +96,7 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlTableModelColumn : public QObject Q_PROPERTY(QJSValue sizeHint READ sizeHint WRITE setSizeHint NOTIFY sizeHintChanged FINAL) Q_PROPERTY(QJSValue setSizeHint READ getSetSizeHint WRITE setSetSizeHint NOTIFY setSizeHintChanged FINAL) + QML_NAMED_ELEMENT(TableModelColumn) public: QQmlTableModelColumn(QObject *parent = nullptr); diff --git a/src/qmlmodels/qquickpackage_p.h b/src/qmlmodels/qquickpackage_p.h index 97f7818fee..801b8d8409 100644 --- a/src/qmlmodels/qquickpackage_p.h +++ b/src/qmlmodels/qquickpackage_p.h @@ -66,6 +66,8 @@ class Q_AUTOTEST_EXPORT QQuickPackage : public QObject Q_DECLARE_PRIVATE(QQuickPackage) Q_CLASSINFO("DefaultProperty", "data") + QML_NAMED_ELEMENT(Package) + QML_ATTACHED(QQuickPackageAttached) Q_PROPERTY(QQmlListProperty<QObject> data READ data) public: @@ -99,6 +101,5 @@ private: QT_END_NAMESPACE QML_DECLARE_TYPE(QQuickPackage) -QML_DECLARE_TYPEINFO(QQuickPackage, QML_HAS_ATTACHED_PROPERTIES) #endif // QQUICKPACKAGE_H |