[ui] Display for loop size on edges

This commit is contained in:
Aurore LAFAURIE 2024-08-19 12:07:22 +02:00
parent 1f995c23d6
commit aba045f4aa
3 changed files with 14 additions and 17 deletions

View file

@ -18,6 +18,7 @@ Item {
property alias thickness: path.strokeWidth property alias thickness: path.strokeWidth
property alias color: path.strokeColor property alias color: path.strokeColor
property bool isForLoop: false property bool isForLoop: false
property int loopSize: 0
property int iteration: 0 property int iteration: 0
// BUG: edgeArea is destroyed before path, need to test if not null to avoid warnings // BUG: edgeArea is destroyed before path, need to test if not null to avoid warnings
@ -82,25 +83,17 @@ Item {
height: childrenRect.height + 2 * margin height: childrenRect.height + 2 * margin
radius: width radius: width
color: path.strokeColor color: path.strokeColor
MaterialLabel { MaterialToolLabel {
id: icon id: icon
x: parent.margin x: parent.margin
y: parent.margin y: parent.margin
text: MaterialIcons.loop iconText: MaterialIcons.loop
label: (root.iteration + 1) + "/" + root.loopSize
color: palette.base color: palette.base
font.pointSize: 24
ToolTip.text: "This is a for loop" ToolTip.text: "This is a for loop"
} }
Label {
x: icon.width / 2.4
y: icon.height / 3
font.pixelSize: 10
text: root.iteration
color: palette.base
font.bold: true
}
} }
} }

View file

@ -411,14 +411,16 @@ Item {
anchors.top: listAttrMenuText.bottom anchors.top: listAttrMenuText.bottom
anchors.horizontalCenter: listAttrColumn.horizontalCenter anchors.horizontalCenter: listAttrColumn.horizontalCenter
visible: edgeMenu.currentEdge && edgeMenu.forLoop visible: edgeMenu.currentEdge && edgeMenu.forLoop
value: listAttrColumn.listAttr ? listAttrColumn.listAttr.value.indexOf(edgeMenu.currentEdge.src) : 0
range: { "min": 0, "max": listAttrColumn.listAttr ? listAttrColumn.listAttr.value.count - 1 : 0 } // 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
range: { "min": 1, "max": listAttrColumn.listAttr ? listAttrColumn.listAttr.value.count : 0 }
onValueChanged: { onValueChanged: {
if (listAttrColumn.listAttr === null) { if (listAttrColumn.listAttr === null) {
return return
} }
const newSrcAttr = listAttrColumn.listAttr.value.at(value) const newSrcAttr = listAttrColumn.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
@ -499,6 +501,7 @@ Item {
edge: object edge: object
isForLoop: forLoop isForLoop: forLoop
loopSize: forLoop ? edge.src.root.value.count : 0
iteration: forLoop ? edge.src.root.value.indexOf(edge.src) : 0 iteration: forLoop ? edge.src.root.value.indexOf(edge.src) : 0
color: edge.dst === root.edgeAboutToBeRemoved ? "red" : inFocus ? activePalette.highlight : activePalette.text color: edge.dst === root.edgeAboutToBeRemoved ? "red" : inFocus ? activePalette.highlight : activePalette.text
thickness: (forLoop && inFocus) ? 3 : (forLoop || inFocus) ? 2 : 1 thickness: (forLoop && inFocus) ? 3 : (forLoop || inFocus) ? 2 : 1

View file

@ -12,6 +12,7 @@ Item {
property alias iconText: iconItem.text property alias iconText: iconItem.text
property alias iconSize: iconItem.font.pointSize property alias iconSize: iconItem.font.pointSize
property alias label: labelItem.text property alias label: labelItem.text
property var color: palette.text
implicitWidth: childrenRect.width implicitWidth: childrenRect.width
implicitHeight: childrenRect.height implicitHeight: childrenRect.height
anchors.rightMargin: 5 anchors.rightMargin: 5
@ -23,12 +24,12 @@ Item {
font.pointSize: 13 font.pointSize: 13
padding: 0 padding: 0
text: "" text: ""
color: palette.text color: color
} }
Label { Label {
id: labelItem id: labelItem
text: "" text: ""
color: palette.text color: color
} }
} }