Handling the key events for autoscrolling in DolphinViewAutoscroller does not work good enough (e. g. when letters are pressed, the current index might change too). Revert to Frank Reininhaus' original patch to fix this issue :-)

CCMAIL: frank78ac@googlemail.com

svn path=/trunk/KDE/kdebase/apps/; revision=896362
This commit is contained in:
Peter Penz 2008-12-13 14:08:07 +00:00
parent a86985b0b4
commit 99271699f3
7 changed files with 21 additions and 24 deletions

View file

@ -447,6 +447,14 @@ void DolphinColumnWidget::selectionChanged(const QItemSelection& selected, const
selModel->select(deselected, QItemSelectionModel::Deselect);
}
void DolphinColumnWidget::currentChanged(const QModelIndex& current, const QModelIndex& previous)
{
QListView::currentChanged(current, previous);
if (current.isValid()) {
scrollTo(current);
}
}
void DolphinColumnWidget::slotEntered(const QModelIndex& index)
{
m_view->m_controller->setItemView(this);

View file

@ -131,6 +131,7 @@ protected:
virtual void wheelEvent(QWheelEvent* event);
virtual void leaveEvent(QEvent* event);
virtual void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
virtual void currentChanged(const QModelIndex& current, const QModelIndex& previous);
private slots:
void slotEntered(const QModelIndex& index);

View file

@ -424,6 +424,9 @@ void DolphinDetailsView::wheelEvent(QWheelEvent* event)
void DolphinDetailsView::currentChanged(const QModelIndex& current, const QModelIndex& previous)
{
QTreeView::currentChanged(current, previous);
if (current.isValid()) {
scrollTo(current);
}
// Stay consistent with QListView: When changing the current index by key presses,
// also change the selection.

View file

@ -314,6 +314,14 @@ void DolphinIconsView::leaveEvent(QEvent* event)
m_controller->emitViewportEntered();
}
void DolphinIconsView::currentChanged(const QModelIndex& current, const QModelIndex& previous)
{
KCategorizedView::currentChanged(current, previous);
if (current.isValid()) {
scrollTo(current);
}
}
void DolphinIconsView::slotShowPreviewChanged()
{
const DolphinView* view = m_controller->dolphinView();

View file

@ -66,6 +66,7 @@ protected:
virtual void wheelEvent(QWheelEvent* event);
virtual void showEvent(QShowEvent* event);
virtual void leaveEvent(QEvent* event);
virtual void currentChanged(const QModelIndex& current, const QModelIndex& previous);
private slots:
void slotShowPreviewChanged();

View file

@ -36,7 +36,6 @@ 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);
@ -84,24 +83,8 @@ bool DolphinViewAutoScroller::eventFilter(QObject* watched, QEvent* event)
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);
}
@ -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) &&

View file

@ -44,7 +44,6 @@ protected:
private slots:
void scrollViewport();
void scrollToCurrentIndex();
private:
void triggerAutoScroll();