diff options
-rw-r--r-- | subsurface-core/CMakeLists.txt | 1 | ||||
-rw-r--r-- | subsurface-core/gpslocation.cpp | 9 | ||||
-rw-r--r-- | subsurface-core/subsurface-qt/DiveObjectHelper.cpp | 201 | ||||
-rw-r--r-- | subsurface-core/subsurface-qt/DiveObjectHelper.h | 24 | ||||
-rw-r--r-- | subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp | 400 | ||||
-rw-r--r-- | subsurface-core/subsurface-qt/SettingsObjectWrapper.h | 266 |
6 files changed, 755 insertions, 146 deletions
diff --git a/subsurface-core/CMakeLists.txt b/subsurface-core/CMakeLists.txt index decc94d5f..0e060b015 100644 --- a/subsurface-core/CMakeLists.txt +++ b/subsurface-core/CMakeLists.txt @@ -84,6 +84,7 @@ set(SUBSURFACE_CORE_LIB_SRCS #Subsurface Qt have the Subsurface structs QObjectified for easy access via QML. subsurface-qt/DiveObjectHelper.cpp + #subsurface-qt/SettingsObjectWrapper.cpp ${SERIAL_FTDI} ${PLATFORM_SRC} ${BT_CORE_SRC_FILES} diff --git a/subsurface-core/gpslocation.cpp b/subsurface-core/gpslocation.cpp index 08c47165d..e44f793ae 100644 --- a/subsurface-core/gpslocation.cpp +++ b/subsurface-core/gpslocation.cpp @@ -331,9 +331,7 @@ QMap<qint64, gpsTracker> GpsLocation::currentGPSInfo() const void GpsLocation::loadFromStorage() { - qDebug() << "loadFromStorage with # trackers" << m_trackers.count(); int nr = geoSettings->value(QString("count")).toInt(); - qDebug() << "loading from settings:" << nr; for (int i = 0; i < nr; i++) { struct gpsTracker gt; gt.when = geoSettings->value(QString("gpsFix%1_time").arg(i)).toLongLong(); @@ -342,14 +340,12 @@ void GpsLocation::loadFromStorage() gt.name = geoSettings->value(QString("gpsFix%1_name").arg(i)).toString(); gt.idx = i; m_trackers.insert(gt.when, gt); - qDebug() << "inserted" << i << "timestamps are" << m_trackers.keys(); } } void GpsLocation::replaceFixToStorage(gpsTracker >) { if (!m_trackers.keys().contains(gt.when)) { - qDebug() << "shouldn't have called replace, call add instead"; addFixToStorage(gt); return; } @@ -366,7 +362,6 @@ void GpsLocation::replaceFixToStorage(gpsTracker >) void GpsLocation::addFixToStorage(gpsTracker >) { int nr = m_trackers.count(); - qDebug() << "addFixToStorage before there are" << nr << "fixes at" << m_trackers.keys(); geoSettings->setValue("count", nr + 1); geoSettings->setValue(QString("gpsFix%1_time").arg(nr), gt.when); geoSettings->setValue(QString("gpsFix%1_lat").arg(nr), gt.latitude.udeg); @@ -459,7 +454,6 @@ void GpsLocation::deleteFixesFromServer() QDateTime dt; QUrlQuery data; dt.setTime_t(gt.when - gettimezoneoffset(gt.when)); - qDebug() << dt.toString() << get_dive_date_string(gt.when); data.addQueryItem("login", prefs.userid); data.addQueryItem("dive_date", dt.toString("yyyy-MM-dd")); data.addQueryItem("dive_time", dt.toString("hh:mm")); @@ -503,14 +497,12 @@ void GpsLocation::uploadToServer() QUrl url(GPS_FIX_ADD_URL); QList<qint64> keys = m_trackers.keys(); qint64 key; - qDebug() << "uploading:" << keys; Q_FOREACH(key, keys) { struct gpsTracker gt = m_trackers.value(key); int idx = gt.idx; QDateTime dt; QUrlQuery data; dt.setTime_t(gt.when - gettimezoneoffset(gt.when)); - qDebug() << dt.toString() << get_dive_date_string(gt.when); data.addQueryItem("login", prefs.userid); data.addQueryItem("dive_date", dt.toString("yyyy-MM-dd")); data.addQueryItem("dive_time", dt.toString("hh:mm")); @@ -601,7 +593,6 @@ void GpsLocation::downloadFromServer() gt.latitude.udeg = latitude.toDouble() * 1000000; gt.longitude.udeg = longitude.toDouble() * 1000000; gt.name = name; - qDebug() << "download new fix at" << gt.when; // add this GPS fix to the QMap and the settings (remove existing fix at the same timestamp first) if (m_trackers.keys().contains(gt.when)) { qDebug() << "already have a fix at time stamp" << gt.when; diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp index 7db882da2..51831efd8 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp @@ -33,93 +33,9 @@ static QString getFormattedCylinder(struct dive *dive, unsigned int idx) return fmt; } -DiveObjectHelper::DiveObjectHelper(struct dive *d) : m_number(d->number), - m_id(d->id), - m_rating(d->rating), - m_timestamp(d->when), - m_location(get_dive_location(d) ? QString::fromUtf8(get_dive_location(d)) : EMPTY_DIVE_STRING), - m_duration(get_dive_duration_string(d->duration.seconds, QObject::tr("h:"), QObject::tr("min"))), - m_depth(get_depth_string(d->dc.maxdepth.mm, true, true)), - m_divemaster(d->divemaster ? d->divemaster : EMPTY_DIVE_STRING), - m_buddy(d->buddy ? d->buddy : EMPTY_DIVE_STRING), - m_airTemp(get_temperature_string(d->airtemp, true)), - m_waterTemp(get_temperature_string(d->watertemp, true)), - m_suit(d->suit ? d->suit : EMPTY_DIVE_STRING), - m_trip(d->divetrip ? d->divetrip->location : EMPTY_DIVE_STRING), - m_maxcns(d->maxcns), - m_otu(d->otu), +DiveObjectHelper::DiveObjectHelper(struct dive *d) : m_dive(d) { - struct dive_site *ds = get_dive_site_by_uuid(d->dive_site_uuid); - if (ds) - m_gps = QString("%1,%2").arg(ds->latitude.udeg / 1000000.0).arg(ds->longitude.udeg / 1000000.0); - - if (m_airTemp.isEmpty()) { - m_airTemp = EMPTY_DIVE_STRING; - } - if (m_waterTemp.isEmpty()) { - m_waterTemp = EMPTY_DIVE_STRING; - } - - m_notes = QString::fromUtf8(d->notes); - if (m_notes.isEmpty()) - m_notes = EMPTY_DIVE_STRING; - if (same_string(d->dc.model, "planned dive")) { - QTextDocument notes; - QString notesFormatted = m_notes; -#define _NOTES_BR "\n" - notesFormatted = notesFormatted.replace("<thead>", "<thead>" _NOTES_BR); - notesFormatted = notesFormatted.replace("<br>", "<br>" _NOTES_BR); - notesFormatted = notesFormatted.replace("<tr>", "<tr>" _NOTES_BR); - notesFormatted = notesFormatted.replace("</tr>", "</tr>" _NOTES_BR); - notes.setHtml(notesFormatted); - m_notes = notes.toPlainText(); - m_notes.replace(_NOTES_BR, "<br>"); -#undef _NOTES_BR - } else { - m_notes.replace("\n", "<br>"); - } - - - char buffer[256]; - taglist_get_tagstring(d->tag_list, buffer, 256); - m_tags = QString(buffer); - - - int added = 0; - QString gas, gases; - for (int i = 0; i < MAX_CYLINDERS; i++) { - if (!is_cylinder_used(d, i)) - continue; - gas = d->cylinder[i].type.description; - gas += QString(!gas.isEmpty() ? " " : "") + gasname(&d->cylinder[i].gasmix); - // if has a description and if such gas is not already present - if (!gas.isEmpty() && gases.indexOf(gas) == -1) { - if (added > 0) - gases += QString(" / "); - gases += gas; - added++; - } - } - m_gas = gases; - - if (d->sac) { - const char *unit; - int decimal; - double value = get_volume_units(d->sac, &decimal, &unit); - m_sac = QString::number(value, 'f', decimal).append(unit); - } - - for (int i = 0; i < MAX_CYLINDERS; i++) - m_cylinders << getFormattedCylinder(d, i); - - for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) - m_weights << getFormattedWeight(d, i); - - QDateTime localTime = QDateTime::fromTime_t(d->when - gettimezoneoffset(d->when)); - localTime.setTimeSpec(Qt::UTC); - m_date = localTime.date().toString(prefs.date_format); - m_time = localTime.time().toString(prefs.time_format); } DiveObjectHelper::~DiveObjectHelper() @@ -128,133 +44,192 @@ DiveObjectHelper::~DiveObjectHelper() int DiveObjectHelper::number() const { - return m_number; + return m_dive->number; } int DiveObjectHelper::id() const { - return m_id; + return m_dive->id; } QString DiveObjectHelper::date() const { - return m_date; + 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_timestamp; + return m_dive->when; } QString DiveObjectHelper::time() const { - return m_time; + 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 m_location; + return get_dive_location(m_dive) ? QString::fromUtf8(get_dive_location(m_dive)) : EMPTY_DIVE_STRING; } QString DiveObjectHelper::gps() const { - return m_gps; + 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 m_duration; + return get_dive_duration_string(m_dive->duration.seconds, QObject::tr("h:"), QObject::tr("min")); } QString DiveObjectHelper::depth() const { - return m_depth; + return get_depth_string(m_dive->dc.maxdepth.mm, true, true); } QString DiveObjectHelper::divemaster() const { - return m_divemaster; + return m_dive->divemaster ? m_dive->divemaster : EMPTY_DIVE_STRING; } QString DiveObjectHelper::buddy() const { - return m_buddy; + return m_dive->buddy ? m_dive->buddy : EMPTY_DIVE_STRING; } QString DiveObjectHelper::airTemp() const { - return m_airTemp; + QString temp = get_temperature_string(m_dive->airtemp, true); + if (temp.isEmpty()) { + temp = EMPTY_DIVE_STRING; + } + return temp; } QString DiveObjectHelper::waterTemp() const { - return m_waterTemp; + QString temp = get_temperature_string(m_dive->watertemp, true); + if (temp.isEmpty()) { + temp = EMPTY_DIVE_STRING; + } + return temp; } QString DiveObjectHelper::notes() const { - return m_notes; + 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 "\n" + 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 { - return m_tags; + static char buffer[256]; + taglist_get_tagstring(m_dive->tag_list, buffer, 256); + return QString(buffer); } QString DiveObjectHelper::gas() const { - return m_gas; + /*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 { - return m_sac; + if (!m_dive->sac) + return QString(); + const char *unit; + int decimal; + double value = get_volume_units(m_dive->sac, &decimal, &unit); + QString::number(value, 'f', decimal).append(unit); } QStringList DiveObjectHelper::weights() const { - return m_weights; + QStringList weights; + for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) + weights << getFormattedWeight(m_dive, i); + return weights; } QString DiveObjectHelper::weight(int idx) const { - if (idx < 0 || idx > m_weights.size() - 1) + if ( (idx < 0) || idx > MAX_WEIGHTSYSTEMS ) return QString(EMPTY_DIVE_STRING); - return m_weights.at(idx); + return getFormattedWeight(m_dive, idx); } QString DiveObjectHelper::suit() const { - return m_suit; + return m_dive->suit ? m_dive->suit : EMPTY_DIVE_STRING; } QStringList DiveObjectHelper::cylinders() const { - return m_cylinders; + 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 > m_cylinders.size() - 1) + if ( (idx < 0) || idx > MAX_CYLINDERS) return QString(EMPTY_DIVE_STRING); - return m_cylinders.at(idx); + return getFormattedCylinder(m_dive, idx); } QString DiveObjectHelper::trip() const { - return m_trip; + return m_dive->divetrip ? m_dive->divetrip->location : EMPTY_DIVE_STRING; } QString DiveObjectHelper::maxcns() const { - return m_maxcns; + return QString(m_dive->maxcns); } QString DiveObjectHelper::otu() const { - return m_otu; + return QString(m_dive->otu); } int DiveObjectHelper::rating() const { - return m_rating; + return m_dive->rating; } diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.h b/subsurface-core/subsurface-qt/DiveObjectHelper.h index 5f6cdf60b..4d1e1acb2 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.h +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.h @@ -62,30 +62,6 @@ public: QString otu() const; private: - int m_number; - int m_id; - int m_rating; - QString m_date; - timestamp_t m_timestamp; - QString m_time; - QString m_location; - QString m_gps; - QString m_duration; - QString m_depth; - QString m_divemaster; - QString m_buddy; - QString m_airTemp; - QString m_waterTemp; - QString m_notes; - QString m_tags; - QString m_gas; - QString m_sac; - QStringList m_weights; - QString m_suit; - QStringList m_cylinders; - QString m_trip; - QString m_maxcns; - QString m_otu; struct dive *m_dive; }; Q_DECLARE_METATYPE(DiveObjectHelper *) diff --git a/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp b/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp new file mode 100644 index 000000000..ccb38b6c3 --- /dev/null +++ b/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp @@ -0,0 +1,400 @@ +#include "SettingsObjectWrapper.h" +#include <QSettings> + +static QString tecDetails = QStringLiteral("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; +} + +double PartialPressureGasSettings:: modp02() const +{ + return prefs.modpO2; +} + +short PartialPressureGasSettings::ead() const +{ + return prefs.ead; +} + +short PartialPressureGasSettings::dcceiling() const +{ + return prefs.dcceiling; +} + +short PartialPressureGasSettings::redceiling() const +{ + return prefs.redceiling; +} + +short PartialPressureGasSettings::calcceiling() const +{ + return prefs.calcceiling; +} + +short PartialPressureGasSettings::calcceiling3m() const +{ + return prefs.calcceiling3m; +} + +short PartialPressureGasSettings::calcalltissues() const +{ + return prefs.calcalltissues; +} + +short PartialPressureGasSettings::calcndltts() const +{ + return prefs.calcndltts; +} + +short PartialPressureGasSettings::gflow() const +{ + return prefs.gflow; +} + +short PartialPressureGasSettings::gfhigh() const +{ + return prefs.gfhigh; +} + +short PartialPressureGasSettings::hrgraph() const +{ + return prefs.hrgraph; +} + +short PartialPressureGasSettings::tankBar() const +{ + return prefs.tankbar; +} + +short PartialPressureGasSettings::percentageGraph() const +{ + return prefs.percentagegraph; +} + +short PartialPressureGasSettings::rulerGraph() const +{ + return prefs.rulergraph; +} + +bool PartialPressureGasSettings::showCCRSetpoint() const +{ + return prefs.show_ccr_setpoint; +} + +bool PartialPressureGasSettings::showCCRSensors() const +{ + return prefs.show_ccr_sensors; +} + +short PartialPressureGasSettings::zoomedPlot() const +{ + return prefs.zoomed_plot; +} + +short PartialPressureGasSettings::showSac() const +{ + return prefs.show_sac; +} + +bool PartialPressureGasSettings::gfLowAtMaxDepth() const +{ + return prefs.gf_low_at_maxdepth; +} + +short PartialPressureGasSettings::displayUnusedTanks() const +{ + return prefs.display_unused_tanks; +} + +short PartialPressureGasSettings::showAverageDepth() const +{ + return prefs.show_average_depth; +} + +short int PartialPressureGasSettings::mod() const +{ + return prefs.mod; +} + +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); +} + +void TechnicalDetailsSettings::setModpO2(double value) +{ + QSettings s; + s.beginGroup(tecDetails); + s.setValue("modpO2", value); + prefs.modpO2 = value; + emit modpO2Changed(value); +} + +void TechnicalDetailsSettings::setEad(short value) +{ + QSettings s; + s.beginGroup(tecDetails); + s.setValue("ead", value); + prefs.ead = value; + emit eadChanged(value); +} + +void TechnicalDetailsSettings::setMod(short value) +{ + QSettings s; + s.beginGroup(tecDetails); + s.setValue("mod", value); + prefs.mod = value; + emit modChanged(value); +} + +void TechnicalDetailsSettings::setDcceiling(short value) +{ + QSettings s; + s.beginGroup(tecDetails); + s.setValue("dcceiling", value); + prefs.dcceiling = value; + emit dcceilingChanged(value); +} + +void TechnicalDetailsSettings::setRedceiling(short value) +{ + QSettings s; + s.beginGroup(tecDetails); + s.setValue("redceiling", value); + prefs.redceiling = value; + emit redceilingChanged(value); +} + +void TechnicalDetailsSettings::setCalcceiling(short value) +{ + QSettings s; + s.beginGroup(tecDetails); + s.setValue("calcceiling", value); + prefs.calcceiling = value; + emit calcceilingChanged(value); +} + +void TechnicalDetailsSettings::setCalcceiling3m(short value) +{ + QSettings s; + s.beginGroup(tecDetails); + s.setValue("calcceiling3m", value); + prefs.calcceiling3m = value; + emit calcceiling3mChanged(value); +} + +void TechnicalDetailsSettings::setCalcalltissues(short value) +{ + QSettings s; + s.beginGroup(tecDetails); + s.setValue("calcalltissues", value); + prefs.calcalltissues = value; + emit calcalltissuesChanged(value); +} + +void TechnicalDetailsSettings::setCalcndltts(short value) +{ + QSettings s; + s.beginGroup(tecDetails); + s.setValue("calcndltts", value); + prefs.calcndltts = value; + emit calcndlttsChanged(value); +} + +void TechnicalDetailsSettings::setGflow(short 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(short 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(short value) +{ + QSettings s; + s.beginGroup(tecDetails); + s.setValue("hrgraph", value); + prefs.hrgraph = value; + emit hrgraphChanged(value); +} + +void TechnicalDetailsSettings::setTankBar(short value) +{ + QSettings s; + s.beginGroup(tecDetails); + s.setValue("tankbar", value); + prefs.tankbar = value; + emit tankBarChanged(value); +} + +void TechnicalDetailsSettings::setPercentageGraph(short value) +{ + QSettings s; + s.beginGroup(tecDetails); + s.setValue("percentagegraph", value); + prefs.percentagegraph = value; + emit percentageGraphChanged(value); +} + +void TechnicalDetailsSettings::setRulerGraph(short value) +{ + /* TODO: search for the QSettings of the RulerBar */ + QSettings s; + s.beginGroup(tecDetails); + s.setValue("phethreshold", value); + prefs.pp_graphs.phe_threshold = value; + emit pheThresholdChanged(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(short value) +{ + QSettings s; + s.beginGroup(tecDetails); + s.setValue("zoomed_plot", value); + prefs.zoomed_plot = value; + emit zoomedPlotChanged(value); +} + +void TechnicalDetailsSettings::setShowSac(short 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(short value) +{ + QSettings s; + s.beginGroup(tecDetails); + s.setValue("display_unused_tanks", value); + prefs.display_unused_tanks = value; + emit displayUnusedTanksChanged(value); +} + +void TechnicalDetailsSettings::setShowAverageDepth(short value) +{ + QSettings s; + s.beginGroup(tecDetails); + s.setValue("show_average_depth", value); + prefs.show_average_depth = value; + emit showAverageDepthChanged(value); +} diff --git a/subsurface-core/subsurface-qt/SettingsObjectWrapper.h b/subsurface-core/subsurface-qt/SettingsObjectWrapper.h new file mode 100644 index 000000000..a42b00cce --- /dev/null +++ b/subsurface-core/subsurface-qt/SettingsObjectWrapper.h @@ -0,0 +1,266 @@ +#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); +}; + +class TechnicalDetailsSettings : public QObject { + Q_PROPERTY(double modpO2 READ modp02 WRITE setModp02 NOTIFY modpO2Changed) + Q_PROPERTY(short ead READ ead WRITE setEad NOTIFY eadChanged) + Q_PROPERTY(short mod READ mod WRITE setMod NOTIFY modChanged); + Q_PROPERTY(short dcceiling READ dcceiling WRITE setDCceiling NOTIFY dcceilingChanged) + Q_PROPERTY(short redceiling READ redceiling WRITE setRedceiling NOTIFY redceilingChanged) + Q_PROPERTY(short calcceiling READ calcceiling WRITE setCalcceiling NOTIFY calcceilingChanged) + Q_PROPERTY(short calcceiling3m READ calcceiling3m WRITE setCalcceiling3m NOTIFY calcceiling3mChanged) + Q_PROPERTY(short calcalltissues READ calcalltissues WRITE setCalcalltissues NOTIFY calcalltissuesChanged) + Q_PROPERTY(short calcndltts READ calcndltts WRITE setCalcndltts NOTIFY calcndlttsChanged) + Q_PROPERTY(short gflow READ gflow WRITE setGflow NOTIFY gflowChanged) + Q_PROPERTY(short gfhigh READ gfhigh WRITE setGfhigh NOTIFY gfhighChanged) + Q_PROPERTY(short hrgraph READ hrgraph WRITE setHRgraph NOTIFY hrgraphChanged) + Q_PROPERTY(short tankbar READ tankBar WRITE setTankBar NOTIFY tankBarChanged) + Q_PROPERTY(short percentagegraph READ percentageGraph WRITE setPercentageGraph NOTIFY percentageGraphChanged) + Q_PROPERTY(short 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(short zoomed_plot READ zoomedPlot WRITE setZoomedPlot NOTIFY zoomedPlotChanged) + Q_PROPERTY(short show_sac READ showSac WRITE setShowSac NOTIFY showSacChanged) + Q_PROPERTY(bool gf_low_at_maxdepth READ gfLowAtMaxDepth WRITE setGfLowAtMaxDepth NOTIFY gfLowAtMaxDepthChanged) + Q_PROPERTY(short display_unused_tanks READ displayUnusedTanks WRITE setDisplayUnusedTanks NOTIFY displayUnusedTanksChanged) + Q_PROPERTY(short show_average_depth READ showAverageDepth WRITE setShowAverageDepth NOTIFY showAverageDepthChanged) + +public: + TechnicalDetailsSettings(QObject *parent); + + double modp02() const; + short ead() const; + short mod() const; + short dcceiling() const; + short redceiling() const; + short calcceiling() const; + short calcceiling3m() const; + short calcalltissues() const; + short calcndltts() const; + short gflow() const; + short gfhigh() const; + short hrgraph() const; + short tankBar() const; + short percentageGraph() const; + short rulerGraph() const; + bool showCCRSetpoint() const; + bool showCCRSensors() const; + short zoomedPlot() const; + short showSac() const; + bool gfLowAtMaxDepth() const; + short displayUnusedTanks() const; + short showAverageDepth() const; + +public slots: + void setMod(short value); + void setModp02(double value); + void setEad(short value); + void setDCceiling(short value); + void setRedceiling(short value); + void setCalcceiling(short value); + void setCalcceiling3m(short value); + void setCalcalltissues(short value); + void setCalcndltts(short value); + void setGflow(short value); + void setGfhigh(short value); + void setHRgraph(short value); + void setTankBar(short value); + void setPercentageGraph(short value); + void setRulerGraph(short value); + void setShowCCRSetpoint(bool value); + void setShowCCRSensors(bool value); + void setZoomedPlot(short value); + void setShowSac(short value); + void setGfLowAtMaxDepth(bool value); + void setDisplayUnusedTanks(short value); + void setShowAverageDepth(short value); + +signals: + void modpO2Changed(double value); + void eadChanged(short value); + void modChanged(short value); + void dcceilingChanged(short value); + void redceilingChanged(short value); + void calcceilingChanged(short value); + void calcceiling3mChanged(short value); + void calcalltissuesChanged(short value); + void calcndlttsChanged(short value); + void gflowChanged(short value); + void gfhighChanged(short value); + void hrgraphChanged(short value); + void tankBarChanged(short value); + void percentageGraphChanged(short value); + void rulerGraphChanged(short value); + void showCCRSetpointChanged(bool value); + void showCCRSensorsChanged(bool value); + void zoomedPlotChanged(short value); + void showSacChanged(short value); + void gfLowAtMaxDepthChanged(bool value); + void displayUnusedTanksChanged(short value); + void showAverageDepthChanged(short value); +}; + +/* Control the state of the Facebook preferences */ +class FacebookSettings : public QObject { + Q_OBJECT + Q_PROPERTY(access_token READ WRITE setAccessToken NOTIFY accessTokenChanged); + Q_PROPERTY(user_id READ WRITE setUserId NOTIFY userIdChanged) + Q_PROPERTY(album_id READ WRITE setAlbumId NOTIFY albumIdChanged) +public: + FacebookSettings(QObject *parent); +}; + +/* 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 READ firstTaxonomyCategory WRITE setFirstTaxonomyCategory NOTIFY firstTaxonomyCategoryChanged) + Q_PROPERTY(taxonomy_category second READ secondTaxonomyCategory WRITE setSecondTaxonomyCategory NOTIFY secondTaxonomyCategoryChanged) + Q_PROPERTY(taxonomy_category third READ thirdTaxonomyCategory WRITE setThirdTaxonomyCategory NOTIFY thirdTaxonomyCategoryChanged) +public: + GeocodingPreferences(QObject *parent); +}; + +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); +}; + +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(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); +}; + +/* Monster class, should be breaken into a few more understandable classes later, wich will be easy to do: +* grab the Q_PROPERTYES and create a wrapper class like the ones above. +*/ +class SettingsObjectWrapper : public QObject { + Q_OBJECT + Q_PROPERTY(QString divelist_font READ divelistFont WRITE setDivelistFont NOTIFY divelistFontChanged) + Q_PROPERTY(QString default_filename READ defaultFilename WRITE setDefaultFilename NOTIFY defaultFilenameChanged) + Q_PROPERTY(QString default_cylinder READ defaultCylinder WRITE setDefaultCylinder NOTIFY defaultCylinderChanged) + Q_PROPERTY(QString cloud_base_url READ cloudBaseUrl WRITE setCloudBaseURL NOTIFY cloudBaseUrlChanged) + Q_PROPERTY(QString cloud_git_url READ cloudGitUrl WRITE setCloudGitUrl NOTIFY cloudGitUrlChanged) + 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(double font_size READ fontSize WRITE setFontSize NOTIFY fontSizeChanged) + Q_PROPERTY(int animation_speed READ animationSpeed WRITE setAnimationSpeed NOTIFY animationSpeedChanged) + Q_PROPERTY(short display_invalid_dives READ displayInvalidDives WRITE setDisplayInvalidDives NOTIFY displayInvalidDivesChanged) + Q_PROPERTY(short unit_system READ unitSystem WRITE setUnitSystem NOTIFY uintSystemChanged) + Q_PROPERTY(bool coordinates_traditional READ coordinatesTraditional WRITE setCoordinatesTraditional NOTIFY coordinatesTraditionalChanged) + Q_PROPERTY(short save_userid_local READ saveUserIdLocal WRITE setSaveUserIdLocal NOTIFY saveUserIdLocalChanged) + Q_PROPERTY(QString userid READ userId WRITE setUserId NOTIFY userIdChanged) + 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(bool doo2breaks READ doo2breaks WRITE setDoo2breaks NOTIFY doo2breaksChanged) + Q_PROPERTY(bool drop_stone_mode READ dropStoneMode WRITE setDropStoneMode NOTIFY dropStoneModeChanged) + 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 safetystop READ safetyStop WRITE setSafetyStop NOTIFY safetyStopChanged) + Q_PROPERTY(bool switch_at_req_stop READ switchAtRequiredStop WRITE setSwitchAtRequiredStop NOTIFY switchAtRequiredStopChanged) + 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(int o2consumption READ o2Consumption WRITE setO2Consumption NOTIFY o2ConsumptionChanged) + Q_PROPERTY(int pscr_ratio READ pscrRatio WRITE setPscrRatio NOTIFY pscrRatioChanged) + Q_PROPERTY(int defaultsetpoint READ defaultSetPoint WRITE setDefaultSetPoint NOTIFY defaultSetPointChanged) + Q_PROPERTY(bool show_pictures_in_profile READ showPicturesInProfile WRITE setShowPicturesInProfile NOTIFY showPicturesInProfileChanged) + Q_PROPERTY(bool use_default_file READ useDefaultFile WRITE setUseDefaultFile NOTIFY useDefaultFileChanged) + Q_PROPERTY(short default_file_behavior READ defaultFileBehavior WRITE setDefaultFileBehavior NOTIFY defaultFileBehaviorChanged) + Q_PROPERTY(short conservatism_level READ conservatism_level WRITE setConservatismLevel NOTIFY conservatismLevelChanged) + Q_PROPERTY(int time_threshold READ timeThreshold WRITE setTimeThreshold NOTIFY timeThresholdChanged) + Q_PROPERTY(int distance_threshold READ distanceThreshold WRITE setDistanceThreshold NOTIFY distanceThresholdChanged) + Q_PROPERTY(bool git_local_only READ gitLocalOnly WRITE setGitLocalOnly NOTIFY gitLocalOnlyChanged) + + TechnicalDetailsSettings *techDetails; + PartialPressureGasSettings *pp_gas; + FacebookSettings *facebook; + GeocodingPreferences *geocoding; + ProxySettings *proxy; + // Units + struct units units; + + // Decompression Mode + enum deco_mode deco_mode; +}; + +public: + SettingsObjectWrapper(QObject *parent = NULL); +}; + +#endif
\ No newline at end of file |