Planner rebreather mode

Do the switching based on the index rather than the string (which is
translatable!).

Update set-points when turning on/off CCR mode (remeber: the rebreather
mode is stored in two places: the divemode and implicitly in the setpoitns.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Robert C. Helling 2015-01-16 15:05:00 +01:00 committed by Dirk Hohndel
parent 881803441e
commit 0d619d569b
2 changed files with 10 additions and 12 deletions

View file

@ -416,7 +416,8 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f)
ui.decopo2->setValue(prefs.decopo2 / 1000.0); ui.decopo2->setValue(prefs.decopo2 / 1000.0);
ui.backgasBreaks->setChecked(prefs.doo2breaks); ui.backgasBreaks->setChecked(prefs.doo2breaks);
ui.drop_stone_mode->setChecked(prefs.drop_stone_mode); ui.drop_stone_mode->setChecked(prefs.drop_stone_mode);
rebreater_modes << "Open circuit" << "pSCR" << "CCR"; // should be the same order as in dive_comp_type!
rebreater_modes << tr("Open circuit") << tr("CCR") << tr("pSCR");
ui.rebreathermode->insertItems(0, rebreater_modes); ui.rebreathermode->insertItems(0, rebreater_modes);
connect(ui.lastStop, SIGNAL(toggled(bool)), plannerModel, SLOT(setLastStop6m(bool))); connect(ui.lastStop, SIGNAL(toggled(bool)), plannerModel, SLOT(setLastStop6m(bool)));
@ -444,7 +445,7 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f)
connect(ui.gfhigh, SIGNAL(editingFinished()), plannerModel, SLOT(triggerGFHigh())); connect(ui.gfhigh, SIGNAL(editingFinished()), plannerModel, SLOT(triggerGFHigh()));
connect(ui.gflow, SIGNAL(editingFinished()), plannerModel, SLOT(triggerGFLow())); connect(ui.gflow, SIGNAL(editingFinished()), plannerModel, SLOT(triggerGFLow()));
connect(ui.backgasBreaks, SIGNAL(toggled(bool)), this, SLOT(setBackgasBreaks(bool))); connect(ui.backgasBreaks, SIGNAL(toggled(bool)), this, SLOT(setBackgasBreaks(bool)));
connect(ui.rebreathermode, SIGNAL(currentIndexChanged(QString)), plannerModel, SLOT(setRebreatherMode(QString))); connect(ui.rebreathermode, SIGNAL(currentIndexChanged(int)), plannerModel, SLOT(setRebreatherMode(int)));
settingsChanged(); settingsChanged();
ui.gflow->setValue(prefs.gflow); ui.gflow->setValue(prefs.gflow);
ui.gfhigh->setValue(prefs.gfhigh); ui.gfhigh->setValue(prefs.gfhigh);
@ -783,16 +784,13 @@ void DivePlannerPointsModel::setGFLow(const int ghflow)
triggerGFLow(); triggerGFLow();
} }
void DivePlannerPointsModel::setRebreatherMode(QString mode) void DivePlannerPointsModel::setRebreatherMode(int mode)
{ {
qDebug() << mode << "selected, was" << displayed_dive.dc.divemode; int i;
if (mode == "OC") displayed_dive.dc.divemode = (dive_comp_type) mode;
displayed_dive.dc.divemode = OC; for (i=0; i < rowCount(); i++)
else if (mode == "pSCR") divepoints[i].setpoint = mode == CCR ? prefs.defaultsetpoint : 0;
displayed_dive.dc.divemode = PSCR; emitDataChanged();
else if (mode == "CCR")
displayed_dive.dc.divemode = CCR;
plannerModel->emitDataChanged();
} }
void DivePlannerPointsModel::triggerGFLow() void DivePlannerPointsModel::triggerGFLow()

View file

@ -90,7 +90,7 @@ slots:
void deleteTemporaryPlan(); void deleteTemporaryPlan();
void loadFromDive(dive *d); void loadFromDive(dive *d);
void emitDataChanged(); void emitDataChanged();
void setRebreatherMode(QString mode); void setRebreatherMode(int mode);
signals: signals:
void planCreated(); void planCreated();