┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2008-01-19 18:20:24 +0000
committerPeter Penz <[email protected]>2008-01-19 18:20:24 +0000
commit418eed751192d4dcf1b537a74863920d592bea10 (patch)
tree002e654546724faa4564069bf377cf46a78188fe /src
parentef2c04a11834bba405281dae61c2c03507738716 (diff)
Backport:
treeview: prevent that when expanding a subtree that the selected item gets hidden by the (maybe) appearing horizontal scrollbar svn path=/branches/KDE/4.0/kdebase/apps/; revision=763550
Diffstat (limited to 'src')
-rw-r--r--src/treeviewsidebarpage.cpp16
-rw-r--r--src/treeviewsidebarpage.h5
2 files changed, 20 insertions, 1 deletions
diff --git a/src/treeviewsidebarpage.cpp b/src/treeviewsidebarpage.cpp
index 7fa56566a..14c877728 100644
--- a/src/treeviewsidebarpage.cpp
+++ b/src/treeviewsidebarpage.cpp
@@ -35,6 +35,7 @@
#include <QBoxLayout>
#include <QModelIndex>
#include <QScrollBar>
+#include <QTimer>
TreeViewSidebarPage::TreeViewSidebarPage(QWidget* parent) :
SidebarPage(parent),
@@ -213,6 +214,15 @@ void TreeViewSidebarPage::loadSubTree()
}
}
+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);
@@ -247,7 +257,11 @@ void TreeViewSidebarPage::selectLeafDirectory()
}
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;
}
diff --git a/src/treeviewsidebarpage.h b/src/treeviewsidebarpage.h
index 9ff37ed06..a389077a9 100644
--- a/src/treeviewsidebarpage.h
+++ b/src/treeviewsidebarpage.h
@@ -99,6 +99,11 @@ private slots:
*/
void loadSubTree();
+ /**
+ * Assures that the leaf folder gets visible.
+ */
+ void scrollToLeaf();
+
private:
/**
* Initializes the base URL of the tree and expands all