mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
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>
This commit is contained in:
parent
5ea702199b
commit
50f42cfdef
2 changed files with 17 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -27,6 +27,7 @@ private:
|
|||
QObject *m_map;
|
||||
MapLocationModel *m_mapLocationModel;
|
||||
qreal m_smallCircleRadius;
|
||||
QList<int> m_selectedDiveIds;
|
||||
|
||||
private slots:
|
||||
void selectedLocationChanged(MapLocation *);
|
||||
|
|
Loading…
Reference in a new issue