]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Handling the key events for autoscrolling in DolphinViewAutoscroller does not work...
authorPeter Penz <peter.penz19@gmail.com>
Sat, 13 Dec 2008 14:08:07 +0000 (14:08 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Sat, 13 Dec 2008 14:08:07 +0000 (14:08 +0000)
CCMAIL: frank78ac@googlemail.com

svn path=/trunk/KDE/kdebase/apps/; revision=896362

src/dolphincolumnwidget.cpp
src/dolphincolumnwidget.h
src/dolphindetailsview.cpp
src/dolphiniconsview.cpp
src/dolphiniconsview.h
src/dolphinviewautoscroller.cpp
src/dolphinviewautoscroller.h

index 804ef8a325b2800f0369c371bfa97bc1c2bb92cf..a9b0b8244573d7101e4eecd0e40b7745d6afe644 100644 (file)
@@ -447,6 +447,14 @@ void DolphinColumnWidget::selectionChanged(const QItemSelection& selected, const
     selModel->select(deselected, QItemSelectionModel::Deselect);
 }
 
     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);
 void DolphinColumnWidget::slotEntered(const QModelIndex& index)
 {
     m_view->m_controller->setItemView(this);
index 825de4ff184033115e1be226765b7c2ccfd08436..c1db48f8df7428007f0896816f103631e16411d9 100644 (file)
@@ -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 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);
 
 private slots:
     void slotEntered(const QModelIndex& index);
index f4b8cd162855c34767dc873ea686ffd8274ccdc7..6b4ef44d04bfe462fec331c4cc2ea7e3856843a0 100644 (file)
@@ -424,6 +424,9 @@ void DolphinDetailsView::wheelEvent(QWheelEvent* event)
 void DolphinDetailsView::currentChanged(const QModelIndex& current, const QModelIndex& previous)
 {
     QTreeView::currentChanged(current, previous);
 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.
 
     // Stay consistent with QListView: When changing the current index by key presses,
     // also change the selection.
index e1ae04adfeb0e8db4975281a04ffbdecc537833f..2e43656babfccfb125860b3b4861b82a99930a11 100644 (file)
@@ -314,6 +314,14 @@ void DolphinIconsView::leaveEvent(QEvent* event)
     m_controller->emitViewportEntered();
 }
 
     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();
 void DolphinIconsView::slotShowPreviewChanged()
 {
     const DolphinView* view = m_controller->dolphinView();
index 3465f6bfcfd551fbb2e18e6ad10a3615ebeb4f1c..966069641a04ac2a7051290bf482da3f2ba8aff5 100644 (file)
@@ -66,6 +66,7 @@ protected:
     virtual void wheelEvent(QWheelEvent* event);
     virtual void showEvent(QShowEvent* event);
     virtual void leaveEvent(QEvent* event);
     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();
 
 private slots:
     void slotShowPreviewChanged();
index b99bbc74954857b91050315f64195f4b1ac11c7f..04a396b9aadde756fc86394a54454d2f0ad53119 100644 (file)
@@ -36,7 +36,6 @@ DolphinViewAutoScroller::DolphinViewAutoScroller(QAbstractItemView* parent) :
 {
     m_itemView->setAutoScroll(false);
     m_itemView->viewport()->installEventFilter(this);
 {
     m_itemView->setAutoScroll(false);
     m_itemView->viewport()->installEventFilter(this);
-    m_itemView->installEventFilter(this);
 
     m_timer = new QTimer(this);
     m_timer->setSingleShot(false);
 
     m_timer = new QTimer(this);
     m_timer->setSingleShot(false);
@@ -84,24 +83,8 @@ bool DolphinViewAutoScroller::eventFilter(QObject* watched, QEvent* event)
         default:
             break;
         }
         default:
             break;
         }
-    } else if ((watched == m_itemView) && (event->type() == QEvent::KeyPress)) {
-        switch (static_cast<QKeyEvent*>(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);
 }
 
     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) &&
 void DolphinViewAutoScroller::triggerAutoScroll()
 {
     const bool verticalScrolling = (m_itemView->verticalScrollBar() != 0) &&
index dd84963a76d31ecc216a855a58d2acdc087638f6..f0f57049b83859b96f90bf86be77f741fc05166d 100644 (file)
@@ -44,7 +44,6 @@ protected:
 
 private slots:
     void scrollViewport();
 
 private slots:
     void scrollViewport();
-    void scrollToCurrentIndex();
 
 private:
     void triggerAutoScroll();
 
 private:
     void triggerAutoScroll();