diff options
-rw-r--r-- | desktop-widgets/diveplanner.cpp | 1 | ||||
-rw-r--r-- | qt-models/diveplannermodel.cpp | 22 | ||||
-rw-r--r-- | qt-models/diveplannermodel.h | 1 |
3 files changed, 7 insertions, 17 deletions
diff --git a/desktop-widgets/diveplanner.cpp b/desktop-widgets/diveplanner.cpp index 527e0021a..13f540124 100644 --- a/desktop-widgets/diveplanner.cpp +++ b/desktop-widgets/diveplanner.cpp @@ -32,7 +32,6 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent) : QWidget(parent, QFlag(0) ui.tableWidget->setTitle(tr("Dive planner points")); ui.tableWidget->setModel(plannerModel); connect(ui.tableWidget, &TableView::itemClicked, plannerModel, &DivePlannerPointsModel::remove); - plannerModel->setRecalc(true); ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::GAS, new AirTypesDelegate(this)); ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::DIVEMODE, new DiveTypesDelegate(this)); ui.cylinderTableWidget->setTitle(tr("Available gases")); diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index 038783d1c..30ab063d2 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -221,13 +221,13 @@ bool DivePlannerPointsModel::updateMaxDepth() void DivePlannerPointsModel::removeDeco() { - bool oldrec = setRecalc(false); + bool oldrec = std::exchange(recalc, false); QVector<int> computedPoints; for (int i = 0; i < rowCount(); i++) if (!at(i).entered) computedPoints.push_back(i); removeSelectedPoints(computedPoints); - setRecalc(oldrec); + recalc = oldrec; } void DivePlannerPointsModel::addCylinder_clicked() @@ -254,13 +254,6 @@ bool DivePlannerPointsModel::isPlanner() const /* When the planner adds deco stops to the model, adding those should not trigger a new deco calculation. * We thus start the planner only when recalc is true. */ -bool DivePlannerPointsModel::setRecalc(bool rec) -{ - bool old = recalc; - recalc = rec; - return old; -} - bool DivePlannerPointsModel::recalcQ() const { return recalc; @@ -456,7 +449,7 @@ DivePlannerPointsModel::DivePlannerPointsModel(QObject *parent) : QAbstractTable d(nullptr), cylinders(true), mode(NOTHING), - recalc(false) + recalc(true) { memset(&diveplan, 0, sizeof(diveplan)); startTime.setTimeSpec(Qt::UTC); @@ -996,14 +989,14 @@ bool DivePlannerPointsModel::tankInUse(int cylinderid) const void DivePlannerPointsModel::clear() { - bool oldRecalc = setRecalc(false); + bool oldrec = std::exchange(recalc, false); beginResetModel(); divepoints.clear(); endResetModel(); cylinders.clear(); preserved_until.seconds = 0; - setRecalc(oldRecalc); + recalc = oldrec; } void DivePlannerPointsModel::createTemporaryPlan() @@ -1240,7 +1233,6 @@ finish: free(save); free(cache); free(dive); -// setRecalc(oldRecalc); } void DivePlannerPointsModel::computeVariationsDone(QString variations) @@ -1255,10 +1247,10 @@ void DivePlannerPointsModel::createPlan(bool replanCopy) { // Ok, so, here the diveplan creates a dive struct deco_state *cache = NULL; - bool oldRecalc = setRecalc(false); + bool oldrec = std::exchange(recalc, false); removeDeco(); createTemporaryPlan(); - setRecalc(oldRecalc); + recalc = oldrec; //TODO: C-based function here? struct decostop stoptable[60]; diff --git a/qt-models/diveplannermodel.h b/qt-models/diveplannermodel.h index 5a5fc0155..9b79232d6 100644 --- a/qt-models/diveplannermodel.h +++ b/qt-models/diveplannermodel.h @@ -41,7 +41,6 @@ public: bool isPlanner() const; void createSimpleDive(struct dive *d); Mode currentMode() const; - bool setRecalc(bool recalc); bool recalcQ() const; bool tankInUse(int cylinderid) const; CylindersModel *cylindersModel(); |