From 75b5d61522f3721adb1761141ce1aeb79c3761c1 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Thu, 25 Oct 2018 20:46:12 +0200 Subject: Dive site: replace UUID by pointer in mobile code Replace UUIDs by pointers to dive-site in mobile code. In both cases, the value is transported via a QVariant. The function getCoordinatesForUUID(), which was only used from mobile, can be replaced by a getCoordinatesFor() function taking a variant supposed to contain a dive-site pointer. Likewise, the variant of the centerOnDiveSite function is now supposed to wrap a pointer-to-divesite. Signed-off-by: Berthold Stoeger --- map-widget/qmlmapwidgethelper.cpp | 10 ++++------ map-widget/qmlmapwidgethelper.h | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'map-widget') diff --git a/map-widget/qmlmapwidgethelper.cpp b/map-widget/qmlmapwidgethelper.cpp index e4311cf83..a4960608a 100644 --- a/map-widget/qmlmapwidgethelper.cpp +++ b/map-widget/qmlmapwidgethelper.cpp @@ -22,19 +22,17 @@ MapWidgetHelper::MapWidgetHelper(QObject *parent) : QObject(parent) this, SLOT(selectedLocationChanged(MapLocation *))); } -QGeoCoordinate MapWidgetHelper::getCoordinatesForUUID(QVariant dive_site_uuid) +QGeoCoordinate MapWidgetHelper::getCoordinates(QVariant dive_site) { - const uint32_t uuid = qvariant_cast(dive_site_uuid); - struct dive_site *ds = get_dive_site_by_uuid(uuid); + struct dive_site *ds = (struct dive_site *)dive_site.value(); if (!ds || !dive_site_has_gps_location(ds)) return QGeoCoordinate(0.0, 0.0); return QGeoCoordinate(ds->location.lat.udeg * 0.000001, ds->location.lon.udeg * 0.000001); } -void MapWidgetHelper::centerOnDiveSiteUUID(QVariant dive_site_uuid) +void MapWidgetHelper::centerOnDiveSite(QVariant dive_site) { - const uint32_t uuid = qvariant_cast(dive_site_uuid); - struct dive_site *ds = get_dive_site_by_uuid(uuid); + struct dive_site *ds = (struct dive_site *)dive_site.value(); if (ds) centerOnDiveSite(ds); } diff --git a/map-widget/qmlmapwidgethelper.h b/map-widget/qmlmapwidgethelper.h index f0d17a28d..8fad3aed2 100644 --- a/map-widget/qmlmapwidgethelper.h +++ b/map-widget/qmlmapwidgethelper.h @@ -29,8 +29,8 @@ public: void centerOnDiveSite(struct dive_site *); void centerOnSelectedDiveSite(); - Q_INVOKABLE QGeoCoordinate getCoordinatesForUUID(QVariant dive_site_uuid); - Q_INVOKABLE void centerOnDiveSiteUUID(QVariant dive_site_uuid); + Q_INVOKABLE QGeoCoordinate getCoordinates(QVariant dive_site); + Q_INVOKABLE void centerOnDiveSite(QVariant dive_site); Q_INVOKABLE void reloadMapLocations(); Q_INVOKABLE void copyToClipboardCoordinates(QGeoCoordinate coord, bool formatTraditional); Q_INVOKABLE void calculateSmallCircleRadius(QGeoCoordinate coord); -- cgit v1.2.3-70-g09d2