From ca8f4300245d289fa24b4cbd594ef25ec62c40c8 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 20 Feb 2019 08:25:10 +0100 Subject: doc: Clarify that DelegateModel is a kind of proxy model It was not quite clear in the GridView DnD example that the ListModel doesn't get reordered, so if new ListElements are inserted after reordering the DelegateModel by DnD, predicting the position where new delegates will appear becomes a bit of a riddle. Also: - the QQmlDelegateModelAttached::model is a model, not an int - disambiguate the properties that have the same names in QQmlDelegateModel and QQmlDelegateModelAttached, using \keyword for linking. Task-number: QTBUG-34891 Change-Id: I485fd632f67d607652428b4e3c9ca528e57f7348 Reviewed-by: Venugopal Shivashankar --- src/qml/types/qqmldelegatemodel.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/qml/types') diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index 53e3f65553..fa7ce946fb 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -353,6 +353,7 @@ void QQmlDelegateModel::componentComplete() \l{QtQuick.XmlListModel::XmlListModel}{XmlListModel}. \sa {qml-data-models}{Data Models} + \keyword dm-model-property */ QVariant QQmlDelegateModel::model() const { @@ -493,11 +494,10 @@ void QQmlDelegateModel::setDelegate(QQmlComponent *delegate) \c view.qml: \snippet delegatemodel/delegatemodel_rootindex/view.qml 0 - If the \l model is a QAbstractItemModel subclass, the delegate can also - reference a \c hasModelChildren property (optionally qualified by a - \e model. prefix) that indicates whether the delegate's model item has - any child nodes. - + If the \l {dm-model-property}{model} is a QAbstractItemModel subclass, + the delegate can also reference a \c hasModelChildren property (optionally + qualified by a \e model. prefix) that indicates whether the delegate's + model item has any child nodes. \sa modelIndex(), parentModelIndex() */ @@ -699,6 +699,7 @@ QQmlDelegateModelGroup *QQmlDelegateModelPrivate::group_at( The following example illustrates using groups to select items in a model. \snippet delegatemodel/delegatemodelgroup.qml 0 + \keyword dm-groups-property */ QQmlListProperty QQmlDelegateModel::groups() @@ -2274,7 +2275,7 @@ void QQmlDelegateModelAttached::resetCurrentIndex() } /*! - \qmlattachedproperty int QtQml.Models::DelegateModel::model + \qmlattachedproperty model QtQml.Models::DelegateModel::model This attached property holds the data model this delegate instance belongs to. @@ -3094,6 +3095,11 @@ void QQmlDelegateModelGroup::setGroups(QQmlV4Function *args) \qmlmethod QtQml.Models::DelegateModelGroup::move(var from, var to, int count) Moves \a count at \a from in a group \a to a new position. + + \note The DelegateModel acts as a proxy model: it holds the delegates in a + different order than the \l{dm-model-property}{underlying model} has them. + Any subsequent changes to the underlying model will not undo whatever + reordering you have done via this function. */ void QQmlDelegateModelGroup::move(QQmlV4Function *args) -- cgit v1.2.3 From 32de8dce311ddc562f88db47149c702fe9dcc950 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 1 Mar 2019 11:16:33 +0100 Subject: Doc: Document peculiarity of sorting DelegateModelGroups If an item is part of multiple groups, moving it in one group also moves it in all other groups. This has been the case since the groups exist. Fixes: QTBUG-73707 Change-Id: Id1a6e82f667eaf992982e693475b734f485eb8a2 Reviewed-by: Mitch Curtis --- src/qml/types/qqmldelegatemodel.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/qml/types') diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index fa7ce946fb..572f58339f 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -2483,7 +2483,8 @@ void QQmlDelegateModelGroupPrivate::destroyingPackage(QQuickPackage *package) information about group membership and indexes as well as model data. In combination with the move() function this can be used to implement view sorting, with remove() to filter items out of a view, or with setGroups() and \l Package delegates to categorize items into - different views. + different views. Different groups can only be sorted independently if they are disjunct. Moving + an item in one group will also move it in all other groups it is a part of. Data from models can be supplemented by inserting data directly into a DelegateModelGroup with the insert() function. This can be used to introduce mock items into a view, or -- cgit v1.2.3