[ui] AttributeEditor: remove SortFilterDelegateModel

Usage of DelegateModel for model filtering has not proven to be the most stable solution, and might be responsible for random crashes happening during engine's garbage collection.  Implement Loader-based alternative:
* first delegate is a Loader which creates the AttributeItemDelegate if necessary
* compensate spacing using negative height when element is hidden
This commit is contained in:
Yann Lanthony 2019-02-08 15:37:06 +01:00
parent b42f637ac0
commit 45faa860c9

View file

@ -19,31 +19,25 @@ ListView {
implicitHeight: contentHeight implicitHeight: contentHeight
clip: true
spacing: 2 spacing: 2
clip: true
ScrollBar.vertical: ScrollBar { id: scrollBar } ScrollBar.vertical: ScrollBar { id: scrollBar }
model: SortFilterDelegateModel {
model: attributes model: attributes
filterRole: GraphEditorSettings.showAdvancedAttributes ? "" : "advanced"
filterValue: false
function modelData(item, roleName) { delegate: Loader {
return item.model.object.desc[roleName] active: !object.desc.advanced || GraphEditorSettings.showAdvancedAttributes
} visible: active
height: item ? item.implicitHeight : -spacing // compensate for spacing if item is hidden
Component { sourceComponent: AttributeItemDelegate {
id: delegateComponent width: root.width - scrollBar.width
AttributeItemDelegate {
width: ListView.view.width - scrollBar.width
readOnly: root.readOnly readOnly: root.readOnly
labelWidth: root.labelWidth labelWidth: root.labelWidth
attribute: object attribute: object
onDoubleClicked: root.attributeDoubleClicked(mouse, attr) onDoubleClicked: root.attributeDoubleClicked(mouse, attr)
} }
} }
}
// Helper MouseArea to lose edit/activeFocus // Helper MouseArea to lose edit/activeFocus
// when clicking on the background // when clicking on the background