From b564debe211d6e046e4265414efe1ddf8ffda861 Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Sat, 25 Nov 2017 23:06:26 +0200 Subject: 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 --- map-widget/qmlmapwidgethelper.cpp | 18 +++++++++++++----- 1 file 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(); - 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(); + 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(); } -- cgit v1.2.3-70-g09d2