diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-04-22 08:38:44 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-04-22 08:42:28 -0700 |
commit | 429fcdb3448ba070826ad36f0ff1f47563b6f58d (patch) | |
tree | 15e16a1fd382849f7466cefa3a773af6bd8774ea /qt-ui/divelistview.cpp | |
parent | 31b8dffbb166ca04e4b9c2e1717ab613b26261b7 (diff) | |
download | subsurface-429fcdb3448ba070826ad36f0ff1f47563b6f58d.tar.gz |
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>
Diffstat (limited to 'qt-ui/divelistview.cpp')
-rw-r--r-- | qt-ui/divelistview.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index b65b88e3a..92ae60b5d 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -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); } } |