aboutsummaryrefslogtreecommitdiffstats
path: root/qt-models/cylindermodel.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-02-23 19:24:06 +0100
committerGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-04-07 00:13:35 +0200
commit5b7a3165932d9b3fced80fec17de01eb1ad89bf7 (patch)
tree8d93ac1a2201f3051cddca19656c3abd92b47886 /qt-models/cylindermodel.cpp
parenta37939889b1a77dd269fd7f25f97b813f733133a (diff)
downloadsubsurface-5b7a3165932d9b3fced80fec17de01eb1ad89bf7.tar.gz
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>
Diffstat (limited to 'qt-models/cylindermodel.cpp')
-rw-r--r--qt-models/cylindermodel.cpp10
1 files changed, 1 insertions, 9 deletions
diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp
index 4b329eafe..3a3f14605 100644
--- a/qt-models/cylindermodel.cpp
+++ b/qt-models/cylindermodel.cpp
@@ -513,15 +513,7 @@ void CylindersModel::remove(QModelIndex index)
changed = true;
endRemoveRows();
- // Create a mapping of cylinder indices:
- // 1) Fill mapping[0]..mapping[index-1] with 0..index
- // 2) Set mapping[index] to -1
- // 3) Fill mapping[index+1]..mapping[end] with index..
- std::vector<int> mapping(d->cylinders.nr + 1);
- std::iota(mapping.begin(), mapping.begin() + index.row(), 0);
- mapping[index.row()] = -1;
- std::iota(mapping.begin() + index.row() + 1, mapping.end(), index.row());
-
+ std::vector<int> mapping = get_cylinder_map_for_remove(d->cylinders.nr + 1, index.row());
cylinder_renumber(d, &mapping[0]);
if (in_planner())
DivePlannerPointsModel::instance()->cylinderRenumber(&mapping[0]);