summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
authorGravatar Rick Walsh <rickmwalsh@gmail.com>2017-01-06 21:10:21 +1100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-01-07 06:44:42 -0800
commite3a7782aff31f267e990066ce1a3cc065447e05c (patch)
treee4131b54d27effbb0fd1b57af6338b5fdec3c552 /qt-models
parent4e375f56a8b15212b96e0ce5b7ca4724dc268612 (diff)
downloadsubsurface-e3a7782aff31f267e990066ce1a3cc065447e05c.tar.gz
Set planner settings with SettingsObjectWrapper
By using SettingsObjectWrapper, the planner settings can be saved and restored correctly Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/diveplannermodel.cpp42
1 files changed, 28 insertions, 14 deletions
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp
index 43e4686ff..defd2c9b2 100644
--- a/qt-models/diveplannermodel.cpp
+++ b/qt-models/diveplannermodel.cpp
@@ -5,6 +5,7 @@
#include "core/planner.h"
#include "qt-models/models.h"
#include "core/device.h"
+#include "core/subsurface-qt/SettingsObjectWrapper.h"
/* TODO: Port this to CleanerTableModel to remove a bit of boilerplate and
* use the signal warningMessage() to communicate errors to the MainWindow.
@@ -377,14 +378,16 @@ void DivePlannerPointsModel::emitDataChanged()
void DivePlannerPointsModel::setBottomSac(double sac)
{
diveplan.bottomsac = units_to_sac(sac);
- prefs.bottomsac = diveplan.bottomsac;
+ auto planner = SettingsObjectWrapper::instance()->planner_settings;
+ planner->setBottomSac(diveplan.bottomsac);
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
}
void DivePlannerPointsModel::setDecoSac(double sac)
{
diveplan.decosac = units_to_sac(sac);
- prefs.decosac = diveplan.decosac;
+ auto planner = SettingsObjectWrapper::instance()->planner_settings;
+ planner->setDecoSac(diveplan.decosac);
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
}
@@ -455,59 +458,68 @@ int DivePlannerPointsModel::getSurfacePressure()
void DivePlannerPointsModel::setLastStop6m(bool value)
{
- prefs.last_stop = value;
+ auto planner = SettingsObjectWrapper::instance()->planner_settings;
+ planner->setLastStop(value);
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
}
void DivePlannerPointsModel::setVerbatim(bool value)
{
- prefs.verbatim_plan = value;
+ auto planner = SettingsObjectWrapper::instance()->planner_settings;
+ planner->setVerbatimPlan(value);
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
}
void DivePlannerPointsModel::setDisplayRuntime(bool value)
{
- prefs.display_runtime = value;
+ auto planner = SettingsObjectWrapper::instance()->planner_settings;
+ planner->setDisplayRuntime(value);
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
}
void DivePlannerPointsModel::setDisplayDuration(bool value)
{
- prefs.display_duration = value;
+ auto planner = SettingsObjectWrapper::instance()->planner_settings;
+ planner->setDisplayDuration(value);
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
}
void DivePlannerPointsModel::setDisplayTransitions(bool value)
{
- prefs.display_transitions = value;
+ auto planner = SettingsObjectWrapper::instance()->planner_settings;
+ planner->setDisplayTransitions(value);
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
}
void DivePlannerPointsModel::setDecoMode(int mode)
{
- prefs.deco_mode = deco_mode(mode);
+ auto planner = SettingsObjectWrapper::instance()->planner_settings;
+ planner->setDecoMode(deco_mode(mode));
emit recreationChanged(mode == int(prefs.deco_mode));
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS -1));
}
void DivePlannerPointsModel::setSafetyStop(bool value)
{
- prefs.safetystop = value;
+ auto planner = SettingsObjectWrapper::instance()->planner_settings;
+ planner->setSafetyStop(value);
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS -1));
}
void DivePlannerPointsModel::setReserveGas(int reserve)
{
+ auto planner = SettingsObjectWrapper::instance()->planner_settings;
if (prefs.units.pressure == units::BAR)
- prefs.reserve_gas = reserve * 1000;
+ planner->setReserveGas(reserve * 1000);
else
- prefs.reserve_gas = psi_to_mbar(reserve);
+ planner->setReserveGas(psi_to_mbar(reserve));
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
}
void DivePlannerPointsModel::setDropStoneMode(bool value)
{
- prefs.drop_stone_mode = value;
+ auto planner = SettingsObjectWrapper::instance()->planner_settings;
+ planner->setDropStoneMode(value);
if (prefs.drop_stone_mode) {
/* Remove the first entry if we enable drop_stone_mode */
if (rowCount() >= 2) {
@@ -529,13 +541,15 @@ void DivePlannerPointsModel::setDropStoneMode(bool value)
void DivePlannerPointsModel::setSwitchAtReqStop(bool value)
{
- prefs.switch_at_req_stop = value;
+ auto planner = SettingsObjectWrapper::instance()->planner_settings;
+ planner->setSwitchAtRequiredStop(value);
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
}
void DivePlannerPointsModel::setMinSwitchDuration(int duration)
{
- prefs.min_switch_duration = duration * 60;
+ auto planner = SettingsObjectWrapper::instance()->planner_settings;
+ planner->setMinSwitchDuration(duration * 60);
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
}