[ui] GraphEditor: Introduced DelegateSelectionLine to the graph editor

Upon selection end the found intersected edges gets removed
This commit is contained in:
waaake 2025-01-12 19:46:10 +05:30 committed by Candice Bentéjac
parent 7883b51c20
commit 3b1e7e9420

View file

@ -143,6 +143,7 @@ Item {
id: mouseArea
anchors.fill: parent
property double factor: 1.15
property bool removingEdges: false;
// Activate multisampling for edges antialiasing
layer.enabled: true
layer.samples: 8
@ -151,7 +152,7 @@ Item {
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
drag.threshold: 0
drag.smoothed: false
cursorShape: drag.target == draggable ? Qt.ClosedHandCursor : Qt.ArrowCursor
cursorShape: drag.target == draggable ? Qt.ClosedHandCursor : removingEdges ? Qt.CrossCursor : Qt.ArrowCursor
onWheel: function(wheel) {
var zoomFactor = wheel.angleDelta.y > 0 ? factor : 1 / factor
@ -176,9 +177,15 @@ Item {
if (mouse.button == Qt.MiddleButton || (mouse.button == Qt.LeftButton && mouse.modifiers & Qt.AltModifier)) {
drag.target = draggable // start drag
}
if (mouse.button == Qt.LeftButton && (mouse.modifiers & Qt.ControlModifier) && (mouse.modifiers & Qt.AltModifier)) {
edgeSelectionLine.startSelection(mouse);
removingEdges = true;
}
}
onReleased: {
removingEdges = false;
edgeSelectionLine.endSelection()
nodeSelectionBox.endSelection();
drag.target = null;
root.forceActiveFocus()
@ -1005,6 +1012,16 @@ Item {
}
}
DelegateSelectionLine {
id: edgeSelectionLine
mouseArea: mouseArea
modelInstantiator: edgesRepeater
container: draggable
onDelegateSelectionEnded: function(selectedIndices, modifiers) {
uigraph.deleteEdgesByIndices(selectedIndices);
}
}
DropArea {
id: dropArea
anchors.fill: parent