summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--desktop-widgets/divelistview.cpp17
-rw-r--r--desktop-widgets/mapwidget.cpp6
-rw-r--r--desktop-widgets/mapwidget.h1
-rw-r--r--map-widget/qml/MapWidget.qml4
-rw-r--r--map-widget/qmlmapwidgethelper.cpp6
-rw-r--r--map-widget/qmlmapwidgethelper.h1
-rw-r--r--qt-models/maplocationmodel.cpp5
-rw-r--r--qt-models/maplocationmodel.h1
8 files changed, 38 insertions, 3 deletions
diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp
index 19eeccb13..489929bc6 100644
--- a/desktop-widgets/divelistview.cpp
+++ b/desktop-widgets/divelistview.cpp
@@ -27,6 +27,7 @@
#include "qt-models/divepicturemodel.h"
#include "core/metrics.h"
#include "desktop-widgets/simplewidgets.h"
+#include "desktop-widgets/mapwidget.h"
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false),
currentLayout(DiveTripModelBase::TREE), dontEmitDiveChangedSignal(false), selectionSaved(false),
@@ -455,6 +456,22 @@ void DiveListView::selectDives(const QList<int> &newDiveSelection)
scrollTo(idx.parent());
scrollTo(idx);
}
+
+ // update the selected-flag for the dive sites.
+ // the actual reloading of the dive sites will be perfomed
+ // by the main-window in response to the divesSelected signal
+ // emitted below.
+ QVector<dive_site *> selectedSites;
+ for (int idx: newDiveSelection) {
+ dive *d = get_dive(idx);
+ if (!d)
+ continue;
+ dive_site *ds = d->dive_site;
+ if (ds && !selectedSites.contains(ds))
+ selectedSites.append(ds);
+ }
+ MapWidget::instance()->setSelected(selectedSites);
+
// now that everything is up to date, update the widgets
emit divesSelected();
dontEmitDiveChangedSignal = false;
diff --git a/desktop-widgets/mapwidget.cpp b/desktop-widgets/mapwidget.cpp
index 376a29998..15fdef960 100644
--- a/desktop-widgets/mapwidget.cpp
+++ b/desktop-widgets/mapwidget.cpp
@@ -84,6 +84,12 @@ bool MapWidget::editMode() const
return isReady && m_mapHelper->editMode();
}
+void MapWidget::setSelected(const QVector<dive_site *> &divesites)
+{
+ CHECK_IS_READY_RETURN_VOID();
+ m_mapHelper->setSelected(divesites);
+}
+
void MapWidget::selectionChanged()
{
CHECK_IS_READY_RETURN_VOID();
diff --git a/desktop-widgets/mapwidget.h b/desktop-widgets/mapwidget.h
index 9e05ce48f..9ebf70c04 100644
--- a/desktop-widgets/mapwidget.h
+++ b/desktop-widgets/mapwidget.h
@@ -24,6 +24,7 @@ public:
static MapWidget *instance();
void reload();
void selectionChanged();
+ void setSelected(const QVector<dive_site *> &divesites);
bool editMode() const;
public slots:
diff --git a/map-widget/qml/MapWidget.qml b/map-widget/qml/MapWidget.qml
index 5b85aaa24..fb5545e88 100644
--- a/map-widget/qml/MapWidget.qml
+++ b/map-widget/qml/MapWidget.qml
@@ -69,10 +69,8 @@ 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)
+ if (!mapHelper.editMode && 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 02bfa78a2..fe43c6fce 100644
--- a/map-widget/qmlmapwidgethelper.cpp
+++ b/map-widget/qmlmapwidgethelper.cpp
@@ -46,6 +46,11 @@ void MapWidgetHelper::centerOnDiveSite(struct dive_site *ds)
}
}
+void MapWidgetHelper::setSelected(const QVector<dive_site *> &divesites)
+{
+ m_mapLocationModel->setSelected(divesites);
+}
+
void MapWidgetHelper::centerOnSelectedDiveSite()
{
QVector<struct dive_site *> selDS = m_mapLocationModel->selectedDs();
@@ -115,6 +120,7 @@ void MapWidgetHelper::reloadMapLocations()
void MapWidgetHelper::selectionChanged()
{
+ updateEditMode();
m_mapLocationModel->selectionChanged();
}
diff --git a/map-widget/qmlmapwidgethelper.h b/map-widget/qmlmapwidgethelper.h
index 046cb4ce1..f2c5eb6bb 100644
--- a/map-widget/qmlmapwidgethelper.h
+++ b/map-widget/qmlmapwidgethelper.h
@@ -37,6 +37,7 @@ public:
Q_INVOKABLE void selectVisibleLocations();
Q_INVOKABLE void selectedLocationChanged(struct dive_site *ds);
void selectionChanged();
+ void setSelected(const QVector<dive_site *> &divesites);
QString pluginObject();
bool editMode() const;
diff --git a/qt-models/maplocationmodel.cpp b/qt-models/maplocationmodel.cpp
index ea7d4f098..10d983575 100644
--- a/qt-models/maplocationmodel.cpp
+++ b/qt-models/maplocationmodel.cpp
@@ -229,6 +229,11 @@ void MapLocationModel::setSelected(struct dive_site *ds)
m_selectedDs.append(ds);
}
+void MapLocationModel::setSelected(const QVector<dive_site *> &divesites)
+{
+ m_selectedDs = divesites;
+}
+
bool MapLocationModel::isSelected(const QVariant &dsVariant) const
{
dive_site *ds = dsVariant.value<dive_site *>();
diff --git a/qt-models/maplocationmodel.h b/qt-models/maplocationmodel.h
index 25ae159bd..3335822e2 100644
--- a/qt-models/maplocationmodel.h
+++ b/qt-models/maplocationmodel.h
@@ -68,6 +68,7 @@ public:
// If map is not null, it will be used to place new dive sites without GPS location at the center of the map
void reload(QObject *map);
void selectionChanged();
+ void setSelected(const QVector<dive_site *> &divesites);
MapLocation *getMapLocation(const struct dive_site *ds);
const QVector<dive_site *> &selectedDs() const;
Q_INVOKABLE void setSelected(struct dive_site *ds);