From: Peter Penz Date: Sat, 13 Dec 2008 14:08:07 +0000 (+0000) Subject: Handling the key events for autoscrolling in DolphinViewAutoscroller does not work... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/99271699f305de4ad25a8c2a6dd7e7307cb61af7 Handling the key events for autoscrolling in DolphinViewAutoscroller does not work good enough (e. g. when letters are pressed, the current index might change too). Revert to Frank Reininhaus' original patch to fix this issue :-) CCMAIL: frank78ac@googlemail.com svn path=/trunk/KDE/kdebase/apps/; revision=896362 --- diff --git a/src/dolphincolumnwidget.cpp b/src/dolphincolumnwidget.cpp index 804ef8a32..a9b0b8244 100644 --- a/src/dolphincolumnwidget.cpp +++ b/src/dolphincolumnwidget.cpp @@ -447,6 +447,14 @@ void DolphinColumnWidget::selectionChanged(const QItemSelection& selected, const selModel->select(deselected, QItemSelectionModel::Deselect); } +void DolphinColumnWidget::currentChanged(const QModelIndex& current, const QModelIndex& previous) +{ + QListView::currentChanged(current, previous); + if (current.isValid()) { + scrollTo(current); + } +} + void DolphinColumnWidget::slotEntered(const QModelIndex& index) { m_view->m_controller->setItemView(this); diff --git a/src/dolphincolumnwidget.h b/src/dolphincolumnwidget.h index 825de4ff1..c1db48f8d 100644 --- a/src/dolphincolumnwidget.h +++ b/src/dolphincolumnwidget.h @@ -131,6 +131,7 @@ protected: virtual void wheelEvent(QWheelEvent* event); virtual void leaveEvent(QEvent* event); virtual void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected); + virtual void currentChanged(const QModelIndex& current, const QModelIndex& previous); private slots: void slotEntered(const QModelIndex& index); diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index f4b8cd162..6b4ef44d0 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -424,6 +424,9 @@ void DolphinDetailsView::wheelEvent(QWheelEvent* event) void DolphinDetailsView::currentChanged(const QModelIndex& current, const QModelIndex& previous) { QTreeView::currentChanged(current, previous); + if (current.isValid()) { + scrollTo(current); + } // Stay consistent with QListView: When changing the current index by key presses, // also change the selection. diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp index e1ae04adf..2e43656ba 100644 --- a/src/dolphiniconsview.cpp +++ b/src/dolphiniconsview.cpp @@ -314,6 +314,14 @@ void DolphinIconsView::leaveEvent(QEvent* event) m_controller->emitViewportEntered(); } +void DolphinIconsView::currentChanged(const QModelIndex& current, const QModelIndex& previous) +{ + KCategorizedView::currentChanged(current, previous); + if (current.isValid()) { + scrollTo(current); + } +} + void DolphinIconsView::slotShowPreviewChanged() { const DolphinView* view = m_controller->dolphinView(); diff --git a/src/dolphiniconsview.h b/src/dolphiniconsview.h index 3465f6bfc..966069641 100644 --- a/src/dolphiniconsview.h +++ b/src/dolphiniconsview.h @@ -66,6 +66,7 @@ protected: virtual void wheelEvent(QWheelEvent* event); virtual void showEvent(QShowEvent* event); virtual void leaveEvent(QEvent* event); + virtual void currentChanged(const QModelIndex& current, const QModelIndex& previous); private slots: void slotShowPreviewChanged(); diff --git a/src/dolphinviewautoscroller.cpp b/src/dolphinviewautoscroller.cpp index b99bbc749..04a396b9a 100644 --- a/src/dolphinviewautoscroller.cpp +++ b/src/dolphinviewautoscroller.cpp @@ -36,7 +36,6 @@ DolphinViewAutoScroller::DolphinViewAutoScroller(QAbstractItemView* parent) : { m_itemView->setAutoScroll(false); m_itemView->viewport()->installEventFilter(this); - m_itemView->installEventFilter(this); m_timer = new QTimer(this); m_timer->setSingleShot(false); @@ -84,24 +83,8 @@ bool DolphinViewAutoScroller::eventFilter(QObject* watched, QEvent* event) default: break; } - } else if ((watched == m_itemView) && (event->type() == QEvent::KeyPress)) { - switch (static_cast(event)->key()) { - case Qt::Key_Up: - case Qt::Key_Down: - case Qt::Key_Left: - case Qt::Key_Right: - case Qt::Key_PageUp: - case Qt::Key_PageDown: - case Qt::Key_Home: - case Qt::Key_End: - QMetaObject::invokeMethod(this, "scrollToCurrentIndex", Qt::QueuedConnection); - break; - default: - break; - } } - return QObject::eventFilter(watched, event); } @@ -131,12 +114,6 @@ void DolphinViewAutoScroller::scrollViewport() } } -void DolphinViewAutoScroller::scrollToCurrentIndex() -{ - const QModelIndex index = m_itemView->currentIndex(); - m_itemView->scrollTo(index); -} - void DolphinViewAutoScroller::triggerAutoScroll() { const bool verticalScrolling = (m_itemView->verticalScrollBar() != 0) && diff --git a/src/dolphinviewautoscroller.h b/src/dolphinviewautoscroller.h index dd84963a7..f0f57049b 100644 --- a/src/dolphinviewautoscroller.h +++ b/src/dolphinviewautoscroller.h @@ -44,7 +44,6 @@ protected: private slots: void scrollViewport(); - void scrollToCurrentIndex(); private: void triggerAutoScroll();