summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2017-11-25 23:06:26 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2017-11-27 22:59:22 +0100
commitb564debe211d6e046e4265414efe1ddf8ffda861 (patch)
tree1e38b87fba53af5911282194cbe1e845e9a4839b
parentd9cfcae88bc7188ba94f62ef2e146e9b19406534 (diff)
downloadsubsurface-b564debe211d6e046e4265414efe1ddf8ffda861.tar.gz
map-widget: start dive site editing with coords pre-entered
Once the user starts editing a dive site, make sure to pass coordinates of either the current map center (if a new MapLocation is being added) or the coordinates of the existing MapLocation. The "Dive site management" coordinates text field would receive these new coordinates after the displayed_dive_site struct is updated and the coordinatesChanged() signal is emitted. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
-rw-r--r--map-widget/qmlmapwidgethelper.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/map-widget/qmlmapwidgethelper.cpp b/map-widget/qmlmapwidgethelper.cpp
index e900debf1..d9d6312a7 100644
--- a/map-widget/qmlmapwidgethelper.cpp
+++ b/map-widget/qmlmapwidgethelper.cpp
@@ -238,11 +238,19 @@ void MapWidgetHelper::setEditMode(bool editMode)
{
m_editMode = editMode;
MapLocation *exists = m_mapLocationModel->getMapLocationForUuid(displayed_dive_site.uuid);
- // if divesite uuid doesn't exist in the model, add a new MapLocation.
- if (editMode && !exists) {
- QGeoCoordinate coord = m_map->property("center").value<QGeoCoordinate>();
- m_mapLocationModel->add(new MapLocation(displayed_dive_site.uuid, coord,
- QString(displayed_dive_site.name)));
+ if (editMode) {
+ QGeoCoordinate coord;
+ // if divesite uuid doesn't exist in the model, add a new MapLocation.
+ if (!exists) {
+ coord = m_map->property("center").value<QGeoCoordinate>();
+ m_mapLocationModel->add(new MapLocation(displayed_dive_site.uuid, coord,
+ QString(displayed_dive_site.name)));
+ } else {
+ coord = exists->coordinate();
+ }
+ displayed_dive_site.latitude.udeg = lrint(coord.latitude() * 1000000.0);
+ displayed_dive_site.longitude.udeg = lrint(coord.longitude() * 1000000.0);
+ emit coordinatesChanged();
}
emit editModeChanged();
}