[ui] GraphEditor: show/hide advanced Attributes

* use SortFilterModels to filter out  advanced attributes when hidden
* add GraphEditorSettings with persistent settings related to the GraphEditor
This commit is contained in:
Yann Lanthony 2018-12-13 21:05:50 +01:00
parent 168b573e36
commit 1c935b6b5a
4 changed files with 60 additions and 24 deletions

View file

@ -46,6 +46,11 @@ ColumnLayout {
}
Menu {
id: settingsMenu
MenuItem {
text: "Advanced Attributes"
checked: GraphEditorSettings.showAdvancedAttributes
onClicked: GraphEditorSettings.showAdvancedAttributes = !GraphEditorSettings.showAdvancedAttributes
}
MenuItem {
text: "Open Cache Folder"
onClicked: Qt.openUrlExternally(Filepath.stringToUrl(node.internalFolder))
@ -87,21 +92,32 @@ ColumnLayout {
id: attributesListView
anchors.fill: parent
anchors.margins: 4
anchors.margins: 2
clip: true
spacing: 1
spacing: 2
ScrollBar.vertical: ScrollBar { id: scrollBar }
model: node ? node.attributes : undefined
model: SortFilterDelegateModel {
delegate: AttributeItemDelegate {
readOnly: root.isCompatibilityNode
labelWidth: 180
width: attributesListView.width
attribute: object
onDoubleClicked: root.attributeDoubleClicked(attr)
model: node ? node.attributes : null
filterRole: GraphEditorSettings.showAdvancedAttributes ? "" : "advanced"
filterValue: false
function modelData(item, roleName) {
return item.model.object.desc[roleName]
}
Component {
id: delegateComponent
AttributeItemDelegate {
width: attributesListView.width - scrollBar.width
readOnly: root.isCompatibilityNode
labelWidth: 180
attribute: object
onDoubleClicked: root.attributeDoubleClicked(attr)
}
}
}
// Helper MouseArea to lose edit/activeFocus
// when clicking on the background
MouseArea {

View file

@ -331,26 +331,34 @@ RowLayout {
id: groupAttribute_component
ListView {
id: chilrenListView
model: attribute.value
implicitWidth: parent.width
implicitHeight: childrenRect.height
onCountChanged: forceLayout()
spacing: 2
model: SortFilterDelegateModel {
model: attribute.value
filterRole: GraphEditorSettings.showAdvancedAttributes ? "" : "advanced"
filterValue: false
delegate: RowLayout {
id: row
width: chilrenListView.width
property var childAttrib: object
function modelData(item, roleName) {
return item.model.object.desc[roleName]
}
Component.onCompleted: {
var cpt = Qt.createComponent("AttributeItemDelegate.qml")
var obj = cpt.createObject(row,
{'attribute': Qt.binding(function() { return row.childAttrib }),
'readOnly': Qt.binding(function() { return root.readOnly })
})
obj.Layout.fillWidth = true
obj.labelWidth = 100 // reduce label width for children (space gain)
obj.doubleClicked.connect(function(attr) {root.doubleClicked(attr)})
delegate: RowLayout {
id: row
width: chilrenListView.width
property var childAttrib: object
Component.onCompleted: {
var cpt = Qt.createComponent("AttributeItemDelegate.qml")
var obj = cpt.createObject(row,
{'attribute': Qt.binding(function() { return row.childAttrib }),
'readOnly': Qt.binding(function() { return root.readOnly })
})
obj.Layout.fillWidth = true
obj.labelWidth = 100 // reduce label width for children (space gain)
obj.doubleClicked.connect(function(attr) {root.doubleClicked(attr)})
}
}
}
}

View file

@ -0,0 +1,11 @@
pragma Singleton
import Qt.labs.settings 1.0
/**
* Persistent Settings related to the GraphEditor module.
*/
Settings {
category: 'GraphEditor'
property bool showAdvancedAttributes: false
}

View file

@ -9,3 +9,4 @@ AttributeEditor 1.0 AttributeEditor.qml
AttributeItemDelegate 1.0 AttributeItemDelegate.qml
CompatibilityBadge 1.0 CompatibilityBadge.qml
CompatibilityManager 1.0 CompatibilityManager.qml
singleton GraphEditorSettings 1.0 GraphEditorSettings.qml