Clean up group handling in SettingsObjectWrapper

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2016-09-25 11:01:03 -07:00
parent 9b4abca9f4
commit fa2fcc4024
2 changed files with 61 additions and 69 deletions

View file

@ -9,7 +9,7 @@
#include "core/helpers.h" #include "core/helpers.h"
DiveComputerSettings::DiveComputerSettings(QObject *parent): DiveComputerSettings::DiveComputerSettings(QObject *parent):
QObject(parent), group(QStringLiteral("DiveComputer")) QObject(parent)
{ {
} }
@ -80,7 +80,7 @@ void DiveComputerSettings::setDownloadMode(int mode)
prefs.dive_computer.download_mode = mode; prefs.dive_computer.download_mode = mode;
} }
UpdateManagerSettings::UpdateManagerSettings(QObject *parent) : QObject(parent), group("UpdateManager") UpdateManagerSettings::UpdateManagerSettings(QObject *parent) : QObject(parent)
{ {
} }
@ -144,11 +144,9 @@ void UpdateManagerSettings::setNextCheck(const QDate& date)
emit nextCheckChanged(date); emit nextCheckChanged(date);
} }
static QString tecDetails = QStringLiteral("TecDetails");
PartialPressureGasSettings::PartialPressureGasSettings(QObject* parent): PartialPressureGasSettings::PartialPressureGasSettings(QObject* parent):
QObject(parent), QObject(parent)
group("TecDetails")
{ {
} }
@ -189,7 +187,7 @@ void PartialPressureGasSettings::setShowPo2(short value)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("po2graph", value); s.setValue("po2graph", value);
prefs.pp_graphs.po2 = value; prefs.pp_graphs.po2 = value;
emit showPo2Changed(value); emit showPo2Changed(value);
@ -201,7 +199,7 @@ void PartialPressureGasSettings::setShowPn2(short value)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("pn2graph", value); s.setValue("pn2graph", value);
prefs.pp_graphs.pn2 = value; prefs.pp_graphs.pn2 = value;
emit showPn2Changed(value); emit showPn2Changed(value);
@ -213,7 +211,7 @@ void PartialPressureGasSettings::setShowPhe(short value)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("phegraph", value); s.setValue("phegraph", value);
prefs.pp_graphs.phe = value; prefs.pp_graphs.phe = value;
emit showPheChanged(value); emit showPheChanged(value);
@ -225,7 +223,7 @@ void PartialPressureGasSettings::setPo2Threshold(double value)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("po2threshold", value); s.setValue("po2threshold", value);
prefs.pp_graphs.po2_threshold = value; prefs.pp_graphs.po2_threshold = value;
emit po2ThresholdChanged(value); emit po2ThresholdChanged(value);
@ -237,7 +235,7 @@ void PartialPressureGasSettings::setPn2Threshold(double value)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("pn2threshold", value); s.setValue("pn2threshold", value);
prefs.pp_graphs.pn2_threshold = value; prefs.pp_graphs.pn2_threshold = value;
emit pn2ThresholdChanged(value); emit pn2ThresholdChanged(value);
@ -249,7 +247,7 @@ void PartialPressureGasSettings::setPheThreshold(double value)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("phethreshold", value); s.setValue("phethreshold", value);
prefs.pp_graphs.phe_threshold = value; prefs.pp_graphs.phe_threshold = value;
emit pheThresholdChanged(value); emit pheThresholdChanged(value);
@ -387,7 +385,7 @@ void TechnicalDetailsSettings::setModp02(double value)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("modpO2", value); s.setValue("modpO2", value);
prefs.modpO2 = value; prefs.modpO2 = value;
emit modpO2Changed(value); emit modpO2Changed(value);
@ -399,7 +397,7 @@ void TechnicalDetailsSettings::setShowPicturesInProfile(bool value)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("show_pictures_in_profile", value); s.setValue("show_pictures_in_profile", value);
prefs.show_pictures_in_profile = value; prefs.show_pictures_in_profile = value;
emit showPicturesInProfileChanged(value); emit showPicturesInProfileChanged(value);
@ -411,7 +409,7 @@ void TechnicalDetailsSettings::setEad(bool value)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("ead", value); s.setValue("ead", value);
prefs.ead = value; prefs.ead = value;
emit eadChanged(value); emit eadChanged(value);
@ -423,7 +421,7 @@ void TechnicalDetailsSettings::setMod(bool value)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("mod", value); s.setValue("mod", value);
prefs.mod = value; prefs.mod = value;
emit modChanged(value); emit modChanged(value);
@ -435,7 +433,7 @@ void TechnicalDetailsSettings::setDCceiling(bool value)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("dcceiling", value); s.setValue("dcceiling", value);
prefs.dcceiling = value; prefs.dcceiling = value;
emit dcceilingChanged(value); emit dcceilingChanged(value);
@ -447,7 +445,7 @@ void TechnicalDetailsSettings::setRedceiling(bool value)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("redceiling", value); s.setValue("redceiling", value);
prefs.redceiling = value; prefs.redceiling = value;
emit redceilingChanged(value); emit redceilingChanged(value);
@ -459,7 +457,7 @@ void TechnicalDetailsSettings::setCalcceiling(bool value)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("calcceiling", value); s.setValue("calcceiling", value);
prefs.calcceiling = value; prefs.calcceiling = value;
emit calcceilingChanged(value); emit calcceilingChanged(value);
@ -471,7 +469,7 @@ void TechnicalDetailsSettings::setCalcceiling3m(bool value)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("calcceiling3m", value); s.setValue("calcceiling3m", value);
prefs.calcceiling3m = value; prefs.calcceiling3m = value;
emit calcceiling3mChanged(value); emit calcceiling3mChanged(value);
@ -483,7 +481,7 @@ void TechnicalDetailsSettings::setCalcalltissues(bool value)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("calcalltissues", value); s.setValue("calcalltissues", value);
prefs.calcalltissues = value; prefs.calcalltissues = value;
emit calcalltissuesChanged(value); emit calcalltissuesChanged(value);
@ -495,7 +493,7 @@ void TechnicalDetailsSettings::setCalcndltts(bool value)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("calcndltts", value); s.setValue("calcndltts", value);
prefs.calcndltts = value; prefs.calcndltts = value;
emit calcndlttsChanged(value); emit calcndlttsChanged(value);
@ -507,7 +505,7 @@ void TechnicalDetailsSettings::setGflow(int value)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("gflow", value); s.setValue("gflow", value);
prefs.gflow = value; prefs.gflow = value;
set_gf(prefs.gflow, prefs.gfhigh, prefs.gf_low_at_maxdepth); set_gf(prefs.gflow, prefs.gfhigh, prefs.gf_low_at_maxdepth);
@ -520,7 +518,7 @@ void TechnicalDetailsSettings::setGfhigh(int value)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("gfhigh", value); s.setValue("gfhigh", value);
prefs.gfhigh = value; prefs.gfhigh = value;
set_gf(prefs.gflow, prefs.gfhigh, prefs.gf_low_at_maxdepth); set_gf(prefs.gflow, prefs.gfhigh, prefs.gf_low_at_maxdepth);
@ -533,7 +531,7 @@ void TechnicalDetailsSettings::setVpmbConservatism(short value)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("vpmb_conservatism", value); s.setValue("vpmb_conservatism", value);
prefs.vpmb_conservatism = value; prefs.vpmb_conservatism = value;
set_vpmb_conservatism(value); set_vpmb_conservatism(value);
@ -546,7 +544,7 @@ void TechnicalDetailsSettings::setHRgraph(bool value)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("hrgraph", value); s.setValue("hrgraph", value);
prefs.hrgraph = value; prefs.hrgraph = value;
emit hrgraphChanged(value); emit hrgraphChanged(value);
@ -558,7 +556,7 @@ void TechnicalDetailsSettings::setTankBar(bool value)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("tankbar", value); s.setValue("tankbar", value);
prefs.tankbar = value; prefs.tankbar = value;
emit tankBarChanged(value); emit tankBarChanged(value);
@ -570,7 +568,7 @@ void TechnicalDetailsSettings::setPercentageGraph(bool value)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("percentagegraph", value); s.setValue("percentagegraph", value);
prefs.percentagegraph = value; prefs.percentagegraph = value;
emit percentageGraphChanged(value); emit percentageGraphChanged(value);
@ -582,7 +580,7 @@ void TechnicalDetailsSettings::setRulerGraph(bool value)
return; return;
/* TODO: search for the QSettings of the RulerBar */ /* TODO: search for the QSettings of the RulerBar */
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("RulerBar", value); s.setValue("RulerBar", value);
prefs.rulergraph = value; prefs.rulergraph = value;
emit rulerGraphChanged(value); emit rulerGraphChanged(value);
@ -594,7 +592,7 @@ void TechnicalDetailsSettings::setShowCCRSetpoint(bool value)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("show_ccr_setpoint", value); s.setValue("show_ccr_setpoint", value);
prefs.show_ccr_setpoint = value; prefs.show_ccr_setpoint = value;
emit showCCRSetpointChanged(value); emit showCCRSetpointChanged(value);
@ -605,7 +603,7 @@ void TechnicalDetailsSettings::setShowCCRSensors(bool value)
if (value == prefs.show_ccr_sensors) if (value == prefs.show_ccr_sensors)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("show_ccr_sensors", value); s.setValue("show_ccr_sensors", value);
prefs.show_ccr_sensors = value; prefs.show_ccr_sensors = value;
emit showCCRSensorsChanged(value); emit showCCRSensorsChanged(value);
@ -616,7 +614,7 @@ void TechnicalDetailsSettings::setZoomedPlot(bool value)
if (value == prefs.zoomed_plot) if (value == prefs.zoomed_plot)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("zoomed_plot", value); s.setValue("zoomed_plot", value);
prefs.zoomed_plot = value; prefs.zoomed_plot = value;
emit zoomedPlotChanged(value); emit zoomedPlotChanged(value);
@ -627,7 +625,7 @@ void TechnicalDetailsSettings::setShowSac(bool value)
if (value == prefs.show_sac) if (value == prefs.show_sac)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("show_sac", value); s.setValue("show_sac", value);
prefs.show_sac = value; prefs.show_sac = value;
emit showSacChanged(value); emit showSacChanged(value);
@ -638,7 +636,7 @@ void TechnicalDetailsSettings::setGfLowAtMaxDepth(bool value)
if (value == prefs.gf_low_at_maxdepth) if (value == prefs.gf_low_at_maxdepth)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("gf_low_at_maxdepth", value); s.setValue("gf_low_at_maxdepth", value);
prefs.gf_low_at_maxdepth = value; prefs.gf_low_at_maxdepth = value;
set_gf(prefs.gflow, prefs.gfhigh, prefs.gf_low_at_maxdepth); set_gf(prefs.gflow, prefs.gfhigh, prefs.gf_low_at_maxdepth);
@ -650,7 +648,7 @@ void TechnicalDetailsSettings::setDisplayUnusedTanks(bool value)
if (value == prefs.display_unused_tanks) if (value == prefs.display_unused_tanks)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("display_unused_tanks", value); s.setValue("display_unused_tanks", value);
prefs.display_unused_tanks = value; prefs.display_unused_tanks = value;
emit displayUnusedTanksChanged(value); emit displayUnusedTanksChanged(value);
@ -661,7 +659,7 @@ void TechnicalDetailsSettings::setShowAverageDepth(bool value)
if (value == prefs.show_average_depth) if (value == prefs.show_average_depth)
return; return;
QSettings s; QSettings s;
s.beginGroup(tecDetails); s.beginGroup(group);
s.setValue("show_average_depth", value); s.setValue("show_average_depth", value);
prefs.show_average_depth = value; prefs.show_average_depth = value;
emit showAverageDepthChanged(value); emit showAverageDepthChanged(value);
@ -731,8 +729,7 @@ void FacebookSettings::setAlbumId(const QString& value)
GeocodingPreferences::GeocodingPreferences(QObject *parent) : GeocodingPreferences::GeocodingPreferences(QObject *parent) :
QObject(parent), QObject(parent)
group(QStringLiteral("geocoding"))
{ {
} }
@ -834,8 +831,7 @@ void GeocodingPreferences::setThirdTaxonomyCategory(taxonomy_category value)
} }
ProxySettings::ProxySettings(QObject *parent) : ProxySettings::ProxySettings(QObject *parent) :
QObject(parent), QObject(parent)
group(QStringLiteral("Network"))
{ {
} }
@ -939,8 +935,7 @@ void ProxySettings::setPass(const QString& value)
} }
CloudStorageSettings::CloudStorageSettings(QObject *parent) : CloudStorageSettings::CloudStorageSettings(QObject *parent) :
QObject(parent), QObject(parent)
group(QStringLiteral("CloudStorage"))
{ {
} }
@ -1137,8 +1132,7 @@ void CloudStorageSettings::setGitLocalOnly(bool value)
} }
DivePlannerSettings::DivePlannerSettings(QObject *parent) : DivePlannerSettings::DivePlannerSettings(QObject *parent) :
QObject(parent), QObject(parent)
group(QStringLiteral("Planner"))
{ {
} }
@ -1510,8 +1504,7 @@ void DivePlannerSettings::setDecoMode(deco_mode value)
} }
UnitsSettings::UnitsSettings(QObject *parent) : UnitsSettings::UnitsSettings(QObject *parent) :
QObject(parent), QObject(parent)
group(QStringLiteral("Units"))
{ {
} }
@ -1662,8 +1655,7 @@ void UnitsSettings::setUnitSystem(const QString& value)
} }
GeneralSettingsObjectWrapper::GeneralSettingsObjectWrapper(QObject *parent) : GeneralSettingsObjectWrapper::GeneralSettingsObjectWrapper(QObject *parent) :
QObject(parent), QObject(parent)
group(QStringLiteral("GeneralSettings"))
{ {
} }
@ -1793,8 +1785,7 @@ void GeneralSettingsObjectWrapper::setPscrRatio(int value)
} }
DisplaySettingsObjectWrapper::DisplaySettingsObjectWrapper(QObject *parent) : DisplaySettingsObjectWrapper::DisplaySettingsObjectWrapper(QObject *parent) :
QObject(parent), QObject(parent)
group(QStringLiteral("Display"))
{ {
} }
@ -1860,8 +1851,7 @@ void DisplaySettingsObjectWrapper::setDisplayInvalidDives(short value)
} }
LanguageSettingsObjectWrapper::LanguageSettingsObjectWrapper(QObject *parent) : LanguageSettingsObjectWrapper::LanguageSettingsObjectWrapper(QObject *parent) :
QObject(parent), QObject(parent)
group("Language")
{ {
} }
@ -1992,9 +1982,7 @@ void LanguageSettingsObjectWrapper::setDateFormatOverride(bool value)
} }
AnimationsSettingsObjectWrapper::AnimationsSettingsObjectWrapper(QObject* parent): AnimationsSettingsObjectWrapper::AnimationsSettingsObjectWrapper(QObject* parent):
QObject(parent), QObject(parent)
group("Animations")
{ {
} }
@ -2016,8 +2004,7 @@ void AnimationsSettingsObjectWrapper::setAnimationSpeed(int value)
} }
LocationServiceSettingsObjectWrapper::LocationServiceSettingsObjectWrapper(QObject* parent): LocationServiceSettingsObjectWrapper::LocationServiceSettingsObjectWrapper(QObject* parent):
QObject(parent), QObject(parent)
group("locationService")
{ {
} }

