planner: access divemode (a.k.a. rebreathermode) from model

The mode was accessed via the global `displayed_dive`. In an effort
to remove globals, access it via the DivePlannerPointsModel instead.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2022-11-06 17:10:37 +01:00 committed by bstoeger
parent c5d6e0f44f
commit d65f2f422c
3 changed files with 12 additions and 6 deletions

View file

@ -214,6 +214,7 @@ void DivePlannerWidget::customSalinityChanged(double density)
void PlannerSettingsWidget::disableDecoElements(int mode)
{
divemode_t rebreathermode = DivePlannerPointsModel::instance()->getRebreatherMode();
if (mode == RECREATIONAL) {
ui.label_gflow->setDisabled(false);
ui.label_gfhigh->setDisabled(false);
@ -248,8 +249,7 @@ void PlannerSettingsWidget::disableDecoElements(int mode)
ui.sacfactor->blockSignals(false);
ui.problemsolvingtime->blockSignals(false);
ui.display_variations->setDisabled(true);
}
else if (mode == VPMB) {
} else if (mode == VPMB) {
ui.label_gflow->setDisabled(true);
ui.label_gfhigh->setDisabled(true);
ui.gflow->setDisabled(true);
@ -266,7 +266,7 @@ void PlannerSettingsWidget::disableDecoElements(int mode)
ui.backgasBreaks->setChecked(false);
ui.backgasBreaks->blockSignals(false);
}
ui.bailout->setDisabled(!(displayed_dive.dc.divemode == CCR || displayed_dive.dc.divemode == PSCR));
ui.bailout->setDisabled(!(rebreathermode == CCR || rebreathermode == PSCR));
ui.bottompo2->setDisabled(false);
ui.decopo2->setDisabled(false);
ui.safetystop->setDisabled(true);
@ -283,8 +283,7 @@ void PlannerSettingsWidget::disableDecoElements(int mode)
ui.sacfactor->setValue(PlannerShared::sacfactor());
ui.problemsolvingtime->setValue(prefs.problemsolvingtime);
ui.display_variations->setDisabled(false);
}
else if (mode == BUEHLMANN) {
} else if (mode == BUEHLMANN) {
ui.label_gflow->setDisabled(false);
ui.label_gfhigh->setDisabled(false);
ui.gflow->setDisabled(false);
@ -301,7 +300,7 @@ void PlannerSettingsWidget::disableDecoElements(int mode)
ui.backgasBreaks->setChecked(false);
ui.backgasBreaks->blockSignals(false);
}
ui.bailout->setDisabled(!(displayed_dive.dc.divemode == CCR || displayed_dive.dc.divemode == PSCR));
ui.bailout->setDisabled(!(rebreathermode == CCR || rebreathermode == PSCR));
ui.bottompo2->setDisabled(false);
ui.decopo2->setDisabled(false);
ui.safetystop->setDisabled(true);

View file

@ -545,6 +545,11 @@ void DivePlannerPointsModel::setRebreatherMode(int mode)
emitDataChanged();
}
divemode_t DivePlannerPointsModel::getRebreatherMode() const
{
return d->dc.divemode;
}
void DivePlannerPointsModel::setVpmbConservatism(int level)
{
if (diveplan.vpmb_conservatism != level) {

View file

@ -7,6 +7,7 @@
#include <vector>
#include "core/deco.h"
#include "core/divemode.h"
#include "core/planner.h"
#include "qt-models/cylindermodel.h"
@ -62,6 +63,7 @@ public:
void loadFromDive(dive *d, int dcNr);
void addStop(int millimeters, int seconds);
divemode_t getRebreatherMode() const;
public
slots:
void addDefaultStop();