summaryrefslogtreecommitdiffstats
path: root/map-widget
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-05-09 21:33:01 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-05-11 12:06:19 -0700
commit44c65fec8855315d322b84b4c4207713b90328d3 (patch)
tree21ba6e6901fa5e46cebca4e7abadc33292e24d05 /map-widget
parent30d96d37043684a4087f09b7171b1873ec140236 (diff)
downloadsubsurface-44c65fec8855315d322b84b4c4207713b90328d3.tar.gz
Map: automatically update names on the map
Currently, dive site names are only updated on full reload. Instead hook directly into the corresponding signal in the MapLocationModel to set the name. Also to the coordinates directly there instead of going via the MapWidgetHelper. In the MapWidgetHelper, just center on the changed dive site. Hook into the signal directly there and remove the slot from the MapWidget. This makes the whole call-chain at least one call shorter. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'map-widget')
-rw-r--r--map-widget/qmlmapwidgethelper.cpp12
-rw-r--r--map-widget/qmlmapwidgethelper.h3
2 files changed, 6 insertions, 9 deletions
diff --git a/map-widget/qmlmapwidgethelper.cpp b/map-widget/qmlmapwidgethelper.cpp
index ccc5a6e7a..7d752cc63 100644
--- a/map-widget/qmlmapwidgethelper.cpp
+++ b/map-widget/qmlmapwidgethelper.cpp
@@ -8,6 +8,7 @@
#include "core/divesite.h"
#include "core/qthelper.h"
#include "qt-models/maplocationmodel.h"
+#include "qt-models/divelocationmodel.h"
#ifndef SUBSURFACE_MOBILE
#include "qt-models/filtermodels.h"
#endif
@@ -22,6 +23,7 @@ MapWidgetHelper::MapWidgetHelper(QObject *parent) : QObject(parent)
m_editMode = false;
connect(m_mapLocationModel, SIGNAL(selectedLocationChanged(MapLocation *)),
this, SLOT(selectedLocationChanged(MapLocation *)));
+ connect(&diveListNotifier, &DiveListNotifier::diveSiteChanged, this, &MapWidgetHelper::diveSiteChanged);
}
QGeoCoordinate MapWidgetHelper::getCoordinates(struct dive_site *ds)
@@ -218,15 +220,9 @@ void MapWidgetHelper::updateCurrentDiveSiteCoordinatesFromMap(struct dive_site *
emit coordinatesChanged(ds, location);
}
-void MapWidgetHelper::updateDiveSiteCoordinates(struct dive_site *ds, const location_t &location)
+void MapWidgetHelper::diveSiteChanged(struct dive_site *ds, int field)
{
- if (!ds)
- return;
- const qreal latitude_r = location.lat.udeg * 0.000001;
- const qreal longitude_r = location.lon.udeg * 0.000001;
- QGeoCoordinate coord(latitude_r, longitude_r);
- m_mapLocationModel->updateMapLocationCoordinates(ds, coord);
- QMetaObject::invokeMethod(m_map, "centerOnCoordinate", Q_ARG(QVariant, QVariant::fromValue(coord)));
+ centerOnDiveSite(ds);
}
void MapWidgetHelper::exitEditMode()
diff --git a/map-widget/qmlmapwidgethelper.h b/map-widget/qmlmapwidgethelper.h
index d6348c346..86d9a8ff5 100644
--- a/map-widget/qmlmapwidgethelper.h
+++ b/map-widget/qmlmapwidgethelper.h
@@ -3,6 +3,7 @@
#define QMLMAPWIDGETHELPER_H
#include "core/units.h"
+#include "core/subsurface-qt/DiveListNotifier.h"
#include <QObject>
#include <QGeoCoordinate>
@@ -34,7 +35,6 @@ public:
Q_INVOKABLE void calculateSmallCircleRadius(QGeoCoordinate coord);
Q_INVOKABLE void updateCurrentDiveSiteCoordinatesFromMap(struct dive_site *ds, QGeoCoordinate coord);
Q_INVOKABLE void selectVisibleLocations();
- void updateDiveSiteCoordinates(struct dive_site *ds, const location_t &);
QString pluginObject();
private:
@@ -47,6 +47,7 @@ private:
private slots:
void selectedLocationChanged(MapLocation *);
+ void diveSiteChanged(struct dive_site *ds, int field);
signals:
void modelChanged();