aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-27 23:19:49 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-27 23:19:49 -0700
commit65babff6bcc43f3a28e107caee12024209c31010 (patch)
tree4f1149a386c559f55396079722568ef3fb5bc743
parent3d8f884abbf953f4399511cbd4a79bfbbdfc8db0 (diff)
downloadsubsurface-65babff6bcc43f3a28e107caee12024209c31010.tar.gz
Dive site rewrite: be smarter when dealing with auto created sites
If we download dive site locations from the companion app we can be slightly smarter if the user overwrite the location feel on the Notes tab. We can be pretty sure that they wanted to keep the GPS location and just correct the dive site name (or possibly assign that location to an existing dive site). This tries to accomplish that. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/maintab.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index f44d850c6..d60e22a79 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -1352,6 +1352,12 @@ void MainTab::on_location_editingFinished()
if (!found) {
uint32_t uuid = create_dive_site(qPrintable(ui.location->text()));
+ ds = get_dive_site_by_uuid(uuid);
+ if (same_string(displayed_dive_site.notes, "SubsurfaceWebservice")) {
+ ds->latitude = displayed_dive_site.latitude;
+ ds->longitude = displayed_dive_site.longitude;
+ delete_dive_site(displayed_dive_site.uuid);
+ }
displayed_dive.dive_site_uuid = uuid;
copy_dive_site(get_dive_site_by_uuid(uuid), &displayed_dive_site);
markChangedWidget(ui.location);
@@ -1371,6 +1377,12 @@ void MainTab::on_location_editingFinished()
if(ds_from_dive && ui.location->text() == ds_from_dive->name)
return;
ds_from_dive = get_dive_site(idx);
+ if (!dive_site_has_gps_location(ds_from_dive) &&
+ same_string(displayed_dive_site.notes, "SubsurfaceWebservice")) {
+ ds_from_dive->latitude = displayed_dive_site.latitude;
+ ds_from_dive->longitude = displayed_dive_site.longitude;
+ delete_dive_site(displayed_dive_site.uuid);
+ }
displayed_dive.dive_site_uuid = ds_from_dive->uuid;
copy_dive_site(get_dive_site_by_uuid(ds_from_dive->uuid), &displayed_dive_site);
markChangedWidget(ui.location);