From ddf5941288cc9238069636685a633d0f5515349f Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr> Date: Fri, 9 Jun 2023 09:46:50 +0200 Subject: [PATCH] Network: Fix edge table set node. --- src/View/Network/Table.py | 3 ++- src/View/Network/UndoCommand.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/View/Network/Table.py b/src/View/Network/Table.py index 3031350a..54ab5d74 100644 --- a/src/View/Network/Table.py +++ b/src/View/Network/Table.py @@ -143,7 +143,8 @@ class GraphTableModel(QAbstractTableModel): self.headers[index.column()] == "node2"): node = self.graph.node(value) self._undo.push( - SetCommand( + SetNodeCommand( + self.graph, self.rows[index.row()], self.headers[index.column()], node diff --git a/src/View/Network/UndoCommand.py b/src/View/Network/UndoCommand.py index 72c4f8ae..979ec866 100644 --- a/src/View/Network/UndoCommand.py +++ b/src/View/Network/UndoCommand.py @@ -94,6 +94,22 @@ class SetCommand(QUndoCommand): def redo(self): self._el[self._column] = self._new + +class SetNodeCommand(QUndoCommand): + def __init__(self, graph, element, column, new_value): + QUndoCommand.__init__(self) + + self._el = element + self._column = column + self._old = graph.node(self._el[self._column]) + self._new = new_value + + def undo(self): + self._el[self._column] = self._old + + def redo(self): + self._el[self._column] = self._new + class EnableEdgeCommand(QUndoCommand): def __init__(self, edge, enable): QUndoCommand.__init__(self) -- GitLab