]> 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 fbce803b8ab5f7fc1d98638cc790c89b75350779..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,50 +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)) {
-        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);
 }
@@ -111,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
@@ -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) &&
@@ -147,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) {
@@ -156,7 +133,7 @@ void DolphinViewAutoScroller::triggerAutoScroll()
     if (horizontalScrolling) {
         calculateScrollIncrement(pos.x(), viewport->width());
     }
-    
+
     if (m_timer->isActive()) {
         if (m_scrollInc == 0) {
             m_timer->stop();
@@ -178,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) {