mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-20 00:41:23 +00:00
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:
parent
a86985b0b4
commit
99271699f3
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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) &&
|
||||
|
|
|
@ -44,7 +44,6 @@ protected:
|
|||
|
||||
private slots:
|
||||
void scrollViewport();
|
||||
void scrollToCurrentIndex();
|
||||
|
||||
private:
|
||||
void triggerAutoScroll();
|
||||
|
|
Loading…
Reference in a new issue