]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinviewautoscroller.cpp
Especially when using the details view in combination with the split functionality...
[dolphin.git] / src / dolphinviewautoscroller.cpp
index 67bc696cc63e319fda7d63eccca2255b5c62f2fc..04a396b9aadde756fc86394a54454d2f0ad53119 100644 (file)
@@ -36,8 +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);
     m_timer->setInterval(1000 / 25); // 25 frames per second
@@ -57,42 +56,34 @@ bool DolphinViewAutoScroller::eventFilter(QObject* watched, QEvent* event)
                 m_rubberBandSelection = true;
             }
             break;
-            
+
         case QEvent::MouseMove:
             if (m_rubberBandSelection) {
                 triggerAutoScroll();
             }
             break;
-            
+
         case QEvent::MouseButtonRelease:
             m_rubberBandSelection = false;
             stopAutoScroll();
             break;
-            
+
         case QEvent::DragEnter:
         case QEvent::DragMove:
             m_rubberBandSelection = false;
             triggerAutoScroll();
             break;
-            
+
         case QEvent::Drop:
         case QEvent::DragLeave:
             m_rubberBandSelection = false;
             stopAutoScroll();
             break;
-            
+
         default:
             break;
         }
-    } else if ((watched == m_itemView) && (event->type() == QEvent::KeyPress)) {
-        const int key = static_cast<QKeyEvent*>(event)->key();
-        const bool arrowKeyPressed = (key == Qt::Key_Up)   || (key == Qt::Key_Down) ||
-                                     (key == Qt::Key_Left) || (key == Qt::Key_Right);
-        if (arrowKeyPressed) {
-            QMetaObject::invokeMethod(this, "scrollToCurrentIndex", Qt::QueuedConnection);
-        }
-    } 
-    
+    }
 
     return QObject::eventFilter(watched, event);
 }
@@ -103,15 +94,15 @@ void DolphinViewAutoScroller::scrollViewport()
     if (verticalScrollBar != 0) {
         const int value = verticalScrollBar->value();
         verticalScrollBar->setValue(value + m_scrollInc);
-        
+
     }
     QScrollBar* horizontalScrollBar = m_itemView->horizontalScrollBar();
     if (horizontalScrollBar != 0) {
         const int value = horizontalScrollBar->value();
         horizontalScrollBar->setValue(value + m_scrollInc);
-        
+
     }
-    
+
     if (m_rubberBandSelection) {
         // The scrolling does not lead to an update of the rubberband
         // selection. Fake a mouse move event to let the QAbstractItemView
@@ -123,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) &&
@@ -139,7 +124,7 @@ void DolphinViewAutoScroller::triggerAutoScroll()
         // no scrollbars are shown at all, so no autoscrolling is necessary
         return;
     }
-    
+
     QWidget* viewport = m_itemView->viewport();
     const QPoint pos = viewport->mapFromGlobal(QCursor::pos());
     if (verticalScrolling) {
@@ -148,7 +133,7 @@ void DolphinViewAutoScroller::triggerAutoScroll()
     if (horizontalScrolling) {
         calculateScrollIncrement(pos.x(), viewport->width());
     }
-    
+
     if (m_timer->isActive()) {
         if (m_scrollInc == 0) {
             m_timer->stop();
@@ -170,7 +155,7 @@ void DolphinViewAutoScroller::calculateScrollIncrement(int cursorPos, int rangeS
     const int maxSpeed = 32;
     const int speedLimiter = 8;
     const int autoScrollBorder = 32;
-    
+
     if (cursorPos < autoScrollBorder) {
         m_scrollInc = -minSpeed + (cursorPos - autoScrollBorder) / speedLimiter;
         if (m_scrollInc < -maxSpeed) {