diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-04-28 10:39:06 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-04-28 12:47:15 -0700 |
commit | 4f20bb9fb2731fdfd9faab3b109a0cbce8c89298 (patch) | |
tree | 53d3ec10cba13faa571cf081cffad0f7902f3124 /qt-ui/divelistview.cpp | |
parent | 2d24779b6226f6f9757abe565307d2956b375c0d (diff) | |
download | subsurface-4f20bb9fb2731fdfd9faab3b109a0cbce8c89298.tar.gz |
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>
Diffstat (limited to 'qt-ui/divelistview.cpp')
-rw-r--r-- | qt-ui/divelistview.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index 28ed09f2c..d8e66d0c6 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -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); } } |