this patch fixes axis units.
while testing this I also found another bug that I'm trying to fix now:
the depth axis will stay the same, but the profile will update it's
size as if it was shrinked when a preference is changed.
From 700b9e1101823603ed08a96d0ee62e2b7e7dc300 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <tomaz.canabr...@intel.com>
Date: Tue, 29 Jul 2014 16:34:57 -0300
Subject: [PATCH] Change the Ruler text values when metric system changes.

"ups", as I did this in Metric system I forgot to update
to imperial when the user selected it.

Signed-off-by: Tomaz Canabrava <tomaz.canabr...@intel.com>
---
 qt-ui/profile/divecartesianaxis.cpp | 29 +++++++++++------------------
 qt-ui/profile/divecartesianaxis.h   |  3 ---
 qt-ui/profile/profilewidget2.cpp    |  1 -
 3 files changed, 11 insertions(+), 22 deletions(-)

diff --git a/qt-ui/profile/divecartesianaxis.cpp b/qt-ui/profile/divecartesianaxis.cpp
index f5123ae..be3e313 100644
--- a/qt-ui/profile/divecartesianaxis.cpp
+++ b/qt-ui/profile/divecartesianaxis.cpp
@@ -308,9 +308,9 @@ qreal DiveCartesianAxis::posAtValue(qreal value)
 	double retValue = realSize * percent;
 	double adjusted =
 		orientation == LeftToRight ? retValue + m.x1() + p.x() :
-					     orientation == RightToLeft ? retValue + m.x1() + p.x() :
-									  orientation == TopToBottom ? retValue + m.y1() + p.y() :
-												       /* entation == BottomToTop */ retValue + m.y1() + p.y();
+		orientation == RightToLeft ? retValue + m.x1() + p.x() :
+		orientation == TopToBottom ? retValue + m.y1() + p.y() :
+		/* entation == BottomToTop */ retValue + m.y1() + p.y();
 	return adjusted;
 }
 
@@ -365,28 +365,21 @@ static bool isPPGraphEnabled()
 	return prefs.pp_graphs.po2 || prefs.pp_graphs.pn2 || prefs.pp_graphs.phe;
 }
 
-DepthAxis::DepthAxis() : showWithPPGraph(false)
+DepthAxis::DepthAxis()
 {
 	connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged()));
-
-	// force the correct size of the line.
-	showWithPPGraph = !isPPGraphEnabled();
+	changed = true;
 	settingsChanged();
 }
 
 void DepthAxis::settingsChanged()
 {
-	// 	bool ppGraph = isPPGraphEnabled();
-	// 	if ( ppGraph == showWithPPGraph){
-	// 		return;
-	// 	}
-	//
-	// 	if (ppGraph) {
-	// 		animateChangeLine(shrinkedLine);
-	// 	} else {
-	// 		animateChangeLine(expandedLine);
-	// 	}
-	// 	showWithPPGraph = ppGraph;
+	static int unitSystem = prefs.units.length;
+	if ( unitSystem == prefs.units.length )
+		return;
+	changed = true;
+	updateTicks();
+	unitSystem = prefs.units.length;
 }
 
 QColor TimeAxis::colorForValue(double value)
diff --git a/qt-ui/profile/divecartesianaxis.h b/qt-ui/profile/divecartesianaxis.h
index e7fa68c..77e2697 100644
--- a/qt-ui/profile/divecartesianaxis.h
+++ b/qt-ui/profile/divecartesianaxis.h
@@ -83,9 +83,6 @@ protected:
 private
 slots:
 	void settingsChanged();
-
-private:
-	bool showWithPPGraph;
 };
 
 class TimeAxis : public DiveCartesianAxis {
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 6ec51e0..c1bdccd 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -450,7 +450,6 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
 	temperatureAxis->setMinimum(pInfo.mintemp);
 	temperatureAxis->setMaximum(pInfo.maxtemp);
 
-
 	if (pInfo.maxhr) {
 		heartBeatAxis->setMinimum(pInfo.minhr);
 		heartBeatAxis->setMaximum(pInfo.maxhr);
-- 
2.0.3

_______________________________________________
subsurface mailing list
subsurface@hohndel.org
http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to