summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
authorGravatar Stefan Fuchs <sfuchs@gmx.de>2017-10-03 10:06:15 +0200
committerGravatar Robert C. Helling <helling@atdotde.de>2017-10-04 08:41:10 +0200
commitcf409b59ba3027537acf0ec36d2186e200ca8934 (patch)
treec44060263a12212584022a575f4ee86a21e1790a /qt-models
parent52445ec8f5bb957a41c6650982e69c96174eee8a (diff)
downloadsubsurface-cf409b59ba3027537acf0ec36d2186e200ca8934.tar.gz
Planner settings ascend and descende rate: Wire up UI elements correctly
Wire up the UI elements (QSpinBoxes) for ascend rates (4x) and descend rate (1x) correctly so that the profile and calculation is updated immediately after the value is changed (e.g. increased/decresed by 1) by clicking the QSpinBox arrows. Until now one had to click into the profile or change another planner preference first before the change became effective. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/diveplannermodel.cpp37
-rw-r--r--qt-models/diveplannermodel.h5
2 files changed, 42 insertions, 0 deletions
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp
index 4c60e6736..482647575 100644
--- a/qt-models/diveplannermodel.cpp
+++ b/qt-models/diveplannermodel.cpp
@@ -10,6 +10,8 @@
#include <QApplication>
#include <QTextDocument>
+#define UNIT_FACTOR ((prefs.units.length == units::METERS) ? 1000.0 / 60.0 : feet_to_mm(1.0) / 60.0)
+
/* TODO: Port this to CleanerTableModel to remove a bit of boilerplate and
* use the signal warningMessage() to communicate errors to the MainWindow.
*/
@@ -494,6 +496,41 @@ void DivePlannerPointsModel::setLastStop6m(bool value)
emitDataChanged();
}
+void DivePlannerPointsModel::setAscrate75(int rate)
+{
+ auto planner = SettingsObjectWrapper::instance()->planner_settings;
+ planner->setAscrate75(lrint(rate * UNIT_FACTOR));
+ emitDataChanged();
+}
+
+void DivePlannerPointsModel::setAscrate50(int rate)
+{
+ auto planner = SettingsObjectWrapper::instance()->planner_settings;
+ planner->setAscrate50(lrint(rate * UNIT_FACTOR));
+ emitDataChanged();
+}
+
+void DivePlannerPointsModel::setAscratestops(int rate)
+{
+ auto planner = SettingsObjectWrapper::instance()->planner_settings;
+ planner->setAscratestops(lrint(rate * UNIT_FACTOR));
+ emitDataChanged();
+}
+
+void DivePlannerPointsModel::setAscratelast6m(int rate)
+{
+ auto planner = SettingsObjectWrapper::instance()->planner_settings;
+ planner->setAscratelast6m(lrint(rate * UNIT_FACTOR));
+ emitDataChanged();
+}
+
+void DivePlannerPointsModel::setDescrate(int rate)
+{
+ auto planner = SettingsObjectWrapper::instance()->planner_settings;
+ planner->setDescrate(lrint(rate * UNIT_FACTOR));
+ emitDataChanged();
+}
+
void DivePlannerPointsModel::setVerbatim(bool value)
{
auto planner = SettingsObjectWrapper::instance()->planner_settings;
diff --git a/qt-models/diveplannermodel.h b/qt-models/diveplannermodel.h
index aebeef766..43a1186d4 100644
--- a/qt-models/diveplannermodel.h
+++ b/qt-models/diveplannermodel.h
@@ -95,6 +95,11 @@ slots:
void setMinSwitchDuration(int duration);
void setSacFactor(double factor);
void setProblemSolvingTime(int minutes);
+ void setAscrate75(int rate);
+ void setAscrate50(int rate);
+ void setAscratestops(int rate);
+ void setAscratelast6m(int rate);
+ void setDescrate(int rate);
signals:
void planCreated();