From 8fa2295a6174a0cc0cd86a0aea0420eb453bdd63 Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Thu, 8 Mar 2018 21:38:14 +0200 Subject: [PATCH] qmapwidgethelper: add centerOnDiveSiteUUID() centerOnDiveSiteUUID() is a helper to center the map on a dive_site UUID instead of a dive_site pointer. Make it call centerOnDiveSite(). Make both this function and reloadMapLocations() Q_INVOKABLE as these are going to be called from QML. Signed-off-by: Lubomir I. Ivanov --- map-widget/qmlmapwidgethelper.cpp | 8 ++++++++ map-widget/qmlmapwidgethelper.h | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/map-widget/qmlmapwidgethelper.cpp b/map-widget/qmlmapwidgethelper.cpp index 26590269a..6046d08cc 100644 --- a/map-widget/qmlmapwidgethelper.cpp +++ b/map-widget/qmlmapwidgethelper.cpp @@ -23,6 +23,14 @@ MapWidgetHelper::MapWidgetHelper(QObject *parent) : QObject(parent) this, SLOT(selectedLocationChanged(MapLocation *))); } +void MapWidgetHelper::centerOnDiveSiteUUID(QVariant dive_site_uuid) +{ + const uint32_t uuid = qvariant_cast(dive_site_uuid); + struct dive_site *ds = get_dive_site_by_uuid(uuid); + if (ds) + centerOnDiveSite(ds); +} + void MapWidgetHelper::centerOnDiveSite(struct dive_site *ds) { int idx; diff --git a/map-widget/qmlmapwidgethelper.h b/map-widget/qmlmapwidgethelper.h index d1ba47f41..d5cdb35bc 100644 --- a/map-widget/qmlmapwidgethelper.h +++ b/map-widget/qmlmapwidgethelper.h @@ -22,7 +22,8 @@ public: explicit MapWidgetHelper(QObject *parent = NULL); void centerOnDiveSite(struct dive_site *); - void reloadMapLocations(); + Q_INVOKABLE void centerOnDiveSiteUUID(QVariant dive_site_uuid); + Q_INVOKABLE void reloadMapLocations(); Q_INVOKABLE void copyToClipboardCoordinates(QGeoCoordinate coord, bool formatTraditional); Q_INVOKABLE void calculateSmallCircleRadius(QGeoCoordinate coord); Q_INVOKABLE void updateCurrentDiveSiteCoordinatesFromMap(quint32 uuid, QGeoCoordinate coord);