diff options
author | Jan Darowski <jan.darowski@gmail.com> | 2015-08-15 15:16:51 +0200 |
---|---|---|
committer | Jan Darowski <jan.darowski@gmail.com> | 2015-08-15 15:16:51 +0200 |
commit | 6856e87689c554bfa7ac058451e030fecfe941f5 (patch) | |
tree | c3a7dad003dd705891af8e2a489579371f928d36 /qt-ui | |
parent | cad866013b6ea8f4bdabc3371b5d319209713fa7 (diff) | |
download | subsurface-6856e87689c554bfa7ac058451e030fecfe941f5.tar.gz |
VPM-B: Add conservatism levels to the ui. Fix planner settings disabling.
Conservatism level can now be changed from gui, is saved in settings.
Also way of disabling the planner settings in the ui was improved
to support more deco models and be called at the widget creation.
Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/diveplanner.cpp | 60 | ||||
-rw-r--r-- | qt-ui/diveplanner.h | 2 | ||||
-rw-r--r-- | qt-ui/plannerSettings.ui | 228 |
3 files changed, 157 insertions, 133 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index efa75ddec..82ecb05dc 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -217,32 +217,37 @@ void PlannerSettingsWidget::decoSacChanged(const double decosac) plannerModel->setDecoSac(decosac); } -void PlannerSettingsWidget::disableDecoElements(bool value) -{ - if (prefs.deco_mode == RECREATIONAL) { - ui.lastStop->setDisabled(value); - ui.backgasBreaks->setDisabled(value); - ui.bottompo2->setDisabled(value); - ui.decopo2->setDisabled(value); - ui.reserve_gas->setDisabled(!value); +void PlannerSettingsWidget::disableDecoElements(int mode) +{ + if (mode == RECREATIONAL) { + ui.gflow->setDisabled(false); + ui.gfhigh->setDisabled(false); + ui.lastStop->setDisabled(true); + ui.backgasBreaks->setDisabled(true); + ui.bottompo2->setDisabled(true); + ui.decopo2->setDisabled(true); + ui.reserve_gas->setDisabled(false); + ui.conservatism_lvl->setDisabled(true); } - else if (prefs.deco_mode == VPMB) { - ui.gflow->setDisabled(value); - ui.gfhigh->setDisabled(value); - ui.lastStop->setDisabled(!value); - ui.backgasBreaks->setDisabled(!value); - ui.bottompo2->setDisabled(!value); - ui.decopo2->setDisabled(!value); - ui.reserve_gas->setDisabled(value); + else if (mode == VPMB) { + ui.gflow->setDisabled(true); + ui.gfhigh->setDisabled(true); + ui.lastStop->setDisabled(false); + ui.backgasBreaks->setDisabled(false); + ui.bottompo2->setDisabled(false); + ui.decopo2->setDisabled(false); + ui.reserve_gas->setDisabled(true); + ui.conservatism_lvl->setDisabled(false); } - else if (prefs.deco_mode == BUEHLMANN) { - ui.gflow->setDisabled(!value); - ui.gfhigh->setDisabled(!value); - ui.lastStop->setDisabled(!value); - ui.backgasBreaks->setDisabled(!value); - ui.bottompo2->setDisabled(!value); - ui.decopo2->setDisabled(!value); - ui.reserve_gas->setDisabled(value); + else if (mode == BUEHLMANN) { + ui.gflow->setDisabled(false); + ui.gfhigh->setDisabled(false); + ui.lastStop->setDisabled(false); + ui.backgasBreaks->setDisabled(false); + ui.bottompo2->setDisabled(false); + ui.decopo2->setDisabled(false); + ui.reserve_gas->setDisabled(true); + ui.conservatism_lvl->setDisabled(true); } } @@ -279,6 +284,7 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f) prefs.drop_stone_mode = s.value("drop_stone_mode", prefs.drop_stone_mode).toBool(); prefs.bottomsac = s.value("bottomsac", prefs.bottomsac).toInt(); prefs.decosac = s.value("decosac", prefs.decosac).toInt(); + prefs.conservatism_level = s.value("conservatism", prefs.conservatism_level).toInt(); plannerModel->getDiveplan().bottomsac = prefs.bottomsac; plannerModel->getDiveplan().decosac = prefs.decosac; s.endGroup(); @@ -300,6 +306,8 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f) ui.recreational_deco->setChecked(prefs.deco_mode == RECREATIONAL); ui.buehlmann_deco->setChecked(prefs.deco_mode == BUEHLMANN); ui.vpmb_deco->setChecked(prefs.deco_mode == VPMB); + ui.conservatism_lvl->setValue(prefs.conservatism_level); + disableDecoElements((int) prefs.deco_mode); // should be the same order as in dive_comp_type! rebreather_modes << tr("Open circuit") << tr("CCR") << tr("pSCR"); @@ -341,11 +349,12 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f) connect(ui.gflow, SIGNAL(valueChanged(int)), plannerModel, SLOT(setGFLow(int))); connect(ui.gfhigh, SIGNAL(editingFinished()), plannerModel, SLOT(triggerGFHigh())); connect(ui.gflow, SIGNAL(editingFinished()), plannerModel, SLOT(triggerGFLow())); + connect(ui.conservatism_lvl, SIGNAL(valueChanged(int)), plannerModel, SLOT(setConservatism(int))); connect(ui.backgasBreaks, SIGNAL(toggled(bool)), this, SLOT(setBackgasBreaks(bool))); connect(ui.switch_at_req_stop, SIGNAL(toggled(bool)), plannerModel, SLOT(setSwitchAtReqStop(bool))); connect(ui.min_switch_duration, SIGNAL(valueChanged(int)), plannerModel, SLOT(setMinSwitchDuration(int))); connect(ui.rebreathermode, SIGNAL(currentIndexChanged(int)), plannerModel, SLOT(setRebreatherMode(int))); - connect(plannerModel, SIGNAL(recreationChanged(bool)), this, SLOT(disableDecoElements(bool))); + connect(modeMapper, SIGNAL(mapped(int)), this, SLOT(disableDecoElements(int))); settingsChanged(); ui.gflow->setValue(prefs.gflow); @@ -389,6 +398,7 @@ PlannerSettingsWidget::~PlannerSettingsWidget() s.setValue("bottomsac", prefs.bottomsac); s.setValue("decosac", prefs.decosac); s.setValue("deco_mode", int(prefs.deco_mode)); + s.setValue("conservatism", prefs.conservatism_level); s.endGroup(); } diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index c4210aadf..b2e03a97b 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -80,7 +80,7 @@ slots: void setBottomPo2(double po2); void setDecoPo2(double po2); void setBackgasBreaks(bool dobreaks); - void disableDecoElements(bool value); + void disableDecoElements(int mode); private: Ui::plannerSettingsWidget ui; diff --git a/qt-ui/plannerSettings.ui b/qt-ui/plannerSettings.ui index 3287b84fb..4ebc868af 100644 --- a/qt-ui/plannerSettings.ui +++ b/qt-ui/plannerSettings.ui @@ -255,94 +255,49 @@ <property name="spacing"> <number>2</number> </property> - <item row="17" column="1"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Min. switch duration</string> - </property> - </widget> - </item> - <item row="19" column="1"> - <spacer name="verticalSpacer_2"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item row="18" column="1"> - <widget class="QComboBox" name="rebreathermode"> - <property name="currentText"> - <string/> - </property> - <property name="maxVisibleItems"> - <number>6</number> - </property> - </widget> - </item> - <item row="8" column="2"> - <widget class="QSpinBox" name="gflow"> - <property name="suffix"> - <string>%</string> - </property> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>150</number> - </property> - </widget> - </item> - <item row="13" column="1" colspan="2"> - <widget class="QCheckBox" name="drop_stone_mode"> + <item row="11" column="1"> + <widget class="QRadioButton" name="vpmb_deco"> <property name="text"> - <string>Drop to first depth</string> + <string>VPM-B deco</string> </property> </widget> </item> - <item row="14" column="1" colspan="2"> - <widget class="QCheckBox" name="lastStop"> + <item row="4" column="1"> + <widget class="QRadioButton" name="buehlmann_deco"> <property name="text"> - <string>Last stop at 6m</string> + <string>Buehlmann deco</string> </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QRadioButton" name="recreational_deco"> - <property name="text"> - <string>Recreational mode</string> + <property name="checked"> + <bool>true</bool> </property> </widget> </item> - <item row="8" column="1"> - <widget class="QLabel" name="label_15"> + <item row="1" column="1"> + <widget class="QLabel" name="label_3"> <property name="text"> - <string>GF low</string> + <string>Reserve gas</string> </property> <property name="indent"> <number>26</number> </property> </widget> </item> - <item row="15" column="1" colspan="2"> - <widget class="QCheckBox" name="backgasBreaks"> - <property name="text"> - <string>Plan backgas breaks</string> + <item row="1" column="2"> + <widget class="QSpinBox" name="reserve_gas"> + <property name="suffix"> + <string>bar</string> </property> - </widget> - </item> - <item row="9" column="1"> - <widget class="QLabel" name="label_16"> - <property name="text"> - <string>GF high</string> + <property name="prefix"> + <string/> </property> - <property name="indent"> - <number>25</number> + <property name="minimum"> + <number>10</number> + </property> + <property name="maximum"> + <number>99</number> + </property> + <property name="value"> + <number>40</number> </property> </widget> </item> @@ -359,7 +314,7 @@ </property> </widget> </item> - <item row="16" column="1" colspan="2"> + <item row="17" column="1" colspan="2"> <widget class="QCheckBox" name="switch_at_req_stop"> <property name="toolTip"> <string>Postpone gas change if a stop is not required</string> @@ -382,20 +337,34 @@ </property> </spacer> </item> - <item row="12" column="1"> - <spacer name="verticalSpacer_5"> - <property name="orientation"> - <enum>Qt::Vertical</enum> + <item row="8" column="1"> + <widget class="QLabel" name="label_15"> + <property name="text"> + <string>GF low</string> </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> + <property name="indent"> + <number>26</number> </property> - </spacer> + </widget> + </item> + <item row="16" column="1" colspan="2"> + <widget class="QCheckBox" name="backgasBreaks"> + <property name="text"> + <string>Plan backgas breaks</string> + </property> + </widget> </item> - <item row="17" column="2"> + <item row="9" column="1"> + <widget class="QLabel" name="label_16"> + <property name="text"> + <string>GF high</string> + </property> + <property name="indent"> + <number>25</number> + </property> + </widget> + </item> + <item row="18" column="2"> <widget class="QSpinBox" name="min_switch_duration"> <property name="suffix"> <string>min</string> @@ -414,52 +383,70 @@ </property> </widget> </item> - <item row="11" column="1"> - <widget class="QRadioButton" name="vpmb_deco"> + <item row="15" column="1" colspan="2"> + <widget class="QCheckBox" name="lastStop"> <property name="text"> - <string>VPM-B deco</string> + <string>Last stop at 6m</string> </property> </widget> </item> - <item row="4" column="1"> - <widget class="QRadioButton" name="buehlmann_deco"> + <item row="0" column="1"> + <widget class="QRadioButton" name="recreational_deco"> <property name="text"> - <string>Buehlmann deco</string> - </property> - <property name="checked"> - <bool>true</bool> + <string>Recreational mode</string> </property> </widget> </item> - <item row="1" column="1"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Reserve gas</string> + <item row="19" column="1"> + <widget class="QComboBox" name="rebreathermode"> + <property name="currentText" stdset="0"> + <string/> </property> - <property name="indent"> - <number>26</number> + <property name="maxVisibleItems"> + <number>6</number> </property> </widget> </item> - <item row="1" column="2"> - <widget class="QSpinBox" name="reserve_gas"> + <item row="8" column="2"> + <widget class="QSpinBox" name="gflow"> <property name="suffix"> - <string>bar</string> - </property> - <property name="prefix"> - <string/> + <string>%</string> </property> <property name="minimum"> - <number>10</number> + <number>1</number> </property> <property name="maximum"> - <number>99</number> + <number>150</number> </property> - <property name="value"> - <number>40</number> + </widget> + </item> + <item row="14" column="1" colspan="2"> + <widget class="QCheckBox" name="drop_stone_mode"> + <property name="text"> + <string>Drop to first depth</string> </property> </widget> </item> + <item row="18" column="1"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Min. switch duration</string> + </property> + </widget> + </item> + <item row="20" column="1"> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> <item row="2" column="1" alignment="Qt::AlignHCenter"> <widget class="QCheckBox" name="safetystop"> <property name="layoutDirection"> @@ -486,6 +473,33 @@ </property> </spacer> </item> + <item row="13" column="1"> + <spacer name="verticalSpacer_5"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="12" column="1"> + <widget class="QLabel" name="label_5"> + <property name="text"> + <string>Conservatism level</string> + </property> + </widget> + </item> + <item row="12" column="2"> + <widget class="QSpinBox" name="conservatism_lvl"> + <property name="maximum"> + <number>4</number> + </property> + </widget> + </item> </layout> </widget> </item> |