From 48c032bb8ee3c2493783f3db3691f7f067f7782f Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Mon, 2 Apr 2018 22:48:23 +0300 Subject: mapwidget-mobile: do not animate the first selection centerOnLocationHard() is added in MapPage.qml so that on `firstRun` the map is hard panned to the desired location without animation. This affects the selection of a new "Dive details" -> "Map it" or when opening a GPS location in the map. The idea behind this change is to avoid starting the map animation from an arbitrary location such as [0,0] or London. Also, to not start the map zoomed out completely and then zoom in on a selected dive. For this change to work, add the helper getCoordinatesForUUID() to qmlmapwidgethelper.cpp/.h and use it to obtain the QGeoCoordinates for a dive site UUID. Signed-off-by: Lubomir I. Ivanov --- map-widget/qmlmapwidgethelper.cpp | 9 +++++++++ map-widget/qmlmapwidgethelper.h | 1 + 2 files changed, 10 insertions(+) (limited to 'map-widget') diff --git a/map-widget/qmlmapwidgethelper.cpp b/map-widget/qmlmapwidgethelper.cpp index e8187a679..fa0616202 100644 --- a/map-widget/qmlmapwidgethelper.cpp +++ b/map-widget/qmlmapwidgethelper.cpp @@ -23,6 +23,15 @@ MapWidgetHelper::MapWidgetHelper(QObject *parent) : QObject(parent) this, SLOT(selectedLocationChanged(MapLocation *))); } +QGeoCoordinate MapWidgetHelper::getCoordinatesForUUID(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 || !dive_site_has_gps_location(ds)) + return QGeoCoordinate(0.0, 0.0); + return QGeoCoordinate(ds->latitude.udeg * 0.000001, ds->longitude.udeg * 0.000001); +} + void MapWidgetHelper::centerOnDiveSiteUUID(QVariant dive_site_uuid) { const uint32_t uuid = qvariant_cast(dive_site_uuid); diff --git a/map-widget/qmlmapwidgethelper.h b/map-widget/qmlmapwidgethelper.h index d5cdb35bc..eb57dcd88 100644 --- a/map-widget/qmlmapwidgethelper.h +++ b/map-widget/qmlmapwidgethelper.h @@ -22,6 +22,7 @@ public: explicit MapWidgetHelper(QObject *parent = NULL); void centerOnDiveSite(struct dive_site *); + Q_INVOKABLE QGeoCoordinate getCoordinatesForUUID(QVariant dive_site_uuid); Q_INVOKABLE void centerOnDiveSiteUUID(QVariant dive_site_uuid); Q_INVOKABLE void reloadMapLocations(); Q_INVOKABLE void copyToClipboardCoordinates(QGeoCoordinate coord, bool formatTraditional); -- cgit v1.2.3-70-g09d2