Commit 92d1549d authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

geometry: Fix profile add, undo.

Showing with 9 additions and 3 deletions
+9 -3
......@@ -79,13 +79,15 @@ class Reach:
index: The position of the new profile.
Returns:
Nothing.
The new profile.
"""
profile = ProfileXYZ(reach=self)
self._profiles.insert(index, profile)
self._update_profile_numbers()
return profile
def insert_profile(self, index: int, profile: Profile):
"""Insert new profile in list
......
......@@ -40,12 +40,16 @@ class AddCommand(QUndoCommand):
self._reach = reach
self._index = index
self._profile = None
def undo(self):
self._reach.delete(self._index)
self._reach.delete_profiles([self._profile])
def redo(self):
self._reach.insert(self._index)
if self._profile is None:
self._profile = self._reach.insert(self._index)
else:
self._reach.insert_profile(self._index, self._profile)
class DelCommand(QUndoCommand):
def __init__(self, reach, rows):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment