aboutsummaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-02-27 22:24:33 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-04-02 13:53:23 -0700
commit601861ef5e05b88b9721cde5b49d16b5b00caa50 (patch)
treea6579646d89b6bc957c57f5a0bad3137828b1aaf /qt-models
parentcbee716316f90f483c272431e1fb766816532b09 (diff)
downloadsubsurface-601861ef5e05b88b9721cde5b49d16b5b00caa50.tar.gz
planner: split DivePlannerPointsModel::removePoints() in two
Split the function in one external version, that updates the dive profile and cylinders and one internal version, that does no recalculations. In the latter case, the caller is responsible for updating the dive. Thus, the recalculation flag-clearing can be removed from removeDeco(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/diveplannermodel.cpp15
-rw-r--r--qt-models/diveplannermodel.h1
2 files changed, 11 insertions, 5 deletions
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp
index c8da6e6a7..7019472c7 100644
--- a/qt-models/diveplannermodel.cpp
+++ b/qt-models/diveplannermodel.cpp
@@ -28,7 +28,7 @@ CylindersModel *DivePlannerPointsModel::cylindersModel()
return &cylinders;
}
-void DivePlannerPointsModel::removeSelectedPoints(const QVector<int> &rows)
+void DivePlannerPointsModel::removePoints(const QVector<int> &rows)
{
if (!rows.count())
return;
@@ -40,6 +40,12 @@ void DivePlannerPointsModel::removeSelectedPoints(const QVector<int> &rows)
divepoints.erase(divepoints.begin() + v2[i]);
endRemoveRows();
}
+}
+
+void DivePlannerPointsModel::removeSelectedPoints(const QVector<int> &rows)
+{
+ removePoints(rows);
+
updateDiveProfile();
emitDataChanged();
cylinders.updateTrashIcon();
@@ -225,13 +231,12 @@ bool DivePlannerPointsModel::updateMaxDepth()
void DivePlannerPointsModel::removeDeco()
{
- bool oldrec = std::exchange(recalc, false);
QVector<int> computedPoints;
- for (int i = 0; i < rowCount(); i++)
+ for (int i = 0; i < rowCount(); i++) {
if (!at(i).entered)
computedPoints.push_back(i);
- removeSelectedPoints(computedPoints);
- recalc = oldrec;
+ }
+ removePoints(computedPoints);
}
void DivePlannerPointsModel::addCylinder_clicked()
diff --git a/qt-models/diveplannermodel.h b/qt-models/diveplannermodel.h
index b1f37d70d..f0ec195e6 100644
--- a/qt-models/diveplannermodel.h
+++ b/qt-models/diveplannermodel.h
@@ -115,6 +115,7 @@ private:
explicit DivePlannerPointsModel(QObject *parent = 0);
void clear();
int addStop(int millimeters, int seconds, int cylinderid_in, int ccpoint, bool entered, enum divemode_t);
+ void removePoints(const QVector<int> &rows);
void setupStartTime();
void setupCylinders();
int lastEnteredPoint() const;