mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-17 21:46:17 +00:00
When remembering the selection, don't try to be too smart with trips
We assumed that a trip was selected when all of its dives were selected instead of just remembering if the trip itself was selected. I'm sure there was a reason for that but I cannot think of any. But a side effect is that if you have a trip with only one dive in it and have that one dive selected and edit it, after saving your changes you end up on the trip (which is now also selected) and are no longer on the dive. And that seems quite wrong. The new code simply remembers that the trip was selected. And selects it again if it was. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
31b8dffbb1
commit
429fcdb344
1 changed files with 9 additions and 2 deletions
|
@ -182,8 +182,13 @@ void DiveListView::rememberSelection()
|
|||
if (index.column() != 0) // We only care about the dives, so, let's stick to rows and discard columns.
|
||||
continue;
|
||||
struct dive *d = (struct dive *)index.data(DiveTripModel::DIVE_ROLE).value<void *>();
|
||||
if (d)
|
||||
if (d) {
|
||||
selectedDives.insert(d->divetrip, get_divenr(d));
|
||||
} else {
|
||||
struct dive_trip *t = (struct dive_trip *)index.data(DiveTripModel::TRIP_ROLE).value<void *>();
|
||||
if (t)
|
||||
selectedDives.insert(t, -1);
|
||||
}
|
||||
}
|
||||
selectionSaved = true;
|
||||
}
|
||||
|
@ -202,8 +207,10 @@ void DiveListView::restoreSelection()
|
|||
QList<int> selectedDivesOnTrip = selectedDives.values(trip);
|
||||
|
||||
// Only select trip if all of its dives were selected
|
||||
if (trip != NULL && divesOnTrip.count() == selectedDivesOnTrip.count())
|
||||
if(selectedDivesOnTrip.contains(-1)) {
|
||||
selectTrip(trip);
|
||||
selectedDivesOnTrip.removeAll(-1);
|
||||
}
|
||||
selectDives(selectedDivesOnTrip);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue