Skip to content

Commit

Permalink
[ui] Graph: add removeSelectedNodes method
Browse files Browse the repository at this point in the history
Add and use an explicit method to remove the currently selected nodes
in a graph.
  • Loading branch information
yann-lty committed Nov 25, 2024
1 parent 8dd2e04 commit dd49c79
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
17 changes: 11 additions & 6 deletions meshroom/ui/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,18 +676,23 @@ def moveSelectedNodesBy(self, offset: QPoint):
position = Position(node.x + offset.x(), node.y + offset.y())
self.moveNode(node, position)

@Slot(QObject)
def removeNodes(self, nodes):
@Slot()
def removeSelectedNodes(self):
"""Remove selected nodes from the graph."""
self.removeNodes(list(self.iterSelectedNodes()))

@Slot(list)
def removeNodes(self, nodes: list[Node]):
"""
Remove 'nodes' from the graph.
Args:
nodes (list[Node]): the nodes to remove
nodes: The nodes to remove.
"""
nodes = self.filterNodes(nodes)
if any([ n.locked for n in nodes ]):
if any(n.locked for n in nodes):
return
with self.groupedGraphModification("Remove Selected Nodes"):

with self.groupedGraphModification("Remove Nodes"):
for node in nodes:
self.push(commands.RemoveNodeCommand(self._graph, node))

Expand Down
2 changes: 1 addition & 1 deletion meshroom/ui/qml/Application.qml
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ Page {
enabled: _reconstruction ? _reconstruction.selectedNodes.count > 0 : false
onTriggered: {
graphEditor.copyNodes()
graphEditor.uigraph.removeNodes(graphEditor.uigraph.selectedNodes)
graphEditor.uigraph.removeSelectedNodes()
}
}

Expand Down
8 changes: 4 additions & 4 deletions meshroom/ui/qml/GraphEditor/GraphEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ Item {
if (event.modifiers === Qt.AltModifier) {
uigraph.removeNodesFrom(uigraph.selectedNodes)
} else {
uigraph.removeNodes(uigraph.selectedNodes)
uigraph.removeSelectedNodes()
}
} else if (event.key === Qt.Key_D) {
duplicateNode(event.modifiers === Qt.AltModifier)
} else if (event.key === Qt.Key_X && event.modifiers === Qt.ControlModifier) {
copyNodes()
uigraph.removeNodes(uigraph.selectedNodes)
uigraph.removeSelectedNodes()
} else if (event.key === Qt.Key_C && event.modifiers === Qt.ControlModifier) {
copyNodes()
} else if (event.key === Qt.Key_V && event.modifiers === Qt.ControlModifier) {
Expand Down Expand Up @@ -680,7 +680,7 @@ Item {
ToolTip.visible: hovered
onTriggered: {
copyNodes()
uigraph.removeNodes(uigraph.selectedNodes)
uigraph.removeSelectedNodes()
}
}
MenuItem {
Expand Down Expand Up @@ -721,7 +721,7 @@ Item {
MenuItem {
text: "Remove Node(s)" + (removeFollowingButton.hovered ? " From Here" : "")
enabled: nodeMenu.currentNode ? !nodeMenu.currentNode.locked : false
onTriggered: uigraph.removeNodes(uigraph.selectedNodes)
onTriggered: uigraph.removeSelectedNodes()
MaterialToolButton {
id: removeFollowingButton
height: parent.height
Expand Down

0 comments on commit dd49c79

Please sign in to comment.