From 93ce7f40e2d067eba48b317ef4028c2c75eebebd Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Fri, 17 Jul 2009 18:33:37 +0000 Subject: [PATCH] When pressing a key after entering a directory, QAbstractItemView::scrollTo() must be invoked to have autoscroll behavior. BUG: 199833 svn path=/trunk/KDE/kdebase/apps/; revision=998474 --- src/dolphinviewautoscroller.cpp | 20 ++++++++++++++++++-- src/dolphinviewautoscroller.h | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/dolphinviewautoscroller.cpp b/src/dolphinviewautoscroller.cpp index ea9b1a2d6..cfd3543a5 100644 --- a/src/dolphinviewautoscroller.cpp +++ b/src/dolphinviewautoscroller.cpp @@ -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; } diff --git a/src/dolphinviewautoscroller.h b/src/dolphinviewautoscroller.h index c95155f58..a858d27cb 100644 --- a/src/dolphinviewautoscroller.h +++ b/src/dolphinviewautoscroller.h @@ -66,6 +66,7 @@ private: private: bool m_rubberBandSelection; + bool m_keyPressed; int m_horizontalScrollInc; int m_verticalScrollInc; QAbstractItemView* m_itemView; -- 2.47.3