File system view: Fix that bread crumbs could hide selected top item

If the current item is at the top, and the bread crumbs widget needs
more space, we may not just scroll, because that would scroll the
current item under the larger bread crumbs widget. We have to do the
delayed layouting in that case.

Task-number: QTCREATORBUG-19800
Change-Id: I93072c1932099501e99963220efdd975c255f586
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Eike Ziller
2018-02-14 15:39:19 +01:00
parent f9deab1140
commit 912d4616f5

View File

@@ -598,7 +598,13 @@ void FolderNavigationWidget::setCrumblePath(const QModelIndex &index, const QMod
// try to fix scroll position, otherwise delay layouting
QScrollBar *bar = m_listView->verticalScrollBar();
const int newBarValue = bar ? bar->value() + diff : 0;
if (bar && bar->minimum() <= newBarValue && bar->maximum() >= newBarValue) {
const QRect currentItemRect = m_listView->visualRect(index);
const int currentItemVStart = currentItemRect.y();
const int currentItemVEnd = currentItemVStart + currentItemRect.height();
const bool currentItemStillVisibleAsBefore = (diff < 0 || currentItemVStart > diff
|| currentItemVEnd <= 0);
if (bar && bar->minimum() <= newBarValue && bar->maximum() >= newBarValue
&& currentItemStillVisibleAsBefore) {
// we need to set the scroll bar when the layout request from the crumble path is
// handled, otherwise it will flicker
m_crumbLabel->setScrollBarOnce(bar, newBarValue);