diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2017-12-13 18:44:41 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2017-12-15 11:05:32 +0000 |
commit | 8a0f0553e4eb8468513bbb8ba45a9ec2bcd6ce68 (patch) | |
tree | 7a160b83efade715c630ce8348bd7561d99cac0d | |
parent | 15c909f4170450cdbe01218a0d7cbea55b70fae5 (diff) | |
download | qtquickcontrols-8a0f0553e4eb8468513bbb8ba45a9ec2bcd6ce68.tar.gz |
TableView: Don't unset the delegate loader source component
Once we've loaded the delegate, we want to keep it. Constantly deleting
and recreating items is rather wasteful.
The items could already be moved to a different location before, so
keeping them around when the item is completely disabled doesn't make
much of a difference. We do retain the behavior of only instantiating
the delegate once we add it to the table, though.
Change-Id: Ic3cd016bc6990f0a9695b5aeb0d1de3aad0f4ca1
Task-number: QTBUG-62809
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Reviewed-by: Louis du Verdier <louis.du.verdier@free.fr>
-rw-r--r-- | src/controls/Private/TableViewItemDelegateLoader.qml | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/controls/Private/TableViewItemDelegateLoader.qml b/src/controls/Private/TableViewItemDelegateLoader.qml index 544b08f8..462a2bb4 100644 --- a/src/controls/Private/TableViewItemDelegateLoader.qml +++ b/src/controls/Private/TableViewItemDelegateLoader.qml @@ -65,7 +65,9 @@ Loader { width: __column ? __column.width : 0 height: parent ? parent.height : 0 visible: __column ? __column.visible : false - sourceComponent: __model === undefined || styleData.row === -1 ? null + + property bool isValid: false + sourceComponent: (__model === undefined || !isValid) ? null : __column && __column.delegate ? __column.delegate : __itemDelegate // All these properties are internal @@ -95,5 +97,6 @@ Loader { readonly property var value: model && model.hasOwnProperty(role) ? model[role] // Qml ListModel and QAbstractItemModel : modelData && modelData.hasOwnProperty(role) ? modelData[role] // QObjectList / QObject : modelData != undefined ? modelData : "" // Models without role + onRowChanged: if (row !== -1) itemDelegateLoader.isValid = true } } |