aboutsummaryrefslogtreecommitdiffstats
path: root/qt-models/diveplannermodel.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2017-01-07 07:12:07 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-01-07 07:12:07 -0800
commit913fa8592625c109c48c9ef08e8ec9223bf48e2b (patch)
treef8d0ade3bc2bb49e98631fa1d1c2655583cafc61 /qt-models/diveplannermodel.cpp
parentc084887939109bd1bf3b5d41112eeec8e04e0f4c (diff)
parente3a7782aff31f267e990066ce1a3cc065447e05c (diff)
downloadsubsurface-913fa8592625c109c48c9ef08e8ec9223bf48e2b.tar.gz
Merge branch 'plannerSettings'
Diffstat (limited to 'qt-models/diveplannermodel.cpp')
-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 792ea822f..6fe4ac003 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.planner_deco_mode = deco_mode(mode);
+ auto planner = SettingsObjectWrapper::instance()->planner_settings;
+ planner->setDecoMode(deco_mode(mode));
emit recreationChanged(mode == int(prefs.planner_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));
}