diff options
author | Robert C. Helling <helling@atdotde.de> | 2015-01-16 15:05:00 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-01-17 08:18:48 +1300 |
commit | 0d619d569bd0b57028eceb16147ea08e850fc946 (patch) | |
tree | 0fa47848d5bfb6cdbb19d245c03b53fcb9158acc | |
parent | 881803441e3c0a24004a25e84197280c4722b679 (diff) | |
download | subsurface-0d619d569bd0b57028eceb16147ea08e850fc946.tar.gz |
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>
-rw-r--r-- | qt-ui/diveplanner.cpp | 20 | ||||
-rw-r--r-- | qt-ui/diveplanner.h | 2 |
2 files changed, 10 insertions, 12 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index cd3206c41..bf7af7fd1 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -416,7 +416,8 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f) ui.decopo2->setValue(prefs.decopo2 / 1000.0); ui.backgasBreaks->setChecked(prefs.doo2breaks); 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); 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.gflow, SIGNAL(editingFinished()), plannerModel, SLOT(triggerGFLow())); 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(); ui.gflow->setValue(prefs.gflow); ui.gfhigh->setValue(prefs.gfhigh); @@ -783,16 +784,13 @@ void DivePlannerPointsModel::setGFLow(const int ghflow) triggerGFLow(); } -void DivePlannerPointsModel::setRebreatherMode(QString mode) +void DivePlannerPointsModel::setRebreatherMode(int mode) { - qDebug() << mode << "selected, was" << displayed_dive.dc.divemode; - if (mode == "OC") - displayed_dive.dc.divemode = OC; - else if (mode == "pSCR") - displayed_dive.dc.divemode = PSCR; - else if (mode == "CCR") - displayed_dive.dc.divemode = CCR; - plannerModel->emitDataChanged(); + int i; + displayed_dive.dc.divemode = (dive_comp_type) mode; + for (i=0; i < rowCount(); i++) + divepoints[i].setpoint = mode == CCR ? prefs.defaultsetpoint : 0; + emitDataChanged(); } void DivePlannerPointsModel::triggerGFLow() diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 6ff4d0f50..e6ae8e8b5 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -90,7 +90,7 @@ slots: void deleteTemporaryPlan(); void loadFromDive(dive *d); void emitDataChanged(); - void setRebreatherMode(QString mode); + void setRebreatherMode(int mode); signals: void planCreated(); |