View file

@ -37,9 +37,10 @@ signals:
void deviceChanged(const QString& device); void deviceChanged(const QString& device);
void downloadModeChanged(int mode); void downloadModeChanged(int mode);
private: private:
QString group; const QString group = QStringLiteral("DiveComputer");
}; };
class UpdateManagerSettings : public QObject { class UpdateManagerSettings : public QObject {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool dont_check_for_updates READ dontCheckForUpdates WRITE setDontCheckForUpdates NOTIFY dontCheckForUpdatesChanged) Q_PROPERTY(bool dont_check_for_updates READ dontCheckForUpdates WRITE setDontCheckForUpdates NOTIFY dontCheckForUpdatesChanged)
@ -62,7 +63,7 @@ signals:
void lastVersionUsedChanged(const QString& value); void lastVersionUsedChanged(const QString& value);
void nextCheckChanged(const QDate& date); void nextCheckChanged(const QDate& date);
private: private:
QString group; const QString group = QStringLiteral("UpdateManager");
}; };
/* Control the state of the Partial Pressure Graphs preferences */ /* Control the state of the Partial Pressure Graphs preferences */
@ -99,8 +100,9 @@ signals:
void po2ThresholdChanged(double value); void po2ThresholdChanged(double value);
void pn2ThresholdChanged(double value); void pn2ThresholdChanged(double value);
void pheThresholdChanged(double value); void pheThresholdChanged(double value);
private: private:
QString group; const QString group = QStringLiteral("TecDetails");
}; };
class TechnicalDetailsSettings : public QObject { class TechnicalDetailsSettings : public QObject {
@ -208,6 +210,9 @@ signals:
void displayUnusedTanksChanged(bool value); void displayUnusedTanksChanged(bool value);
void showAverageDepthChanged(bool value); void showAverageDepthChanged(bool value);
void showPicturesInProfileChanged(bool value); void showPicturesInProfileChanged(bool value);
private:
const QString group = QStringLiteral("TecDetails");
}; };
/* Control the state of the Facebook preferences */ /* Control the state of the Facebook preferences */
@ -271,7 +276,7 @@ signals:
void secondTaxonomyCategoryChanged(taxonomy_category value); void secondTaxonomyCategoryChanged(taxonomy_category value);
void thirdTaxonomyCategoryChanged(taxonomy_category value); void thirdTaxonomyCategoryChanged(taxonomy_category value);
private: private:
QString group; const QString group = QStringLiteral("geocoding");
}; };
class ProxySettings : public QObject { class ProxySettings : public QObject {
@ -308,7 +313,7 @@ signals:
void userChanged(const QString& value); void userChanged(const QString& value);
void passChanged(const QString& value); void passChanged(const QString& value);
private: private:
QString group; const QString group = QStringLiteral("Network");
}; };
class CloudStorageSettings : public QObject { class CloudStorageSettings : public QObject {
@ -369,7 +374,7 @@ signals:
void saveUserIdLocalChanged(short value); void saveUserIdLocalChanged(short value);
private: private:
QString group; const QString group = QStringLiteral("CloudStorage");
}; };
class DivePlannerSettings : public QObject { class DivePlannerSettings : public QObject {
@ -471,7 +476,7 @@ signals:
void decoModeChanged(deco_mode value); void decoModeChanged(deco_mode value);
private: private:
QString group; const QString group = QStringLiteral("Planner");
}; };
class UnitsSettings : public QObject { class UnitsSettings : public QObject {
@ -516,7 +521,7 @@ signals:
void unitSystemChanged(const QString& value); void unitSystemChanged(const QString& value);
void coordinatesTraditionalChanged(bool value); void coordinatesTraditionalChanged(bool value);
private: private:
QString group; const QString group = QStringLiteral("Units");
}; };
class GeneralSettingsObjectWrapper : public QObject { class GeneralSettingsObjectWrapper : public QObject {
@ -557,7 +562,7 @@ signals:
void o2ConsumptionChanged(int value); void o2ConsumptionChanged(int value);
void pscrRatioChanged(int value); void pscrRatioChanged(int value);
private: private:
QString group; const QString group = QStringLiteral("GeneralSettings");
}; };
class DisplaySettingsObjectWrapper : public QObject { class DisplaySettingsObjectWrapper : public QObject {
@ -579,7 +584,7 @@ signals:
void fontSizeChanged(double value); void fontSizeChanged(double value);
void displayInvalidDivesChanged(short value); void displayInvalidDivesChanged(short value);
private: private:
QString group; const QString group = QStringLiteral("Display");
}; };
class LanguageSettingsObjectWrapper : public QObject { class LanguageSettingsObjectWrapper : public QObject {
@ -621,7 +626,7 @@ signals:
void useSystemLanguageChanged(bool value); void useSystemLanguageChanged(bool value);
private: private:
QString group; const QString group = QStringLiteral("Language");
}; };
class AnimationsSettingsObjectWrapper : public QObject { class AnimationsSettingsObjectWrapper : public QObject {
@ -638,7 +643,7 @@ signals:
void animationSpeedChanged(int value); void animationSpeedChanged(int value);
private: private:
QString group; const QString group = QStringLiteral("Animations");
}; };
class LocationServiceSettingsObjectWrapper : public QObject { class LocationServiceSettingsObjectWrapper : public QObject {
@ -656,7 +661,7 @@ signals:
void timeThresholdChanged(int value); void timeThresholdChanged(int value);
void distanceThresholdChanged(int value); void distanceThresholdChanged(int value);
private: private:
QString group; const QString group = QStringLiteral("locationService");
}; };
class SettingsObjectWrapper : public QObject { class SettingsObjectWrapper : public QObject {