diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2017-08-07 02:58:19 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-08-07 00:51:21 -0700 |
commit | 93896e54dbd9ab5d82c72516ea1acaa8d63710e1 (patch) | |
tree | 5f91cbec3ae8f1f9dbc63fea197bb522f0042592 /mobile-widgets/qmlmapwidgethelper.cpp | |
parent | 5db24601689d5c3827a8b12c50c2cbfdf53f48da (diff) | |
download | subsurface-93896e54dbd9ab5d82c72516ea1acaa8d63710e1.tar.gz |
mapwidgethelper: add the selectVisibleLocations() method
The new method selectVisibleLocations() contains a routine
to find all visible MapLocation objects in the Map viewport and
select the dives associated to said MapLocation objects.
This method is to be invoked from the QML context menu.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'mobile-widgets/qmlmapwidgethelper.cpp')
-rw-r--r-- | mobile-widgets/qmlmapwidgethelper.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/mobile-widgets/qmlmapwidgethelper.cpp b/mobile-widgets/qmlmapwidgethelper.cpp index 954a83ebf..1b9c9a909 100644 --- a/mobile-widgets/qmlmapwidgethelper.cpp +++ b/mobile-widgets/qmlmapwidgethelper.cpp @@ -144,6 +144,33 @@ void MapWidgetHelper::selectedLocationChanged(MapLocation *location) emit selectedDivesChanged(m_selectedDiveIds); } +void MapWidgetHelper::selectVisibleLocations() +{ + int idx; + struct dive *dive; + bool selectedFirst = false; + m_selectedDiveIds.clear(); + for_each_dive (idx, dive) { + struct dive_site *ds = get_dive_site_for_dive(dive); + if (!dive_site_has_gps_location(ds)) + continue; + MapLocation *loc = m_mapLocationModel->getMapLocationForUuid(ds->uuid); + if (loc) { + QPointF point; + QMetaObject::invokeMethod(m_map, "fromCoordinate", Q_RETURN_ARG(QPointF, point), + Q_ARG(QGeoCoordinate, loc->coordinate())); + if (!qIsNaN(point.x())) { + if (!selectedFirst) { + m_mapLocationModel->setSelectedUuid(ds->uuid, false); + selectedFirst = true; + } + m_selectedDiveIds.append(idx); + } + } + } + emit selectedDivesChanged(m_selectedDiveIds); +} + /* * Based on a 2D Map widget circle with center "coord" and radius SMALL_CIRCLE_RADIUS_PX, * obtain a "small circle" with radius m_smallCircleRadius in meters: |