core: create qPrefTechnicalDetails from SettingsObjectWrapper

Update set/get functions to follow common name scheme:
- get function have same name as in struct diveComputer
- set function have set_<name>
- signal function have <name>_changed

one class one .h/.cpp is the C++ idiom. Having load/sync of each
variable in 1 functions (in contrast to the distributed way
SettingsObjectWrapper handles it) secures the same storage name
is used. Having the set/get/load/sync functions grouped together
makes it easier to get an overview.

REMARK: this commit only defines the class, it is not active in production

Signed-off-by: Jan Iversen <jani@apache.org>
This commit is contained in:
jan Iversen 2018-08-04 12:02:29 +02:00 committed by Dirk Hohndel
parent 3c69c8299b
commit b98ba9ba94
6 changed files with 272 additions and 0 deletions

View file

@ -111,6 +111,7 @@ set(SUBSURFACE_CORE_LIB_SRCS
settings/qPrefFacebook.cpp
settings/qPrefPrivate.cpp
settings/qPrefProxy.cpp
settings/qPrefTechnicalDetails.cpp
settings/qPrefUnit.cpp
settings/qPrefUpdateManager.cpp

View file

@ -12,6 +12,7 @@
#include "qPrefDivePlanner.h"
#include "qPrefFacebook.h"
#include "qPrefProxy.h"
#include "qPrefTechnicalDetails.h"
#include "qPrefUnit.h"
#include "qPrefUpdateManager.h"

View file

@ -21,6 +21,7 @@ public:
friend class qPrefDivePlanner;
friend class qPrefFacebook;
friend class qPrefProxy;
friend class qPrefTechnicalDetails;
friend class qPrefUnits;
friend class qPrefUpdateManager;

View file

@ -0,0 +1,103 @@
// SPDX-License-Identifier: GPL-2.0
#include "qPref.h"
#include "qPrefPrivate.h"
static const QString group = QStringLiteral("TecDetails");
qPrefTechnicalDetails::qPrefTechnicalDetails(QObject *parent) : QObject(parent)
{
}
qPrefTechnicalDetails *qPrefTechnicalDetails::instance()
{
static qPrefTechnicalDetails *self = new qPrefTechnicalDetails;
return self;
}
void qPrefTechnicalDetails::loadSync(bool doSync)
{
disk_calcalltissues(doSync);
disk_calcceiling(doSync);
disk_calcceiling3m(doSync);
disk_calcndltts(doSync);
disk_dcceiling(doSync);
disk_display_deco_mode(doSync);
disk_display_unused_tanks(doSync);
disk_ead(doSync);
disk_gfhigh(doSync);
disk_gflow(doSync);
disk_gf_low_at_maxdepth(doSync);
disk_hrgraph(doSync);
disk_mod(doSync);
disk_modpO2(doSync);
disk_percentagegraph(doSync);
disk_redceiling(doSync);
disk_rulergraph(doSync);
disk_show_average_depth(doSync);
disk_show_ccr_sensors(doSync);
disk_show_ccr_setpoint(doSync);
disk_show_icd(doSync);
disk_show_pictures_in_profile(doSync);
disk_show_sac(doSync);
disk_show_scr_ocpo2(doSync);
disk_tankbar(doSync);
disk_vpmb_conservatism(doSync);
disk_zoomed_plot(doSync);
}
HANDLE_PREFERENCE_BOOL(TechnicalDetails, "/calcalltissues", calcalltissues);
HANDLE_PREFERENCE_BOOL(TechnicalDetails, "/calcceiling", calcceiling);
HANDLE_PREFERENCE_BOOL(TechnicalDetails, "/calcceiling3m", calcceiling3m);
HANDLE_PREFERENCE_BOOL(TechnicalDetails, "/calcndltts", calcndltts);
HANDLE_PREFERENCE_BOOL(TechnicalDetails, "/dcceiling", dcceiling);
HANDLE_PREFERENCE_ENUM(TechnicalDetails, deco_mode, "/display_deco_mode", display_deco_mode);
HANDLE_PREFERENCE_BOOL(TechnicalDetails, "/display_unused_tanks", display_unused_tanks);
HANDLE_PREFERENCE_BOOL(TechnicalDetails, "/ead", ead);
HANDLE_PREFERENCE_INT(TechnicalDetails, "/gfhigh", gfhigh);
HANDLE_PREFERENCE_INT(TechnicalDetails, "/gflow", gflow);
HANDLE_PREFERENCE_BOOL(TechnicalDetails, "/gf_low_at_maxdepth", gf_low_at_maxdepth);
HANDLE_PREFERENCE_BOOL(TechnicalDetails, "/hrgraph", hrgraph);
HANDLE_PREFERENCE_BOOL(TechnicalDetails, "/mod", mod);
HANDLE_PREFERENCE_DOUBLE(TechnicalDetails, "/modpO2", modpO2);
HANDLE_PREFERENCE_BOOL(TechnicalDetails, "/percentagegraph", percentagegraph);
HANDLE_PREFERENCE_BOOL(TechnicalDetails, "/redceiling", redceiling);
HANDLE_PREFERENCE_BOOL(TechnicalDetails, "/RulerBar", rulergraph);
HANDLE_PREFERENCE_BOOL(TechnicalDetails, "/show_average_depth", show_average_depth);
HANDLE_PREFERENCE_BOOL(TechnicalDetails, "/show_ccr_sensors", show_ccr_sensors);
HANDLE_PREFERENCE_BOOL(TechnicalDetails, "/show_ccr_setpoint", show_ccr_setpoint);
HANDLE_PREFERENCE_BOOL(TechnicalDetails, "/show_icd", show_icd);
HANDLE_PREFERENCE_BOOL(TechnicalDetails, "/show_pictures_in_profile", show_pictures_in_profile);
HANDLE_PREFERENCE_BOOL(TechnicalDetails, "/show_sac", show_sac);
HANDLE_PREFERENCE_BOOL(TechnicalDetails, "/show_scr_ocpo2", show_scr_ocpo2);
HANDLE_PREFERENCE_BOOL(TechnicalDetails, "/tankbar", tankbar);
HANDLE_PREFERENCE_INT(TechnicalDetails, "/vpmb_conservatism", vpmb_conservatism);
HANDLE_PREFERENCE_BOOL(TechnicalDetails, "/zoomed_plot", zoomed_plot);

View file

@ -0,0 +1,164 @@
// SPDX-License-Identifier: GPL-2.0
#ifndef QPREFTECHNICALDETAILS_H
#define QPREFTECHNICALDETAILS_H
#include "core/pref.h"
#include <QObject>
class qPrefTechnicalDetails : public QObject {
Q_OBJECT
Q_PROPERTY(bool calcalltissues READ calcalltissues WRITE set_calcalltissues NOTIFY calcalltissues_changed);
Q_PROPERTY(bool calcceiling READ calcceiling WRITE set_calcceiling NOTIFY calcceiling_changed);
Q_PROPERTY(bool calcceiling3m READ calcceiling3m WRITE set_calcceiling3m NOTIFY calcceiling3m_changed);
Q_PROPERTY(bool calcndltts READ calcndltts WRITE set_calcndltts NOTIFY calcndltts_changed);
Q_PROPERTY(bool dcceiling READ dcceiling WRITE set_dcceiling NOTIFY dcceiling_changed);
Q_PROPERTY(deco_mode display_deco_mode READ display_deco_mode WRITE set_display_deco_mode NOTIFY display_deco_mode_changed);
Q_PROPERTY(bool display_unused_tanks READ display_unused_tanks WRITE set_display_unused_tanks NOTIFY display_unused_tanks_changed);
Q_PROPERTY(bool ead READ ead WRITE set_ead NOTIFY ead_changed);
Q_PROPERTY(int gfhigh READ gfhigh WRITE set_gfhigh NOTIFY gfhigh_changed);
Q_PROPERTY(int gflow READ gflow WRITE set_gflow NOTIFY gflow_changed);
Q_PROPERTY(bool gf_low_at_maxdepth READ gf_low_at_maxdepth WRITE set_gf_low_at_maxdepth NOTIFY gf_low_at_maxdepth_changed);
Q_PROPERTY(bool hrgraph READ hrgraph WRITE set_hrgraph NOTIFY hrgraph_changed);
Q_PROPERTY(bool mod READ mod WRITE set_mod NOTIFY mod_changed);
Q_PROPERTY(double modpO2 READ modpO2 WRITE set_modpO2 NOTIFY modpO2_changed);
Q_PROPERTY(bool percentagegraph READ percentagegraph WRITE set_percentagegraph NOTIFY percentagegraph_changed);
Q_PROPERTY(bool redceiling READ redceiling WRITE set_redceiling NOTIFY redceiling_changed);
Q_PROPERTY(bool rulergraph READ rulergraph WRITE set_rulergraph NOTIFY rulergraph_changed);
Q_PROPERTY(bool show_average_depth READ show_average_depth WRITE set_show_average_depth NOTIFY show_average_depth_changed);
Q_PROPERTY(bool show_ccr_sensors READ show_ccr_sensors WRITE set_show_ccr_sensors NOTIFY show_ccr_sensors_changed);
Q_PROPERTY(bool show_ccr_setpoint READ show_ccr_setpoint WRITE set_show_ccr_setpoint NOTIFY show_ccr_setpoint_changed);
Q_PROPERTY(bool show_icd READ show_icd WRITE set_show_icd NOTIFY show_icd_changed);
Q_PROPERTY(bool show_pictures_in_profile READ show_pictures_in_profile WRITE set_show_pictures_in_profile NOTIFY show_pictures_in_profile_changed);
Q_PROPERTY(bool show_sac READ show_sac WRITE set_show_sac NOTIFY show_sac_changed);
Q_PROPERTY(bool show_scr_ocpo2 READ show_scr_ocpo2 WRITE set_show_scr_ocpo2 NOTIFY show_scr_ocpo2_changed);
Q_PROPERTY(bool tankbar READ tankbar WRITE set_tankbar NOTIFY tankbar_changed);
Q_PROPERTY(int vpmb_conservatism READ vpmb_conservatism WRITE set_vpmb_conservatism NOTIFY vpmb_conservatism_changed);
Q_PROPERTY(bool zoomed_plot READ zoomed_plot WRITE set_zoomed_plot NOTIFY zoomed_plot_changed);
public:
qPrefTechnicalDetails(QObject *parent = NULL);
static qPrefTechnicalDetails *instance();
// Load/Sync local settings (disk) and struct preference
void loadSync(bool doSync);
void load() { loadSync(false); }
void sync() { loadSync(true); }
static bool calcalltissues() { return prefs.calcalltissues; }
static bool calcceiling() { return prefs.calcceiling; }
static bool calcceiling3m() { return prefs.calcceiling3m; }
static bool calcndltts() { return prefs.calcndltts; }
static bool dcceiling() { return prefs.dcceiling; }
static deco_mode display_deco_mode() { return prefs.display_deco_mode; }
static bool display_unused_tanks() { return prefs.display_unused_tanks; }
static bool ead() { return prefs.ead; }
static int gfhigh() { return prefs.gfhigh; }
static int gflow() { return prefs.gflow; }
static bool gf_low_at_maxdepth() { return prefs.gf_low_at_maxdepth; }
static bool hrgraph() { return prefs.hrgraph; }
static bool mod() { return prefs.mod; }
static double modpO2() { return prefs.modpO2; }
static bool percentagegraph() { return prefs.percentagegraph; }
static bool redceiling() { return prefs.redceiling; }
static bool rulergraph() { return prefs.rulergraph; }
static bool show_average_depth() { return prefs.show_average_depth; }
static bool show_ccr_sensors() { return prefs.show_ccr_sensors; }
static bool show_ccr_setpoint() { return prefs.show_ccr_setpoint; }
static bool show_icd() { return prefs.show_icd; }
static bool show_pictures_in_profile() { return prefs.show_pictures_in_profile; }
static bool show_sac() { return prefs.show_sac; }
static bool show_scr_ocpo2() { return prefs.show_scr_ocpo2; }
static bool tankbar() { return prefs.tankbar; }
static int vpmb_conservatism() { return prefs.vpmb_conservatism; }
static bool zoomed_plot() { return prefs.zoomed_plot; }
public slots:
void set_calcalltissues(bool value);
void set_calcceiling(bool value);
void set_calcceiling3m(bool value);
void set_calcndltts(bool value);
void set_dcceiling(bool value);
void set_display_deco_mode(deco_mode value);
void set_display_unused_tanks(bool value);
void set_ead(bool value);
void set_gfhigh(int value);
void set_gflow(int value);
void set_gf_low_at_maxdepth(bool value);
void set_hrgraph(bool value);
void set_mod(bool value);
void set_modpO2(double value);
void set_percentagegraph(bool value);
void set_redceiling(bool value);
void set_rulergraph(bool value);
void set_show_average_depth(bool value);
void set_show_ccr_sensors(bool value);
void set_show_ccr_setpoint(bool value);
void set_show_icd(bool value);
void set_show_pictures_in_profile(bool value);
void set_show_sac(bool value);
void set_show_scr_ocpo2(bool value);
void set_tankbar(bool value);
void set_vpmb_conservatism(int value);
void set_zoomed_plot(bool value);
signals:
void calcalltissues_changed(bool value);
void calcceiling_changed(bool value);
void calcceiling3m_changed(bool value);
void calcndltts_changed(bool value);
void dcceiling_changed(bool value);
void display_deco_mode_changed(deco_mode value);
void display_unused_tanks_changed(bool value);
void ead_changed(bool value);
void gfhigh_changed(int value);
void gflow_changed(int value);
void gf_low_at_maxdepth_changed(bool value);
void hrgraph_changed(bool value);
void mod_changed(bool value);
void modpO2_changed(double value);
void percentagegraph_changed(bool value);
void redceiling_changed(bool value);
void rulergraph_changed(bool value);
void show_average_depth_changed(bool value);
void show_ccr_sensors_changed(bool value);
void show_ccr_setpoint_changed(bool value);
void show_icd_changed(bool value);
void show_pictures_in_profile_changed(bool value);
void show_scr_ocpo2_changed(bool value);
void show_sac_changed(bool value);
void tankbar_changed(bool value);
void vpmb_conservatism_changed(int value);
void zoomed_plot_changed(bool value);
private:
void disk_calcalltissues(bool doSync);
void disk_calcceiling(bool doSync);
void disk_calcceiling3m(bool doSync);
void disk_calcndltts(bool doSync);
void disk_dcceiling(bool doSync);
void disk_display_deco_mode(bool doSync);
void disk_display_unused_tanks(bool doSync);
void disk_ead(bool doSync);
void disk_gfhigh(bool doSync);
void disk_gflow(bool doSync);
void disk_gf_low_at_maxdepth(bool doSync);
void disk_hrgraph(bool doSync);
void disk_mod(bool doSync);
void disk_modpO2(bool doSync);
void disk_percentagegraph(bool doSync);
void disk_redceiling(bool doSync);
void disk_rulergraph(bool doSync);
void disk_show_average_depth(bool doSync);
void disk_show_ccr_sensors(bool doSync);
void disk_show_ccr_setpoint(bool doSync);
void disk_show_icd(bool doSync);
void disk_show_pictures_in_profile(bool doSync);
void disk_show_sac(bool doSync);
void disk_show_scr_ocpo2(bool doSync);
void disk_tankbar(bool doSync);
void disk_vpmb_conservatism(bool doSync);
void disk_zoomed_plot(bool doSync);
};
#endif

View file

@ -86,6 +86,7 @@ SOURCES += ../../subsurface-mobile-main.cpp \
../../core/settings/qPrefFacebook.cpp \
../../core/settings/qPrefPrivate.cpp \
../../core/settings/qPrefProxy.cpp \
../../core/settings/qPrefTechnicalDetails.cpp \
../../core/settings/qPrefUnit.cpp \
../../core/settings/qPrefUpdateManager.cpp \
../../core/subsurface-qt/CylinderObjectHelper.cpp \
@ -203,6 +204,7 @@ HEADERS += \
../../core/settings/qPrefFacebook.h \
../../core/settings/qPrefPrivate.h \
../../core/settings/qPrefProxy.h \
../../core/settings/qPrefTechnicalDetails.h \
../../core/settings/qPrefUnit.h \
../../core/settings/qPrefUpdateManager.h \
../../core/subsurface-qt/CylinderObjectHelper.h \