]> cloud.milkyroute.net Git - dolphin.git/commitdiff
When pressing a key after entering a directory, QAbstractItemView::scrollTo() must...
authorPeter Penz <peter.penz19@gmail.com>
Fri, 17 Jul 2009 18:33:37 +0000 (18:33 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Fri, 17 Jul 2009 18:33:37 +0000 (18:33 +0000)
BUG: 199833

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

src/dolphinviewautoscroller.cpp
src/dolphinviewautoscroller.h

index ea9b1a2d6bb2103007baa3bf0c558d17164304b2..cfd3543a509016242c25b5dca3671de695774698 100644 (file)
@@ -31,6 +31,7 @@
 DolphinViewAutoScroller::DolphinViewAutoScroller(QAbstractItemView* parent) :
     QObject(parent),
     m_rubberBandSelection(false),
+    m_keyPressed(false),
     m_horizontalScrollInc(0),
     m_verticalScrollInc(0),
     m_itemView(parent),
@@ -38,6 +39,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);
@@ -59,8 +61,9 @@ void DolphinViewAutoScroller::handleCurrentIndexChange(const QModelIndex& curren
 {
     // When the autoscroller is inactive and a key has been pressed, it must be
     // assured that the current item stays visible. The check whether the previous
-    // item is valid is important because of #197951.
-    if (current.isValid() && previous.isValid() && !isActive()) {
+    // item is valid is important because of #197951. The keypress check is done
+    // because of #199833.
+    if (current.isValid() && (previous.isValid() || m_keyPressed) && !isActive()) {
         m_itemView->scrollTo(current);
     }
 }
@@ -98,6 +101,19 @@ bool DolphinViewAutoScroller::eventFilter(QObject* watched, QEvent* event)
             stopAutoScroll();
             break;
 
+        default:
+            break;
+        }
+    } else if (watched == m_itemView) {
+        switch (event->type()) {
+        case QEvent::KeyPress:
+            m_keyPressed = true;
+            break;
+
+        case QEvent::KeyRelease:
+            m_keyPressed = false;
+            break;
+
         default:
             break;
         }
index c95155f58bb9109521e085d370f853f1edc893ed..a858d27cbf8f5c60407e3cad4a1acf075b4b96f9 100644 (file)
@@ -66,6 +66,7 @@ private:
 
 private:
     bool m_rubberBandSelection;
+    bool m_keyPressed;
     int m_horizontalScrollInc;
     int m_verticalScrollInc;
     QAbstractItemView* m_itemView;