From: Peter Penz Date: Fri, 29 Oct 2010 15:12:59 +0000 (+0000) Subject: Don't do an automatic horizontal scrolling, if the user has adjusted the horizontal... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/2f1051d1b41d0cf087099e71b9449a44b103e3ac Don't do an automatic horizontal scrolling, if the user has adjusted the horizontal scrollbar. The autoscrolling gets reactivated again if the vertical scrollbar has been moved by the user. svn path=/trunk/KDE/kdebase/apps/; revision=1191098 --- diff --git a/src/panels/folders/folderspanel.cpp b/src/panels/folders/folderspanel.cpp index 1b75f36bc..b825cb1fa 100644 --- a/src/panels/folders/folderspanel.cpp +++ b/src/panels/folders/folderspanel.cpp @@ -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); diff --git a/src/panels/folders/folderspanel.h b/src/panels/folders/folderspanel.h index 93223ffeb..2aa94d1ff 100644 --- a/src/panels/folders/folderspanel.h +++ b/src/panels/folders/folderspanel.h @@ -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 diff --git a/src/panels/folders/ktreeview.cpp b/src/panels/folders/ktreeview.cpp index 2e9ccaa41..222956234 100644 --- a/src/panels/folders/ktreeview.cpp +++ b/src/panels/folders/ktreeview.cpp @@ -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(); diff --git a/src/panels/folders/ktreeview.h b/src/panels/folders/ktreeview.h index 6bc6ea56a..fb0746aa6 100644 --- a/src/panels/folders/ktreeview.h +++ b/src/panels/folders/ktreeview.h @@ -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: