From 0da86dfd8601edd33c47c787d42e4a687fff8aaf Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Wed, 8 May 2019 22:15:01 +0200 Subject: Map: in edit mode place no-gps dive sites at center of map Move the code to add the first selected dive site from MapWidgetHelper::enterEditMode() to MapLocationModel::reload(). Thus, the list of sites is built only at one place. For this it is necessary to pass a pointer to the map, so that new dive sites can be added at the center of the map. Signed-off-by: Berthold Stoeger --- map-widget/qmlmapwidgethelper.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'map-widget') diff --git a/map-widget/qmlmapwidgethelper.cpp b/map-widget/qmlmapwidgethelper.cpp index a7ef00bf8..9aba7f27a 100644 --- a/map-widget/qmlmapwidgethelper.cpp +++ b/map-widget/qmlmapwidgethelper.cpp @@ -100,7 +100,7 @@ void MapWidgetHelper::reloadMapLocations() else exitEditMode(); #endif - m_mapLocationModel->reload(); + m_mapLocationModel->reload(m_map); } void MapWidgetHelper::selectedLocationChanged(MapLocation *location) @@ -239,14 +239,6 @@ void MapWidgetHelper::enterEditMode() return; m_editMode = true; - // if divesite of the first selected dive doesn't exist in the model, add a new MapLocation. - const QVector selDs = m_mapLocationModel->selectedDs(); - if (!selDs.isEmpty() && ! m_mapLocationModel->getMapLocation(selDs[0])) { - // If the dive site doesn't have a GPS location, use the centre of the map - QGeoCoordinate coord = has_location(&selDs[0]->location) ? getCoordinates(selDs[0]) - : m_map->property("center").value(); - m_mapLocationModel->add(new MapLocation(selDs[0], coord, QString(selDs[0]->name))); - } emit editModeChanged(); } -- cgit v1.2.3-70-g09d2