With a better explanation and more separation between them.
From 0f50f03bf85828553e0cdd9f233ade1edaefc102 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Wed, 21 May 2014 11:24:22 -0300
Subject: [PATCH 1/5] Fix compilation with CMake.

This changes are only to make CMake compile again after the
addition of the export dialog.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 CMakeLists.txt | 1 +
 qthelper.cpp   | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 153f8d6..ef58bbf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -136,6 +136,7 @@ SET(SUBSURFACE_INTERFACE
 	qt-ui/tagwidget.cpp
 	qt-ui/groupedlineedit.cpp
 	qt-ui/usermanual.cpp
+	qt-ui/divelogexportdialog.cpp
 )
 
 #the profile widget
diff --git a/qthelper.cpp b/qthelper.cpp
index 101530d..b2baedc 100644
--- a/qthelper.cpp
+++ b/qthelper.cpp
@@ -6,7 +6,6 @@
 #include <QDebug>
 #include <QSettings>
 #include <libxslt/documents.h>
-#include "mainwindow.h"
 
 #define tr(_arg) QObject::tr(_arg)
 
-- 
1.9.3

From 79f3db466778c6c912ca8c2f63acba67c37a67ea Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Wed, 21 May 2014 12:06:02 -0300
Subject: [PATCH 2/5] Create a 'remove_event' function that removes an event.

The logic of removing the event was in the UI, and this makes
the code harder to test because we need to take into account
also the events that the interface is receiving, instead of
only relying on the algorithm to test.

so, now it lives in dive.h/.c and a unittest is easyer to make.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 dive.c                           | 11 +++++++++++
 dive.h                           |  1 +
 qt-ui/profile/profilewidget2.cpp |  8 +-------
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/dive.c b/dive.c
index d9943c2..7e211f1 100644
--- a/dive.c
+++ b/dive.c
@@ -65,6 +65,17 @@ void add_event(struct divecomputer *dc, int time, int type, int flags, int value
 	remember_event(name);
 }
 
+void remove_event(struct event* event)
+{
+	struct event **ep = &current_dc->events;
+	while (ep && *ep != event)
+		ep = &(*ep)->next;
+	if (ep) {
+		*ep = event->next;
+		free(event);
+	}
+}
+
 int get_pressure_units(unsigned int mb, const char **units)
 {
 	int pressure;
diff --git a/dive.h b/dive.h
index a4bc7f0..11a724c 100644
--- a/dive.h
+++ b/dive.h
@@ -562,6 +562,7 @@ extern void copy_samples(struct dive *s, struct dive *d);
 extern void fill_default_cylinder(cylinder_t *cyl);
 extern void add_gas_switch_event(struct dive *dive, struct divecomputer *dc, int time, int idx);
 extern void add_event(struct divecomputer *dc, int time, int type, int flags, int value, const char *name);
+extern void remove_event(struct event* event);
 extern void per_cylinder_mean_depth(struct dive *dive, struct divecomputer *dc, int *mean, int *duration);
 extern int get_cylinder_index(struct dive *dive, struct event *ev);
 extern int nr_cylinders(struct dive *dive);
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index d95a32b..4a599d7 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -830,13 +830,7 @@ void ProfileWidget2::removeEvent()
 							      tr("Remove the selected event?"),
 							      tr("%1 @ %2:%3").arg(event->name).arg(event->time.seconds / 60).arg(event->time.seconds % 60, 2, 10, QChar('0'))),
 				  QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) {
-		struct event **ep = &current_dc->events;
-		while (ep && *ep != event)
-			ep = &(*ep)->next;
-		if (ep) {
-			*ep = event->next;
-			free(event);
-		}
+		remove_event(event);
 		mark_divelist_changed(true);
 		replot();
 	}
-- 
1.9.3

From 16465b156e1734a4eaf99154e771667d7df91fb3 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Wed, 21 May 2014 12:18:05 -0300
Subject: [PATCH 3/5] Code Cleanup: Move the Hide/Show ruler to an internal
 method

By moving the Hide/Show of the ruler to an internal method,
we gain a bit of codecleanuperism by removing a lot of une
cessary calls to their dest and source drag-handlers.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/profile/profilewidget2.cpp | 10 ----------
 qt-ui/profile/ruleritem.cpp      |  9 +++++++++
 qt-ui/profile/ruleritem.h        |  2 +-
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 4a599d7..306ee2c 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -364,8 +364,6 @@ void ProfileWidget2::plotDives(QList<dive *> dives)
 	s.beginGroup("TecDetails");
 	const bool rulerVisible = s.value("rulergraph", false).toBool() && !printMode;
 	rulerItem->setVisible(rulerVisible);
-	rulerItem->sourceNode()->setVisible(rulerVisible);
-	rulerItem->destNode()->setVisible(rulerVisible);
 
 	// No need to do this again if we are already showing the same dive
 	// computer of the same dive, so we check the unique id of the dive
