aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlmodels/qqmldelegatemodel_p.h
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2019-05-16 10:10:30 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2019-10-09 18:58:18 +0200
commit2d9cf3ef0fc09254b1a63ab04b86d9beb52e71bc (patch)
tree2a4a09fc481336b193677b7e58fc995aeda41681 /src/qmlmodels/qqmldelegatemodel_p.h
parentd522746afa394960bef225ba08080d8364b69a7e (diff)
When a DelegateModel delegate changes, refill the view
It looked a bit odd that the DelegateModel delegate property was not a notifying property. Adding the delegateChanged signal makes it easier to update the view when this happens. The previous approach of removing all delegates and adding all new ones resulted in the view losing its currentIndex and often scrolling to a different place. It's also nice to reduce the number of d-> indirections by adding the QQuickItemViewPrivate::applyDelegateChange() function, so that we just need one indirection to call it, and then it updates all the internal stuff in one place. Done-with: Frederik Gladhorn Done-with: Joni Poikelin Fixes: QTBUG-63477 Change-Id: I2d17fd11ff4a2fcb20968a7182dd2c403abb715a Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/qmlmodels/qqmldelegatemodel_p.h')
-rw-r--r--src/qmlmodels/qqmldelegatemodel_p.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/qmlmodels/qqmldelegatemodel_p.h b/src/qmlmodels/qqmldelegatemodel_p.h
index 21eaef02e0..9e846ccc3e 100644
--- a/src/qmlmodels/qqmldelegatemodel_p.h
+++ b/src/qmlmodels/qqmldelegatemodel_p.h
@@ -77,7 +77,7 @@ class Q_QMLMODELS_PRIVATE_EXPORT QQmlDelegateModel : public QQmlInstanceModel, p
Q_DECLARE_PRIVATE(QQmlDelegateModel)
Q_PROPERTY(QVariant model READ model WRITE setModel)
- Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate)
+ Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
Q_PROPERTY(QString filterOnGroup READ filterGroup WRITE setFilterGroup NOTIFY filterGroupChanged RESET resetFilterGroup)
Q_PROPERTY(QQmlDelegateModelGroup *items READ items CONSTANT) //TODO : worth renaming?
Q_PROPERTY(QQmlDelegateModelGroup *persistedItems READ persistedItems CONSTANT)
@@ -136,6 +136,7 @@ Q_SIGNALS:
void filterGroupChanged();
void defaultGroupsChanged();
void rootIndexChanged();
+ void delegateChanged();
private Q_SLOTS:
void _q_itemsChanged(int index, int count, const QVector<int> &roles);