mirror of https://gitlab.com/pamhyr/pamhyr2
BC: Make node association unique (#25).
parent
01fd7dbec8
commit
c69cbdb34e
|
|
@ -89,3 +89,11 @@ class BoundaryConditionList(PamhyrModelListWithTab):
|
|||
|
||||
def copy(self):
|
||||
return copy(self)
|
||||
|
||||
def get_assoc_to_node(self, tab, node):
|
||||
return next(
|
||||
filter(
|
||||
lambda i: i.node is node,
|
||||
self._tabs[tab]
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -53,12 +53,19 @@ class SetNodeCommand(QUndoCommand):
|
|||
self._index = index
|
||||
self._old = self._bcs.get(self._tab, self._index).node
|
||||
self._new = node
|
||||
self._prev_assoc_to_node = self._bcs.get_assoc_to_node(tab, node)
|
||||
|
||||
def _previous_assoc_node(self, node):
|
||||
if self._prev_assoc_to_node is not None:
|
||||
self._prev_assoc_to_node.node = node
|
||||
|
||||
def undo(self):
|
||||
self._bcs.get(self._tab, self._index).node = self._old
|
||||
self._previous_assoc_node(self._new)
|
||||
|
||||
def redo(self):
|
||||
self._bcs.get(self._tab, self._index).node = self._new
|
||||
self._previous_assoc_node(None)
|
||||
|
||||
|
||||
class SetTypeCommand(QUndoCommand):
|
||||
|
|
|
|||
Loading…
Reference in New Issue