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 <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-04-01 22:42:07 +02:00 committed by Dirk Hohndel
parent 8c6205fc0d
commit 53c9d524ca

View file

@ -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<QGeoCoordinate>();
// 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<QGeoCoordinate>();
m_mapLocationModel->add(new MapLocation(ds, coord, QString(ds->name)));
} else {
coord = exists->coordinate();