summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mobile-widgets/qmlmapwidgethelper.cpp27
-rw-r--r--mobile-widgets/qmlmapwidgethelper.h1
2 files changed, 28 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:
diff --git a/mobile-widgets/qmlmapwidgethelper.h b/mobile-widgets/qmlmapwidgethelper.h
index 6cba3dc91..830c8478f 100644
--- a/mobile-widgets/qmlmapwidgethelper.h
+++ b/mobile-widgets/qmlmapwidgethelper.h
@@ -24,6 +24,7 @@ public:
Q_INVOKABLE void copyToClipboardCoordinates(QGeoCoordinate coord, bool formatTraditional);
Q_INVOKABLE void calculateSmallCircleRadius(QGeoCoordinate coord);
Q_INVOKABLE void updateCurrentDiveSiteCoordinates(quint32 uuid, QGeoCoordinate coord);
+ Q_INVOKABLE void selectVisibleLocations();
bool editMode();
void setEditMode(bool editMode);