summaryrefslogtreecommitdiffstats
path: root/qt-ui/diveplanner.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-17 08:03:52 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-17 08:06:15 -0700
commit24472a3b232f49765fd5e5455a3c8c8fd4a7bac3 (patch)
tree10e0a4fdb35a94a4d0115f80f08598428c71cda8 /qt-ui/diveplanner.cpp
parent13b8680b0ce2412608488fa4ee49f2bba0cd60d8 (diff)
downloadsubsurface-24472a3b232f49765fd5e5455a3c8c8fd4a7bac3.tar.gz
Planner: correctly deal with units in Ascent/descent rates
This adds two changes a) it uses rint() to make sure we don't truncate the displayed values b) it moves the update of the displayed values into a helper function that is also called whenever the settings change Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r--qt-ui/diveplanner.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index dddeac1d1..e0a6959de 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -321,7 +321,6 @@ void DivePlannerWidget::settingsChanged()
} else {
ui.atmHeight->setSuffix(("m"));
}
-
}
void DivePlannerPointsModel::addCylinder_clicked()
@@ -380,11 +379,7 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f)
prefs.decosac = s.value("decosac", 17000).toInt();
s.endGroup();
- 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);
+ updateUnitsUI();
ui.bottompo2->setValue(prefs.bottompo2 / 1000.0);
ui.decopo2->setValue(prefs.decopo2 / 1000.0);
ui.backgasBreaks->setChecked(prefs.doo2breaks);
@@ -423,6 +418,15 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f)
setMinimumHeight(0);
}
+void PlannerSettingsWidget::updateUnitsUI()
+{
+ ui.ascRate75->setValue(rint(prefs.ascrate75 / UNIT_FACTOR));
+ ui.ascRate50->setValue(rint(prefs.ascrate50 / UNIT_FACTOR));
+ ui.ascRateStops->setValue(rint(prefs.ascratestops / UNIT_FACTOR));
+ ui.ascRateLast6m->setValue(rint(prefs.ascratelast6m / UNIT_FACTOR));
+ ui.descRate->setValue(rint(prefs.descrate / UNIT_FACTOR));
+}
+
PlannerSettingsWidget::~PlannerSettingsWidget()
{
QSettings s;
@@ -451,6 +455,7 @@ void PlannerSettingsWidget::settingsChanged()
vs.append(tr("m/min"));
ui.lastStop->setText(tr("Last stop at 6m"));
}
+ updateUnitsUI();
ui.ascRate75->setSuffix(vs);
ui.ascRate50->setSuffix(vs);
ui.ascRateStops->setSuffix(vs);