aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Stefan Fuchs <sfuchs@gmx.de>2017-10-20 16:54:14 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-10-21 15:33:57 -0400
commit96d2e578431dab460e62c2241f4b89d553084a49 (patch)
treef9a153c3ebcf1210b1be4d4761909ee1d8e50d4a
parentdaac80b7bda0e073e325bc9561132cdfe666d327 (diff)
downloadsubsurface-96d2e578431dab460e62c2241f4b89d553084a49.tar.gz
When removing a cylinder completely fill the mapping table
When deleting a cylinder the mapping was not filled with all necessary values. Values for cylinders before deleted cylinder were missing. Plus do the endRemoveRows at the right time. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
-rw-r--r--qt-models/cylindermodel.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp
index cda27ebaf..854c148f3 100644
--- a/qt-models/cylindermodel.cpp
+++ b/qt-models/cylindermodel.cpp
@@ -563,6 +563,8 @@ void CylindersModel::remove(const QModelIndex &index)
// as first gas
memmove(cyl, &displayed_dive.cylinder[same_gas], sizeof(*cyl));
remove_cylinder(&displayed_dive, same_gas);
+ for (int i = 0; i < same_gas - 1; i++)
+ mapping[i] = i;
mapping[same_gas] = 0;
for (int i = same_gas + 1; i < MAX_CYLINDERS; i++)
mapping[i] = i - 1;
@@ -570,15 +572,17 @@ void CylindersModel::remove(const QModelIndex &index)
remove_cylinder(&displayed_dive, index.row());
if (same_gas > index.row())
same_gas--;
+ for (int i = 0; i < index.row(); i++)
+ mapping[i] = i;
mapping[index.row()] = same_gas;
for (int i = index.row() + 1; i < MAX_CYLINDERS; i++)
mapping[i] = i - 1;
}
- changed = true;
- endRemoveRows();
cylinder_renumber(&displayed_dive, mapping);
if (in_planner())
DivePlannerPointsModel::instance()->cylinderRenumber(mapping);
+ changed = true;
+ endRemoveRows();
dataChanged(index, index);
}
@@ -597,11 +601,11 @@ void CylindersModel::moveAtFirst(int cylid)
mapping[cylid] = 0;
for (int i = cylid + 1; i < MAX_CYLINDERS; i++)
mapping[i] = i;
- changed = true;
- endMoveRows();
cylinder_renumber(&displayed_dive, mapping);
if (in_planner())
DivePlannerPointsModel::instance()->cylinderRenumber(mapping);
+ changed = true;
+ endMoveRows();
}
void CylindersModel::updateDecoDepths(pressure_t olddecopo2)