diff options
| author | Peter Penz <[email protected]> | 2009-07-17 18:33:37 +0000 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2009-07-17 18:33:37 +0000 |
| commit | 93ce7f40e2d067eba48b317ef4028c2c75eebebd (patch) | |
| tree | ea20704224e1f3398da69f7ede0bb37418ddc692 /src/dolphinviewautoscroller.cpp | |
| parent | 17b8ac74588c9aded8bc04b6bf1c37703038c458 (diff) | |
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
Diffstat (limited to 'src/dolphinviewautoscroller.cpp')
| -rw-r--r-- | src/dolphinviewautoscroller.cpp | 20 |
1 files changed, 18 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); } } @@ -101,6 +104,19 @@ bool DolphinViewAutoScroller::eventFilter(QObject* watched, QEvent* event) 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; + } } return QObject::eventFilter(watched, event); |
