From 912d4616f5b58ba5b5a9db78460c17a9d27df8bc Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Wed, 14 Feb 2018 15:39:19 +0100 Subject: [PATCH] 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 --- src/plugins/projectexplorer/foldernavigationwidget.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plugins/projectexplorer/foldernavigationwidget.cpp b/src/plugins/projectexplorer/foldernavigationwidget.cpp index a2bdd4c6c83..f4132351abe 100644 --- a/src/plugins/projectexplorer/foldernavigationwidget.cpp +++ b/src/plugins/projectexplorer/foldernavigationwidget.cpp @@ -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);