map-widget: use current center when editing new markers

When starting to edit a new dive location, create
a marker at the current map center instead of zooming
out and centering on the 0,0 coordinate.

This will help (and speed up) a lot the edition,
if the user needs to add numerous dive markers
at a specific location close to each other.

refs #754

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
Lubomir I. Ivanov 2017-11-09 16:11:13 +02:00 committed by Dirk Hohndel
parent 9771255919
commit 89ccdc3178

View file

@ -231,11 +231,9 @@ void MapWidgetHelper::setEditMode(bool 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(0.0, 0.0);
QGeoCoordinate coord = m_map->property("center").value<QGeoCoordinate>();
m_mapLocationModel->add(new MapLocation(displayed_dive_site.uuid, coord,
QString(displayed_dive_site.name)));
QMetaObject::invokeMethod(m_map, "centerOnCoordinate",
Q_ARG(QVariant, QVariant::fromValue(coord)));
}
emit editModeChanged();
}