[2014-07-03 16:28:54 -0700] Dirk Hohndel:
> OK, there is one type that I like even better. The ones that come with a
> patch that has a commit message and a Signed-off-by: line :-)
> 
> Would you mind adding that?

Of course not!

And as an added bonus I'll add part of my email as commit message. :)

Cheers.

-- 
Gaetan
>From 18074c1f41b2b655dd14028c9d02f2e6175f3517 Mon Sep 17 00:00:00 2001
From: Gaetan Bisson <[email protected]>
Date: Thu, 3 Jul 2014 13:12:47 -1000
Subject: [PATCH] Autofill GPS coordinates for added dives.

Prior to commit 95cb4e, when a new dive was added with the same location
name as a previous dive, the GPS coordinates for that new dive would be
automatically set to that of the matching previous dive.

This restores this feature, by duplicating code further down
qt-ui/maintab.cpp that handles the case where multiple dives are
modified at once.

Signed-off-by: Gaetan Bisson <[email protected]>
---
 qt-ui/maintab.cpp | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 4495731..fda75e6 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -616,6 +616,25 @@ void MainTab::acceptChanges()
 		// we need to add the dive we just created to the dive list and select it.
 		// Easy, right?
 		struct dive *added_dive = clone_dive(&displayed_dive);
+
+		if (!same_string(added_dive->location, "") &&
+		     ui.coordinates->text().trimmed().isEmpty()) {
+			struct dive *dive;
+			int i = 0;
+			for_each_dive (i, dive) {
+				QString location(dive->location);
+				if (location == ui.location->text() &&
+				    (dive->latitude.udeg || dive->longitude.udeg)) {
+					if (same_string(added_dive->location, dive->location)) {
+						added_dive->latitude = dive->latitude;
+						added_dive->longitude = dive->longitude;
+					}
+					MainWindow::instance()->globe()->reload();
+					break;
+				}
+			}
+		}
+
 		record_dive(added_dive);
 		addedId = added_dive->id;
 		// unselect everything as far as the UI is concerned - we'll fix that below
-- 
2.0.1

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

Reply via email to