mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
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>
This commit is contained in:
parent
65df9ca7b0
commit
670a5bd55a
1 changed files with 2 additions and 2 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue