diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-08-30 17:38:54 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-09-06 11:48:47 -0700 |
commit | 488eb1542336088245841d79549e26938e2d3fd9 (patch) | |
tree | bba9ed5d849fa7ac8639078651582576b0ab4867 /desktop-widgets | |
parent | b39f2406c6a520f0b3743324744f3c55914adc52 (diff) | |
download | subsurface-488eb1542336088245841d79549e26938e2d3fd9.tar.gz |
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 <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets')
-rw-r--r-- | desktop-widgets/divelistview.cpp | 17 | ||||
-rw-r--r-- | desktop-widgets/mapwidget.cpp | 6 | ||||
-rw-r--r-- | desktop-widgets/mapwidget.h | 1 |
3 files changed, 24 insertions, 0 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: |