From 488eb1542336088245841d79549e26938e2d3fd9 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 30 Aug 2019 17:38:54 +0200 Subject: Desktop: show all selected dive sites on click When clicking a dive site on the map, the QML code would set the selected dive site, but then all dives of dive sites in the vicinity were set. But still only the clicked-on dive site was shown. Therefore, don't set the list of selected dive sites in QML, but later in DiveListView::selectDives(), where we know all the dives that were selected. This, again, gives nasty entanglement of diverse widgets and models. Signed-off-by: Berthold Stoeger --- desktop-widgets/divelistview.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'desktop-widgets/divelistview.cpp') 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 &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 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; -- cgit v1.2.3-70-g09d2