qmlmapwidgethelper: add the centerOnDiveSite() method

MapWidget sould not handle any of the map backend.
Instead it should just pass calls to MapWidgetHelper.

Do that for centerOnDiveSite().

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
Lubomir I. Ivanov 2017-07-17 00:06:05 +03:00 committed by Dirk Hohndel
parent c68536ec56
commit 5cc2c02dfb
3 changed files with 17 additions and 7 deletions

View file

@ -23,13 +23,7 @@ MapWidget::MapWidget(QWidget *parent) : QQuickWidget(parent)
void MapWidget::centerOnDiveSite(struct dive_site *ds) void MapWidget::centerOnDiveSite(struct dive_site *ds)
{ {
if (!dive_site_has_gps_location(ds)) m_mapHelper->centerOnDiveSite(ds);
return;
qreal longitude = ds->longitude.udeg / 1000000.0;
qreal latitude = ds->latitude.udeg / 1000000.0;
qDebug() << longitude << latitude;
} }
void MapWidget::centerOnIndex(const QModelIndex& idx) void MapWidget::centerOnIndex(const QModelIndex& idx)

View file

@ -1,6 +1,18 @@
#include <QDebug> #include <QDebug>
#include "qmlmapwidgethelper.h" #include "qmlmapwidgethelper.h"
#include "core/dive.h"
#include "core/divesite.h"
MapWidgetHelper::MapWidgetHelper(QObject *parent) : QObject(parent) MapWidgetHelper::MapWidgetHelper(QObject *parent) : QObject(parent)
{ {
} }
void MapWidgetHelper::centerOnDiveSite(struct dive_site *ds)
{
if (!dive_site_has_gps_location(ds))
return;
qreal longitude = ds->longitude.udeg / 1000000.0;
qreal latitude = ds->latitude.udeg / 1000000.0;
}

View file

@ -3,6 +3,8 @@
#include <QObject> #include <QObject>
struct dive_site;
class MapWidgetHelper : public QObject { class MapWidgetHelper : public QObject {
Q_OBJECT Q_OBJECT
@ -11,6 +13,8 @@ class MapWidgetHelper : public QObject {
public: public:
explicit MapWidgetHelper(QObject *parent = NULL); explicit MapWidgetHelper(QObject *parent = NULL);
void centerOnDiveSite(struct dive_site *);
private: private:
QObject *m_map; QObject *m_map;
}; };