summaryrefslogtreecommitdiffstats
path: root/map-widget/qmlmapwidgethelper.cpp
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2018-03-08 21:43:23 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-03-11 11:40:12 -0700
commitfbbb6ba4fb748eace8d8f8674ec799813012cf0f (patch)
treeb85f9dc3aceae7365884e15d1766e60f5ce36941 /map-widget/qmlmapwidgethelper.cpp
parent8fa2295a6174a0cc0cd86a0aea0420eb453bdd63 (diff)
downloadsubsurface-fbbb6ba4fb748eace8d8f8674ec799813012cf0f.tar.gz
qmapwidgethelper: make adjustmets for the mobile version
The mobile version is limited as it does not support dive list selection of multiple dives and editing multiple dives. Also the dive list on mobile does not follow the same indexing as the desktop version dive list. Use the SUBSURFACE_MOBILE macro and for: - centerOnDiveSite() either deselect map markers or center on a single one (never on a rectangle like the desktop version) - selectedLocationChanged() and selectVisibleLocations() return a list of single dive ID Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'map-widget/qmlmapwidgethelper.cpp')
-rw-r--r--map-widget/qmlmapwidgethelper.cpp38
1 files changed, 36 insertions, 2 deletions
diff --git a/map-widget/qmlmapwidgethelper.cpp b/map-widget/qmlmapwidgethelper.cpp
index 6046d08cc..e8187a679 100644
--- a/map-widget/qmlmapwidgethelper.cpp
+++ b/map-widget/qmlmapwidgethelper.cpp
@@ -33,12 +33,15 @@ void MapWidgetHelper::centerOnDiveSiteUUID(QVariant dive_site_uuid)
void MapWidgetHelper::centerOnDiveSite(struct dive_site *ds)
{
- int idx;
- struct dive *dive;
QVector<struct dive_site *> selDS;
QVector<QGeoCoordinate> selGC;
QGeoCoordinate dsCoord;
+// selection of multiple dives is only possible on the desktop.
+// in the case of the mobile version only handle the passed dive_site.
+#ifndef SUBSURFACE_MOBILE
+ int idx;
+ struct dive *dive;
for_each_dive (idx, dive) {
struct dive_site *dss = get_dive_site_for_dive(dive);
if (!dive_site_has_gps_location(dss) || !dive->selected)
@@ -48,6 +51,13 @@ void MapWidgetHelper::centerOnDiveSite(struct dive_site *ds)
selGC.append(QGeoCoordinate(dss->latitude.udeg * 0.000001,
dss->longitude.udeg * 0.000001));
}
+#else
+ if (dive_site_has_gps_location(ds)) {
+ selDS.append(ds);
+ selGC.append(QGeoCoordinate(ds->latitude.udeg * 0.000001,
+ ds->longitude.udeg * 0.000001));
+ }
+#endif
if (!dive_site_has_gps_location(ds) && !selDS.size()) {
// only a single dive site with no GPS selected
m_mapLocationModel->setSelectedUuid(ds ? ds->uuid : 0, false);
@@ -146,12 +156,24 @@ void MapWidgetHelper::selectedLocationChanged(MapLocation *location)
struct dive_site *ds = get_dive_site_for_dive(dive);
if (!dive_site_has_gps_location(ds))
continue;
+#ifndef SUBSURFACE_MOBILE
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);
}
+#else // the mobile version doesn't support multi-dive selection
+ if (ds->uuid == location->uuid())
+ m_selectedDiveIds.append(dive->id); // use id here instead of index
+ }
+ int last; // get latest dive chronologically
+ if (!m_selectedDiveIds.isEmpty()) {
+ last = m_selectedDiveIds.last();
+ m_selectedDiveIds.clear();
+ m_selectedDiveIds.append(last);
+ }
+#endif
emit selectedDivesChanged(m_selectedDiveIds);
}
@@ -176,9 +198,21 @@ void MapWidgetHelper::selectVisibleLocations()
m_mapLocationModel->setSelectedUuid(ds->uuid, false);
selectedFirst = true;
}
+#ifndef SUBSURFACE_MOBILE // indexes on desktop
m_selectedDiveIds.append(idx);
}
}
+#else // use id on mobile instead of index
+ m_selectedDiveIds.append(dive->id);
+ }
+ }
+ int last; // get latest dive chronologically
+ if (!m_selectedDiveIds.isEmpty()) {
+ last = m_selectedDiveIds.last();
+ m_selectedDiveIds.clear();
+ m_selectedDiveIds.append(last);
+ }
+#endif
emit selectedDivesChanged(m_selectedDiveIds);
}