aboutsummaryrefslogtreecommitdiffstats
path: root/core/subsurface-qt
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2016-04-04 22:02:03 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-04-04 22:33:58 -0700
commit7be962bfc2879a72c32ff67518731347dcdff6de (patch)
treed05bf7ab234a448ee37a15b608e2b939f2285d07 /core/subsurface-qt
parent2d760a7bff71c46c5aeba37c40d236ea16eefea2 (diff)
downloadsubsurface-7be962bfc2879a72c32ff67518731347dcdff6de.tar.gz
Move subsurface-core to core and qt-mobile to mobile-widgets
Having subsurface-core as a directory name really messes with autocomplete and is obviously redundant. Simmilarly, qt-mobile caused an autocomplete conflict and also was inconsistent with the desktop-widget name for the directory containing the "other" UI. And while cleaning up the resulting change in the path name for include files, I decided to clean up those even more to make them consistent overall. This could have been handled in more commits, but since this requires a make clean before the build, it seemed more sensible to do it all in one. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/subsurface-qt')
-rw-r--r--core/subsurface-qt/DiveObjectHelper.cpp338
-rw-r--r--core/subsurface-qt/DiveObjectHelper.h89
-rw-r--r--core/subsurface-qt/SettingsObjectWrapper.cpp1617
-rw-r--r--core/subsurface-qt/SettingsObjectWrapper.h642
4 files changed, 2686 insertions, 0 deletions
diff --git a/core/subsurface-qt/DiveObjectHelper.cpp b/core/subsurface-qt/DiveObjectHelper.cpp
new file mode 100644
index 000000000..ab88d2f3c
--- /dev/null
+++ b/core/subsurface-qt/DiveObjectHelper.cpp
@@ -0,0 +1,338 @@
+#include "DiveObjectHelper.h"
+
+#include <QDateTime>
+#include <QTextDocument>
+
+#include "../qthelper.h"
+#include "../helpers.h"
+
+static QString EMPTY_DIVE_STRING = QStringLiteral("--");
+enum returnPressureSelector {START_PRESSURE, END_PRESSURE};
+
+static QString getFormattedWeight(struct dive *dive, unsigned int idx)
+{
+ weightsystem_t *weight = &dive->weightsystem[idx];
+ if (!weight->description)
+ return QString(EMPTY_DIVE_STRING);
+ QString fmt = QString(weight->description);
+ fmt += ", " + get_weight_string(weight->weight, true);
+ return fmt;
+}
+
+static QString getFormattedCylinder(struct dive *dive, unsigned int idx)
+{
+ cylinder_t *cyl = &dive->cylinder[idx];
+ const char *desc = cyl->type.description;
+ if (!desc && idx > 0)
+ return QString(EMPTY_DIVE_STRING);
+ QString fmt = desc ? QString(desc) : QObject::tr("unknown");
+ fmt += ", " + get_volume_string(cyl->type.size, true);
+ fmt += ", " + get_pressure_string(cyl->type.workingpressure, true);
+ fmt += ", " + get_pressure_string(cyl->start, false) + " - " + get_pressure_string(cyl->end, true);
+ fmt += ", " + get_gas_string(cyl->gasmix);
+ return fmt;
+}
+
+static QString getPressures(struct dive *dive, enum returnPressureSelector ret)
+{
+ cylinder_t *cyl = &dive->cylinder[0];
+ QString fmt;
+ if (ret == START_PRESSURE) {
+ if (cyl->start.mbar)
+ fmt = get_pressure_string(cyl->start, true);
+ else if (cyl->sample_start.mbar)
+ fmt = get_pressure_string(cyl->sample_start, true);
+ }
+ if (ret == END_PRESSURE) {
+ if (cyl->end.mbar)
+ fmt = get_pressure_string(cyl->end, true);
+ else if(cyl->sample_end.mbar)
+ fmt = get_pressure_string(cyl->sample_end, true);
+ }
+ return fmt;
+}
+
+DiveObjectHelper::DiveObjectHelper(struct dive *d) :
+ m_dive(d)
+{
+}
+
+DiveObjectHelper::~DiveObjectHelper()
+{
+}
+
+int DiveObjectHelper::number() const
+{
+ return m_dive->number;
+}
+
+int DiveObjectHelper::id() const
+{
+ return m_dive->id;
+}
+
+QString DiveObjectHelper::date() const
+{
+ QDateTime localTime = QDateTime::fromTime_t(m_dive->when - gettimezoneoffset(m_dive->when));
+ localTime.setTimeSpec(Qt::UTC);
+ return localTime.date().toString(prefs.date_format);
+}
+
+timestamp_t DiveObjectHelper::timestamp() const
+{
+ return m_dive->when;
+}
+
+QString DiveObjectHelper::time() const
+{
+ QDateTime localTime = QDateTime::fromTime_t(m_dive->when - gettimezoneoffset(m_dive->when));
+ localTime.setTimeSpec(Qt::UTC);
+ return localTime.time().toString(prefs.time_format);
+}
+
+QString DiveObjectHelper::location() const
+{
+ return get_dive_location(m_dive) ? QString::fromUtf8(get_dive_location(m_dive)) : EMPTY_DIVE_STRING;
+}
+
+QString DiveObjectHelper::gps() const
+{
+ struct dive_site *ds = get_dive_site_by_uuid(m_dive->dive_site_uuid);
+ return ds ? QString(printGPSCoords(ds->latitude.udeg, ds->longitude.udeg)) : QString();
+}
+QString DiveObjectHelper::duration() const
+{
+ return get_dive_duration_string(m_dive->duration.seconds, QObject::tr("h:"), QObject::tr("min"));
+}
+
+bool DiveObjectHelper::noDive() const
+{
+ return m_dive->duration.seconds == 0 && m_dive->dc.duration.seconds == 0;
+}
+
+QString DiveObjectHelper::depth() const
+{
+ return get_depth_string(m_dive->dc.maxdepth.mm, true, true);
+}
+
+QString DiveObjectHelper::divemaster() const
+{
+ return m_dive->divemaster ? m_dive->divemaster : EMPTY_DIVE_STRING;
+}
+
+QString DiveObjectHelper::buddy() const
+{
+ return m_dive->buddy ? m_dive->buddy : EMPTY_DIVE_STRING;
+}
+
+QString DiveObjectHelper::airTemp() const
+{
+ QString temp = get_temperature_string(m_dive->airtemp, true);
+ if (temp.isEmpty()) {
+ temp = EMPTY_DIVE_STRING;
+ }
+ return temp;
+}
+
+QString DiveObjectHelper::waterTemp() const
+{
+ QString temp = get_temperature_string(m_dive->watertemp, true);
+ if (temp.isEmpty()) {
+ temp = EMPTY_DIVE_STRING;
+ }
+ return temp;
+}
+
+QString DiveObjectHelper::notes() const
+{
+ QString tmp = m_dive->notes ? QString::fromUtf8(m_dive->notes) : EMPTY_DIVE_STRING;
+ if (same_string(m_dive->dc.model, "planned dive")) {
+ QTextDocument notes;
+ #define _NOTES_BR "&#92n"
+ tmp.replace("<thead>", "<thead>" _NOTES_BR)
+ .replace("<br>", "<br>" _NOTES_BR)
+ .replace("<tr>", "<tr>" _NOTES_BR)
+ .replace("</tr>", "</tr>" _NOTES_BR);
+ notes.setHtml(tmp);
+ tmp = notes.toPlainText();
+ tmp.replace(_NOTES_BR, "<br>");
+ #undef _NOTES_BR
+ } else {
+ tmp.replace("\n", "<br>");
+ }
+ return tmp;
+}
+
+QString DiveObjectHelper::tags() const
+{
+ static char buffer[256];
+ taglist_get_tagstring(m_dive->tag_list, buffer, 256);
+ return QString(buffer);
+}
+
+QString DiveObjectHelper::gas() const
+{
+ /*WARNING: here should be the gastlist, returned
+ * from the get_gas_string function or this is correct?
+ */
+ QString gas, gases;
+ for (int i = 0; i < MAX_CYLINDERS; i++) {
+ if (!is_cylinder_used(m_dive, i))
+ continue;
+ gas = m_dive->cylinder[i].type.description;
+ if (!gas.isEmpty())
+ gas += QChar(' ');
+ gas += gasname(&m_dive->cylinder[i].gasmix);
+ // if has a description and if such gas is not already present
+ if (!gas.isEmpty() && gases.indexOf(gas) == -1) {
+ if (!gases.isEmpty())
+ gases += QString(" / ");
+ gases += gas;
+ }
+ }
+ return gases;
+}
+
+QString DiveObjectHelper::sac() const
+{
+ if (!m_dive->sac)
+ return QString();
+ const char *unit;
+ int decimal;
+ double value = get_volume_units(m_dive->sac, &decimal, &unit);
+ return QString::number(value, 'f', decimal).append(unit);
+}
+
+QString DiveObjectHelper::weightList() const
+{
+ QString weights;
+ for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) {
+ QString w = getFormattedWeight(m_dive, i);
+ if (w == EMPTY_DIVE_STRING)
+ continue;
+ weights += w + "; ";
+ }
+ return weights;
+}
+
+QStringList DiveObjectHelper::weights() const
+{
+ QStringList weights;
+ for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++)
+ weights << getFormattedWeight(m_dive, i);
+ return weights;
+}
+
+bool DiveObjectHelper::singleWeight() const
+{
+ return weightsystem_none(&m_dive->weightsystem[1]);
+}
+
+QString DiveObjectHelper::weight(int idx) const
+{
+ if ( (idx < 0) || idx > MAX_WEIGHTSYSTEMS )
+ return QString(EMPTY_DIVE_STRING);
+ return getFormattedWeight(m_dive, idx);
+}
+
+QString DiveObjectHelper::suit() const
+{
+ return m_dive->suit ? m_dive->suit : EMPTY_DIVE_STRING;
+}
+
+QString DiveObjectHelper::cylinderList() const
+{
+ QString cylinders;
+ for (int i = 0; i < MAX_CYLINDERS; i++) {
+ QString cyl = getFormattedCylinder(m_dive, i);
+ if (cyl == EMPTY_DIVE_STRING)
+ continue;
+ cylinders += cyl + "; ";
+ }
+ return cylinders;
+}
+
+QStringList DiveObjectHelper::cylinders() const
+{
+ QStringList cylinders;
+ for (int i = 0; i < MAX_CYLINDERS; i++)
+ cylinders << getFormattedCylinder(m_dive, i);
+ return cylinders;
+}
+
+QString DiveObjectHelper::cylinder(int idx) const
+{
+ if ( (idx < 0) || idx > MAX_CYLINDERS)
+ return QString(EMPTY_DIVE_STRING);
+ return getFormattedCylinder(m_dive, idx);
+}
+
+QString DiveObjectHelper::trip() const
+{
+ return m_dive->divetrip ? m_dive->divetrip->location : EMPTY_DIVE_STRING;
+}
+
+// combine the pointer address with the trip location so that
+// we detect multiple, destinct trips to the same location
+QString DiveObjectHelper::tripMeta() const
+{
+ QString ret = EMPTY_DIVE_STRING;
+ if (m_dive->divetrip)
+ ret = QString::number((quint64)m_dive->divetrip, 16) + QLatin1Literal("::") + m_dive->divetrip->location;
+ return ret;
+}
+
+QString DiveObjectHelper::maxcns() const
+{
+ return QString(m_dive->maxcns);
+}
+
+QString DiveObjectHelper::otu() const
+{
+ return QString(m_dive->otu);
+}
+
+int DiveObjectHelper::rating() const
+{
+ return m_dive->rating;
+}
+
+QString DiveObjectHelper::sumWeight() const
+{
+ weight_t sum = { 0 };
+ for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++){
+ sum.grams += m_dive->weightsystem[i].weight.grams;
+ }
+ return get_weight_string(sum, true);
+}
+
+QString DiveObjectHelper::getCylinder() const
+{
+ QString getCylinder;
+ if (is_cylinder_used(m_dive, 1)){
+ getCylinder = QObject::tr("Multiple");
+ }
+ else {
+ getCylinder = m_dive->cylinder[0].type.description;
+ }
+ return getCylinder;
+}
+
+QString DiveObjectHelper::startPressure() const
+{
+ QString startPressure = getPressures(m_dive, START_PRESSURE);
+ return startPressure;
+}
+
+QString DiveObjectHelper::endPressure() const
+{
+ QString endPressure = getPressures(m_dive, END_PRESSURE);
+ return endPressure;
+}
+
+QString DiveObjectHelper::firstGas() const
+{
+ QString gas;
+ gas = get_gas_string(m_dive->cylinder[0].gasmix);
+ return gas;
+}
diff --git a/core/subsurface-qt/DiveObjectHelper.h b/core/subsurface-qt/DiveObjectHelper.h
new file mode 100644
index 000000000..602775ef8
--- /dev/null
+++ b/core/subsurface-qt/DiveObjectHelper.h
@@ -0,0 +1,89 @@
+#ifndef DIVE_QOBJECT_H
+#define DIVE_QOBJECT_H
+
+#include "../dive.h"
+#include <QObject>
+#include <QString>
+#include <QStringList>
+
+class DiveObjectHelper : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(int number READ number CONSTANT)
+ Q_PROPERTY(int id READ id CONSTANT)
+ Q_PROPERTY(int rating READ rating CONSTANT)
+ Q_PROPERTY(QString date READ date CONSTANT)
+ Q_PROPERTY(QString time READ time CONSTANT)
+ Q_PROPERTY(QString location READ location CONSTANT)
+ Q_PROPERTY(QString gps READ gps CONSTANT)
+ Q_PROPERTY(QString duration READ duration CONSTANT)
+ Q_PROPERTY(bool noDive READ noDive CONSTANT)
+ Q_PROPERTY(QString depth READ depth CONSTANT)
+ Q_PROPERTY(QString divemaster READ divemaster CONSTANT)
+ Q_PROPERTY(QString buddy READ buddy CONSTANT)
+ Q_PROPERTY(QString airTemp READ airTemp CONSTANT)
+ Q_PROPERTY(QString waterTemp READ waterTemp CONSTANT)
+ Q_PROPERTY(QString notes READ notes CONSTANT)
+ Q_PROPERTY(QString tags READ tags CONSTANT)
+ Q_PROPERTY(QString gas READ gas CONSTANT)
+ Q_PROPERTY(QString sac READ sac CONSTANT)
+ Q_PROPERTY(QString weightList READ weightList CONSTANT)
+ Q_PROPERTY(QStringList weights READ weights CONSTANT)
+ Q_PROPERTY(bool singleWeight READ singleWeight CONSTANT)
+ Q_PROPERTY(QString suit READ suit CONSTANT)
+ Q_PROPERTY(QString cylinderList READ cylinderList CONSTANT)
+ Q_PROPERTY(QStringList cylinders READ cylinders CONSTANT)
+ Q_PROPERTY(QString trip READ trip CONSTANT)
+ Q_PROPERTY(QString tripMeta READ tripMeta CONSTANT)
+ Q_PROPERTY(QString maxcns READ maxcns CONSTANT)
+ Q_PROPERTY(QString otu READ otu CONSTANT)
+ Q_PROPERTY(QString sumWeight READ sumWeight CONSTANT)
+ Q_PROPERTY(QString getCylinder READ getCylinder CONSTANT)
+ Q_PROPERTY(QString startPressure READ startPressure CONSTANT)
+ Q_PROPERTY(QString endPressure READ endPressure CONSTANT)
+ Q_PROPERTY(QString firstGas READ firstGas CONSTANT)
+public:
+ DiveObjectHelper(struct dive *dive = NULL);
+ ~DiveObjectHelper();
+ int number() const;
+ int id() const;
+ int rating() const;
+ QString date() const;
+ timestamp_t timestamp() const;
+ QString time() const;
+ QString location() const;
+ QString gps() const;
+ QString duration() const;
+ bool noDive() const;
+ QString depth() const;
+ QString divemaster() const;
+ QString buddy() const;
+ QString airTemp() const;
+ QString waterTemp() const;
+ QString notes() const;
+ QString tags() const;
+ QString gas() const;
+ QString sac() const;
+ QString weightList() const;
+ QStringList weights() const;
+ QString weight(int idx) const;
+ bool singleWeight() const;
+ QString suit() const;
+ QString cylinderList() const;
+ QStringList cylinders() const;
+ QString cylinder(int idx) const;
+ QString trip() const;
+ QString tripMeta() const;
+ QString maxcns() const;
+ QString otu() const;
+ QString sumWeight() const;
+ QString getCylinder() const;
+ QString startPressure() const;
+ QString endPressure() const;
+ QString firstGas() const;
+
+private:
+ struct dive *m_dive;
+};
+ Q_DECLARE_METATYPE(DiveObjectHelper *)
+
+#endif
diff --git a/core/subsurface-qt/SettingsObjectWrapper.cpp b/core/subsurface-qt/SettingsObjectWrapper.cpp
new file mode 100644
index 000000000..e43be1a9b
--- /dev/null
+++ b/core/subsurface-qt/SettingsObjectWrapper.cpp
@@ -0,0 +1,1617 @@
+#include "SettingsObjectWrapper.h"
+#include <QSettings>
+#include <QApplication>
+#include <QFont>
+
+#include "../dive.h" // TODO: remove copy_string from dive.h
+
+
+static QString tecDetails = QStringLiteral("TecDetails");
+
+PartialPressureGasSettings::PartialPressureGasSettings(QObject* parent):
+ QObject(parent),
+ group("TecDetails")
+{
+
+}
+
+short PartialPressureGasSettings::showPo2() const
+{
+ return prefs.pp_graphs.po2;
+}
+
+short PartialPressureGasSettings::showPn2() const
+{
+ return prefs.pp_graphs.pn2;
+}
+
+short PartialPressureGasSettings::showPhe() const
+{
+ return prefs.pp_graphs.phe;
+}
+
+double PartialPressureGasSettings::po2Threshold() const
+{
+ return prefs.pp_graphs.po2_threshold;
+}
+
+double PartialPressureGasSettings::pn2Threshold() const
+{
+ return prefs.pp_graphs.pn2_threshold;
+}
+
+double PartialPressureGasSettings::pheThreshold() const
+{
+ return prefs.pp_graphs.phe_threshold;
+}
+
+void PartialPressureGasSettings::setShowPo2(short value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("po2graph", value);
+ prefs.pp_graphs.po2 = value;
+ emit showPo2Changed(value);
+}
+
+void PartialPressureGasSettings::setShowPn2(short value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("pn2graph", value);
+ prefs.pp_graphs.pn2 = value;
+ emit showPn2Changed(value);
+}
+
+void PartialPressureGasSettings::setShowPhe(short value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("phegraph", value);
+ prefs.pp_graphs.phe = value;
+ emit showPheChanged(value);
+}
+
+void PartialPressureGasSettings::setPo2Threshold(double value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("po2threshold", value);
+ prefs.pp_graphs.po2_threshold = value;
+ emit po2ThresholdChanged(value);
+}
+
+void PartialPressureGasSettings::setPn2Threshold(double value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("pn2threshold", value);
+ prefs.pp_graphs.pn2_threshold = value;
+ emit pn2ThresholdChanged(value);
+}
+
+void PartialPressureGasSettings::setPheThreshold(double value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("phethreshold", value);
+ prefs.pp_graphs.phe_threshold = value;
+ emit pheThresholdChanged(value);
+}
+
+
+TechnicalDetailsSettings::TechnicalDetailsSettings(QObject* parent): QObject(parent)
+{
+
+}
+
+double TechnicalDetailsSettings:: modp02() const
+{
+ return prefs.modpO2;
+}
+
+bool TechnicalDetailsSettings::ead() const
+{
+ return prefs.ead;
+}
+
+bool TechnicalDetailsSettings::dcceiling() const
+{
+ return prefs.dcceiling;
+}
+
+bool TechnicalDetailsSettings::redceiling() const
+{
+ return prefs.redceiling;
+}
+
+bool TechnicalDetailsSettings::calcceiling() const
+{
+ return prefs.calcceiling;
+}
+
+bool TechnicalDetailsSettings::calcceiling3m() const
+{
+ return prefs.calcceiling3m;
+}
+
+bool TechnicalDetailsSettings::calcalltissues() const
+{
+ return prefs.calcalltissues;
+}
+
+bool TechnicalDetailsSettings::calcndltts() const
+{
+ return prefs.calcndltts;
+}
+
+bool TechnicalDetailsSettings::gflow() const
+{
+ return prefs.gflow;
+}
+
+bool TechnicalDetailsSettings::gfhigh() const
+{
+ return prefs.gfhigh;
+}
+
+bool TechnicalDetailsSettings::hrgraph() const
+{
+ return prefs.hrgraph;
+}
+
+bool TechnicalDetailsSettings::tankBar() const
+{
+ return prefs.tankbar;
+}
+
+bool TechnicalDetailsSettings::percentageGraph() const
+{
+ return prefs.percentagegraph;
+}
+
+bool TechnicalDetailsSettings::rulerGraph() const
+{
+ return prefs.rulergraph;
+}
+
+bool TechnicalDetailsSettings::showCCRSetpoint() const
+{
+ return prefs.show_ccr_setpoint;
+}
+
+bool TechnicalDetailsSettings::showCCRSensors() const
+{
+ return prefs.show_ccr_sensors;
+}
+
+bool TechnicalDetailsSettings::zoomedPlot() const
+{
+ return prefs.zoomed_plot;
+}
+
+bool TechnicalDetailsSettings::showSac() const
+{
+ return prefs.show_sac;
+}
+
+bool TechnicalDetailsSettings::gfLowAtMaxDepth() const
+{
+ return prefs.gf_low_at_maxdepth;
+}
+
+bool TechnicalDetailsSettings::displayUnusedTanks() const
+{
+ return prefs.display_unused_tanks;
+}
+
+bool TechnicalDetailsSettings::showAverageDepth() const
+{
+ return prefs.show_average_depth;
+}
+
+bool TechnicalDetailsSettings::mod() const
+{
+ return prefs.mod;
+}
+
+bool TechnicalDetailsSettings::showPicturesInProfile() const
+{
+ return prefs.show_pictures_in_profile;
+}
+
+void TechnicalDetailsSettings::setModp02(double value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("modpO2", value);
+ prefs.modpO2 = value;
+ emit modpO2Changed(value);
+}
+
+void TechnicalDetailsSettings::setShowPicturesInProfile(bool value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("show_pictures_in_profile", value);
+ prefs.show_pictures_in_profile = value;
+ emit showPicturesInProfileChanged(value);
+}
+
+void TechnicalDetailsSettings::setEad(bool value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("ead", value);
+ prefs.ead = value;
+ emit eadChanged(value);
+}
+
+void TechnicalDetailsSettings::setMod(bool value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("mod", value);
+ prefs.mod = value;
+ emit modChanged(value);
+}
+
+void TechnicalDetailsSettings::setDCceiling(bool value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("dcceiling", value);
+ prefs.dcceiling = value;
+ emit dcceilingChanged(value);
+}
+
+void TechnicalDetailsSettings::setRedceiling(bool value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("redceiling", value);
+ prefs.redceiling = value;
+ emit redceilingChanged(value);
+}
+
+void TechnicalDetailsSettings::setCalcceiling(bool value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("calcceiling", value);
+ prefs.calcceiling = value;
+ emit calcceilingChanged(value);
+}
+
+void TechnicalDetailsSettings::setCalcceiling3m(bool value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("calcceiling3m", value);
+ prefs.calcceiling3m = value;
+ emit calcceiling3mChanged(value);
+}
+
+void TechnicalDetailsSettings::setCalcalltissues(bool value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("calcalltissues", value);
+ prefs.calcalltissues = value;
+ emit calcalltissuesChanged(value);
+}
+
+void TechnicalDetailsSettings::setCalcndltts(bool value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("calcndltts", value);
+ prefs.calcndltts = value;
+ emit calcndlttsChanged(value);
+}
+
+void TechnicalDetailsSettings::setGflow(bool value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("gflow", value);
+ prefs.gflow = value;
+ set_gf(prefs.gflow, prefs.gfhigh, prefs.gf_low_at_maxdepth);
+ emit gflowChanged(value);
+}
+
+void TechnicalDetailsSettings::setGfhigh(bool value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("gfhigh", value);
+ prefs.gfhigh = value;
+ set_gf(prefs.gflow, prefs.gfhigh, prefs.gf_low_at_maxdepth);
+ emit gfhighChanged(value);
+}
+
+void TechnicalDetailsSettings::setHRgraph(bool value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("hrgraph", value);
+ prefs.hrgraph = value;
+ emit hrgraphChanged(value);
+}
+
+void TechnicalDetailsSettings::setTankBar(bool value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("tankbar", value);
+ prefs.tankbar = value;
+ emit tankBarChanged(value);
+}
+
+void TechnicalDetailsSettings::setPercentageGraph(bool value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("percentagegraph", value);
+ prefs.percentagegraph = value;
+ emit percentageGraphChanged(value);
+}
+
+void TechnicalDetailsSettings::setRulerGraph(bool value)
+{
+ /* TODO: search for the QSettings of the RulerBar */
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("RulerBar", value);
+ prefs.rulergraph = value;
+ emit rulerGraphChanged(value);
+}
+
+void TechnicalDetailsSettings::setShowCCRSetpoint(bool value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("show_ccr_setpoint", value);
+ prefs.show_ccr_setpoint = value;
+ emit showCCRSetpointChanged(value);
+}
+
+void TechnicalDetailsSettings::setShowCCRSensors(bool value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("show_ccr_sensors", value);
+ prefs.show_ccr_sensors = value;
+ emit showCCRSensorsChanged(value);
+}
+
+void TechnicalDetailsSettings::setZoomedPlot(bool value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("zoomed_plot", value);
+ prefs.zoomed_plot = value;
+ emit zoomedPlotChanged(value);
+}
+
+void TechnicalDetailsSettings::setShowSac(bool value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("show_sac", value);
+ prefs.show_sac = value;
+ emit showSacChanged(value);
+}
+
+void TechnicalDetailsSettings::setGfLowAtMaxDepth(bool value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("gf_low_at_maxdepth", value);
+ prefs.gf_low_at_maxdepth = value;
+ set_gf(prefs.gflow, prefs.gfhigh, prefs.gf_low_at_maxdepth);
+ emit gfLowAtMaxDepthChanged(value);
+}
+
+void TechnicalDetailsSettings::setDisplayUnusedTanks(bool value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("display_unused_tanks", value);
+ prefs.display_unused_tanks = value;
+ emit displayUnusedTanksChanged(value);
+}
+
+void TechnicalDetailsSettings::setShowAverageDepth(bool value)
+{
+ QSettings s;
+ s.beginGroup(tecDetails);
+ s.setValue("show_average_depth", value);
+ prefs.show_average_depth = value;
+ emit showAverageDepthChanged(value);
+}
+
+
+
+FacebookSettings::FacebookSettings(QObject *parent) :
+ QObject(parent),
+ group(QStringLiteral("WebApps")),
+ subgroup(QStringLiteral("Facebook"))
+{
+}
+
+QString FacebookSettings::accessToken() const
+{
+ return QString(prefs.facebook.access_token);
+}
+
+QString FacebookSettings::userId() const
+{
+ return QString(prefs.facebook.user_id);
+}
+
+QString FacebookSettings::albumId() const
+{
+ return QString(prefs.facebook.album_id);
+}
+
+void FacebookSettings::setAccessToken (const QString& value)
+{
+#if SAVE_FB_CREDENTIALS
+ QSettings s;
+ s.beginGroup(group);
+ s.beginGroup(subgroup);
+ s.setValue("ConnectToken", value);
+#endif
+ prefs.facebook.access_token = copy_string(qPrintable(value));
+ emit accessTokenChanged(value);
+}
+
+void FacebookSettings::setUserId(const QString& value)
+{
+#if SAVE_FB_CREDENTIALS
+ QSettings s;
+ s.beginGroup(group);
+ s.beginGroup(subgroup);
+ s.setValue("UserId", value);
+#endif
+ prefs.facebook.user_id = copy_string(qPrintable(value));
+ emit userIdChanged(value);
+}
+
+void FacebookSettings::setAlbumId(const QString& value)
+{
+#if SAVE_FB_CREDENTIALS
+ QSettings s;
+ s.beginGroup(group);
+ s.beginGroup(subgroup);
+ s.setValue("AlbumId", value);
+#endif
+ prefs.facebook.album_id = copy_string(qPrintable(value));
+ emit albumIdChanged(value);
+}
+
+
+GeocodingPreferences::GeocodingPreferences(QObject *parent) :
+ QObject(parent),
+ group(QStringLiteral("geocoding"))
+{
+
+}
+
+bool GeocodingPreferences::enableGeocoding() const
+{
+ return prefs.geocoding.enable_geocoding;
+}
+
+bool GeocodingPreferences::parseDiveWithoutGps() const
+{
+ return prefs.geocoding.parse_dive_without_gps;
+}
+
+bool GeocodingPreferences::tagExistingDives() const
+{
+ return prefs.geocoding.tag_existing_dives;
+}
+
+taxonomy_category GeocodingPreferences::firstTaxonomyCategory() const
+{
+ return prefs.geocoding.category[0];
+}
+
+taxonomy_category GeocodingPreferences::secondTaxonomyCategory() const
+{
+ return prefs.geocoding.category[1];
+}
+
+taxonomy_category GeocodingPreferences::thirdTaxonomyCategory() const
+{
+ return prefs.geocoding.category[2];
+}
+
+void GeocodingPreferences::setEnableGeocoding(bool value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("enable_geocoding", value);
+ prefs.geocoding.enable_geocoding = value;
+ emit enableGeocodingChanged(value);
+}
+
+void GeocodingPreferences::setParseDiveWithoutGps(bool value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("parse_dives_without_gps", value);
+ prefs.geocoding.parse_dive_without_gps = value;
+ emit parseDiveWithoutGpsChanged(value);
+}
+
+void GeocodingPreferences::setTagExistingDives(bool value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("tag_existing_dives", value);
+ prefs.geocoding.tag_existing_dives = value;
+ emit tagExistingDivesChanged(value);
+}
+
+void GeocodingPreferences::setFirstTaxonomyCategory(taxonomy_category value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("cat0", value);
+ prefs.show_average_depth = value;
+ emit firstTaxonomyCategoryChanged(value);
+}
+
+void GeocodingPreferences::setSecondTaxonomyCategory(taxonomy_category value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("cat1", value);
+ prefs.show_average_depth = value;
+ emit secondTaxonomyCategoryChanged(value);
+}
+
+void GeocodingPreferences::setThirdTaxonomyCategory(taxonomy_category value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("cat2", value);
+ prefs.show_average_depth = value;
+ emit thirdTaxonomyCategoryChanged(value);
+}
+
+ProxySettings::ProxySettings(QObject *parent) :
+ QObject(parent),
+ group(QStringLiteral("Network"))
+{
+}
+
+int ProxySettings::type() const
+{
+ return prefs.proxy_type;
+}
+
+QString ProxySettings::host() const
+{
+ return prefs.proxy_host;
+}
+
+int ProxySettings::port() const
+{
+ return prefs.proxy_port;
+}
+
+short ProxySettings::auth() const
+{
+ return prefs.proxy_auth;
+}
+
+QString ProxySettings::user() const
+{
+ return prefs.proxy_user;
+}
+
+QString ProxySettings::pass() const
+{
+ return prefs.proxy_pass;
+}
+
+void ProxySettings::setType(int value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("proxy_type", value);
+ prefs.proxy_type = value;
+ emit typeChanged(value);
+}
+
+void ProxySettings::setHost(const QString& value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("proxy_host", value);
+ free(prefs.proxy_host);
+ prefs.proxy_host = copy_string(qPrintable(value));;
+ emit hostChanged(value);
+}
+
+void ProxySettings::setPort(int value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("proxy_port", value);
+ prefs.proxy_port = value;
+ emit portChanged(value);
+}
+
+void ProxySettings::setAuth(short value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("proxy_auth", value);
+ prefs.proxy_auth = value;
+ emit authChanged(value);
+}
+
+void ProxySettings::setUser(const QString& value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("proxy_user", value);
+ free(prefs.proxy_user);
+ prefs.proxy_user = copy_string(qPrintable(value));
+ emit userChanged(value);
+}
+
+void ProxySettings::setPass(const QString& value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("proxy_pass", value);
+ free(prefs.proxy_pass);
+ prefs.proxy_pass = copy_string(qPrintable(value));
+ emit passChanged(value);
+}
+
+CloudStorageSettings::CloudStorageSettings(QObject *parent) :
+ QObject(parent),
+ group(QStringLiteral("CloudStorage"))
+{
+
+}
+
+bool CloudStorageSettings::gitLocalOnly() const
+{
+ return prefs.git_local_only;
+}
+
+QString CloudStorageSettings::password() const
+{
+ return QString(prefs.cloud_storage_password);
+}
+
+QString CloudStorageSettings::newPassword() const
+{
+ return QString(prefs.cloud_storage_newpassword);
+}
+
+QString CloudStorageSettings::email() const
+{
+ return QString(prefs.cloud_storage_email);
+}
+
+QString CloudStorageSettings::emailEncoded() const
+{
+ return QString(prefs.cloud_storage_email_encoded);
+}
+
+bool CloudStorageSettings::savePasswordLocal() const
+{
+ return prefs.save_password_local;
+}
+
+short CloudStorageSettings::verificationStatus() const
+{
+ return prefs.cloud_verification_status;
+}
+
+bool CloudStorageSettings::backgroundSync() const
+{
+ return prefs.cloud_background_sync;
+}
+
+QString CloudStorageSettings::userId() const
+{
+ return QString(prefs.userid);
+}
+
+QString CloudStorageSettings::baseUrl() const
+{
+ return QString(prefs.cloud_base_url);
+}
+
+QString CloudStorageSettings::gitUrl() const
+{
+ return QString(prefs.cloud_git_url);
+}
+
+void CloudStorageSettings::setPassword(const QString& value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("password", value);
+ free(prefs.proxy_pass);
+ prefs.proxy_pass = copy_string(qPrintable(value));
+ emit passwordChanged(value);
+}
+
+void CloudStorageSettings::setNewPassword(const QString& value)
+{
+ /*TODO: This looks like wrong, but 'new password' is not saved on disk, why it's on prefs? */
+ free(prefs.cloud_storage_newpassword);
+ prefs.cloud_storage_newpassword = copy_string(qPrintable(value));
+ emit newPasswordChanged(value);
+}
+
+void CloudStorageSettings::setEmail(const QString& value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("email", value);
+ free(prefs.cloud_storage_email);
+ prefs.cloud_storage_email = copy_string(qPrintable(value));
+ emit emailChanged(value);
+}
+
+void CloudStorageSettings::setUserId(const QString& value)
+{
+ //WARNING: UserId is stored outside of any group, but it belongs to Cloud Storage.
+ QSettings s;
+ s.setValue("subsurface_webservice_uid", value);
+ free(prefs.userid);
+ prefs.userid = copy_string(qPrintable(value));
+ emit userIdChanged(value);
+}
+
+void CloudStorageSettings::setEmailEncoded(const QString& value)
+{
+ /*TODO: This looks like wrong, but 'email encoded' is not saved on disk, why it's on prefs? */
+ free(prefs.cloud_storage_email_encoded);
+ prefs.cloud_storage_email_encoded = copy_string(qPrintable(value));
+ emit emailEncodedChanged(value);
+}
+
+void CloudStorageSettings::setSavePasswordLocal(bool value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("save_password_local", value);
+ prefs.save_password_local = value;
+ emit savePasswordLocalChanged(value);
+}
+
+void CloudStorageSettings::setVerificationStatus(short value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("cloud_verification_status", value);
+ prefs.cloud_verification_status = value;
+ emit verificationStatusChanged(value);
+}
+
+void CloudStorageSettings::setBackgroundSync(bool value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("cloud_background_sync", value);
+ prefs.cloud_background_sync = value;
+ emit backgroundSyncChanged(value);
+}
+
+void CloudStorageSettings::setBaseUrl(const QString& value)
+{
+ free((void*)prefs.cloud_base_url);
+ free((void*)prefs.cloud_git_url);
+ prefs.cloud_base_url = copy_string(qPrintable(value));
+ prefs.cloud_git_url = copy_string(qPrintable(QString(prefs.cloud_base_url) + "/git"));
+}
+
+void CloudStorageSettings::setGitUrl(const QString& value)
+{
+ Q_UNUSED(value); /* no op */
+}
+
+void CloudStorageSettings::setGitLocalOnly(bool value)
+{
+ prefs.git_local_only = value;
+}
+
+DivePlannerSettings::DivePlannerSettings(QObject *parent) :
+ QObject(parent),
+ group(QStringLiteral("Planner"))
+{
+}
+
+bool DivePlannerSettings::lastStop() const
+{
+ return prefs.last_stop;
+}
+
+bool DivePlannerSettings::verbatimPlan() const
+{
+ return prefs.verbatim_plan;
+}
+
+bool DivePlannerSettings::displayRuntime() const
+{
+ return prefs.display_runtime;
+}
+
+bool DivePlannerSettings::displayDuration() const
+{
+ return prefs.display_duration;
+}
+
+bool DivePlannerSettings::displayTransitions() const
+{
+ return prefs.display_transitions;
+}
+
+bool DivePlannerSettings::doo2breaks() const
+{
+ return prefs.doo2breaks;
+}
+
+bool DivePlannerSettings::dropStoneMode() const
+{
+ return prefs.drop_stone_mode;
+}
+
+bool DivePlannerSettings::safetyStop() const
+{
+ return prefs.safetystop;
+}
+
+bool DivePlannerSettings::switchAtRequiredStop() const
+{
+ return prefs.switch_at_req_stop;
+}
+
+int DivePlannerSettings::ascrate75() const
+{
+ return prefs.ascrate75;
+}
+
+int DivePlannerSettings::ascrate50() const
+{
+ return prefs.ascrate50;
+}
+
+int DivePlannerSettings::ascratestops() const
+{
+ return prefs.ascratestops;
+}
+
+int DivePlannerSettings::ascratelast6m() const
+{
+ return prefs.ascratelast6m;
+}
+
+int DivePlannerSettings::descrate() const
+{
+ return prefs.descrate;
+}
+
+int DivePlannerSettings::bottompo2() const
+{
+ return prefs.bottompo2;
+}
+
+int DivePlannerSettings::decopo2() const
+{
+ return prefs.decopo2;
+}
+
+int DivePlannerSettings::reserveGas() const
+{
+ return prefs.reserve_gas;
+}
+
+int DivePlannerSettings::minSwitchDuration() const
+{
+ return prefs.min_switch_duration;
+}
+
+int DivePlannerSettings::bottomSac() const
+{
+ return prefs.bottomsac;
+}
+
+int DivePlannerSettings::decoSac() const
+{
+ return prefs.decosac;
+}
+
+short DivePlannerSettings::conservatismLevel() const
+{
+ return prefs.conservatism_level;
+}
+
+deco_mode DivePlannerSettings::decoMode() const
+{
+ return prefs.deco_mode;
+}
+
+void DivePlannerSettings::setLastStop(bool value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("last_stop", value);
+ prefs.last_stop = value;
+ emit lastStopChanged(value);
+}
+
+void DivePlannerSettings::setVerbatimPlan(bool value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("verbatim_plan", value);
+ prefs.verbatim_plan = value;
+ emit verbatimPlanChanged(value);
+}
+
+void DivePlannerSettings::setDisplayRuntime(bool value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("display_runtime", value);
+ prefs.display_runtime = value;
+ emit displayRuntimeChanged(value);
+}
+
+void DivePlannerSettings::setDisplayDuration(bool value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("display_duration", value);
+ prefs.display_duration = value;
+ emit displayDurationChanged(value);
+}
+
+void DivePlannerSettings::setDisplayTransitions(bool value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("display_transitions", value);
+ prefs.display_transitions = value;
+ emit displayTransitionsChanged(value);
+}
+
+void DivePlannerSettings::setDoo2breaks(bool value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("doo2breaks", value);
+ prefs.doo2breaks = value;
+ emit doo2breaksChanged(value);
+}
+
+void DivePlannerSettings::setDropStoneMode(bool value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("drop_stone_mode", value);
+ prefs.drop_stone_mode = value;
+ emit dropStoneModeChanged(value);
+}
+
+void DivePlannerSettings::setSafetyStop(bool value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("safetystop", value);
+ prefs.safetystop = value;
+ emit safetyStopChanged(value);
+}
+
+void DivePlannerSettings::setSwitchAtRequiredStop(bool value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("switch_at_req_stop", value);
+ prefs.switch_at_req_stop = value;
+ emit switchAtRequiredStopChanged(value);
+}
+
+void DivePlannerSettings::setAscrate75(int value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("ascrate75", value);
+ prefs.ascrate75 = value;
+ emit ascrate75Changed(value);
+}
+
+void DivePlannerSettings::setAscrate50(int value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("ascrate50", value);
+ prefs.ascrate50 = value;
+ emit ascrate50Changed(value);
+}
+
+void DivePlannerSettings::setAscratestops(int value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("ascratestops", value);
+ prefs.ascratestops = value;
+ emit ascratestopsChanged(value);
+}
+
+void DivePlannerSettings::setAscratelast6m(int value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("ascratelast6m", value);
+ prefs.ascratelast6m = value;
+ emit ascratelast6mChanged(value);
+}
+
+void DivePlannerSettings::setDescrate(int value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("descrate", value);
+ prefs.descrate = value;
+ emit descrateChanged(value);
+}
+
+void DivePlannerSettings::setBottompo2(int value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("bottompo2", value);
+ prefs.bottompo2 = value;
+ emit bottompo2Changed(value);
+}
+
+void DivePlannerSettings::setDecopo2(int value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("decopo2", value);
+ prefs.decopo2 = value;
+ emit decopo2Changed(value);
+}
+
+void DivePlannerSettings::setReserveGas(int value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("reserve_gas", value);
+ prefs.reserve_gas = value;
+ emit reserveGasChanged(value);
+}
+
+void DivePlannerSettings::setMinSwitchDuration(int value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("min_switch_duration", value);
+ prefs.min_switch_duration = value;
+ emit minSwitchDurationChanged(value);
+}
+
+void DivePlannerSettings::setBottomSac(int value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("bottomsac", value);
+ prefs.bottomsac = value;
+ emit bottomSacChanged(value);
+}
+
+void DivePlannerSettings::setSecoSac(int value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("decosac", value);
+ prefs.decosac = value;
+ emit decoSacChanged(value);
+}
+
+void DivePlannerSettings::setConservatismLevel(int value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("conservatism", value);
+ prefs.conservatism_level = value;
+ emit conservatismLevelChanged(value);
+}
+
+void DivePlannerSettings::setDecoMode(deco_mode value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("deco_mode", value);
+ prefs.deco_mode = value;
+ emit decoModeChanged(value);
+}
+
+UnitsSettings::UnitsSettings(QObject *parent) :
+ QObject(parent),
+ group(QStringLiteral("Units"))
+{
+
+}
+
+int UnitsSettings::length() const
+{
+ return prefs.units.length;
+}
+
+int UnitsSettings::pressure() const
+{
+ return prefs.units.pressure;
+}
+
+int UnitsSettings::volume() const
+{
+ return prefs.units.volume;
+}
+
+int UnitsSettings::temperature() const
+{
+ return prefs.units.temperature;
+}
+
+int UnitsSettings::weight() const
+{
+ return prefs.units.weight;
+}
+
+int UnitsSettings::verticalSpeedTime() const
+{
+ return prefs.units.vertical_speed_time;
+}
+
+QString UnitsSettings::unitSystem() const
+{
+ return QString(); /*FIXME: there's no char * units on the prefs. */
+}
+
+bool UnitsSettings::coordinatesTraditional() const
+{
+ return prefs.coordinates_traditional;
+}
+
+void UnitsSettings::setLength(int value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("length", value);
+ prefs.units.length = (units::LENGHT) value;
+ emit lengthChanged(value);
+}
+
+void UnitsSettings::setPressure(int value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("pressure", value);
+ prefs.units.pressure = (units::PRESSURE) value;
+ emit pressureChanged(value);
+}
+
+void UnitsSettings::setVolume(int value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("volume", value);
+ prefs.units.volume = (units::VOLUME) value;
+ emit volumeChanged(value);
+}
+
+void UnitsSettings::setTemperature(int value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("temperature", value);
+ prefs.units.temperature = (units::TEMPERATURE) value;
+ emit temperatureChanged(value);
+}
+
+void UnitsSettings::setWeight(int value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("weight", value);
+ prefs.units.weight = (units::WEIGHT) value;
+ emit weightChanged(value);
+}
+
+void UnitsSettings::setVerticalSpeedTime(int value)
+{
+ QSettings s;
+ s.beginGroup(group);
+ s.setValue("vertical_speed_time", value);
+ prefs.units.vertical_speed_time = (units::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);
+
+ 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?
+}
+
+GeneralSettingsObjectWrapper::GeneralSettingsObjectWrapper(QObject *parent) :
+ QObject(parent),
+ group(QStringLiteral("GeneralSettings"))
+{
+}
+
+QString GeneralSettingsObjectWrapper::defaultFilename() const
+{
+ return prefs.default_filename;
+}
+
+QString GeneralSettingsObjectWrapper::defaultCylinder() const
+{
+ return prefs.default_cylinder;
+}
+
+short GeneralSettingsObjectWrapper::defaultFileBehavior() const
+{
+ return prefs.default_file_behavior;
+}
+
+bool GeneralSettingsObjectWrapper::useDefaultFile() const
+{
+ return prefs.use_default_file;
+}
+
+int GeneralSettingsObjectWrapper::defaultSetPoint() const
+{
+ return prefs.defaultsetpoint;
+}
+
+int GeneralSettingsObjectWrapper::o2Consumption() const
+{
+ return prefs.o2consumption;
+}
+
+int GeneralSettingsObjectWrapper::pscrRatio() const
+{
+ return prefs.pscr_ratio;
+}
+
+void GeneralSettingsObjectWrapper::setDefaultFilename(const QString& value)
+{
+ QSettings s;
+ s.setValue("default_filename", value);
+ prefs.default_filename = copy_string(qPrintable(value));
+ emit defaultFilenameChanged(value);
+}
+
+void GeneralSettingsObjectWrapper::setDefaultCylinder(const QString& value)
+{
+ QSettings s;
+ s.setValue("default_cylinder", value);
+ prefs.default_cylinder = copy_string(qPrintable(value));
+ emit defaultCylinderChanged(value);
+}
+
+void GeneralSettingsObjectWrapper::setDefaultFileBehavior(short value)
+{
+ QSettings s;
+ s.setValue("default_file_behavior", value);
+ prefs.default_file_behavior = value;
+ if (prefs.default_file_behavior == UNDEFINED_DEFAULT_FILE) {
+ // undefined, so check if there's a filename set and
+ // use that, otherwise go with no default file
+ if (QString(prefs.default_filename).isEmpty())
+ prefs.default_file_behavior = NO_DEFAULT_FILE;
+ else
+ prefs.default_file_behavior = LOCAL_DEFAULT_FILE;
+ }
+ emit defaultFileBehaviorChanged(value);
+}
+
+void GeneralSettingsObjectWrapper::setUseDefaultFile(bool value)
+{
+ QSettings s;
+ s.setValue("use_default_file", value);
+ prefs.use_default_file = value;
+ emit useDefaultFileChanged(value);
+}
+
+void GeneralSettingsObjectWrapper::setDefaultSetPoint(int value)
+{
+ QSettings s;
+ s.setValue("defaultsetpoint", value);
+ prefs.defaultsetpoint = value;
+ emit defaultSetPointChanged(value);
+}
+
+void GeneralSettingsObjectWrapper::setO2Consumption(int value)
+{
+ QSettings s;
+ s.setValue("o2consumption", value);
+ prefs.o2consumption = value;
+ emit o2ConsumptionChanged(value);
+}
+
+void GeneralSettingsObjectWrapper::setPscrRatio(int value)
+{
+ QSettings s;
+ s.setValue("pscr_ratio", value);
+ prefs.pscr_ratio = value;
+ emit pscrRatioChanged(value);
+}
+
+DisplaySettingsObjectWrapper::DisplaySettingsObjectWrapper(QObject *parent) :
+ QObject(parent),
+ group(QStringLiteral("Display"))
+{
+}
+
+QString DisplaySettingsObjectWrapper::divelistFont() const
+{
+ return prefs.divelist_font;
+}
+
+double DisplaySettingsObjectWrapper::fontSize() const
+{
+ return prefs.font_size;
+}
+
+short DisplaySettingsObjectWrapper::displayInvalidDives() const
+{
+ return prefs.display_invalid_dives;
+}
+
+void DisplaySettingsObjectWrapper::setDivelistFont(const QString& value)
+{
+ QSettings s;
+ s.setValue("divelist_font", value);
+ QString newValue = value;
+ if (value.contains(","))
+ newValue = value.left(value.indexOf(","));
+
+ if (!subsurface_ignore_font(newValue.toUtf8().constData())) {
+ free((void *)prefs.divelist_font);
+ prefs.divelist_font = strdup(newValue.toUtf8().constData());
+ qApp->setFont(QFont(newValue));
+ }
+ emit divelistFontChanged(newValue);
+}
+
+void DisplaySettingsObjectWrapper::setFontSize(double value)
+{
+ QSettings s;
+ s.setValue("font_size", value);
+ prefs.font_size = value;
+ QFont defaultFont = qApp->font();
+ defaultFont.setPointSizeF(prefs.font_size);
+ qApp->setFont(defaultFont);
+ emit fontSizeChanged(value);
+}
+
+void DisplaySettingsObjectWrapper::setDisplayInvalidDives(short value)
+{
+ QSettings s;
+ s.setValue("displayinvalid", value);
+ prefs.display_invalid_dives = value;
+ emit displayInvalidDivesChanged(value);
+}
+
+LanguageSettingsObjectWrapper::LanguageSettingsObjectWrapper(QObject *parent) :
+ QObject(parent),
+ group("Language")
+{
+}
+
+QString LanguageSettingsObjectWrapper::language() const
+{
+ return prefs.locale.language;
+}
+
+QString LanguageSettingsObjectWrapper::timeFormat() const
+{
+ return prefs.time_format;
+}
+
+QString LanguageSettingsObjectWrapper::dateFormat() const
+{
+ return prefs.date_format;
+}
+
+QString LanguageSettingsObjectWrapper::dateFormatShort() const
+{
+ return prefs.date_format_short;
+}
+
+bool LanguageSettingsObjectWrapper::timeFormatOverride() const
+{
+ return prefs.time_format_override;
+}
+
+bool LanguageSettingsObjectWrapper::dateFormatOverride() const
+{
+ return prefs.date_format_override;
+}
+
+bool LanguageSettingsObjectWrapper::useSystemLanguage() const
+{
+ return prefs.locale.use_system_language;
+}
+
+void LanguageSettingsObjectWrapper::setUseSystemLanguage(bool value)
+{
+ QSettings s;
+ s.setValue("UseSystemLanguage", value);
+ prefs.locale.use_system_language = copy_string(qPrintable(value));
+ emit useSystemLanguageChanged(value);
+}
+
+void LanguageSettingsObjectWrapper::setLanguage(const QString& value)
+{
+ QSettings s;
+ s.setValue("UiLanguage", value);
+ prefs.locale.language = copy_string(qPrintable(value));
+ emit languageChanged(value);
+}
+
+void LanguageSettingsObjectWrapper::setTimeFormat(const QString& value)
+{
+ QSettings s;
+ s.setValue("time_format", value);
+ prefs.time_format = copy_string(qPrintable(value));;
+ emit timeFormatChanged(value);
+}
+
+void LanguageSettingsObjectWrapper::setDateFormat(const QString& value)
+{
+ QSettings s;
+ s.setValue("date_format", value);
+ prefs.date_format = copy_string(qPrintable(value));;
+ emit dateFormatChanged(value);
+}
+
+void LanguageSettingsObjectWrapper::setDateFormatShort(const QString& value)
+{
+ QSettings s;
+ s.setValue("date_format_short", value);
+ prefs.date_format_short = copy_string(qPrintable(value));;
+ emit dateFormatShortChanged(value);
+}
+
+void LanguageSettingsObjectWrapper::setTimeFormatOverride(bool value)
+{
+ QSettings s;
+ s.setValue("time_format_override", value);
+ prefs.time_format_override = value;
+ emit timeFormatOverrideChanged(value);
+}
+
+void LanguageSettingsObjectWrapper::setDateFormatOverride(bool value)
+{
+ QSettings s;
+ s.setValue("date_format_override", value);
+ prefs.date_format_override = value;
+ emit dateFormatOverrideChanged(value);
+}
+
+AnimationsSettingsObjectWrapper::AnimationsSettingsObjectWrapper(QObject* parent):
+ QObject(parent),
+ group("Animations")
+
+{
+}
+
+int AnimationsSettingsObjectWrapper::animationSpeed() const
+{
+ return prefs.animation_speed;
+}
+
+void AnimationsSettingsObjectWrapper::setAnimationSpeed(int value)
+{
+ QSettings s;
+ s.setValue("animation_speed", value);
+ prefs.animation_speed = value;
+ emit animationSpeedChanged(value);
+}
+
+LocationServiceSettingsObjectWrapper::LocationServiceSettingsObjectWrapper(QObject* parent):
+ QObject(parent),
+ group("locationService")
+{
+}
+
+int LocationServiceSettingsObjectWrapper::distanceThreshold() const
+{
+ return prefs.distance_threshold;
+}
+
+int LocationServiceSettingsObjectWrapper::timeThreshold() const
+{
+ return prefs.time_threshold;
+}
+
+void LocationServiceSettingsObjectWrapper::setDistanceThreshold(int value)
+{
+ QSettings s;
+ s.setValue("distance_threshold", value);
+ prefs.distance_threshold = value;
+ emit distanceThresholdChanged(value);
+}
+
+void LocationServiceSettingsObjectWrapper::setTimeThreshold(int value)
+{
+ QSettings s;
+ s.setValue("time_threshold", value);
+ prefs.time_threshold = value;
+ emit timeThresholdChanged( value);
+}
+
+SettingsObjectWrapper::SettingsObjectWrapper(QObject* parent):
+QObject(parent),
+ techDetails(new TechnicalDetailsSettings(this)),
+ pp_gas(new PartialPressureGasSettings(this)),
+ facebook(new FacebookSettings(this)),
+ geocoding(new GeocodingPreferences(this)),
+ proxy(new ProxySettings(this)),
+ cloud_storage(new CloudStorageSettings(this)),
+ planner_settings(new DivePlannerSettings(this)),
+ unit_settings(new UnitsSettings(this)),
+ general_settings(new GeneralSettingsObjectWrapper(this)),
+ display_settings(new DisplaySettingsObjectWrapper(this)),
+ language_settings(new LanguageSettingsObjectWrapper(this)),
+ animation_settings(new AnimationsSettingsObjectWrapper(this)),
+ location_settings(new LocationServiceSettingsObjectWrapper(this))
+{
+}
+
+void SettingsObjectWrapper::setSaveUserIdLocal(short int value)
+{
+ Q_UNUSED(value);
+ //TODO: Find where this is stored on the preferences.
+}
+
+short int SettingsObjectWrapper::saveUserIdLocal() const
+{
+ return prefs.save_userid_local;
+}
+
+SettingsObjectWrapper* SettingsObjectWrapper::instance()
+{
+ static SettingsObjectWrapper settings;
+ return &settings;
+}
diff --git a/core/subsurface-qt/SettingsObjectWrapper.h b/core/subsurface-qt/SettingsObjectWrapper.h
new file mode 100644
index 000000000..f115e2d86
--- /dev/null
+++ b/core/subsurface-qt/SettingsObjectWrapper.h
@@ -0,0 +1,642 @@
+#ifndef SETTINGSOBJECTWRAPPER_H
+#define SETTINGSOBJECTWRAPPER_H
+
+#include <QObject>
+
+#include "../pref.h"
+#include "../prefs-macros.h"
+
+/* Wrapper class for the Settings. This will allow
+ * seamlessy integration of the settings with the QML
+ * and QWidget frontends. This class will be huge, since
+ * I need tons of properties, one for each option. */
+
+/* Control the state of the Partial Pressure Graphs preferences */
+class PartialPressureGasSettings : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(short show_po2 READ showPo2 WRITE setShowPo2 NOTIFY showPo2Changed)
+ Q_PROPERTY(short show_pn2 READ showPn2 WRITE setShowPn2 NOTIFY showPn2Changed)
+ Q_PROPERTY(short show_phe READ showPhe WRITE setShowPhe NOTIFY showPheChanged)
+ Q_PROPERTY(double po2_threshold READ po2Threshold WRITE setPo2Threshold NOTIFY po2ThresholdChanged)
+ Q_PROPERTY(double pn2_threshold READ pn2Threshold WRITE setPn2Threshold NOTIFY pn2ThresholdChanged)
+ Q_PROPERTY(double phe_threshold READ pheThreshold WRITE setPheThreshold NOTIFY pheThresholdChanged)
+
+public:
+ PartialPressureGasSettings(QObject *parent);
+ short showPo2() const;
+ short showPn2() const;
+ short showPhe() const;
+ double po2Threshold() const;
+ double pn2Threshold() const;
+ double pheThreshold() const;
+
+public slots:
+ void setShowPo2(short value);
+ void setShowPn2(short value);
+ void setShowPhe(short value);
+ void setPo2Threshold(double value);
+ void setPn2Threshold(double value);
+ void setPheThreshold(double value);
+
+signals:
+ void showPo2Changed(short value);
+ void showPn2Changed(short value);
+ void showPheChanged(short value);
+ void po2ThresholdChanged(double value);
+ void pn2ThresholdChanged(double value);
+ void pheThresholdChanged(double value);
+private:
+ QString group;
+};
+
+class TechnicalDetailsSettings : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(double modpO2 READ modp02 WRITE setModp02 NOTIFY modpO2Changed)
+ Q_PROPERTY(bool ead READ ead WRITE setEad NOTIFY eadChanged)
+ Q_PROPERTY(bool mod READ mod WRITE setMod NOTIFY modChanged);
+ Q_PROPERTY(bool dcceiling READ dcceiling WRITE setDCceiling NOTIFY dcceilingChanged)
+ Q_PROPERTY(bool redceiling READ redceiling WRITE setRedceiling NOTIFY redceilingChanged)
+ Q_PROPERTY(bool calcceiling READ calcceiling WRITE setCalcceiling NOTIFY calcceilingChanged)
+ Q_PROPERTY(bool calcceiling3m READ calcceiling3m WRITE setCalcceiling3m NOTIFY calcceiling3mChanged)
+ Q_PROPERTY(bool calcalltissues READ calcalltissues WRITE setCalcalltissues NOTIFY calcalltissuesChanged)
+ Q_PROPERTY(bool calcndltts READ calcndltts WRITE setCalcndltts NOTIFY calcndlttsChanged)
+ Q_PROPERTY(bool gflow READ gflow WRITE setGflow NOTIFY gflowChanged)
+ Q_PROPERTY(bool gfhigh READ gfhigh WRITE setGfhigh NOTIFY gfhighChanged)
+ Q_PROPERTY(bool hrgraph READ hrgraph WRITE setHRgraph NOTIFY hrgraphChanged)
+ Q_PROPERTY(bool tankbar READ tankBar WRITE setTankBar NOTIFY tankBarChanged)
+ Q_PROPERTY(bool percentagegraph READ percentageGraph WRITE setPercentageGraph NOTIFY percentageGraphChanged)
+ Q_PROPERTY(bool rulergraph READ rulerGraph WRITE setRulerGraph NOTIFY rulerGraphChanged)
+ Q_PROPERTY(bool show_ccr_setpoint READ showCCRSetpoint WRITE setShowCCRSetpoint NOTIFY showCCRSetpointChanged)
+ Q_PROPERTY(bool show_ccr_sensors READ showCCRSensors WRITE setShowCCRSensors NOTIFY showCCRSensorsChanged)
+ Q_PROPERTY(bool zoomed_plot READ zoomedPlot WRITE setZoomedPlot NOTIFY zoomedPlotChanged)
+ Q_PROPERTY(bool show_sac READ showSac WRITE setShowSac NOTIFY showSacChanged)
+ Q_PROPERTY(bool gf_low_at_maxdepth READ gfLowAtMaxDepth WRITE setGfLowAtMaxDepth NOTIFY gfLowAtMaxDepthChanged)
+ Q_PROPERTY(bool display_unused_tanks READ displayUnusedTanks WRITE setDisplayUnusedTanks NOTIFY displayUnusedTanksChanged)
+ Q_PROPERTY(bool show_average_depth READ showAverageDepth WRITE setShowAverageDepth NOTIFY showAverageDepthChanged)
+ Q_PROPERTY(bool show_pictures_in_profile READ showPicturesInProfile WRITE setShowPicturesInProfile NOTIFY showPicturesInProfileChanged)
+public:
+ TechnicalDetailsSettings(QObject *parent);
+
+ double modp02() const;
+ bool ead() const;
+ bool mod() const;
+ bool dcceiling() const;
+ bool redceiling() const;
+ bool calcceiling() const;
+ bool calcceiling3m() const;
+ bool calcalltissues() const;
+ bool calcndltts() const;
+ bool gflow() const;
+ bool gfhigh() const;
+ bool hrgraph() const;
+ bool tankBar() const;
+ bool percentageGraph() const;
+ bool rulerGraph() const;
+ bool showCCRSetpoint() const;
+ bool showCCRSensors() const;
+ bool zoomedPlot() const;
+ bool showSac() const;
+ bool gfLowAtMaxDepth() const;
+ bool displayUnusedTanks() const;
+ bool showAverageDepth() const;
+ bool showPicturesInProfile() const;
+
+public slots:
+ void setMod(bool value);
+ void setModp02(double value);
+ void setEad(bool value);
+ void setDCceiling(bool value);
+ void setRedceiling(bool value);
+ void setCalcceiling(bool value);
+ void setCalcceiling3m(bool value);
+ void setCalcalltissues(bool value);
+ void setCalcndltts(bool value);
+ void setGflow(bool value);
+ void setGfhigh(bool value);
+ void setHRgraph(bool value);
+ void setTankBar(bool value);
+ void setPercentageGraph(bool value);
+ void setRulerGraph(bool value);
+ void setShowCCRSetpoint(bool value);
+ void setShowCCRSensors(bool value);
+ void setZoomedPlot(bool value);
+ void setShowSac(bool value);
+ void setGfLowAtMaxDepth(bool value);
+ void setDisplayUnusedTanks(bool value);
+ void setShowAverageDepth(bool value);
+ void setShowPicturesInProfile(bool value);
+
+signals:
+ void modpO2Changed(double value);
+ void eadChanged(bool value);
+ void modChanged(bool value);
+ void dcceilingChanged(bool value);
+ void redceilingChanged(bool value);
+ void calcceilingChanged(bool value);
+ void calcceiling3mChanged(bool value);
+ void calcalltissuesChanged(bool value);
+ void calcndlttsChanged(bool value);
+ void gflowChanged(bool value);
+ void gfhighChanged(bool value);
+ void hrgraphChanged(bool value);
+ void tankBarChanged(bool value);
+ void percentageGraphChanged(bool value);
+ void rulerGraphChanged(bool value);
+ void showCCRSetpointChanged(bool value);
+ void showCCRSensorsChanged(bool value);
+ void zoomedPlotChanged(bool value);
+ void showSacChanged(bool value);
+ void gfLowAtMaxDepthChanged(bool value);
+ void displayUnusedTanksChanged(bool value);
+ void showAverageDepthChanged(bool value);
+ void showPicturesInProfileChanged(bool value);
+};
+
+/* Control the state of the Facebook preferences */
+class FacebookSettings : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QString accessToken READ accessToken WRITE setAccessToken NOTIFY accessTokenChanged)
+ Q_PROPERTY(QString userId READ userId WRITE setUserId NOTIFY userIdChanged)
+ Q_PROPERTY(QString albumId READ albumId WRITE setAlbumId NOTIFY albumIdChanged)
+
+public:
+ FacebookSettings(QObject *parent);
+ QString accessToken() const;
+ QString userId() const;
+ QString albumId() const;
+
+public slots:
+ void setAccessToken (const QString& value);
+ void setUserId(const QString& value);
+ void setAlbumId(const QString& value);
+
+signals:
+ void accessTokenChanged(const QString& value);
+ void userIdChanged(const QString& value);
+ void albumIdChanged(const QString& value);
+private:
+ QString group;
+ QString subgroup;
+};
+
+/* Control the state of the Geocoding preferences */
+class GeocodingPreferences : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(bool enable_geocoding READ enableGeocoding WRITE setEnableGeocoding NOTIFY enableGeocodingChanged)
+ Q_PROPERTY(bool parse_dive_without_gps READ parseDiveWithoutGps WRITE setParseDiveWithoutGps NOTIFY parseDiveWithoutGpsChanged)
+ Q_PROPERTY(bool tag_existing_dives READ tagExistingDives WRITE setTagExistingDives NOTIFY tagExistingDivesChanged)
+ Q_PROPERTY(taxonomy_category first_category READ firstTaxonomyCategory WRITE setFirstTaxonomyCategory NOTIFY firstTaxonomyCategoryChanged)
+ Q_PROPERTY(taxonomy_category second_category READ secondTaxonomyCategory WRITE setSecondTaxonomyCategory NOTIFY secondTaxonomyCategoryChanged)
+ Q_PROPERTY(taxonomy_category third_category READ thirdTaxonomyCategory WRITE setThirdTaxonomyCategory NOTIFY thirdTaxonomyCategoryChanged)
+public:
+ GeocodingPreferences(QObject *parent);
+ bool enableGeocoding() const;
+ bool parseDiveWithoutGps() const;
+ bool tagExistingDives() const;
+ taxonomy_category firstTaxonomyCategory() const;
+ taxonomy_category secondTaxonomyCategory() const;
+ taxonomy_category thirdTaxonomyCategory() const;
+
+public slots:
+ void setEnableGeocoding(bool value);
+ void setParseDiveWithoutGps(bool value);
+ void setTagExistingDives(bool value);
+ void setFirstTaxonomyCategory(taxonomy_category value);
+ void setSecondTaxonomyCategory(taxonomy_category value);
+ void setThirdTaxonomyCategory(taxonomy_category value);
+
+signals:
+ void enableGeocodingChanged(bool value);
+ void parseDiveWithoutGpsChanged(bool value);
+ void tagExistingDivesChanged(bool value);
+ void firstTaxonomyCategoryChanged(taxonomy_category value);
+ void secondTaxonomyCategoryChanged(taxonomy_category value);
+ void thirdTaxonomyCategoryChanged(taxonomy_category value);
+private:
+ QString group;
+};
+
+class ProxySettings : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(int type READ type WRITE setType NOTIFY typeChanged)
+ Q_PROPERTY(QString host READ host WRITE setHost NOTIFY hostChanged)
+ Q_PROPERTY(int port READ port WRITE setPort NOTIFY portChanged)
+ Q_PROPERTY(short auth READ auth WRITE setAuth NOTIFY authChanged)
+ Q_PROPERTY(QString user READ user WRITE setUser NOTIFY userChanged)
+ Q_PROPERTY(QString pass READ pass WRITE setPass NOTIFY passChanged)
+
+public:
+ ProxySettings(QObject *parent);
+ int type() const;
+ QString host() const;
+ int port() const;
+ short auth() const;
+ QString user() const;
+ QString pass() const;
+
+public slots:
+ void setType(int value);
+ void setHost(const QString& value);
+ void setPort(int value);
+ void setAuth(short value);
+ void setUser(const QString& value);
+ void setPass(const QString& value);
+
+signals:
+ void typeChanged(int value);
+ void hostChanged(const QString& value);
+ void portChanged(int value);
+ void authChanged(short value);
+ void userChanged(const QString& value);
+ void passChanged(const QString& value);
+private:
+ QString group;
+};
+
+class CloudStorageSettings : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QString password READ password WRITE setPassword NOTIFY passwordChanged)
+ Q_PROPERTY(QString newpassword READ newPassword WRITE setNewPassword NOTIFY newPasswordChanged)
+ Q_PROPERTY(QString email READ email WRITE setEmail NOTIFY emailChanged)
+ Q_PROPERTY(QString email_encoded READ emailEncoded WRITE setEmailEncoded NOTIFY emailEncodedChanged)
+ Q_PROPERTY(QString userid READ userId WRITE setUserId NOTIFY userIdChanged)
+ Q_PROPERTY(QString base_url READ baseUrl WRITE setBaseUrl NOTIFY baseUrlChanged)
+ Q_PROPERTY(QString git_url READ gitUrl WRITE setGitUrl NOTIFY gitUrlChanged)
+ Q_PROPERTY(bool git_local_only READ gitLocalOnly WRITE setGitLocalOnly NOTIFY gitLocalOnlyChanged)
+ Q_PROPERTY(bool save_password_local READ savePasswordLocal WRITE setSavePasswordLocal NOTIFY savePasswordLocalChanged)
+ Q_PROPERTY(short verification_status READ verificationStatus WRITE setVerificationStatus NOTIFY verificationStatusChanged)
+ Q_PROPERTY(bool background_sync READ backgroundSync WRITE setBackgroundSync NOTIFY backgroundSyncChanged)
+public:
+ CloudStorageSettings(QObject *parent);
+ QString password() const;
+ QString newPassword() const;
+ QString email() const;
+ QString emailEncoded() const;
+ QString userId() const;
+ QString baseUrl() const;
+ QString gitUrl() const;
+ bool savePasswordLocal() const;
+ short verificationStatus() const;
+ bool backgroundSync() const;
+ bool gitLocalOnly() const;
+
+public slots:
+ void setPassword(const QString& value);
+ void setNewPassword(const QString& value);
+ void setEmail(const QString& value);
+ void setEmailEncoded(const QString& value);
+ void setUserId(const QString& value);
+ void setBaseUrl(const QString& value);
+ void setGitUrl(const QString& value);
+ void setSavePasswordLocal(bool value);
+ void setVerificationStatus(short value);
+ void setBackgroundSync(bool value);
+ void setGitLocalOnly(bool value);
+
+signals:
+ void passwordChanged(const QString& value);
+ void newPasswordChanged(const QString& value);
+ void emailChanged(const QString& value);
+ void emailEncodedChanged(const QString& value);
+ void userIdChanged(const QString& value);
+ void baseUrlChanged(const QString& value);
+ void gitUrlChanged(const QString& value);
+ void savePasswordLocalChanged(bool value);
+ void verificationStatusChanged(short value);
+ void backgroundSyncChanged(bool value);
+ void gitLocalOnlyChanged(bool value);
+private:
+ QString group;
+};
+
+class DivePlannerSettings : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(bool last_stop READ lastStop WRITE setLastStop NOTIFY lastStopChanged)
+ Q_PROPERTY(bool verbatim_plan READ verbatimPlan WRITE setVerbatimPlan NOTIFY verbatimPlanChanged)
+ Q_PROPERTY(bool display_runtime READ displayRuntime WRITE setDisplayRuntime NOTIFY displayRuntimeChanged)
+ Q_PROPERTY(bool display_duration READ displayDuration WRITE setDisplayDuration NOTIFY displayDurationChanged)
+ Q_PROPERTY(bool display_transitions READ displayTransitions WRITE setDisplayTransitions NOTIFY displayTransitionsChanged)
+ Q_PROPERTY(bool doo2breaks READ doo2breaks WRITE setDoo2breaks NOTIFY doo2breaksChanged)
+ Q_PROPERTY(bool drop_stone_mode READ dropStoneMode WRITE setDropStoneMode NOTIFY dropStoneModeChanged)
+ Q_PROPERTY(bool safetystop READ safetyStop WRITE setSafetyStop NOTIFY safetyStopChanged)
+ Q_PROPERTY(bool switch_at_req_stop READ switchAtRequiredStop WRITE setSwitchAtRequiredStop NOTIFY switchAtRequiredStopChanged)
+ Q_PROPERTY(int ascrate75 READ ascrate75 WRITE setAscrate75 NOTIFY ascrate75Changed)
+ Q_PROPERTY(int ascrate50 READ ascrate50 WRITE setAscrate50 NOTIFY ascrate50Changed)
+ Q_PROPERTY(int ascratestops READ ascratestops WRITE setAscratestops NOTIFY ascratestopsChanged)
+ Q_PROPERTY(int ascratelast6m READ ascratelast6m WRITE setAscratelast6m NOTIFY ascratelast6mChanged)
+ Q_PROPERTY(int descrate READ descrate WRITE setDescrate NOTIFY descrateChanged)
+ Q_PROPERTY(int bottompo2 READ bottompo2 WRITE setBottompo2 NOTIFY bottompo2Changed)
+ Q_PROPERTY(int decopo2 READ decopo2 WRITE setDecopo2 NOTIFY decopo2Changed)
+ Q_PROPERTY(int reserve_gas READ reserveGas WRITE setReserveGas NOTIFY reserveGasChanged)
+ Q_PROPERTY(int min_switch_duration READ minSwitchDuration WRITE setMinSwitchDuration NOTIFY minSwitchDurationChanged)
+ Q_PROPERTY(int bottomsac READ bottomSac WRITE setBottomSac NOTIFY bottomSacChanged)
+ Q_PROPERTY(int decosac READ decoSac WRITE setSecoSac NOTIFY decoSacChanged)
+ Q_PROPERTY(short conservatism_level READ conservatismLevel WRITE setConservatismLevel NOTIFY conservatismLevelChanged)
+ Q_PROPERTY(deco_mode decoMode READ decoMode WRITE setDecoMode NOTIFY decoModeChanged)
+
+public:
+ DivePlannerSettings(QObject *parent = 0);
+ bool lastStop() const;
+ bool verbatimPlan() const;
+ bool displayRuntime() const;
+ bool displayDuration() const;
+ bool displayTransitions() const;
+ bool doo2breaks() const;
+ bool dropStoneMode() const;
+ bool safetyStop() const;
+ bool switchAtRequiredStop() const;
+ int ascrate75() const;
+ int ascrate50() const;
+ int ascratestops() const;
+ int ascratelast6m() const;
+ int descrate() const;
+ int bottompo2() const;
+ int decopo2() const;
+ int reserveGas() const;
+ int minSwitchDuration() const;
+ int bottomSac() const;
+ int decoSac() const;
+ short conservatismLevel() const;
+ deco_mode decoMode() const;
+
+public slots:
+ void setLastStop(bool value);
+ void setVerbatimPlan(bool value);
+ void setDisplayRuntime(bool value);
+ void setDisplayDuration(bool value);
+ void setDisplayTransitions(bool value);
+ void setDoo2breaks(bool value);
+ void setDropStoneMode(bool value);
+ void setSafetyStop(bool value);
+ void setSwitchAtRequiredStop(bool value);
+ void setAscrate75(int value);
+ void setAscrate50(int value);
+ void setAscratestops(int value);
+ void setAscratelast6m(int value);
+ void setDescrate(int value);
+ void setBottompo2(int value);
+ void setDecopo2(int value);
+ void setReserveGas(int value);
+ void setMinSwitchDuration(int value);
+ void setBottomSac(int value);
+ void setSecoSac(int value);
+ void setConservatismLevel(int value);
+ void setDecoMode(deco_mode value);
+
+signals:
+ void lastStopChanged(bool value);
+ void verbatimPlanChanged(bool value);
+ void displayRuntimeChanged(bool value);
+ void displayDurationChanged(bool value);
+ void displayTransitionsChanged(bool value);
+ void doo2breaksChanged(bool value);
+ void dropStoneModeChanged(bool value);
+ void safetyStopChanged(bool value);
+ void switchAtRequiredStopChanged(bool value);
+ void ascrate75Changed(int value);
+ void ascrate50Changed(int value);
+ void ascratestopsChanged(int value);
+ void ascratelast6mChanged(int value);
+ void descrateChanged(int value);
+ void bottompo2Changed(int value);
+ void decopo2Changed(int value);
+ void reserveGasChanged(int value);
+ void minSwitchDurationChanged(int value);
+ void bottomSacChanged(int value);
+ void decoSacChanged(int value);
+ void conservatismLevelChanged(int value);
+ void decoModeChanged(deco_mode value);
+
+private:
+ QString group;
+};
+
+class UnitsSettings : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(int length READ length WRITE setLength NOTIFY lengthChanged)
+ Q_PROPERTY(int pressure READ pressure WRITE setPressure NOTIFY pressureChanged)
+ Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY volumeChanged)
+ Q_PROPERTY(int temperature READ temperature WRITE setTemperature NOTIFY temperatureChanged)
+ Q_PROPERTY(int weight READ weight WRITE setWeight NOTIFY weightChanged)
+ Q_PROPERTY(QString unit_system READ unitSystem WRITE setUnitSystem NOTIFY unitSystemChanged)
+ Q_PROPERTY(bool coordinates_traditional READ coordinatesTraditional WRITE setCoordinatesTraditional NOTIFY coordinatesTraditionalChanged)
+ Q_PROPERTY(int vertical_speed_time READ verticalSpeedTime WRITE setVerticalSpeedTime NOTIFY verticalSpeedTimeChanged)
+
+public:
+ UnitsSettings(QObject *parent = 0);
+ int length() const;
+ int pressure() const;
+ int volume() const;
+ int temperature() const;
+ int weight() const;
+ int verticalSpeedTime() const;
+ QString unitSystem() const;
+ bool coordinatesTraditional() const;
+
+public slots:
+ void setLength(int value);
+ void setPressure(int value);
+ void setVolume(int value);
+ void setTemperature(int value);
+ void setWeight(int value);
+ void setVerticalSpeedTime(int value);
+ void setUnitSystem(const QString& value);
+ void setCoordinatesTraditional(bool value);
+
+signals:
+ void lengthChanged(int value);
+ void pressureChanged(int value);
+ void volumeChanged(int value);
+ void temperatureChanged(int value);
+ void weightChanged(int value);
+ void verticalSpeedTimeChanged(int value);
+ void unitSystemChanged(const QString& value);
+ void coordinatesTraditionalChanged(bool value);
+private:
+ QString group;
+};
+
+class GeneralSettingsObjectWrapper : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QString default_filename READ defaultFilename WRITE setDefaultFilename NOTIFY defaultFilenameChanged)
+ Q_PROPERTY(QString default_cylinder READ defaultCylinder WRITE setDefaultCylinder NOTIFY defaultCylinderChanged)
+ Q_PROPERTY(short default_file_behavior READ defaultFileBehavior WRITE setDefaultFileBehavior NOTIFY defaultFileBehaviorChanged)
+ Q_PROPERTY(bool use_default_file READ useDefaultFile WRITE setUseDefaultFile NOTIFY useDefaultFileChanged)
+ Q_PROPERTY(int defaultsetpoint READ defaultSetPoint WRITE setDefaultSetPoint NOTIFY defaultSetPointChanged)
+ Q_PROPERTY(int o2consumption READ o2Consumption WRITE setO2Consumption NOTIFY o2ConsumptionChanged)
+ Q_PROPERTY(int pscr_ratio READ pscrRatio WRITE setPscrRatio NOTIFY pscrRatioChanged)
+
+public:
+ GeneralSettingsObjectWrapper(QObject *parent);
+ QString defaultFilename() const;
+ QString defaultCylinder() const;
+ short defaultFileBehavior() const;
+ bool useDefaultFile() const;
+ int defaultSetPoint() const;
+ int o2Consumption() const;
+ int pscrRatio() const;
+
+public slots:
+ void setDefaultFilename (const QString& value);
+ void setDefaultCylinder (const QString& value);
+ void setDefaultFileBehavior (short value);
+ void setUseDefaultFile (bool value);
+ void setDefaultSetPoint (int value);
+ void setO2Consumption (int value);
+ void setPscrRatio (int value);
+
+signals:
+ void defaultFilenameChanged(const QString& value);
+ void defaultCylinderChanged(const QString& value);
+ void defaultFileBehaviorChanged(short value);
+ void useDefaultFileChanged(bool value);
+ void defaultSetPointChanged(int value);
+ void o2ConsumptionChanged(int value);
+ void pscrRatioChanged(int value);
+private:
+ QString group;
+};
+
+class DisplaySettingsObjectWrapper : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QString divelist_font READ divelistFont WRITE setDivelistFont NOTIFY divelistFontChanged)
+ Q_PROPERTY(double font_size READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
+ Q_PROPERTY(short display_invalid_dives READ displayInvalidDives WRITE setDisplayInvalidDives NOTIFY displayInvalidDivesChanged)
+public:
+ DisplaySettingsObjectWrapper(QObject *parent);
+ QString divelistFont() const;
+ double fontSize() const;
+ short displayInvalidDives() const;
+public slots:
+ void setDivelistFont(const QString& value);
+ void setFontSize(double value);
+ void setDisplayInvalidDives(short value);
+signals:
+ void divelistFontChanged(const QString& value);
+ void fontSizeChanged(double value);
+ void displayInvalidDivesChanged(short value);
+private:
+ QString group;
+};
+
+class LanguageSettingsObjectWrapper : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QString language READ language WRITE setLanguage NOTIFY languageChanged)
+ Q_PROPERTY(QString time_format READ timeFormat WRITE setTimeFormat NOTIFY timeFormatChanged)
+ Q_PROPERTY(QString date_format READ dateFormat WRITE setDateFormat NOTIFY dateFormatChanged)
+ Q_PROPERTY(QString date_format_short READ dateFormatShort WRITE setDateFormatShort NOTIFY dateFormatShortChanged)
+ Q_PROPERTY(bool time_format_override READ timeFormatOverride WRITE setTimeFormatOverride NOTIFY timeFormatOverrideChanged)
+ Q_PROPERTY(bool date_format_override READ dateFormatOverride WRITE setDateFormatOverride NOTIFY dateFormatOverrideChanged)
+ Q_PROPERTY(bool use_system_language READ useSystemLanguage WRITE setUseSystemLanguage NOTIFY useSystemLanguageChanged)
+
+public:
+ LanguageSettingsObjectWrapper(QObject *parent);
+ QString language() const;
+ QString timeFormat() const;
+ QString dateFormat() const;
+ QString dateFormatShort() const;
+ bool timeFormatOverride() const;
+ bool dateFormatOverride() const;
+ bool useSystemLanguage() const;
+
+public slots:
+ void setLanguage (const QString& value);
+ void setTimeFormat (const QString& value);
+ void setDateFormat (const QString& value);
+ void setDateFormatShort (const QString& value);
+ void setTimeFormatOverride (bool value);
+ void setDateFormatOverride (bool value);
+ void setUseSystemLanguage (bool value);
+signals:
+ void languageChanged(const QString& value);
+ void timeFormatChanged(const QString& value);
+ void dateFormatChanged(const QString& value);
+ void dateFormatShortChanged(const QString& value);
+ void timeFormatOverrideChanged(bool value);
+ void dateFormatOverrideChanged(bool value);
+ void useSystemLanguageChanged(bool value);
+
+private:
+ QString group;
+};
+
+class AnimationsSettingsObjectWrapper : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(int animation_speed READ animationSpeed WRITE setAnimationSpeed NOTIFY animationSpeedChanged)
+public:
+ AnimationsSettingsObjectWrapper(QObject *parent);
+ int animationSpeed() const;
+
+public slots:
+ void setAnimationSpeed(int value);
+
+signals:
+ void animationSpeedChanged(int value);
+
+private:
+ QString group;
+};
+
+class LocationServiceSettingsObjectWrapper : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(int time_threshold READ timeThreshold WRITE setTimeThreshold NOTIFY timeThresholdChanged)
+ Q_PROPERTY(int distance_threshold READ distanceThreshold WRITE setDistanceThreshold NOTIFY distanceThresholdChanged)
+public:
+ LocationServiceSettingsObjectWrapper(QObject *parent);
+ int timeThreshold() const;
+ int distanceThreshold() const;
+public slots:
+ void setTimeThreshold(int value);
+ void setDistanceThreshold(int value);
+signals:
+ void timeThresholdChanged(int value);
+ void distanceThresholdChanged(int value);
+private:
+ QString group;
+};
+
+class SettingsObjectWrapper : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(short save_userid_local READ saveUserIdLocal WRITE setSaveUserIdLocal NOTIFY saveUserIdLocalChanged)
+
+ Q_PROPERTY(TechnicalDetailsSettings* techical_details MEMBER techDetails CONSTANT)
+ Q_PROPERTY(PartialPressureGasSettings* pp_gas MEMBER pp_gas CONSTANT)
+ Q_PROPERTY(FacebookSettings* facebook MEMBER facebook CONSTANT)
+ Q_PROPERTY(GeocodingPreferences* geocoding MEMBER geocoding CONSTANT)
+ Q_PROPERTY(ProxySettings* proxy MEMBER proxy CONSTANT)
+ Q_PROPERTY(CloudStorageSettings* cloud_storage MEMBER cloud_storage CONSTANT)
+ Q_PROPERTY(DivePlannerSettings* planner MEMBER planner_settings CONSTANT)
+ Q_PROPERTY(UnitsSettings* units MEMBER unit_settings CONSTANT)
+
+ Q_PROPERTY(GeneralSettingsObjectWrapper* general MEMBER general_settings CONSTANT)
+ Q_PROPERTY(DisplaySettingsObjectWrapper* display MEMBER display_settings CONSTANT)
+ Q_PROPERTY(LanguageSettingsObjectWrapper* language MEMBER language_settings CONSTANT)
+ Q_PROPERTY(AnimationsSettingsObjectWrapper* animation MEMBER animation_settings CONSTANT)
+ Q_PROPERTY(LocationServiceSettingsObjectWrapper* Location MEMBER location_settings CONSTANT)
+public:
+ static SettingsObjectWrapper *instance();
+ short saveUserIdLocal() const;
+
+ TechnicalDetailsSettings *techDetails;
+ PartialPressureGasSettings *pp_gas;
+ FacebookSettings *facebook;
+ GeocodingPreferences *geocoding;
+ ProxySettings *proxy;
+ CloudStorageSettings *cloud_storage;
+ DivePlannerSettings *planner_settings;
+ UnitsSettings *unit_settings;
+ GeneralSettingsObjectWrapper *general_settings;
+ DisplaySettingsObjectWrapper *display_settings;
+ LanguageSettingsObjectWrapper *language_settings;
+ AnimationsSettingsObjectWrapper *animation_settings;
+ LocationServiceSettingsObjectWrapper *location_settings;
+
+public slots:
+ void setSaveUserIdLocal(short value);
+private:
+ SettingsObjectWrapper(QObject *parent = NULL);
+signals:
+ void saveUserIdLocalChanged(short value);
+};
+
+#endif