[PATCH 1/2] Rename conservatism_level to vpmb_conservatism

Rick Walsh rickmwalsh at gmail.com
Sat Sep 24 01:02:07 PDT 2016


Make the variable purpose less ambiguous

Signed-off-by: Rick Walsh <rickmwalsh at gmail.com>
---
 core/deco.c                                  |  8 ++++----
 core/planner.c                               |  4 ++--
 core/pref.h                                  |  2 +-
 core/subsurface-qt/SettingsObjectWrapper.cpp | 16 ++++++++--------
 core/subsurface-qt/SettingsObjectWrapper.h   |  8 ++++----
 core/subsurfacestartup.c                     |  2 +-
 desktop-widgets/diveplanner.cpp              |  4 ++--
 profile-widget/profilewidget2.cpp            |  4 ++--
 qt-models/diveplannermodel.cpp               |  4 ++--
 qt-models/diveplannermodel.h                 |  2 +-
 tests/testplan.cpp                           |  2 +-
 11 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/core/deco.c b/core/deco.c
index 6c3d6dd..628550d 100644
--- a/core/deco.c
+++ b/core/deco.c
@@ -174,15 +174,15 @@ double initial_he_gradient[16];
 
 double get_crit_radius_He()
 {
-	if (prefs.conservatism_level <= 4)
-		return vpmb_config.crit_radius_He * conservatism_lvls[prefs.conservatism_level] * subsurface_conservatism_factor;
+	if (prefs.vpmb_conservatism <= 4)
+		return vpmb_config.crit_radius_He * conservatism_lvls[prefs.vpmb_conservatism] * subsurface_conservatism_factor;
 	return vpmb_config.crit_radius_He;
 }
 
 double get_crit_radius_N2()
 {
-	if (prefs.conservatism_level <= 4)
-		return vpmb_config.crit_radius_N2 * conservatism_lvls[prefs.conservatism_level] * subsurface_conservatism_factor;
+	if (prefs.vpmb_conservatism <= 4)
+		return vpmb_config.crit_radius_N2 * conservatism_lvls[prefs.vpmb_conservatism] * subsurface_conservatism_factor;
 	return vpmb_config.crit_radius_N2;
 }
 
diff --git a/core/planner.c b/core/planner.c
index bbc1599..e127cf1 100644
--- a/core/planner.c
+++ b/core/planner.c
@@ -565,10 +565,10 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
 		snprintf(temp, sz_temp, translate("gettextFromC", "based on Bühlmann ZHL-16C with GFlow = %d and GFhigh = %d"),
 			diveplan->gflow, diveplan->gfhigh);
 	} else if (prefs.deco_mode == VPMB){
-		if (prefs.conservatism_level == 0)
+		if (prefs.vpmb_conservatism == 0)
 			snprintf(temp, sz_temp, "%s", translate("gettextFromC", "based on VPM-B at nominal conservatism"));
 		else
-			snprintf(temp, sz_temp, translate("gettextFromC", "based on VPM-B at +%d conservatism"), prefs.conservatism_level);
+			snprintf(temp, sz_temp, translate("gettextFromC", "based on VPM-B at +%d conservatism"), prefs.vpmb_conservatism);
 	} else if (prefs.deco_mode == RECREATIONAL){
 		snprintf(temp, sz_temp, translate("gettextFromC", "recreational mode based on Bühlmann ZHL-16B with GFlow = %d and GFhigh = %d"),
 			diveplan->gflow, diveplan->gfhigh);
diff --git a/core/pref.h b/core/pref.h
index 3d80763..c12a040 100644
--- a/core/pref.h
+++ b/core/pref.h
@@ -143,7 +143,7 @@ struct preferences {
 	bool cloud_background_sync;
 	geocoding_prefs_t geocoding;
 	enum deco_mode deco_mode;
-	short conservatism_level;
+	short vpmb_conservatism;
 	int time_threshold;
 	int distance_threshold;
 	bool git_local_only;
diff --git a/core/subsurface-qt/SettingsObjectWrapper.cpp b/core/subsurface-qt/SettingsObjectWrapper.cpp
index 42be027..62e746a 100644
--- a/core/subsurface-qt/SettingsObjectWrapper.cpp
+++ b/core/subsurface-qt/SettingsObjectWrapper.cpp
@@ -1229,9 +1229,9 @@ int DivePlannerSettings::decoSac() const
 	return prefs.decosac;
 }
 
-short DivePlannerSettings::conservatismLevel() const
+short DivePlannerSettings::vpmbConservatism() const
 {
-	return prefs.conservatism_level;
+	return prefs.vpmb_conservatism;
 }
 
 deco_mode DivePlannerSettings::decoMode() const
@@ -1484,16 +1484,16 @@ void DivePlannerSettings::setSecoSac(int value)
 	emit decoSacChanged(value);
 }
 
-void DivePlannerSettings::setConservatismLevel(int value)
+void DivePlannerSettings::setVpmbConservatism(int value)
 {
-	if (value == prefs.conservatism_level)
+	if (value == prefs.vpmb_conservatism)
 		return;
 
 	QSettings s;
 	s.beginGroup(group);
 	s.setValue("conservatism", value);
-	prefs.conservatism_level = value;
-	emit conservatismLevelChanged(value);
+	prefs.vpmb_conservatism = value;
+	emit vpmbConservatismChanged(value);
 }
 
 void DivePlannerSettings::setDecoMode(deco_mode value)
@@ -2259,7 +2259,7 @@ void SettingsObjectWrapper::load()
 	prefs.drop_stone_mode = s.value("drop_stone_mode", prefs.drop_stone_mode).toBool();
 	prefs.bottomsac = s.value("bottomsac", prefs.bottomsac).toInt();
 	prefs.decosac = s.value("decosac", prefs.decosac).toInt();
-	prefs.conservatism_level = s.value("conservatism", prefs.conservatism_level).toInt();
+	prefs.vpmb_conservatism = s.value("conservatism", prefs.vpmb_conservatism).toInt();
 	s.endGroup();
 
 	s.beginGroup("UpdateManager");
@@ -2296,7 +2296,7 @@ void SettingsObjectWrapper::sync()
 	s.setValue("bottomsac", prefs.bottomsac);
 	s.setValue("decosac", prefs.decosac);
 	s.setValue("deco_mode", int(prefs.deco_mode));
-	s.setValue("conservatism", prefs.conservatism_level);
+	s.setValue("conservatism", prefs.vpmb_conservatism);
 	s.endGroup();
 }
 
diff --git a/core/subsurface-qt/SettingsObjectWrapper.h b/core/subsurface-qt/SettingsObjectWrapper.h
index 7edb74e..9e823fd 100644
--- a/core/subsurface-qt/SettingsObjectWrapper.h
+++ b/core/subsurface-qt/SettingsObjectWrapper.h
@@ -391,7 +391,7 @@ class DivePlannerSettings : public QObject {
 	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(short conservatism_level READ conservatismLevel    WRITE setConservatismLevel    NOTIFY conservatismLevelChanged)
+	Q_PROPERTY(short vpmb_conservatism  READ vpmbConservatism     WRITE setVpmbConservatism     NOTIFY vpmbConservatismChanged)
 	Q_PROPERTY(deco_mode decoMode       READ decoMode             WRITE setDecoMode             NOTIFY decoModeChanged)
 
 public:
@@ -417,7 +417,7 @@ public:
 	int minSwitchDuration() const;
 	int bottomSac() const;
 	int decoSac() const;
-	short conservatismLevel() const;
+	short vpmbConservatism() const;
 	deco_mode decoMode() const;
 
 public slots:
@@ -442,7 +442,7 @@ public slots:
 	void setMinSwitchDuration(int value);
 	void setBottomSac(int value);
 	void setSecoSac(int value);
-	void setConservatismLevel(int value);
+	void setVpmbConservatism(int value);
 	void setDecoMode(deco_mode value);
 
 signals:
@@ -467,7 +467,7 @@ signals:
 	void minSwitchDurationChanged(int value);
 	void bottomSacChanged(int value);
 	void decoSacChanged(int value);
-	void conservatismLevelChanged(int value);
+	void vpmbConservatismChanged(int value);
 	void decoModeChanged(deco_mode value);
 
 private:
diff --git a/core/subsurfacestartup.c b/core/subsurfacestartup.c
index 1041e7d..7534a49 100644
--- a/core/subsurfacestartup.c
+++ b/core/subsurfacestartup.c
@@ -84,7 +84,7 @@ struct preferences default_prefs = {
 		.category = { 0 }
 	},
 	.deco_mode = BUEHLMANN,
-	.conservatism_level = 3,
+	.vpmb_conservatism = 3,
 	.distance_threshold = 1000,
 	.time_threshold = 600,
 	.cloud_timeout = 5
diff --git a/desktop-widgets/diveplanner.cpp b/desktop-widgets/diveplanner.cpp
index d76ef5d..ed6515e 100644
--- a/desktop-widgets/diveplanner.cpp
+++ b/desktop-widgets/diveplanner.cpp
@@ -296,7 +296,7 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f)
 	ui.recreational_deco->setChecked(prefs.deco_mode == RECREATIONAL);
 	ui.buehlmann_deco->setChecked(prefs.deco_mode == BUEHLMANN);
 	ui.vpmb_deco->setChecked(prefs.deco_mode == VPMB);
-	ui.conservatism_lvl->setValue(prefs.conservatism_level);
+	ui.conservatism_lvl->setValue(prefs.vpmb_conservatism);
 	disableDecoElements((int) prefs.deco_mode);
 
 	// should be the same order as in dive_comp_type!
@@ -330,7 +330,7 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f)
 	connect(ui.gflow, SIGNAL(valueChanged(int)), plannerModel, SLOT(setGFLow(int)));
 	connect(ui.gfhigh, SIGNAL(editingFinished()), plannerModel, SLOT(triggerGFHigh()));
 	connect(ui.gflow, SIGNAL(editingFinished()), plannerModel, SLOT(triggerGFLow()));
-	connect(ui.conservatism_lvl, SIGNAL(valueChanged(int)), plannerModel, SLOT(setConservatism(int)));
+	connect(ui.conservatism_lvl, SIGNAL(valueChanged(int)), plannerModel, SLOT(setVpmbConservatism(int)));
 	connect(ui.backgasBreaks, SIGNAL(toggled(bool)), this, SLOT(setBackgasBreaks(bool)));
 	connect(ui.switch_at_req_stop, SIGNAL(toggled(bool)), plannerModel, SLOT(setSwitchAtReqStop(bool)));
 	connect(ui.min_switch_duration, SIGNAL(valueChanged(int)), plannerModel, SLOT(setMinSwitchDuration(int)));
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp
index 58cebf6..8894855 100644
--- a/profile-widget/profilewidget2.cpp
+++ b/profile-widget/profilewidget2.cpp
@@ -559,7 +559,7 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
 		copy_dive(d, &displayed_dive);
 #ifndef SUBSURFACE_MOBILE
 		if (prefs.deco_mode == VPMB)
-			decoModelParameters->setText(QString("VPM-B +%1").arg(prefs.conservatism_level));
+			decoModelParameters->setText(QString("VPM-B +%1").arg(prefs.vpmb_conservatism));
 		else
 			decoModelParameters->setText(QString("GF %1/%2").arg(prefs.gflow).arg(prefs.gfhigh));
 	} else {
@@ -571,7 +571,7 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
 			return;
 		}
 		if (prefs.deco_mode == VPMB)
-			decoModelParameters->setText(QString("VPM-B +%1").arg(prefs.conservatism_level));
+			decoModelParameters->setText(QString("VPM-B +%1").arg(prefs.vpmb_conservatism));
 		else
 			decoModelParameters->setText(QString("GF %1/%2").arg(diveplan.gflow).arg(diveplan.gfhigh));
 #endif
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp
index 425d8bc..10713f3 100644
--- a/qt-models/diveplannermodel.cpp
+++ b/qt-models/diveplannermodel.cpp
@@ -421,9 +421,9 @@ void DivePlannerPointsModel::triggerGFLow()
 	}
 }
 
-void DivePlannerPointsModel::setConservatism(int level)
+void DivePlannerPointsModel::setVpmbConservatism(int level)
 {
-	prefs.conservatism_level = level;
+	prefs.vpmb_conservatism = level;
 	emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
 }
 
diff --git a/qt-models/diveplannermodel.h b/qt-models/diveplannermodel.h
index 8bbe8f6..eff6689 100644
--- a/qt-models/diveplannermodel.h
+++ b/qt-models/diveplannermodel.h
@@ -63,7 +63,7 @@ slots:
 	void triggerGFHigh();
 	void setGFLow(const int ghflow);
 	void triggerGFLow();
-	void setConservatism(int level);
+	void setVpmbConservatism(int level);
 	void setSurfacePressure(int pressure);
 	void setSalinity(int salinity);
 	int getSurfacePressure();
diff --git a/tests/testplan.cpp b/tests/testplan.cpp
index 19852d4..43473db 100644
--- a/tests/testplan.cpp
+++ b/tests/testplan.cpp
@@ -33,7 +33,7 @@ void setupPrefsVpmb()
 	prefs.descrate = 99000 / 60;
 	prefs.last_stop = false;
 	prefs.deco_mode = VPMB;
-	prefs.conservatism_level = 0;
+	prefs.vpmb_conservatism = 0;
 }
 
 void setupPlan(struct diveplan *dp)
-- 
2.7.4



More information about the subsurface mailing list