Skip to content

Commit

Permalink
map-widget: add support for filtering of map locations
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
neolit123 authored and bstoeger committed Aug 18, 2018
1 parent 7cf0589 commit b4f1055
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions map-widget/qmlmapwidgethelper.cpp
Expand Up @@ -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)) {
Expand All @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit b4f1055

Please sign in to comment.