{
m_itemView->setAutoScroll(false);
m_itemView->viewport()->installEventFilter(this);
+ m_itemView->installEventFilter(this);
m_timer = new QTimer(this);
m_timer->setSingleShot(false);
default:
break;
}
- }
+ } else if ((watched == m_itemView) && (event->type() == QEvent::KeyPress)) {
+ const int key = static_cast<QKeyEvent*>(event)->key();
+ const bool arrowKeyPressed = (key == Qt::Key_Up) || (key == Qt::Key_Down) ||
+ (key == Qt::Key_Left) || (key == Qt::Key_Right);
+ if (arrowKeyPressed) {
+ QMetaObject::invokeMethod(this, "scrollToCurrentIndex", Qt::QueuedConnection);
+ }
+ }
+
return QObject::eventFilter(watched, event);
}
}
}
+void DolphinViewAutoScroller::scrollToCurrentIndex()
+{
+ const QModelIndex index = m_itemView->currentIndex();
+ m_itemView->scrollTo(index);
+}
+
void DolphinViewAutoScroller::triggerAutoScroll()
{
const bool verticalScrolling = (m_itemView->verticalScrollBar() != 0) &&