From 4334d334134784722f6e1a86da0ce0f132293531 Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Sat, 15 Jul 2017 23:34:44 +0300 Subject: mapwidget: add the method centerOnIndex() Again for the port from Marble, later can be removed / renamed. Signed-off-by: Lubomir I. Ivanov --- desktop-widgets/mapwidget.cpp | 10 ++++++++++ desktop-widgets/mapwidget.h | 1 + 2 files changed, 11 insertions(+) diff --git a/desktop-widgets/mapwidget.cpp b/desktop-widgets/mapwidget.cpp index 8753e1d98..c083c5f73 100644 --- a/desktop-widgets/mapwidget.cpp +++ b/desktop-widgets/mapwidget.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "mapwidget.h" #include "core/dive.h" @@ -27,6 +28,15 @@ void MapWidget::centerOnDiveSite(struct dive_site *ds) qDebug() << longitude << latitude; } +void MapWidget::centerOnIndex(const QModelIndex& idx) +{ + struct dive_site *ds = get_dive_site_by_uuid(idx.model()->index(idx.row(), 0).data().toInt()); + if (!ds || !dive_site_has_gps_location(ds)) + centerOnDiveSite(&displayed_dive_site); + else + centerOnDiveSite(ds); +} + void MapWidget::reload() { // TODO; diff --git a/desktop-widgets/mapwidget.h b/desktop-widgets/mapwidget.h index 7a372f6ae..cdd117e8a 100644 --- a/desktop-widgets/mapwidget.h +++ b/desktop-widgets/mapwidget.h @@ -22,6 +22,7 @@ public: public slots: void centerOnDiveSite(struct dive_site *); + void centerOnIndex(const QModelIndex& idx); void endGetDiveCoordinates(); private: -- cgit v1.2.3-70-g09d2