]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinviewautoscroller.cpp
as the detailsview and columnview can also have icon sizes up to 256 x 256 pixels...
[dolphin.git] / src / dolphinviewautoscroller.cpp
index 5e9e17f1fcdfc32956ca69e61042e3d55ad73ae5..fbce803b8ab5f7fc1d98638cc790c89b75350779 100644 (file)
@@ -36,6 +36,7 @@ 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);
@@ -83,7 +84,23 @@ bool DolphinViewAutoScroller::eventFilter(QObject* watched, QEvent* event)
         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);
 }
@@ -114,6 +131,12 @@ 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) &&