summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/command_edit.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-04-24 23:59:59 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-05-11 12:35:11 -0700
commitbab7033ccba8840eb661feed0750e60404d06fc0 (patch)
treecbabc793980bc844e4d36a88234eb46034d1648f /desktop-widgets/command_edit.cpp
parentc529cfd361365d3440823efe289a68af6310a983 (diff)
downloadsubsurface-bab7033ccba8840eb661feed0750e60404d06fc0.tar.gz
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 <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/command_edit.cpp')
-rw-r--r--desktop-widgets/command_edit.cpp8
1 files changed, 8 insertions, 0 deletions
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;
}