diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2018-08-17 20:37:30 +0300 |
---|---|---|
committer | bstoeger <32835590+bstoeger@users.noreply.github.com> | 2018-08-18 18:50:26 +0200 |
commit | b4f10553cc9f426597e45c282e01e4bd37e3a0e7 (patch) | |
tree | dc9ebd9b066c1405049abccf0f9ea27c3e0e37d3 | |
parent | 7cf05897a2c4ecccdfda2a3967b947f38441c5b6 (diff) | |
download | subsurface-b4f10553cc9f426597e45c282e01e4bd37e3a0e7.tar.gz |
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 <willemferguson@zoology.up.ac.za>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
-rw-r--r-- | map-widget/qmlmapwidgethelper.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
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<QString, MapLocation *> locationNameMap; m_mapLocationModel->clear(); MapLocation *location; QVector<MapLocation *> locationList; + QVector<uint32_t> 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); |