]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Don't do an automatic horizontal scrolling, if the user has adjusted the horizontal...
authorPeter Penz <peter.penz19@gmail.com>
Fri, 29 Oct 2010 15:12:59 +0000 (15:12 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Fri, 29 Oct 2010 15:12:59 +0000 (15:12 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=1191098

src/panels/folders/folderspanel.cpp
src/panels/folders/folderspanel.h
src/panels/folders/ktreeview.cpp
src/panels/folders/ktreeview.h

index 1b75f36bc213b2e6e5cbe7b3ba9bb5bc66498789..b825cb1fa05d5f580d801a16dbf90ddf50864cd6 100644 (file)
@@ -167,6 +167,7 @@ void FoldersPanel::showEvent(QShowEvent* event)
         m_treeView->setModel(m_proxyModel);
         m_proxyModel->setSorting(DolphinView::SortByName);
         m_proxyModel->setSortOrder(Qt::AscendingOrder);
+        m_treeView->setAutoHorizontalScroll(FoldersPanelSettings::autoScrolling());
 
         new FolderExpander(m_treeView, m_proxyModel);
 
@@ -177,12 +178,14 @@ void FoldersPanel::showEvent(QShowEvent* event)
         connect(m_treeView, SIGNAL(pressed(const QModelIndex&)),
                 this, SLOT(updateMouseButtons()));
 
+        connect(m_treeView->horizontalScrollBar(), SIGNAL(sliderMoved(int)),
+                this, SLOT(slotHorizontalScrollBarMoved(int)));
+        connect(m_treeView->verticalScrollBar(), SIGNAL(sliderMoved(int)),
+                this, SLOT(slotVerticalScrollBarMoved(int)));
+
         QVBoxLayout* layout = new QVBoxLayout(this);
         layout->setMargin(0);
         layout->addWidget(m_treeView);
-
-        setAutoScrolling(FoldersPanelSettings::autoScrolling());
-        setShowHiddenFiles(FoldersPanelSettings::showHiddenFiles());
     }
 
     loadTree(url());
@@ -270,6 +273,22 @@ void FoldersPanel::slotDirListerCompleted()
     }
 }
 
+void FoldersPanel::slotHorizontalScrollBarMoved(int value)
+{
+    Q_UNUSED(value);
+    // Disable the auto-scrolling until the vertical scrollbar has
+    // been moved by the user.
+    m_treeView->setAutoHorizontalScroll(false);
+}
+
+void FoldersPanel::slotVerticalScrollBarMoved(int value)
+{
+    Q_UNUSED(value);
+    // Enable the auto-scrolling again (it might have been disabled by
+    // moving the horizontal scrollbar).
+    m_treeView->setAutoHorizontalScroll(FoldersPanelSettings::autoScrolling());
+}
+
 void FoldersPanel::loadTree(const KUrl& url)
 {
     Q_ASSERT(m_dirLister != 0);
index 93223ffeb07a2bc0edb4fa651e520eb891e92e1a..2aa94d1ffd6ba14f71ed000b921bb9f15c74c9ac 100644 (file)
@@ -103,6 +103,10 @@ private slots:
 
     void slotDirListerCompleted();
 
+    void slotHorizontalScrollBarMoved(int value);
+
+    void slotVerticalScrollBarMoved(int value);
+
 private:
     /**
      * Initializes the base URL of the tree and expands all
index 2e9ccaa4189322ea96e0a2fe05efc5235b407fc3..222956234bdf5a596e94802272df117f89d465d0 100644 (file)
@@ -116,9 +116,12 @@ KTreeView::~KTreeView()
 {
 }
 
-void KTreeView::setAutoHorizontalScroll(bool value)
+void KTreeView::setAutoHorizontalScroll(bool enable)
 {
-    d->autoHorizontalScroll = value;
+    d->autoHorizontalScroll = enable;
+    if (!enable) {
+        d->timeLine->stop();
+    }
 }
 
 bool KTreeView::autoHorizontalScroll() const
@@ -126,14 +129,6 @@ bool KTreeView::autoHorizontalScroll() const
     return d->autoHorizontalScroll;
 }
 
-void KTreeView::setSelectionModel(QItemSelectionModel *selectionModel)
-{
-    QTreeView::setSelectionModel(selectionModel);
-    connect(selectionModel,
-            SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
-            this, SLOT(startScrolling()));
-}
-
 void KTreeView::scrollTo(const QModelIndex& index, ScrollHint hint)
 {
     const int value = horizontalScrollBar()->value();
index 6bc6ea56a7c831dc0d42cd93340fb381ccdf49a2..fb0746aa6f6b9f30c55203e4cf71a42c7dcdfaad 100644 (file)
@@ -31,10 +31,9 @@ public:
     KTreeView(QWidget *parent = 0);
     virtual ~KTreeView();
 
-    void setAutoHorizontalScroll(bool value);
+    void setAutoHorizontalScroll(bool enable);
     bool autoHorizontalScroll() const;
 
-    virtual void setSelectionModel(QItemSelectionModel *selectionModel);
     virtual void scrollTo(const QModelIndex& index, ScrollHint hint = EnsureVisible);
 
 protected: