The patch attached changes some QSettings refrences to prefs struct.
Some are not changed yet like the "rulergraph" setting , because I
didn't implement the setter function yet.
--
Regards,
Gehad Elrobey
>From ee5d456d72519f516a447c51958dc8e6577dcb82 Mon Sep 17 00:00:00 2001
From: Gehad elrobey <[email protected]>
Date: Fri, 11 Apr 2014 23:06:25 +0200
Subject: [PATCH] Removing unneeded refrences to QSettings
-Changing some references of QSettings to the preference structure instead.
-Removing some unused functions in pref.h were left over from an old version.
-Changing some settings name in QSettings for consistency.
Signed-off-by: Gehad elrobey <[email protected]>
---
pref.h | 13 +++----------
qt-ui/preferences.cpp | 10 +++++++---
qt-ui/profile/divecartesianaxis.cpp | 13 ++++---------
qt-ui/profile/diveprofileitem.cpp | 18 +++++-------------
qt-ui/profile/profilewidget2.cpp | 31 +++++++++++++++----------------
5 files changed, 34 insertions(+), 51 deletions(-)
diff --git a/pref.h b/pref.h
index 712a2d1..7db4fd7 100644
--- a/pref.h
+++ b/pref.h
@@ -39,9 +39,9 @@ struct preferences {
short unit_system;
struct units units;
short show_sac;
- bool display_unused_tanks;
- bool show_average_depth;
- bool zoomed_plot;
+ short display_unused_tanks;
+ short show_average_depth;
+ short zoomed_plot;
short heart_rate;
};
enum unit_system_values {
@@ -54,16 +54,9 @@ extern struct preferences prefs, default_prefs;
#define PP_GRAPHS_ENABLED (prefs.pp_graphs.po2 || prefs.pp_graphs.pn2 || prefs.pp_graphs.phe)
-extern void subsurface_open_conf(void);
extern void subsurface_set_conf(const char *name, const char *value);
extern void subsurface_set_conf_bool(const char *name, bool value);
extern void subsurface_set_conf_int(const char *name, int value);
-extern void subsurface_unset_conf(const char *name);
-extern const char *subsurface_get_conf(const char *name);
-extern int subsurface_get_conf_bool(const char *name);
-extern int subsurface_get_conf_int(const char *name);
-extern void subsurface_flush_conf(void);
-extern void subsurface_close_conf(void);
extern const char system_divelist_default_font[];
extern const int system_divelist_default_font_size;
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp
index 1e87662..73178ef 100644
--- a/qt-ui/preferences.cpp
+++ b/qt-ui/preferences.cpp
@@ -172,12 +172,11 @@ void PreferencesDialog::syncSettings()
// Graph
s.beginGroup("TecDetails");
-
s.setValue("phethreshold", ui.pheThreshold->value());
s.setValue("po2threshold", ui.po2Threshold->value());
s.setValue("pn2threshold", ui.pn2Threshold->value());
s.setValue("modppO2", ui.maxppo2->value());
- SB("redceiling", ui.red_ceiling);
+ SB("profile_red_ceiling", ui.red_ceiling);
s.setValue("gflow", ui.gflow->value());
s.setValue("gfhigh", ui.gfhigh->value());
SB("gf_low_at_maxdepth", ui.gf_low_at_maxdepth);
@@ -196,6 +195,7 @@ void PreferencesDialog::syncSettings()
s.setValue("weight", ui.lbs->isChecked() ? units::LBS : units::KG);
s.setValue("vertical_speed_time", ui.vertical_speed_minutes->isChecked() ? units::MINUTES : units::SECONDS);
s.endGroup();
+
// Defaults
s.beginGroup("GeneralSettings");
s.setValue("default_filename", ui.defaultfilename->text());
@@ -209,6 +209,7 @@ void PreferencesDialog::syncSettings()
s.endGroup();
s.sync();
+ // Locale
QLocale loc;
s.beginGroup("Language");
bool useSystemLang = s.value("UseSystemLanguage", true).toBool();
@@ -221,8 +222,11 @@ void PreferencesDialog::syncSettings()
s.setValue("UiLanguage", ui.languageView->currentIndex().data(Qt::UserRole));
s.endGroup();
+ // Animation
s.beginGroup("Animations");
s.setValue("animation_speed",ui.velocitySlider->value());
+ s.endGroup();
+
loadSettings();
emit settingsChanged();
}
@@ -262,7 +266,7 @@ void PreferencesDialog::loadSettings()
GET_BOOL("mod", mod);
GET_DOUBLE("modppO2", mod_ppO2);
GET_BOOL("ead", ead);
- GET_BOOL("redceiling", profile_red_ceiling);
+ GET_BOOL("profile_red_ceiling", profile_red_ceiling);
GET_BOOL("dcceiling", profile_dc_ceiling);
GET_BOOL("calcceiling", profile_calc_ceiling);
GET_BOOL("calcceiling3m", calc_ceiling_3m_incr);
diff --git a/qt-ui/profile/divecartesianaxis.cpp b/qt-ui/profile/divecartesianaxis.cpp
index f5ba988..2729647 100644
--- a/qt-ui/profile/divecartesianaxis.cpp
+++ b/qt-ui/profile/divecartesianaxis.cpp
@@ -353,10 +353,7 @@ QColor DepthAxis::colorForValue(double value)
static bool isPPGraphEnabled()
{
- QSettings s;
-
- s.beginGroup("TecDetails");
- return s.value("phegraph").toBool() || s.value("po2graph").toBool() || s.value("pn2graph").toBool();
+ return prefs.pp_graphs.po2 || prefs.pp_graphs.pn2 || prefs.pp_graphs.phe;
}
DepthAxis::DepthAxis() : showWithPPGraph(false)
@@ -426,11 +423,9 @@ void PartialGasPressureAxis::setModel(DivePlotDataModel *m)
void PartialGasPressureAxis::preferencesChanged()
{
- QSettings s;
- s.beginGroup("TecDetails");
- bool showPhe = s.value("phegraph").toBool();
- bool showPn2 = s.value("pn2graph").toBool();
- bool showPo2 = s.value("po2graph").toBool();
+ bool showPhe = prefs.pp_graphs.phe;
+ bool showPn2 = prefs.pp_graphs.pn2;
+ bool showPo2 = prefs.pp_graphs.po2;
setVisible(showPhe || showPn2 || showPo2);
if (!model->rowCount())
return;
diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp
index 51d6a3f..e182477 100644
--- a/qt-ui/profile/diveprofileitem.cpp
+++ b/qt-ui/profile/diveprofileitem.cpp
@@ -555,9 +555,7 @@ DiveCalculatedTissue::DiveCalculatedTissue()
void DiveCalculatedTissue::preferencesChanged()
{
- QSettings s;
- s.beginGroup("TecDetails");
- setVisible(s.value("calcalltissues").toBool() && s.value("calcceiling").toBool());
+ setVisible(prefs.calc_all_tissues && prefs.profile_calc_ceiling);
}
void DiveReportedCeiling::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
@@ -589,23 +587,17 @@ void DiveReportedCeiling::modelDataChanged(const QModelIndex &topLeft, const QMo
void DiveCalculatedCeiling::preferencesChanged()
{
- QSettings s;
- s.beginGroup("TecDetails");
-
- bool shouldShow3mIncrement = s.value("calcceiling3m").toBool();
- if (dataModel && is3mIncrement != shouldShow3mIncrement) {
+ if (dataModel && is3mIncrement != prefs.calc_ceiling_3m_incr) {
// recalculate that part.
dataModel->calculateDecompression();
}
- is3mIncrement = shouldShow3mIncrement;
- setVisible(s.value("calcceiling").toBool());
+ is3mIncrement = prefs.calc_ceiling_3m_incr;
+ setVisible(prefs.profile_calc_ceiling);
}
void DiveReportedCeiling::preferencesChanged()
{
- QSettings s;
- s.beginGroup("TecDetails");
- setVisible(s.value("redceiling").toBool());
+ setVisible(prefs.profile_red_ceiling);
}
void DiveReportedCeiling::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 97511c7..2d9698c 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -13,8 +13,8 @@
#include "planner.h"
#include "device.h"
#include "ruleritem.h"
-#include "../../dive.h"
-#include "../../pref.h"
+#include "dive.h"
+#include "pref.h"
#include <libdivecomputer/parser.h>
#include <QSignalTransition>
#include <QPropertyAnimation>
@@ -477,7 +477,7 @@ void ProfileWidget2::settingsChanged()
{
QSettings s;
s.beginGroup("TecDetails");
- if (s.value("phegraph").toBool() || s.value("po2graph").toBool() || s.value("pn2graph").toBool()) {
+ if (prefs.pp_graphs.phe || prefs.pp_graphs.po2 || prefs.pp_graphs.pn2) {
profileYAxis->animateChangeLine(itemPos.depth.shrinked);
temperatureAxis->animateChangeLine(itemPos.temperature.shrinked);
cylinderPressureAxis->animateChangeLine(itemPos.cylinder.shrinked);
@@ -486,8 +486,8 @@ void ProfileWidget2::settingsChanged()
temperatureAxis->animateChangeLine(itemPos.temperature.expanded);
cylinderPressureAxis->animateChangeLine(itemPos.cylinder.expanded);
}
- if (s.value("zoomed_plot").toBool() != isPlotZoomed) {
- isPlotZoomed = s.value("zoomed_plot").toBool();
+ if (prefs.zoomed_plot != isPlotZoomed) {
+ isPlotZoomed = prefs.zoomed_plot;
replot();
}
@@ -635,9 +635,7 @@ void ProfileWidget2::setProfileState()
cylinderPressureAxis->setVisible(true);
profileYAxis->setPos(itemPos.depth.pos.on);
- QSettings s;
- s.beginGroup("TecDetails");
- if (s.value("phegraph").toBool() || s.value("po2graph").toBool() || s.value("pn2graph").toBool()) {
+ if (prefs.pp_graphs.phe || prefs.pp_graphs.po2 || prefs.pp_graphs.pn2) {
profileYAxis->setLine(itemPos.depth.shrinked);
temperatureAxis->setLine(itemPos.temperature.shrinked);
cylinderPressureAxis->setLine(itemPos.cylinder.shrinked);
@@ -646,9 +644,9 @@ void ProfileWidget2::setProfileState()
temperatureAxis->setLine(itemPos.temperature.expanded);
cylinderPressureAxis->setLine(itemPos.cylinder.expanded);
}
- pn2GasItem->setVisible(s.value("pn2graph").toBool());
- po2GasItem->setVisible(s.value("po2graph").toBool());
- pheGasItem->setVisible(s.value("phegraph").toBool());
+ pn2GasItem->setVisible(prefs.pp_graphs.pn2);
+ po2GasItem->setVisible(prefs.pp_graphs.po2);
+ pheGasItem->setVisible(prefs.pp_graphs.phe);
gasYAxis->setPos(itemPos.partialPressure.pos.on);
gasYAxis->setLine(itemPos.partialPressure.expanded);
@@ -660,21 +658,22 @@ void ProfileWidget2::setProfileState()
temperatureAxis->setPos(itemPos.temperature.pos.on);
heartBeatAxis->setPos(itemPos.heartBeat.pos.on);
heartBeatAxis->setLine(itemPos.heartBeat.expanded);
- heartBeatItem->setVisible(s.value("hrgraph").toBool());
+ heartBeatItem->setVisible(prefs.heart_rate);
meanDepth->setVisible(true);
diveComputerText->setVisible(true);
diveComputerText->setPos(itemPos.dcLabel.on);
- diveCeiling->setVisible(s.value("calcceiling").toBool());
- reportedCeiling->setVisible(s.value("dcceiling").toBool());
+ diveCeiling->setVisible(prefs.profile_calc_ceiling);
+ reportedCeiling->setVisible(prefs.profile_dc_ceiling);
- if (s.value("calcalltissues").toBool()) {
+ if (prefs.calc_all_tissues) {
Q_FOREACH(DiveCalculatedTissue * tissue, allTissues) {
tissue->setVisible(true);
}
}
-
+ QSettings s;
+ s.beginGroup("TecDetails");
bool rulerVisible = s.value("rulergraph", false).toBool();
rulerItem->setVisible(rulerVisible);
rulerItem->destNode()->setVisible(rulerVisible);
--
1.8.3.2
_______________________________________________
subsurface mailing list
[email protected]
http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface