[PATCH] Move drop_stone_mode setting to prefs

Anton Lundin glance at acc.umu.se
Wed Jul 9 14:37:30 PDT 2014


There is no reason to treat drop_stone_mode different from the rest of
the planner settings, so move it to our prefs structure.

Signed-off-by: Anton Lundin <glance at acc.umu.se>
---
 pref.h                |  1 +
 qt-ui/diveplanner.cpp | 10 +++++-----
 qt-ui/diveplanner.h   |  1 -
 subsurfacestartup.c   |  3 ++-
 4 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/pref.h b/pref.h
index 19830a9..ebe5ecd 100644
--- a/pref.h
+++ b/pref.h
@@ -62,6 +62,7 @@ struct preferences {
 	char *proxy_user;
 	char *proxy_pass;
 	bool doo2breaks;
+	bool drop_stone_mode;
 };
 enum unit_system_values {
 	METRIC,
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 475fe25..5109643 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -76,7 +76,7 @@ void DivePlannerPointsModel::createSimpleDive()
 
 	// If we're in drop_stone_mode, don't add a first point.
 	// It will be added implicit.
-	if (!drop_stone_mode)
+	if (!prefs.drop_stone_mode)
 		plannerModel->addStop(M_OR_FT(15, 45), 1 * 60, &gas, 0, true);
 
 	plannerModel->addStop(M_OR_FT(15, 45), 40 * 60, &gas, 0, true);
@@ -618,7 +618,7 @@ int DivePlannerPointsModel::rowCount(const QModelIndex &parent) const
 	return divepoints.count();
 }
 
-DivePlannerPointsModel::DivePlannerPointsModel(QObject *parent) : QAbstractTableModel(parent), mode(NOTHING), drop_stone_mode(false)
+DivePlannerPointsModel::DivePlannerPointsModel(QObject *parent) : QAbstractTableModel(parent), mode(NOTHING)
 {
 	memset(&diveplan, 0, sizeof(diveplan));
 	startTime = QDateTime::currentDateTimeUtc();
@@ -697,8 +697,8 @@ void DivePlannerPointsModel::setDisplayTransitions(bool value)
 
 void DivePlannerPointsModel::setDropStoneMode(bool value)
 {
-	drop_stone_mode = value;
-	if (drop_stone_mode) {
+	prefs.drop_stone_mode = value;
+	if (prefs.drop_stone_mode) {
 	/* Remove the first entry if we enable drop_stone_mode */
 		if (rowCount() >= 2) {
 			beginRemoveRows(QModelIndex(), 0, 0);
@@ -992,7 +992,7 @@ void DivePlannerPointsModel::createTemporaryPlan()
 		divedatapoint p = at(i);
 		int deltaT = lastIndex != -1 ? p.time - at(lastIndex).time : p.time;
 		lastIndex = i;
-		if (i == 0 && drop_stone_mode) {
+		if (i == 0 && prefs.drop_stone_mode) {
 			/* Okay, we add a fist segment where we go down to depth */
 			plan_add_segment(&diveplan, p.depth / prefs.descrate, p.depth, p.gasmix, p.po2, false);
 			deltaT -= p.depth / prefs.descrate;
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h
index 873ee8d..a2c33f8 100644
--- a/qt-ui/diveplanner.h
+++ b/qt-ui/diveplanner.h
@@ -101,7 +101,6 @@ private:
 	void deleteTemporaryPlan(struct divedatapoint *dp);
 	QVector<sample> backupSamples; // For editing added dives.
 	QVector<QPair<int, int> > oldGases;
-	bool drop_stone_mode;
 	QDateTime startTime;
 };
 
diff --git a/subsurfacestartup.c b/subsurfacestartup.c
index a451c2b..58291d2 100644
--- a/subsurfacestartup.c
+++ b/subsurfacestartup.c
@@ -40,7 +40,8 @@ struct preferences default_prefs = {
 	.descrate = 18000 / 60,
 	.bottompo2 = 1400,
 	.decopo2 = 1600,
-	.doo2breaks = false
+	.doo2breaks = false,
+	.drop_stone_mode = false
 };
 
 int run_survey;
-- 
1.9.1



More information about the subsurface mailing list