summaryrefslogtreecommitdiffstats
path: root/mobile-widgets
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2017-07-24 21:15:23 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-07-28 07:31:11 -0700
commit50f42cfdef3e77ad912869af931d0796655368df (patch)
tree725820ed049c31eed8240557a68be66db09606d7 /mobile-widgets
parent5ea702199bba685e78c9592b4016dc3afed12833 (diff)
downloadsubsurface-50f42cfdef3e77ad912869af931d0796655368df.tar.gz
mapwidgethelper: obtain a list of nearby dives
Based on a current location (MapLocation), iterate the dive list and add nearby dives (distance smaller than m_smallCircleRadius) to a local QList property (m_selectedDiveIds). Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'mobile-widgets')
-rw-r--r--mobile-widgets/qmlmapwidgethelper.cpp17
-rw-r--r--mobile-widgets/qmlmapwidgethelper.h1
2 files changed, 17 insertions, 1 deletions
diff --git a/mobile-widgets/qmlmapwidgethelper.cpp b/mobile-widgets/qmlmapwidgethelper.cpp
index 27505d192..415cc2483 100644
--- a/mobile-widgets/qmlmapwidgethelper.cpp
+++ b/mobile-widgets/qmlmapwidgethelper.cpp
@@ -59,7 +59,22 @@ void MapWidgetHelper::reloadMapLocations()
void MapWidgetHelper::selectedLocationChanged(MapLocation *location)
{
- qDebug() << location;
+ int idx;
+ struct dive *dive;
+ m_selectedDiveIds.clear();
+ QGeoCoordinate locationCoord = qvariant_cast<QGeoCoordinate>(location->getRole(MapLocation::Roles::RoleCoordinate));
+ for_each_dive (idx, dive) {
+ struct dive_site *ds = get_dive_site_for_dive(dive);
+ if (!dive_site_has_gps_location(ds))
+ continue;
+ const qreal latitude = ds->latitude.udeg * 0.000001;
+ const qreal longitude = ds->longitude.udeg * 0.000001;
+ QGeoCoordinate dsCoord(latitude, longitude);
+ if (locationCoord.distanceTo(dsCoord) < m_smallCircleRadius)
+ m_selectedDiveIds.append(idx);
+ }
+
+ qDebug() << "selectedDiveIds:" << m_selectedDiveIds;
}
/*
diff --git a/mobile-widgets/qmlmapwidgethelper.h b/mobile-widgets/qmlmapwidgethelper.h
index d5cf669fc..514a52161 100644
--- a/mobile-widgets/qmlmapwidgethelper.h
+++ b/mobile-widgets/qmlmapwidgethelper.h
@@ -27,6 +27,7 @@ private:
QObject *m_map;
MapLocationModel *m_mapLocationModel;
qreal m_smallCircleRadius;
+ QList<int> m_selectedDiveIds;
private slots:
void selectedLocationChanged(MapLocation *);