┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2008-12-13 14:08:07 +0000
committerPeter Penz <[email protected]>2008-12-13 14:08:07 +0000
commit99271699f305de4ad25a8c2a6dd7e7307cb61af7 (patch)
tree8410decfe5f1aff0af84d4e127c1b3bd06235848
parenta86985b0b46ee97e7705242f3d5648f84425a87b (diff)
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: [email protected] svn path=/trunk/KDE/kdebase/apps/; revision=896362
-rw-r--r--src/dolphincolumnwidget.cpp8
-rw-r--r--src/dolphincolumnwidget.h1
-rw-r--r--src/dolphindetailsview.cpp3
-rw-r--r--src/dolphiniconsview.cpp8
-rw-r--r--src/dolphiniconsview.h1
-rw-r--r--src/dolphinviewautoscroller.cpp23
-rw-r--r--src/dolphinviewautoscroller.h1
7 files changed, 21 insertions, 24 deletions
diff --git a/src/dolphincolumnwidget.cpp b/src/dolphincolumnwidget.cpp
index 804ef8a32..a9b0b8244 100644
--- a/src/dolphincolumnwidget.cpp
+++ b/src/dolphincolumnwidget.cpp
@@ -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);
diff --git a/src/dolphincolumnwidget.h b/src/dolphincolumnwidget.h
index 825de4ff1..c1db48f8d 100644
--- a/src/dolphincolumnwidget.h
+++ b/src/dolphincolumnwidget.h
@@ -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);
diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp
index f4b8cd162..6b4ef44d0 100644
--- a/src/dolphindetailsview.cpp
+++ b/src/dolphindetailsview.cpp
@@ -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.
diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp
index e1ae04adf..2e43656ba 100644
--- a/src/dolphiniconsview.cpp
+++ b/src/dolphiniconsview.cpp
@@ -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();
diff --git a/src/dolphiniconsview.h b/src/dolphiniconsview.h
index 3465f6bfc..966069641 100644
--- a/src/dolphiniconsview.h
+++ b/src/dolphiniconsview.h
@@ -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();
diff --git a/src/dolphinviewautoscroller.cpp b/src/dolphinviewautoscroller.cpp
index b99bbc749..04a396b9a 100644
--- a/src/dolphinviewautoscroller.cpp
+++ b/src/dolphinviewautoscroller.cpp
@@ -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) &&
diff --git a/src/dolphinviewautoscroller.h b/src/dolphinviewautoscroller.h
index dd84963a7..f0f57049b 100644
--- a/src/dolphinviewautoscroller.h
+++ b/src/dolphinviewautoscroller.h
@@ -44,7 +44,6 @@ protected:
private slots:
void scrollViewport();
- void scrollToCurrentIndex();
private:
void triggerAutoScroll();