@@ -507,13 +505,9 @@ void ProfileWidget2::settingsChanged()
 
 	if (currentState == PROFILE) {
 		rulerItem->setVisible(prefs.rulergraph);
-		rulerItem->destNode()->setVisible(prefs.rulergraph);
-		rulerItem->sourceNode()->setVisible(prefs.rulergraph);
 		needReplot = true;
 	} else {
 		rulerItem->setVisible(false);
-		rulerItem->destNode()->setVisible(false);
-		rulerItem->sourceNode()->setVisible(false);
 	}
 	if (needReplot)
 		replot();
@@ -617,8 +611,6 @@ void ProfileWidget2::setEmptyState()
 	diveCeiling->setVisible(false);
 	reportedCeiling->setVisible(false);
 	rulerItem->setVisible(false);
-	rulerItem->destNode()->setVisible(false);
-	rulerItem->sourceNode()->setVisible(false);
 	pn2GasItem->setVisible(false);
 	po2GasItem->setVisible(false);
 	pheGasItem->setVisible(false);
@@ -691,8 +683,6 @@ void ProfileWidget2::setProfileState()
 	s.beginGroup("TecDetails");
 	bool rulerVisible = s.value("rulergraph", false).toBool();
 	rulerItem->setVisible(rulerVisible);
-	rulerItem->destNode()->setVisible(rulerVisible);
-	rulerItem->sourceNode()->setVisible(rulerVisible);
 }
 
 extern struct ev_select *ev_namelist;
diff --git a/qt-ui/profile/ruleritem.cpp b/qt-ui/profile/ruleritem.cpp
index 768d912..1c52c6e 100644
--- a/qt-ui/profile/ruleritem.cpp
+++ b/qt-ui/profile/ruleritem.cpp
@@ -157,3 +157,12 @@ void RulerItem2::setAxis(DiveCartesianAxis *time, DiveCartesianAxis *depth)
 	source->timeAxis = time;
 	recalculate();
 }
+
+void RulerItem2::setVisible(bool visible)
+{
+	QGraphicsLineItem::setVisible(visible);
+	if (source)
+		source->setVisible(visible);
+	if (dest)
+		dest->setVisible(visible);
+}
diff --git a/qt-ui/profile/ruleritem.h b/qt-ui/profile/ruleritem.h
index 7bfc63e..d00e345 100644
--- a/qt-ui/profile/ruleritem.h
+++ b/qt-ui/profile/ruleritem.h
@@ -40,7 +40,7 @@ public:
 	RulerNodeItem2 *sourceNode() const;
 	RulerNodeItem2 *destNode() const;
 	void setAxis(DiveCartesianAxis *time, DiveCartesianAxis *depth);
-
+	void setVisible(bool visible);
 private:
 	struct plot_info pInfo;
 	QPointF startPoint, endPoint;
-- 
1.9.3

From a56433cc13bd2cf1208bd12aee00046a9d56c12e Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Wed, 21 May 2014 12:57:48 -0300
Subject: [PATCH 4/5] Removed use of QSettings for ruler visibility, use
 prefs.rulergraph instead.

The QSettings is a bit bloated on it's use, so we are trying to narrow
down the amount of calls to it. We have a preferences struct, use that
instead.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/profile/profilewidget2.cpp | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 306ee2c..d222ad9 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -21,7 +21,6 @@
 #include <QMenu>
 #include <QContextMenuEvent>
 #include <QDebug>
-#include <QSettings>
 #include <QScrollBar>
 #include <QtCore/qmath.h>
 #include <QMessageBox>
@@ -360,10 +359,7 @@ void ProfileWidget2::plotDives(QList<dive *> dives)
 
 	// reset some item visibility on printMode changes
 	toolTipItem->setVisible(!printMode);
-	QSettings s;
-	s.beginGroup("TecDetails");
-	const bool rulerVisible = s.value("rulergraph", false).toBool() && !printMode;
-	rulerItem->setVisible(rulerVisible);
+	rulerItem->setVisible(prefs.rulergraph && !printMode);
 
 	// No need to do this again if we are already showing the same dive
 	// computer of the same dive, so we check the unique id of the dive
@@ -679,10 +675,7 @@ void ProfileWidget2::setProfileState()
 			tissue->setVisible(true);
 		}
 	}
-	QSettings s;
-	s.beginGroup("TecDetails");
-	bool rulerVisible = s.value("rulergraph", false).toBool();
-	rulerItem->setVisible(rulerVisible);
+	rulerItem->setVisible(prefs.rulergraph);
 }
 
 extern struct ev_select *ev_namelist;
-- 
1.9.3

From be0569ddd7e32c48de953fe77a3c50bf00d31b55 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Wed, 21 May 2014 13:00:16 -0300
Subject: [PATCH 5/5] Don't replot everytime a pref changes, regardless of what
 preferences.

The list of preferences that should trigger a full repaint are on the
top of this method, *if* this introduces a bug is because some of the
preferences are not being correctly triagged yet and it needs to be
fixed.  Regardless of that, now the profile will only enable / disables
the *ruler* instead of repplotting everything.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/profile/profilewidget2.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index d222ad9..fbbf3df 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -501,7 +501,6 @@ void ProfileWidget2::settingsChanged()
 
 	if (currentState == PROFILE) {
 		rulerItem->setVisible(prefs.rulergraph);
-		needReplot = true;
 	} else {
 		rulerItem->setVisible(false);
 	}
-- 
1.9.3

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

Reply via email to