From bab7033ccba8840eb661feed0750e60404d06fc0 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Wed, 24 Apr 2019 23:59:59 +0200 Subject: Dive site: create new dive site at location from GPS data Some dive computers save GPS data. Currently, this is stored by libdivecomputer in an "extra field". When generating a new dive site for a dive try to use this data to place the dive site. To do so, create a "dive_get_gps_location()" function. This function can be extended later to use e.g. event. When creating a dive site, use the result of this function over a potential pre-existing dive site. Signed-off-by: Berthold Stoeger --- desktop-widgets/command_edit.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'desktop-widgets/command_edit.cpp') diff --git a/desktop-widgets/command_edit.cpp b/desktop-widgets/command_edit.cpp index 31d34a89b..3419749d7 100644 --- a/desktop-widgets/command_edit.cpp +++ b/desktop-widgets/command_edit.cpp @@ -341,6 +341,14 @@ static struct dive_site *createDiveSite(const QString &name) copy_dive_site(old, ds); free(ds->name); // Free name, as we will overwrite it with our own version } + + // If the current dive has a location, use that as location for the new dive site + if (current_dive) { + location_t loc = dive_get_gps_location(current_dive); + if (has_location(&loc)) + ds->location = loc; + } + ds->name = copy_qstring(name); return ds; } -- cgit v1.2.3-70-g09d2