From 53c9d524ca7038e2cb8a510ede9e3aea9648a326 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 1 Apr 2019 22:42:07 +0200 Subject: Map: Use proper location for flag when editing dive site When the dive site was not on the map because it had no dives, entering dive site edit mode would place the map at the center of the map, not at the location of the dive site. Use the location of the dive site unless it has no location. In that case use the map center. Signed-off-by: Berthold Stoeger --- map-widget/qmlmapwidgethelper.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'map-widget') diff --git a/map-widget/qmlmapwidgethelper.cpp b/map-widget/qmlmapwidgethelper.cpp index a0062db6b..aad201722 100644 --- a/map-widget/qmlmapwidgethelper.cpp +++ b/map-widget/qmlmapwidgethelper.cpp @@ -288,7 +288,9 @@ void MapWidgetHelper::enterEditMode(struct dive_site *ds) QGeoCoordinate coord; // if divesite doesn't exist in the model, add a new MapLocation. if (!exists) { - coord = m_map->property("center").value(); + // If the dive site doesn't have a GPS location, use the centre of the map + coord = has_location(&ds->location) ? getCoordinates(ds) + : m_map->property("center").value(); m_mapLocationModel->add(new MapLocation(ds, coord, QString(ds->name))); } else { coord = exists->coordinate(); -- cgit v1.2.3-70-g09d2