summaryrefslogtreecommitdiffstats
path: root/map-widget
diff options
context:
space:
mode:
Diffstat (limited to 'map-widget')
-rw-r--r--map-widget/qml/MapWidget.qml6
-rw-r--r--map-widget/qmlmapwidgethelper.cpp15
-rw-r--r--map-widget/qmlmapwidgethelper.h2
3 files changed, 15 insertions, 8 deletions
diff --git a/map-widget/qml/MapWidget.qml b/map-widget/qml/MapWidget.qml
index 602b7c338..42fc0ab88 100644
--- a/map-widget/qml/MapWidget.qml
+++ b/map-widget/qml/MapWidget.qml
@@ -69,8 +69,10 @@ Item {
drag.target: (mapHelper.editMode && mapHelper.model.isSelected(model.divesite)) ? mapItem : undefined
anchors.fill: parent
onClicked: {
- if (!mapHelper.editMode && model.divesite)
- mapHelper.model.setSelected(model.divesite, true)
+ if (!mapHelper.editMode && model.divesite) {
+ mapHelper.model.setSelected(model.divesite)
+ mapHelper.selectedLocationChanged(model.divesite)
+ }
}
onDoubleClicked: map.doubleClickHandler(mapItem.coordinate)
onReleased: {
diff --git a/map-widget/qmlmapwidgethelper.cpp b/map-widget/qmlmapwidgethelper.cpp
index b49ec248d..a40fa1d9f 100644
--- a/map-widget/qmlmapwidgethelper.cpp
+++ b/map-widget/qmlmapwidgethelper.cpp
@@ -21,8 +21,6 @@ MapWidgetHelper::MapWidgetHelper(QObject *parent) : QObject(parent)
m_smallCircleRadius = SMALL_CIRCLE_RADIUS_PX;
m_map = nullptr;
m_editMode = false;
- connect(m_mapLocationModel, SIGNAL(selectedLocationChanged(MapLocation *)),
- this, SLOT(selectedLocationChanged(MapLocation *)));
connect(&diveListNotifier, &DiveListNotifier::diveSiteChanged, this, &MapWidgetHelper::diveSiteChanged);
}
@@ -37,11 +35,11 @@ void MapWidgetHelper::centerOnDiveSite(struct dive_site *ds)
{
if (!dive_site_has_gps_location(ds)) {
// dive site with no GPS
- m_mapLocationModel->setSelected(ds, false);
+ m_mapLocationModel->setSelected(ds);
QMetaObject::invokeMethod(m_map, "deselectMapLocation");
} else {
// dive site with GPS
- m_mapLocationModel->setSelected(ds, false);
+ m_mapLocationModel->setSelected(ds);
QGeoCoordinate dsCoord (ds->location.lat.udeg * 0.000001, ds->location.lon.udeg * 0.000001);
QMetaObject::invokeMethod(m_map, "centerOnCoordinate", Q_ARG(QVariant, QVariant::fromValue(dsCoord)));
}
@@ -114,12 +112,19 @@ void MapWidgetHelper::reloadMapLocations()
m_mapLocationModel->reload(m_map);
}
-void MapWidgetHelper::selectedLocationChanged(MapLocation *location)
+void MapWidgetHelper::selectedLocationChanged(struct dive_site *ds_in)
{
int idx;
struct dive *dive;
QList<int> selectedDiveIds;
+
+ if (!ds_in)
+ return;
+ MapLocation *location = m_mapLocationModel->getMapLocation(ds_in);
+ if (!location)
+ return;
QGeoCoordinate locationCoord = location->coordinate();
+
for_each_dive (idx, dive) {
struct dive_site *ds = get_dive_site_for_dive(dive);
if (!dive_site_has_gps_location(ds))
diff --git a/map-widget/qmlmapwidgethelper.h b/map-widget/qmlmapwidgethelper.h
index 4079b6aa0..3560a51d1 100644
--- a/map-widget/qmlmapwidgethelper.h
+++ b/map-widget/qmlmapwidgethelper.h
@@ -35,6 +35,7 @@ public:
Q_INVOKABLE void calculateSmallCircleRadius(QGeoCoordinate coord);
Q_INVOKABLE void updateCurrentDiveSiteCoordinatesFromMap(struct dive_site *ds, QGeoCoordinate coord);
Q_INVOKABLE void selectVisibleLocations();
+ Q_INVOKABLE void selectedLocationChanged(struct dive_site *ds);
QString pluginObject();
private:
@@ -45,7 +46,6 @@ private:
bool m_editMode;
private slots:
- void selectedLocationChanged(MapLocation *);
void diveSiteChanged(struct dive_site *ds, int field);
signals: