Dive list: use helper function when restoring selection

Looping over the individual dives will be very slow if there are many of
them, as the profile will try to render each of them in succession.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-05-28 13:10:33 -07:00
parent 1e4f744165
commit fa705a5bc9

View file

@ -156,17 +156,10 @@ void DiveListView::restoreSelection()
QList<int> divesOnTrip = getDivesInTrip(trip);
QList<int> selectedDivesOnTrip = selectedDives.values(trip);
// Trip was not selected, let's select single-dives.
if (trip == NULL || divesOnTrip.count() != selectedDivesOnTrip.count()) {
Q_FOREACH (int i, selectedDivesOnTrip) {
selectDive(i);
}
} else {
// Only select trip if all of its dives were selected
if (trip != NULL && divesOnTrip.count() == selectedDivesOnTrip.count())
selectTrip(trip);
Q_FOREACH (int i, selectedDivesOnTrip) {
selectDive(i);
}
}
selectDives(selectedDivesOnTrip);
}
}