[ui] GraphEditor: simplify foreach loop menu

This commit is contained in:
Fabien Castan 2024-08-21 00:42:11 +02:00 committed by Aurore LAFAURIE
parent f84654b2ae
commit 62ea6924f6

View file

@ -389,34 +389,21 @@ Item {
} }
contentItem: Row { contentItem: Row {
spacing: 20
Column {
id: listAttrColumn
visible: edgeMenu.currentEdge && edgeMenu.forLoop && expandButton.canExpand
property var listAttr: edgeMenu.currentEdge ? edgeMenu.currentEdge.src.root : null
Layout.alignment: Qt.AlignTop
Text {
id: listAttrMenuText
text: "<b>Iteration:</b>"
color: activePalette.text
}
IntSelector { IntSelector {
tooltipText: "Iterations" tooltipText: "Iterations"
width: listAttrColumn.width
visible: edgeMenu.currentEdge && edgeMenu.forLoop visible: edgeMenu.currentEdge && edgeMenu.forLoop
property var listAttr: edgeMenu.currentEdge ? edgeMenu.currentEdge.src.root : null
// We add 1 to the index because of human readable index (starting at 1) // We add 1 to the index because of human readable index (starting at 1)
value: listAttrColumn.listAttr ? listAttrColumn.listAttr.value.indexOf(edgeMenu.currentEdge.src) + 1 : 0 value: listAttr ? listAttr.value.indexOf(edgeMenu.currentEdge.src) + 1 : 0
range: { "min": 1, "max": listAttrColumn.listAttr ? listAttrColumn.listAttr.value.count : 0 } range: { "min": 1, "max": listAttr ? listAttr.value.count : 0 }
onValueChanged: { onValueChanged: {
if (listAttrColumn.listAttr === null) { if (listAttr === null) {
return return
} }
const newSrcAttr = listAttrColumn.listAttr.value.at(value - 1) const newSrcAttr = listAttr.value.at(value - 1)
const dst = edgeMenu.currentEdge.dst const dst = edgeMenu.currentEdge.dst
// if the edge exists do not replace it // if the edge exists do not replace it
@ -426,16 +413,7 @@ Item {
edgeMenu.currentEdge = uigraph.replaceEdge(edgeMenu.currentEdge, newSrcAttr, dst) edgeMenu.currentEdge = uigraph.replaceEdge(edgeMenu.currentEdge, newSrcAttr, dst)
} }
} }
}
Column {
Layout.alignment: Qt.AlignTop
Text {
text: "<b>Actions:</b>"
color: activePalette.text
}
Row {
MaterialToolButton { MaterialToolButton {
font.pointSize: 13 font.pointSize: 13
ToolTip.text: "Remove edge" ToolTip.text: "Remove edge"
@ -482,8 +460,6 @@ Item {
} }
} }
} }
}
}
// Edges // Edges
Repeater { Repeater {