diff options
author | Robert C. Helling <helling@atdotde.de> | 2014-06-25 00:08:36 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-06-25 13:48:44 +0800 |
commit | 772727fc7f44faaf94afc24bd1f151e40ddaefef (patch) | |
tree | cf74530d4a42e244f174c23e4e723b0a013189f0 /qt-ui/diveplanner.cpp | |
parent | 2ae6f8078a7ea2a034295fcd00f210854a572ee7 (diff) | |
download | subsurface-772727fc7f44faaf94afc24bd1f151e40ddaefef.tar.gz |
Hook up UI elements for ascent rates to planner
That provides some UI elements that were recently introduced with function
of allowing the ascent rates of the planner to be configured by the user.
I tried to make it work both with senisble as well as with imperial units.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r-- | qt-ui/diveplanner.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 516b36b0f..249b03773 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -31,6 +31,8 @@ #define MAX_DEPTH M_OR_FT(150, 450) #define MIN_DEPTH M_OR_FT(20, 60) +#define UNIT_FACTOR ((prefs.units.length == units::METERS) ? 1000.0 / 60.0 : feet_to_mm(1.0) / 60.0) + QString gasToStr(struct gasmix gas) { uint o2 = (gas.o2.permille + 5) / 10, he = (gas.he.permille + 5) / 10; @@ -333,11 +335,34 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f) { ui.setupUi(this); + if (prefs.units.METERS == units::FEET) { + ui.ascRate75->setSuffix("ft/min"); + ui.ascRate50->setSuffix("ft/min"); + ui.ascRateStops->setSuffix("ft/min"); + ui.ascRateLast6m->setSuffix("ft/min"); + ui.descRate->setSuffix("ft/min"); + } + ui.ascRate75->setValue(prefs.ascrate75 / UNIT_FACTOR); + ui.ascRate50->setValue(prefs.ascrate50 / UNIT_FACTOR); + ui.ascRateStops->setValue(prefs.ascratestops / UNIT_FACTOR); + ui.ascRateLast6m->setValue(prefs.ascratelast6m / UNIT_FACTOR); + ui.descRate->setValue(prefs.descrate / UNIT_FACTOR); + connect(ui.lastStop, SIGNAL(toggled(bool)), plannerModel, SLOT(setLastStop6m(bool))); connect(ui.verbatim_plan, SIGNAL(toggled(bool)), plannerModel, SLOT(setVerbatim(bool))); connect(ui.display_duration, SIGNAL(toggled(bool)), plannerModel, SLOT(setDisplayDuration(bool))); connect(ui.display_runtime, SIGNAL(toggled(bool)), plannerModel, SLOT(setDisplayRuntime(bool))); connect(ui.display_transitions, SIGNAL(toggled(bool)), plannerModel, SLOT(setDisplayTransitions(bool))); + connect(ui.ascRate75, SIGNAL(valueChanged(int)), this, SLOT(setAscRate75(int))); + connect(ui.ascRate75, SIGNAL(valueChanged(int)), plannerModel, SLOT(emitDataChanged())); + connect(ui.ascRate50, SIGNAL(valueChanged(int)), this, SLOT(setAscRate50(int))); + connect(ui.ascRate50, SIGNAL(valueChanged(int)), plannerModel, SLOT(emitDataChanged())); + connect(ui.ascRateStops, SIGNAL(valueChanged(int)), this, SLOT(setAscRateStops(int))); + connect(ui.ascRateStops, SIGNAL(valueChanged(int)), plannerModel, SLOT(emitDataChanged())); + connect(ui.ascRateLast6m, SIGNAL(valueChanged(int)), this, SLOT(setAscRateLast6m(int))); + connect(ui.ascRateLast6m, SIGNAL(valueChanged(int)), plannerModel, SLOT(emitDataChanged())); + connect(ui.descRate, SIGNAL(valueChanged(int)), this, SLOT(setDescRate())); + connect(ui.descRate, SIGNAL(valueChanged(int)), plannerModel, SLOT(emitDataChanged())); setMinimumWidth(0); setMinimumHeight(0); @@ -363,6 +388,30 @@ void PlannerSettingsWidget::printDecoPlan() { } +void PlannerSettingsWidget::setAscRate75(int rate) +{ + prefs.ascrate75 = rate * UNIT_FACTOR; +} + +void PlannerSettingsWidget::setAscRate50(int rate) +{ + prefs.ascrate50 = rate * UNIT_FACTOR; +} + +void PlannerSettingsWidget::setAscRateStops(int rate) +{ + prefs.ascratestops = rate * UNIT_FACTOR; +} + +void PlannerSettingsWidget::setAscRateLast6m(int rate) +{ + prefs.ascratelast6m = rate * UNIT_FACTOR; +} + +void PlannerSettingsWidget::setDescRate(int rate) +{ + prefs.descrate = rate * UNIT_FACTOR; +} void DivePlannerPointsModel::setPlanMode(Mode m) { |