still need a bit more to finish. one thing I realized two minutes ago that this will greatly improve testability, I'm already starting to write the unittests for it.
From 16ec2d0a0e4649343e454ccd66cea1f94e846b3b Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Wed, 13 Jan 2016 17:09:46 -0200 Subject: [PATCH 1/5] Implemented the QObjectification of Facebook Settings
Signed-off-by: Tomaz Canabrava <[email protected]> --- .../subsurface-qt/SettingsObjectWrapper.cpp | 59 ++++++++++++++++++++++ .../subsurface-qt/SettingsObjectWrapper.h | 29 ++++++++--- 2 files changed, 82 insertions(+), 6 deletions(-) diff --git a/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp b/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp index ccb38b6..7745f37 100644 --- a/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp +++ b/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp @@ -1,5 +1,7 @@ #include "SettingsObjectWrapper.h" #include <QSettings> +#include "../dive.h" // TODO: remove copy_string from dive.h + static QString tecDetails = QStringLiteral("TecDetails"); @@ -398,3 +400,60 @@ void TechnicalDetailsSettings::setShowAverageDepth(short value) prefs.show_average_depth = value; emit showAverageDepthChanged(value); } + +FacebookSettings::FacebookSettings(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); +} \ No newline at end of file diff --git a/subsurface-core/subsurface-qt/SettingsObjectWrapper.h b/subsurface-core/subsurface-qt/SettingsObjectWrapper.h index a42b00c..cc7e063 100644 --- a/subsurface-core/subsurface-qt/SettingsObjectWrapper.h +++ b/subsurface-core/subsurface-qt/SettingsObjectWrapper.h @@ -149,11 +149,28 @@ signals: /* 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) + 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 */ @@ -162,9 +179,9 @@ class GeocodingPreferences : public QObject { 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) + Q_PROPERTY(taxonomy_category first_taxonomy READ firstTaxonomyCategory WRITE setFirstTaxonomyCategory NOTIFY firstTaxonomyCategoryChanged) + Q_PROPERTY(taxonomy_category second_taxonomy READ secondTaxonomyCategory WRITE setSecondTaxonomyCategory NOTIFY secondTaxonomyCategoryChanged) + Q_PROPERTY(taxonomy_category third_taxonomy READ thirdTaxonomyCategory WRITE setThirdTaxonomyCategory NOTIFY thirdTaxonomyCategoryChanged) public: GeocodingPreferences(QObject *parent); }; -- 2.7.0
From 458cc36b4522e3a9bcae5d466ec5f0e0d15c5f37 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Wed, 13 Jan 2016 17:13:10 -0200 Subject: [PATCH 2/5] Rename a few methods wrongly named, and place them on the correct place on the file. Signed-off-by: Tomaz Canabrava <[email protected]> --- .../subsurface-qt/SettingsObjectWrapper.cpp | 153 +++++++++++---------- 1 file changed, 77 insertions(+), 76 deletions(-) diff --git a/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp b/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp index 7745f37..edc3230 100644 --- a/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp +++ b/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp @@ -35,170 +35,171 @@ double PartialPressureGasSettings::pheThreshold() const return prefs.pp_graphs.phe_threshold; } -double PartialPressureGasSettings:: modp02() const +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); +} + + +double TechnicalDetailsSettings:: modp02() const { return prefs.modpO2; } -short PartialPressureGasSettings::ead() const +short TechnicalDetailsSettings::ead() const { return prefs.ead; } -short PartialPressureGasSettings::dcceiling() const +short TechnicalDetailsSettings::dcceiling() const { return prefs.dcceiling; } -short PartialPressureGasSettings::redceiling() const +short TechnicalDetailsSettings::redceiling() const { return prefs.redceiling; } -short PartialPressureGasSettings::calcceiling() const +short TechnicalDetailsSettings::calcceiling() const { return prefs.calcceiling; } -short PartialPressureGasSettings::calcceiling3m() const +short TechnicalDetailsSettings::calcceiling3m() const { return prefs.calcceiling3m; } -short PartialPressureGasSettings::calcalltissues() const +short TechnicalDetailsSettings::calcalltissues() const { return prefs.calcalltissues; } -short PartialPressureGasSettings::calcndltts() const +short TechnicalDetailsSettings::calcndltts() const { return prefs.calcndltts; } -short PartialPressureGasSettings::gflow() const +short TechnicalDetailsSettings::gflow() const { return prefs.gflow; } -short PartialPressureGasSettings::gfhigh() const +short TechnicalDetailsSettings::gfhigh() const { return prefs.gfhigh; } -short PartialPressureGasSettings::hrgraph() const +short TechnicalDetailsSettings::hrgraph() const { return prefs.hrgraph; } -short PartialPressureGasSettings::tankBar() const +short TechnicalDetailsSettings::tankBar() const { return prefs.tankbar; } -short PartialPressureGasSettings::percentageGraph() const +short TechnicalDetailsSettings::percentageGraph() const { return prefs.percentagegraph; } -short PartialPressureGasSettings::rulerGraph() const +short TechnicalDetailsSettings::rulerGraph() const { return prefs.rulergraph; } -bool PartialPressureGasSettings::showCCRSetpoint() const +bool TechnicalDetailsSettings::showCCRSetpoint() const { return prefs.show_ccr_setpoint; } -bool PartialPressureGasSettings::showCCRSensors() const +bool TechnicalDetailsSettings::showCCRSensors() const { return prefs.show_ccr_sensors; } -short PartialPressureGasSettings::zoomedPlot() const +short TechnicalDetailsSettings::zoomedPlot() const { return prefs.zoomed_plot; } -short PartialPressureGasSettings::showSac() const +short TechnicalDetailsSettings::showSac() const { return prefs.show_sac; } -bool PartialPressureGasSettings::gfLowAtMaxDepth() const +bool TechnicalDetailsSettings::gfLowAtMaxDepth() const { return prefs.gf_low_at_maxdepth; } -short PartialPressureGasSettings::displayUnusedTanks() const +short TechnicalDetailsSettings::displayUnusedTanks() const { return prefs.display_unused_tanks; } -short PartialPressureGasSettings::showAverageDepth() const +short TechnicalDetailsSettings::showAverageDepth() const { return prefs.show_average_depth; } -short int PartialPressureGasSettings::mod() const +short int TechnicalDetailsSettings::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; -- 2.7.0
From bcdc8644f7b16e56b49aa0a2851bef1c17dd840d Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Wed, 13 Jan 2016 17:36:11 -0200 Subject: [PATCH 3/5] Implement Geocoding Preferences Signed-off-by: Tomaz Canabrava <[email protected]> --- .../subsurface-qt/SettingsObjectWrapper.cpp | 89 ++++++++++++++++++++++ .../subsurface-qt/SettingsObjectWrapper.h | 30 +++++++- 2 files changed, 116 insertions(+), 3 deletions(-) diff --git a/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp b/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp index edc3230..f313988 100644 --- a/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp +++ b/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp @@ -457,4 +457,93 @@ void FacebookSettings::setAlbumId(const QString& value) #endif prefs.facebook.album_id = copy_string(qPrintable(value)); emit albumIdChanged(value); +} + + +GeocodingPreferences::GeocodingPreferences(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); } \ No newline at end of file diff --git a/subsurface-core/subsurface-qt/SettingsObjectWrapper.h b/subsurface-core/subsurface-qt/SettingsObjectWrapper.h index cc7e063..71e2e49 100644 --- a/subsurface-core/subsurface-qt/SettingsObjectWrapper.h +++ b/subsurface-core/subsurface-qt/SettingsObjectWrapper.h @@ -179,11 +179,35 @@ class GeocodingPreferences : public QObject { 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_taxonomy READ firstTaxonomyCategory WRITE setFirstTaxonomyCategory NOTIFY firstTaxonomyCategoryChanged) - Q_PROPERTY(taxonomy_category second_taxonomy READ secondTaxonomyCategory WRITE setSecondTaxonomyCategory NOTIFY secondTaxonomyCategoryChanged) - Q_PROPERTY(taxonomy_category third_taxonomy READ thirdTaxonomyCategory WRITE setThirdTaxonomyCategory NOTIFY thirdTaxonomyCategoryChanged) + 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 { -- 2.7.0
From a03d8e2f50a70c03f02fd3bc167135042de2c7df Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Wed, 13 Jan 2016 17:53:22 -0200 Subject: [PATCH 4/5] some cleanups Signed-off-by: Tomaz Canabrava <[email protected]> --- subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp b/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp index f313988..73137b8 100644 --- a/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp +++ b/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp @@ -333,9 +333,9 @@ void TechnicalDetailsSettings::setRulerGraph(short value) /* TODO: search for the QSettings of the RulerBar */ QSettings s; s.beginGroup(tecDetails); - s.setValue("phethreshold", value); + s.setValue("RulerBar", value); prefs.pp_graphs.phe_threshold = value; - emit pheThresholdChanged(value); + emit rulerGraphChanged(value); } void TechnicalDetailsSettings::setShowCCRSetpoint(bool value) @@ -504,6 +504,7 @@ void GeocodingPreferences::setEnableGeocoding(bool value) prefs.geocoding.enable_geocoding = value; emit enableGeocodingChanged(value); } + void GeocodingPreferences::setParseDiveWithoutGps(bool value) { QSettings s; @@ -512,6 +513,7 @@ void GeocodingPreferences::setParseDiveWithoutGps(bool value) prefs.geocoding.parse_dive_without_gps = value; emit parseDiveWithoutGpsChanged(value); } + void GeocodingPreferences::setTagExistingDives(bool value) { QSettings s; -- 2.7.0
From b43161a9571bd0a1dcd5c8fe92faff7f5aa1f536 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Wed, 13 Jan 2016 17:57:48 -0200 Subject: [PATCH 5/5] Start the implementation of the Proxy QObject config. Signed-off-by: Tomaz Canabrava <[email protected]> --- subsurface-core/subsurface-qt/SettingsObjectWrapper.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/subsurface-core/subsurface-qt/SettingsObjectWrapper.h b/subsurface-core/subsurface-qt/SettingsObjectWrapper.h index 71e2e49..6098b0d 100644 --- a/subsurface-core/subsurface-qt/SettingsObjectWrapper.h +++ b/subsurface-core/subsurface-qt/SettingsObjectWrapper.h @@ -220,6 +220,20 @@ class ProxySettings : public QObject { 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); }; class CloudStorageSettings : public QObject { -- 2.7.0
_______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
