mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
undo: reorder cylinders on remove-cylinder undo/redo
The cylinders in the events must be reordered if we remove a cylinder. To avoid duplication of code, move the reordering function into qthelper.cpp, though it might not be ideal there. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
a37939889b
commit
5b7a316593
4 changed files with 39 additions and 9 deletions
|
@ -1106,6 +1106,7 @@ RemoveCylinder::RemoveCylinder(int index, bool currentDiveOnly) :
|
|||
void RemoveCylinder::undo()
|
||||
{
|
||||
for (size_t i = 0; i < dives.size(); ++i) {
|
||||
std::vector<int> mapping = get_cylinder_map_for_add(dives[i]->cylinders.nr, indexes[i]);
|
||||
add_to_cylinder_table(&dives[i]->cylinders, indexes[i], clone_cylinder(cyl));
|
||||
emit diveListNotifier.cylinderAdded(dives[i], indexes[i]);
|
||||
}
|
||||
|
@ -1114,7 +1115,9 @@ void RemoveCylinder::undo()
|
|||
void RemoveCylinder::redo()
|
||||
{
|
||||
for (size_t i = 0; i < dives.size(); ++i) {
|
||||
std::vector<int> mapping = get_cylinder_map_for_remove(dives[i]->cylinders.nr, indexes[i]);
|
||||
remove_cylinder(dives[i], indexes[i]);
|
||||
cylinder_renumber(dives[i], &mapping[0]);
|
||||
emit diveListNotifier.cylinderRemoved(dives[i], indexes[i]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue