diff --git a/desktop-widgets/diveplanner.cpp b/desktop-widgets/diveplanner.cpp index eacff368a..f545fecd0 100644 --- a/desktop-widgets/diveplanner.cpp +++ b/desktop-widgets/diveplanner.cpp @@ -216,9 +216,8 @@ void DivePlannerWidget::customSalinityChanged(double density) } } -void PlannerSettingsWidget::disableDecoElements(int mode) +void PlannerSettingsWidget::disableDecoElements(int mode, divemode_t rebreathermode) { - divemode_t rebreathermode = DivePlannerPointsModel::instance()->getRebreatherMode(); if (mode == RECREATIONAL) { ui.label_gflow->setDisabled(false); ui.label_gfhigh->setDisabled(false); @@ -342,7 +341,7 @@ void PlannerSettingsWidget::disableBackgasBreaks(bool enabled) } } -PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent) : QWidget(parent, QFlag(0)) +PlannerSettingsWidget::PlannerSettingsWidget(PlannerWidgets *parent) { ui.setupUi(this); @@ -373,7 +372,7 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent) : QWidget(parent, ui.recreational_deco->setChecked(prefs.planner_deco_mode == RECREATIONAL); ui.buehlmann_deco->setChecked(prefs.planner_deco_mode == BUEHLMANN); ui.vpmb_deco->setChecked(prefs.planner_deco_mode == VPMB); - disableDecoElements((int) prefs.planner_deco_mode); + disableDecoElements((int) prefs.planner_deco_mode, OC); // should be the same order as in dive_comp_type! QStringList rebreather_modes = QStringList(); @@ -412,9 +411,9 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent) : QWidget(parent, connect(ui.rebreathermode, QOverload::of(&QComboBox::currentIndexChanged), plannerModel, &DivePlannerPointsModel::setRebreatherMode); connect(ui.rebreathermode, QOverload::of(&QComboBox::currentIndexChanged), this, &PlannerSettingsWidget::setBailoutVisibility); - connect(ui.recreational_deco, &QAbstractButton::clicked, [this] { disableDecoElements(RECREATIONAL); }); - connect(ui.buehlmann_deco, &QAbstractButton::clicked, [this] { disableDecoElements(BUEHLMANN); }); - connect(ui.vpmb_deco, &QAbstractButton::clicked, [this] { disableDecoElements(VPMB); }); + connect(ui.recreational_deco, &QAbstractButton::clicked, [this, parent] { disableDecoElements(RECREATIONAL, parent->getRebreatherMode()); }); + connect(ui.buehlmann_deco, &QAbstractButton::clicked, [this, parent] { disableDecoElements(BUEHLMANN, parent->getRebreatherMode()); }); + connect(ui.vpmb_deco, &QAbstractButton::clicked, [this, parent] { disableDecoElements(VPMB, parent->getRebreatherMode()); }); connect(ui.sacfactor, QOverload::of(&QDoubleSpinBox::valueChanged), &PlannerShared::set_sacfactor); connect(ui.problemsolvingtime, QOverload::of(&QSpinBox::valueChanged), plannerModel, &DivePlannerPointsModel::setProblemSolvingTime); @@ -543,7 +542,8 @@ void PlannerDetails::setPlanNotes(QString plan) PlannerWidgets::PlannerWidgets() : planned_dive(alloc_dive()), - plannerWidget(*planned_dive, this) + plannerWidget(*planned_dive, this), + plannerSettingsWidget(this) { gasModel = std::make_unique(); diveTypeModel = std::make_unique(); @@ -561,6 +561,11 @@ struct dive *PlannerWidgets::getDive() const return planned_dive.get(); } +divemode_t PlannerWidgets::getRebreatherMode() const +{ + return planned_dive->dc.divemode; +} + void PlannerWidgets::preparePlanDive(const dive *currentDive) { // create a simple starting dive, using the first gas from the just copied cylinders diff --git a/desktop-widgets/diveplanner.h b/desktop-widgets/diveplanner.h index 8c95b3f01..d24e4c8c6 100644 --- a/desktop-widgets/diveplanner.h +++ b/desktop-widgets/diveplanner.h @@ -2,6 +2,7 @@ #ifndef DIVEPLANNER_H #define DIVEPLANNER_H +#include "core/divemode.h" #include "core/owning_ptrs.h" #include @@ -43,13 +44,13 @@ private: class PlannerSettingsWidget : public QWidget { Q_OBJECT public: - explicit PlannerSettingsWidget(QWidget *parent = 0); + explicit PlannerSettingsWidget(PlannerWidgets *parent); ~PlannerSettingsWidget(); public slots: void settingsChanged(); void setBackgasBreaks(bool dobreaks); - void disableDecoElements(int mode); + void disableDecoElements(int mode, divemode_t rebreathermode); void disableBackgasBreaks(bool enabled); void setDiveMode(int mode); void setBailoutVisibility(int mode); @@ -86,6 +87,7 @@ public: void prepareReplanDive(const dive *d); // Make a copy of the dive to be replanned void replanDive(int currentDC); struct dive *getDive() const; + divemode_t getRebreatherMode() const; public slots: void printDecoPlan(); diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index 2f62e8927..b464d98f3 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -542,11 +542,6 @@ void DivePlannerPointsModel::setRebreatherMode(int mode) emitDataChanged(); } -divemode_t DivePlannerPointsModel::getRebreatherMode() const -{ - return d ? d->dc.divemode : OC; -} - void DivePlannerPointsModel::setVpmbConservatism(int level) { if (diveplan.vpmb_conservatism != level) { diff --git a/qt-models/diveplannermodel.h b/qt-models/diveplannermodel.h index 13a647bc0..0956ed573 100644 --- a/qt-models/diveplannermodel.h +++ b/qt-models/diveplannermodel.h @@ -63,7 +63,6 @@ public: void loadFromDive(dive *d, int dcNr); void addStop(int millimeters, int seconds); - divemode_t getRebreatherMode() const; public slots: void addDefaultStop();