+void TreeViewSidebarPage::selectLeafDirectory()
+{
+ const QModelIndex dirIndex = m_dolphinModel->indexForUrl(m_leafDir);
+ const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex);
+ if (!proxyIndex.isValid()) {
+ return;
+ }
+
+ if (m_setLeafVisible) {
+ // Invoke m_treeView->scrollTo(proxyIndex) asynchronously by
+ // scrollToLeaf(). This assures that the scrolling is done after
+ // the horizontal scrollbar gets visible (otherwise the scrollbar
+ // might hide the leaf).
+ QTimer::singleShot(100, this, SLOT(scrollToLeaf()));
+ m_setLeafVisible = false;
+ }
+
+ QItemSelectionModel* selModel = m_treeView->selectionModel();
+ selModel->setCurrentIndex(proxyIndex, QItemSelectionModel::Select);
+
+ m_treeView->horizontalScrollBar()->setValue(m_horizontalPos);
+}
+