mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
When scrolling to dive, scroll to trip first
The behavior at startup is actually very annoying: we select the latest dive, and expand the trip it is in, but since we use "scrollTo()" on just the dive, and it's not initially visible, the startup will make the first dive be at the top of the list view. Which means that the actual _trip_ detail is not visible at all, since it will have been scrolled off the list view entirely. Fix this by first scrolling to the trip, and only then scrolling to the actual dive (using the default "EnsureVisible" policy). Obviously, if it's a trip with lots of dives, scrolling to the dive may end up scrolling away from the trip header again, but at least that never happens at startup, and at that point you have to scroll away from the trip just to show the dive. Do this same dance when changing the dive selection (mainly noticeable when picking dives on the globe view). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
2d24779b62
commit
4f20bb9fb2
1 changed files with 5 additions and 0 deletions
|
@ -218,6 +218,8 @@ void DiveListView::selectDive(int i, bool scrollto, bool toggle)
|
|||
if (idx.parent().isValid()) {
|
||||
setAnimated(false);
|
||||
expand(idx.parent());
|
||||
if (scrollto)
|
||||
scrollTo(idx.parent());
|
||||
setAnimated(true);
|
||||
}
|
||||
if (scrollto)
|
||||
|
@ -274,6 +276,8 @@ void DiveListView::selectDives(const QList<int> &newDiveSelection)
|
|||
this, SLOT(currentChanged(QModelIndex, QModelIndex)));
|
||||
Q_EMIT currentDiveChanged(selected_dive);
|
||||
const QModelIndex &idx = m->match(m->index(0, 0), DiveTripModel::DIVE_IDX, selected_dive, 2, Qt::MatchRecursive).first();
|
||||
if (idx.parent().isValid())
|
||||
scrollTo(idx.parent());
|
||||
scrollTo(idx);
|
||||
}
|
||||
|
||||
|
@ -371,6 +375,7 @@ void DiveListView::reload(DiveTripModel::Layout layout, bool forceSort)
|
|||
if (!isExpanded(curr)) {
|
||||
setAnimated(false);
|
||||
expand(curr);
|
||||
scrollTo(curr);
|
||||
setAnimated(true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue