From c980216dc0e15a21b245a902870f9b8c5a18275c Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 28 Oct 2018 22:04:56 +0100 Subject: [PATCH] Dive list: take pointer-to-dive_site instead of QVariant Since "struct dive_site *" is now a Q_METATYPE, the functions MapWidgetHelper::centerOnDiveSite() and ::getCoordinates() can directly get such a pointer instead of a QVariant. This makes the code nicer to read. Signed-off-by: Berthold Stoeger --- map-widget/qmlmapwidgethelper.cpp | 10 +--------- map-widget/qmlmapwidgethelper.h | 6 ++---- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/map-widget/qmlmapwidgethelper.cpp b/map-widget/qmlmapwidgethelper.cpp index 011433818..a7fb86d9b 100644 --- a/map-widget/qmlmapwidgethelper.cpp +++ b/map-widget/qmlmapwidgethelper.cpp @@ -22,21 +22,13 @@ MapWidgetHelper::MapWidgetHelper(QObject *parent) : QObject(parent) this, SLOT(selectedLocationChanged(MapLocation *))); } -QGeoCoordinate MapWidgetHelper::getCoordinates(QVariant dive_site) +QGeoCoordinate MapWidgetHelper::getCoordinates(struct dive_site *ds) { - 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::centerOnDiveSite(QVariant dive_site) -{ - struct dive_site *ds = (struct dive_site *)dive_site.value(); - if (ds) - centerOnDiveSite(ds); -} - void MapWidgetHelper::centerOnDiveSite(struct dive_site *ds) { if (!ds || !dive_site_has_gps_location(ds)) { diff --git a/map-widget/qmlmapwidgethelper.h b/map-widget/qmlmapwidgethelper.h index 9300bf3bc..43f722aba 100644 --- a/map-widget/qmlmapwidgethelper.h +++ b/map-widget/qmlmapwidgethelper.h @@ -5,7 +5,6 @@ #include "core/units.h" #include #include -#include #if defined(Q_OS_IOS) #include @@ -27,10 +26,9 @@ class MapWidgetHelper : public QObject { public: explicit MapWidgetHelper(QObject *parent = NULL); - void centerOnDiveSite(struct dive_site *); void centerOnSelectedDiveSite(); - Q_INVOKABLE QGeoCoordinate getCoordinates(QVariant dive_site); - Q_INVOKABLE void centerOnDiveSite(QVariant dive_site); + Q_INVOKABLE QGeoCoordinate getCoordinates(struct dive_site *ds); + Q_INVOKABLE void centerOnDiveSite(struct dive_site *ds); Q_INVOKABLE void reloadMapLocations(); Q_INVOKABLE void copyToClipboardCoordinates(QGeoCoordinate coord, bool formatTraditional); Q_INVOKABLE void calculateSmallCircleRadius(QGeoCoordinate coord);