From b4f10553cc9f426597e45c282e01e4bd37e3a0e7 Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Fri, 17 Aug 2018 20:37:30 +0300 Subject: map-widget: add support for filtering of map locations If the dive list is filtered the map should hide dive locations that do not match the dive list filter. To achieve that, loop over dives instead of dive sites in MapWidgetHelper::reloadMapLocations() and discard dives that are hidden by the filter. Then check if a dive has a dive site attached to it and re-use the old functionality. Suggested-by: Willem Ferguson Signed-off-by: Lubomir I. Ivanov --- map-widget/qmlmapwidgethelper.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'map-widget/qmlmapwidgethelper.cpp') diff --git a/map-widget/qmlmapwidgethelper.cpp b/map-widget/qmlmapwidgethelper.cpp index 76a3f5097..0b1f7cb2a 100644 --- a/map-widget/qmlmapwidgethelper.cpp +++ b/map-widget/qmlmapwidgethelper.cpp @@ -116,12 +116,13 @@ void MapWidgetHelper::centerOnDiveSite(struct dive_site *ds) void MapWidgetHelper::reloadMapLocations() { - struct dive_site *ds; int idx; + struct dive *dive; QMap locationNameMap; m_mapLocationModel->clear(); MapLocation *location; QVector locationList; + QVector locationUuids; qreal latitude, longitude; if (displayed_dive_site.uuid && dive_site_has_gps_location(&displayed_dive_site)) { @@ -132,8 +133,11 @@ void MapWidgetHelper::reloadMapLocations() locationList.append(location); locationNameMap[QString(displayed_dive_site.name)] = location; } - for_each_dive_site(idx, ds) { - if (!dive_site_has_gps_location(ds) || ds->uuid == displayed_dive_site.uuid) + for_each_dive(idx, dive) { + if (dive->hidden_by_filter) + continue; + struct dive_site *ds = get_dive_site_for_dive(dive); + if (!dive_site_has_gps_location(ds) || ds->uuid == displayed_dive_site.uuid || locationUuids.contains(ds->uuid)) continue; latitude = ds->latitude.udeg * 0.000001; longitude = ds->longitude.udeg * 0.000001; @@ -149,6 +153,7 @@ void MapWidgetHelper::reloadMapLocations() } location = new MapLocation(ds->uuid, dsCoord, name); locationList.append(location); + locationUuids.append(ds->uuid); locationNameMap[name] = location; } m_mapLocationModel->addList(locationList); -- cgit v1.2.3-70-g09d2