[ui] return command result after pushing it to the undo stack

this allows to directly retrieve, for instance, the node created by UIGraph.addNode method
This commit is contained in:
Yann Lanthony 2018-01-10 14:12:48 +01:00
parent 22c54bd1c5
commit 4ea793be74
2 changed files with 19 additions and 8 deletions

View file

@ -210,7 +210,7 @@ class UIGraph(QObject):
Args:
command (commands.UndoCommand): the command to push
"""
self._undoStack.tryAndPush(command)
return self._undoStack.tryAndPush(command)
def groupedGraphModification(self, title):
""" Get a GroupedGraphModification for this Reconstruction.
@ -223,9 +223,18 @@ class UIGraph(QObject):
"""
return commands.GroupedGraphModification(self._graph, self._undoStack, title)
@Slot(str)
def addNode(self, nodeType):
self.push(commands.AddNodeCommand(self._graph, nodeType))
@Slot(str, result=QObject)
def addNode(self, nodeType, **kwargs):
""" [Undoable]
Create a new Node of type 'nodeType' and returns it.
Args:
nodeType (str): the type of the Node to create.
**kwargs: optional node attributes values
Returns:
Node: the created node
"""
return self.push(commands.AddNodeCommand(self._graph, nodeType, **kwargs))
@Slot(graph.Node)
def removeNode(self, node):