mapwidgethelper: pass a MapLocation object to QML in centerOnDiveSite()

The function in QML centerOnCoordinate() is now renamed
centerOnMapLocation() and accepts a MapLocation object, so that
a marker is selected (based on UUID).

In MapWidgetHelper::centerOnDiveSite(), the pointer to a MapLocation
is retrieved via MapLocationModel::getMapLocationForUuid(). Added in the
previous commit.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
Lubomir I. Ivanov 2017-07-19 03:06:40 +03:00 committed by Dirk Hohndel
parent 4a126b553f
commit b4740803a1
2 changed files with 5 additions and 7 deletions

View file

@ -70,10 +70,11 @@ Item {
}
}
function centerOnCoordinate(coordinate) {
map.newCenter = coordinate;
function centerOnMapLocation(mapLocation) {
map.newCenter = mapLocation.coordinate;
map.zoomLevel = 2;
mapAnimation.restart();
mapHelper.model.selectedUuid = mapLocation.uuid;
}
}
}

View file

@ -17,11 +17,8 @@ void MapWidgetHelper::centerOnDiveSite(struct dive_site *ds)
{
if (!dive_site_has_gps_location(ds))
return;
qreal longitude = ds->longitude.udeg / 1000000.0;
qreal latitude = ds->latitude.udeg / 1000000.0;
QVariant coord = QVariant::fromValue(QGeoCoordinate(latitude, longitude));
QMetaObject::invokeMethod(m_map, "centerOnCoordinate", Q_ARG(QVariant, coord));
MapLocation *location = m_mapLocationModel->getMapLocationForUuid(ds->uuid);
QMetaObject::invokeMethod(m_map, "centerOnMapLocation", Q_ARG(QVariant, QVariant::fromValue(location)));
}
void MapWidgetHelper::reloadMapLocations()