diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-08-31 09:09:14 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-09-06 11:48:47 -0700 |
commit | 093adf1ea88dbcab465051b28f8a60a3a29f7a87 (patch) | |
tree | 01611381737d3fe7bcb872503e452602217ee0fe /desktop-widgets | |
parent | fc706a0d722c2ae07d298f6e13794216e8d96a90 (diff) | |
download | subsurface-093adf1ea88dbcab465051b28f8a60a3a29f7a87.tar.gz |
Map: highlight correct dive sites in dive site mode
Since changing the highlighting to use the selected dive, dive
sites with no dive were never highlighted in dive site mode.
Obviously, because there was no dive to be selected.
Therefore special-case all dive-site selection code to recognize
when we are in dive site mode.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets')
-rw-r--r-- | desktop-widgets/divelistview.cpp | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp index fffb1186f..4983b41f4 100644 --- a/desktop-widgets/divelistview.cpp +++ b/desktop-widgets/divelistview.cpp @@ -461,16 +461,21 @@ void DiveListView::selectDives(const QList<int> &newDiveSelection) // 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); + // But don't do this if we are in divesite mode, because then + // the dive-site selection is controlled by the filter not + // by the selected dives. + if (!MultiFilterSortModel::instance()->diveSiteMode()) { + 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); } - MapWidget::instance()->setSelected(selectedSites); // now that everything is up to date, update the widgets emit divesSelected(); @@ -691,14 +696,19 @@ void DiveListView::selectionChanged(const QItemSelection &selected, const QItemS // When receiving the divesSelected signal the main window will // instruct the map to update the flags. Thus, make sure that // the selected maps are registered correctly. - QVector<dive_site *> selectedSites; - for (QModelIndex index: selectionModel()->selection().indexes()) { - const QAbstractItemModel *model = index.model(); - struct dive *dive = model->data(index, DiveTripModelBase::DIVE_ROLE).value<struct dive *>(); - if (dive && dive->dive_site) - selectedSites.push_back(dive->dive_site); + // But don't do this if we are in divesite mode, because then + // the dive-site selection is controlled by the filter not + // by the selected dives. + if (!MultiFilterSortModel::instance()->diveSiteMode()) { + QVector<dive_site *> selectedSites; + for (QModelIndex index: selectionModel()->selection().indexes()) { + const QAbstractItemModel *model = index.model(); + struct dive *dive = model->data(index, DiveTripModelBase::DIVE_ROLE).value<struct dive *>(); + if (dive && dive->dive_site) + selectedSites.push_back(dive->dive_site); + } + MapWidget::instance()->setSelected(selectedSites); } - MapWidget::instance()->setSelected(selectedSites); emit divesSelected(); } |