diff options
author | Eike Ziller <eike.ziller@qt.io> | 2018-08-13 16:18:33 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2018-08-15 12:29:44 +0000 |
commit | 4e1a3b0029ee3adcb6ef2cc0e9cec58f8bc69b63 (patch) | |
tree | baccc5c0ddd66b426e0db3b5829a5ac78c4987bd | |
parent | 7d5013cefd55f7edd42c685fa0ddfa2c119605aa (diff) |
File System View: Fix scroll position and bread crumb in some cases
Use a model index from the right model, and update the bread crumb, when
updating the scroll position delayed, for the case where the directory
for the file was not already loaded in the file system model yet.
Broke with introduction of the folder vs alphabetic sorting.
Task-number: QTCREATORBUG-20897
Change-Id: Ifc912184b4910ed546c0141044eead3650b98c87
Reviewed-by: David Schulz <david.schulz@qt.io>
-rw-r--r-- | src/plugins/projectexplorer/foldernavigationwidget.cpp | 14 | ||||
-rw-r--r-- | src/plugins/projectexplorer/foldernavigationwidget.h | 2 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/plugins/projectexplorer/foldernavigationwidget.cpp b/src/plugins/projectexplorer/foldernavigationwidget.cpp index d4c91d32b9..b0df620375 100644 --- a/src/plugins/projectexplorer/foldernavigationwidget.cpp +++ b/src/plugins/projectexplorer/foldernavigationwidget.cpp @@ -378,10 +378,7 @@ FolderNavigationWidget::FolderNavigationWidget(QWidget *parent) : QWidget(parent connect(m_listView->selectionModel(), &QItemSelectionModel::currentChanged, this, - [this](const QModelIndex ¤t, const QModelIndex &previous) { - setCrumblePath(m_sortProxyModel->mapToSource(current), - m_sortProxyModel->mapToSource(previous)); - }, + &FolderNavigationWidget::setCrumblePath, Qt::QueuedConnection); connect(m_crumbLabel, &Utils::FileCrumbLabel::pathClicked, [this](const Utils::FileName &path) { const QModelIndex rootIndex = m_sortProxyModel->mapToSource(m_listView->rootIndex()); @@ -618,13 +615,15 @@ void FolderNavigationWidget::selectFile(const Utils::FileName &filePath) // Use magic timer for scrolling. m_listView->setCurrentIndex(fileIndex); QTimer::singleShot(200, this, [this, filePath] { - const QModelIndex fileIndex = m_fileSystemModel->index(filePath.toString()); + const QModelIndex fileIndex = m_sortProxyModel->mapFromSource( + m_fileSystemModel->index(filePath.toString())); if (fileIndex == m_listView->rootIndex()) { m_listView->horizontalScrollBar()->setValue(0); m_listView->verticalScrollBar()->setValue(0); } else { m_listView->scrollTo(fileIndex); } + setCrumblePath(fileIndex); }); } } @@ -700,11 +699,12 @@ void FolderNavigationWidget::createNewFolder(const QModelIndex &parent) m_listView->edit(index); } -void FolderNavigationWidget::setCrumblePath(const QModelIndex &index, const QModelIndex &) +void FolderNavigationWidget::setCrumblePath(const QModelIndex &index) { + const QModelIndex sourceIndex = m_sortProxyModel->mapToSource(index); const int width = m_crumbLabel->width(); const int previousHeight = m_crumbLabel->immediateHeightForWidth(width); - m_crumbLabel->setPath(Utils::FileName::fromString(m_fileSystemModel->filePath(index))); + m_crumbLabel->setPath(Utils::FileName::fromString(m_fileSystemModel->filePath(sourceIndex))); const int currentHeight = m_crumbLabel->immediateHeightForWidth(width); const int diff = currentHeight - previousHeight; if (diff != 0 && m_crumbLabel->isVisible()) { diff --git a/src/plugins/projectexplorer/foldernavigationwidget.h b/src/plugins/projectexplorer/foldernavigationwidget.h index 8f428863eb..f10f69d595 100644 --- a/src/plugins/projectexplorer/foldernavigationwidget.h +++ b/src/plugins/projectexplorer/foldernavigationwidget.h @@ -131,7 +131,7 @@ private: QStringList projectsInDirectory(const QModelIndex &index) const; void openProjectsInDirectory(const QModelIndex &index); void createNewFolder(const QModelIndex &parent); - void setCrumblePath(const QModelIndex &index, const QModelIndex &); + void setCrumblePath(const QModelIndex &index); Core::IContext *m_context = nullptr; Utils::NavigationTreeView *m_listView = nullptr; |