diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-02-03 11:51:25 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-02-04 02:18:28 +0100 |
commit | 670a5bd55a44c0b5605dfdf796911c51aea55aba (patch) | |
tree | ac572660559b1c9414ce4eb850cc060a55cb97da /desktop-widgets | |
parent | 65df9ca7b089adf649dae4379c5e14fc3489650e (diff) | |
download | subsurface-670a5bd55a44c0b5605dfdf796911c51aea55aba.tar.gz |
Dive sites: select each dive site only once
After selecting dives, the selected dive sites are collected.
This was done using the selectionModel()->selection().indexes(),
which is wrong, because it gives one index per row *and* column.
Accordingly, every dive site was added numerous times to the
array of dive sites to be selected. Change this to
selectionModel()->selectedRows(), which gives one entry per row.
Moreover, if multiple dives with the same site were selected,
this site was also added to the array multiple times. Therefore,
check the array before adding sites.
Note that all this should not change the user experience in
any way, it is only a code-hygiene thing.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets')
-rw-r--r-- | desktop-widgets/divelistview.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp index a34d78e5c..6cb4a81c3 100644 --- a/desktop-widgets/divelistview.cpp +++ b/desktop-widgets/divelistview.cpp @@ -555,10 +555,10 @@ void DiveListView::selectionChangeDone() // by the selected dives. if (!DiveFilter::instance()->diveSiteMode()) { QVector<dive_site *> selectedSites; - for (QModelIndex index: selectionModel()->selection().indexes()) { + for (QModelIndex index: selectionModel()->selectedRows()) { const QAbstractItemModel *model = index.model(); struct dive *dive = model->data(index, DiveTripModelBase::DIVE_ROLE).value<struct dive *>(); - if (dive && dive->dive_site) + if (dive && dive->dive_site && !selectedSites.contains(dive->dive_site)) selectedSites.push_back(dive->dive_site); } MapWidget::instance()->setSelected(selectedSites); |