summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/divelistview.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-05-03 22:17:03 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-05-11 12:06:19 -0700
commit403206ca06cf87d64b75cafa8629956ea7cf282b (patch)
tree59a1d29131fe43ff369a38c0c95178070e892c45 /desktop-widgets/divelistview.cpp
parent8eb586d1d4b5de9433239cda9a9462ba5a250058 (diff)
downloadsubsurface-403206ca06cf87d64b75cafa8629956ea7cf282b.tar.gz
Selection: automatically unselect old selection in selectDives()
DiveListView::selectDives() would only select new dives but not clear the old selection. Thus, callers would have to clear the selection first. That would lead to two selection-changed signals. Move the unselectDives() call into DiveListView::selectDives(). The DiveListView has an internal flag to prevent double signals. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/divelistview.cpp')
-rw-r--r--desktop-widgets/divelistview.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp
index 86da4ba1a..c98338061 100644
--- a/desktop-widgets/divelistview.cpp
+++ b/desktop-widgets/divelistview.cpp
@@ -277,9 +277,7 @@ void DiveListView::restoreSelection()
return;
selectionSaved = false;
- dontEmitDiveChangedSignal = true;
- unselectDives();
- dontEmitDiveChangedSignal = false;
+ QList<int> divesToSelect;
Q_FOREACH (dive_trip_t *trip, selectedDives.keys()) {
QList<int> divesOnTrip = getDivesInTrip(trip);
QList<int> selectedDivesOnTrip = selectedDives.values(trip);
@@ -289,8 +287,9 @@ void DiveListView::restoreSelection()
selectTrip(trip);
selectedDivesOnTrip.removeAll(-1);
}
- selectDives(selectedDivesOnTrip);
+ divesToSelect += selectedDivesOnTrip;
}
+ selectDives(divesToSelect);
}
// This is a bit ugly: we hook directly into the tripChanged signal to
@@ -417,6 +416,10 @@ void DiveListView::selectDives(const QList<int> &newDiveSelection)
return;
dontEmitDiveChangedSignal = true;
+
+ // First, clear the old selection
+ unselectDives();
+
// select the dives, highest index first - this way the oldest of the dives
// becomes the selected_dive that we scroll to
QList<int> sortedSelection = newDiveSelection;