Hi,

I wrote the attached patch to save me from inputting my bottom and deco
SAC values all over again for every dive plan I make. Same for
drop_stone_mode, although it's just one click. :)

Cheers.

-- 
Gaetan
>From 9b3d34bc30d9876a7507846e169486d76fa136ff Mon Sep 17 00:00:00 2001
From: Gaetan Bisson <[email protected]>
Date: Wed, 16 Jul 2014 17:32:06 -1000
Subject: [PATCH] Store drop_stone_mode, bottomsac, decosac in prefs

The values for drop_stone_mode, bottomsac, and decosac are typically the
kind of personal data specific to a diver that is unlikely to change
from one dive plan to the next.

This patch stores/restores them to/from the preferences file. For this,
it adds bottomsac and decosac to the prefs structure; drop_stone_mode
was already there, though not stored/restored.

Signed-off-by: Gaetan Bisson <[email protected]>
---
 pref.h                |  2 ++
 qt-ui/diveplanner.cpp | 13 +++++++++++--
 subsurfacestartup.c   |  2 ++
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/pref.h b/pref.h
index 3efe0a5..bf153f5 100644
--- a/pref.h
+++ b/pref.h
@@ -63,6 +63,8 @@ struct preferences {
 	char *proxy_pass;
 	bool doo2breaks;
 	bool drop_stone_mode;
+	int bottomsac;
+	int decosac;
 	bool show_pictures_in_profile;
 	bool use_default_file;
 };
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 9efe80e..b670546 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -375,6 +375,9 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f)
 	prefs.bottompo2 = s.value("bottompo2", 1400).toInt();
 	prefs.decopo2 = s.value("decopo2",1600).toInt();
 	prefs.doo2breaks = s.value("doo2breaks", false).toBool();
+	prefs.drop_stone_mode = s.value("drop_stone_mode", false).toBool();
+	prefs.bottomsac = s.value("bottomsac", 20000).toInt();
+	prefs.decosac = s.value("decosac", 17000).toInt();
 	s.endGroup();
 
 	ui.ascRate75->setValue(prefs.ascrate75 / UNIT_FACTOR);
@@ -385,6 +388,7 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f)
 	ui.bottompo2->setValue(prefs.bottompo2 / 1000.0);
 	ui.decopo2->setValue(prefs.decopo2 / 1000.0);
 	ui.backgasBreaks->setChecked(prefs.doo2breaks);
+	ui.drop_stone_mode->setChecked(prefs.drop_stone_mode);
 
 	connect(ui.lastStop, SIGNAL(toggled(bool)), plannerModel, SLOT(setLastStop6m(bool)));
 	connect(ui.verbatim_plan, SIGNAL(toggled(bool)), plannerModel, SLOT(setVerbatim(bool)));
@@ -410,8 +414,8 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f)
 	connect(ui.gflow, SIGNAL(valueChanged(int)), plannerModel, SLOT(setGFLow(int)));
 	connect(ui.backgasBreaks, SIGNAL(toggled(bool)), this, SLOT(setBackgasBreaks(bool)));
 
-	ui.bottomSAC->setValue(20);
-	ui.decoStopSAC->setValue(17);
+	ui.bottomSAC->setValue(prefs.bottomsac / 1000.0);
+	ui.decoStopSAC->setValue(prefs.decosac / 1000.0);
 	ui.gflow->setValue(prefs.gflow);
 	ui.gfhigh->setValue(prefs.gfhigh);
 
@@ -431,6 +435,9 @@ PlannerSettingsWidget::~PlannerSettingsWidget()
 	s.setValue("bottompo2", prefs.bottompo2);
 	s.setValue("decopo2", prefs.decopo2);
 	s.setValue("doo2breaks", prefs.doo2breaks);
+	s.setValue("drop_stone_mode", prefs.drop_stone_mode);
+	s.setValue("bottomsac", prefs.bottomsac);
+	s.setValue("decosac", prefs.decosac);
 	s.endGroup();
 }
 
@@ -669,12 +676,14 @@ void DivePlannerPointsModel::emitDataChanged()
 void DivePlannerPointsModel::setBottomSac(int sac)
 {
 	diveplan.bottomsac = sac * 1000;
+	prefs.bottomsac = diveplan.bottomsac;
 	emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
 }
 
 void DivePlannerPointsModel::setDecoSac(int sac)
 {
 	diveplan.decosac = sac * 1000;
+	prefs.decosac = diveplan.decosac;
 	emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
 }
 
diff --git a/subsurfacestartup.c b/subsurfacestartup.c
index 1af6851..29d3ddd 100644
--- a/subsurfacestartup.c
+++ b/subsurfacestartup.c
@@ -42,6 +42,8 @@ struct preferences default_prefs = {
 	.decopo2 = 1600,
 	.doo2breaks = false,
 	.drop_stone_mode = false,
+	.bottomsac = 20,
+	.decosac = 17,
 	.show_pictures_in_profile = true
 };
 
-- 
2.0.1

_______________________________________________
subsurface mailing list
[email protected]
http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to