mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-04 20:56:50 +02:00
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
50 lines
1.2 KiB
QML
50 lines
1.2 KiB
QML
import QtQuick 2.9
|
|
import QtQuick.Layouts 1.3
|
|
import QtQuick.Controls 2.2
|
|
import MaterialIcons 2.2
|
|
import Utils 1.0
|
|
|
|
/**
|
|
* A component to display and edit the attributes of a Node.
|
|
*/
|
|
|
|
ListView {
|
|
id: root
|
|
property variant attributes: null
|
|
property bool readOnly: false
|
|
property int labelWidth: 180
|
|
|
|
signal upgradeRequest()
|
|
signal attributeDoubleClicked(var mouse, var attribute)
|
|
|
|
implicitHeight: contentHeight
|
|
|
|
spacing: 2
|
|
clip: true
|
|
ScrollBar.vertical: ScrollBar { id: scrollBar }
|
|
|
|
model: attributes
|
|
|
|
delegate: Loader {
|
|
active: !object.desc.advanced || GraphEditorSettings.showAdvancedAttributes
|
|
visible: active
|
|
height: item ? item.implicitHeight : -spacing // compensate for spacing if item is hidden
|
|
|
|
sourceComponent: AttributeItemDelegate {
|
|
width: root.width - scrollBar.width
|
|
readOnly: root.readOnly
|
|
labelWidth: root.labelWidth
|
|
attribute: object
|
|
onDoubleClicked: root.attributeDoubleClicked(mouse, attr)
|
|
}
|
|
}
|
|
|
|
// Helper MouseArea to lose edit/activeFocus
|
|
// when clicking on the background
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
onClicked: root.forceActiveFocus()
|
|
z: -1
|
|
}
|
|
}
|
|
|