#include <QBoxLayout>
#include <QModelIndex>
#include <QScrollBar>
+#include <QTimer>
TreeViewSidebarPage::TreeViewSidebarPage(QWidget* parent) :
SidebarPage(parent),
}
}
+void TreeViewSidebarPage::scrollToLeaf()
+{
+ const QModelIndex dirIndex = m_dolphinModel->indexForUrl(m_leafDir);
+ const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex);
+ if (proxyIndex.isValid()) {
+ m_treeView->scrollTo(proxyIndex);
+ }
+}
+
void TreeViewSidebarPage::loadTree(const KUrl& url)
{
Q_ASSERT(m_dirLister != 0);
}
if (m_setLeafVisible) {
- m_treeView->scrollTo(proxyIndex);
+ // 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;
}