summaryrefslogtreecommitdiffstats
path: root/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2016-01-14 17:06:55 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-15 05:56:43 -0800
commitba111ce9a3a913bdbcc54f7eb2f96b3514a1673e (patch)
treeb99f4053d369083069d140d20f2e0af4caffa42f /subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp
parent455f7bd51ba3a0b2be2dca01d936cd0073a6db36 (diff)
downloadsubsurface-ba111ce9a3a913bdbcc54f7eb2f96b3514a1673e.tar.gz
Settings QObjectification: implement the unit settings
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp')
-rw-r--r--subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp131
1 files changed, 130 insertions, 1 deletions
diff --git a/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp b/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp
index 3deaafdad..ef48dfa59 100644
--- a/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp
+++ b/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp
@@ -1094,6 +1094,135 @@ void DivePlannerSettings::setDecoMode(deco_mode value)
QSettings s;
s.beginGroup(group);
s.setValue("deco_mode", value);
- prefs.deco_mode = value.;
+ prefs.deco_mode = value;
emit decoModeChanged(value);
}
+
+UnitsSettings::UnitsSettings(QObject *parent = 0) :
+ QObject(parent),
+ group(QStringLiteral("Units"))
+{
+
+}
+
+units::length UnitsSettings::length() const
+{
+ return prefs.units.length;
+}
+
+units::pressure UnitsSettings::pressure() const
+{
+ return prefs.units.pressure;
+}
+
+units::volume UnitsSettings::volume() const
+{
+ return prefs.units.volume;
+}
+
+units::temperature UnitsSettings::temperature() const
+{
+ return prefs.units.temperature;
+}
+
+units::weight UnitsSettings::weight() const
+{
+ return prefs.units.weight;
+}
+
+units::vertical_speed_time UnitsSettings::verticalSpeedTime() const
+{
+ return prefs.units.vertical_speed_time;
+}
+
+QString UnitsSettings::unitSystem() const
+{
+ return prefs.unit_system;
+}
+
+bool UnitsSettings::coordinatesTraditional() const
+{
+ return prefs.coordinates_traditional;
+}
+
+void UnitsSettings::setLength(units::length value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("length", value);
+ prefs.units.length = value;
+ emit lengthChanged(value);
+}
+
+void UnitsSettings::setPressure(units::pressure value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("pressure", value);
+ prefs.units.pressure = value;
+ emit pressureChanged(value);
+}
+
+void UnitsSettings::setVolume(units::volume value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("volume", value);
+ prefs.units.volume = value;
+ emit volumeChanged(value);
+}
+
+void UnitsSettings::setTemperature(units::temperature value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("temperature", value);
+ prefs.units.temperature = value;
+ emit temperatureChanged(value);
+}
+
+void UnitsSettings::setWeight(units::weight value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("weight", value);
+ prefs.units.weight = value;
+ emit weightChanged(value);
+}
+
+void UnitsSettings::setVerticalSpeedTime(units::vertical_speed_time value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("vertical_speed_time", value);
+ prefs.units.vertical_speed_time = value;
+ emit verticalSpeedTimeChanged(value);
+}
+
+void UnitsSettings::setCoordinatesTraditional(bool value)
+{
+ QSettings s;
+ s.setValue("coordinates", value);
+ prefs.coordinates_traditional = value.;
+ emit coordinatesTraditionalChanged(value);
+}
+
+void UnitsSettings::setUnitSystem(const QString& value)
+{
+ QSettings s;
+ s.setValue("unit_system", value);
+ prefs.unit_system = value;
+
+ if (value == QStringLiteral("metric")) {
+ prefs.unit_system = METRIC;
+ prefs.units = SI_units;
+ } else if (value == QStringLiteral("imperial")) {
+ prefs.unit_system = IMPERIAL;
+ prefs.units = IMPERIAL_units;
+ } else {
+ prefs.unit_system = PERSONALIZE;
+ }
+
+ emit unitSystemChanged(value);
+ // TODO: emit the other values here?
+}