From 7c99b3a76fc2d257b5d89f271154cf4b91574d0c Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Thu, 2 May 2019 21:44:05 +0200 Subject: Map: don't update map-selection in centerOnSelectedDiveSite() To detangle this code a little bit, let centerOnSelectedDiveSite() just do what is says: center on the selected dive sites. Don't update the selected dive site by calling MapLocationModel::setSelected(). Signed-off-by: Berthold Stoeger --- map-widget/qmlmapwidgethelper.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/map-widget/qmlmapwidgethelper.cpp b/map-widget/qmlmapwidgethelper.cpp index f00105f04..57ad01ad5 100644 --- a/map-widget/qmlmapwidgethelper.cpp +++ b/map-widget/qmlmapwidgethelper.cpp @@ -63,14 +63,13 @@ void MapWidgetHelper::centerOnSelectedDiveSite() if (selDS.isEmpty()) { // no selected dives with GPS coordinates - m_mapLocationModel->setSelected(nullptr, false); QMetaObject::invokeMethod(m_map, "deselectMapLocation"); } else if (selDS.size() == 1) { - centerOnDiveSite(selDS[0]); - } else if (selDS.size() > 1) { + QGeoCoordinate dsCoord (selDS[0]->location.lat.udeg * 0.000001, selDS[0]->location.lon.udeg * 0.000001); + QMetaObject::invokeMethod(m_map, "centerOnCoordinate", Q_ARG(QVariant, QVariant::fromValue(dsCoord))); + } else { /* more than one dive sites with GPS selected. * find the most top-left and bottom-right dive sites on the map coordinate system. */ - m_mapLocationModel->setSelected(selDS[0], false); qreal minLat = 0.0, minLon = 0.0, maxLat = 0.0, maxLon = 0.0; bool start = true; for(struct dive_site *dss: selDS) { -- cgit v1.2.3-70-g09d2