┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2009-06-29 19:32:39 +0000
committerPeter Penz <[email protected]>2009-06-29 19:32:39 +0000
commitc1a086da25e746ddf7dbe7f212d3cc61a9174035 (patch)
tree68434866e3901365caf7b925d1e00afbd0862abd
parent76d52a5ff1b3ec3f991ed71b322aa7bbcb2e4ef1 (diff)
Fixed issue that the scroll position is reset if the focus of the itemview changes.
BUG: 197951 svn path=/trunk/KDE/kdebase/apps/; revision=989236
-rw-r--r--src/dolphincolumnwidget.cpp4
-rw-r--r--src/dolphindetailsview.cpp4
-rw-r--r--src/dolphiniconsview.cpp4
-rw-r--r--src/dolphinviewautoscroller.cpp11
-rw-r--r--src/dolphinviewautoscroller.h8
5 files changed, 22 insertions, 9 deletions
diff --git a/src/dolphincolumnwidget.cpp b/src/dolphincolumnwidget.cpp
index e85c9491b..c8bff0290 100644
--- a/src/dolphincolumnwidget.cpp
+++ b/src/dolphincolumnwidget.cpp
@@ -491,9 +491,7 @@ void DolphinColumnWidget::selectionChanged(const QItemSelection& selected, const
void DolphinColumnWidget::currentChanged(const QModelIndex& current, const QModelIndex& previous)
{
QListView::currentChanged(current, previous);
- if (current.isValid() && !m_autoScroller->isActive()) {
- scrollTo(current);
- }
+ m_autoScroller->handleCurrentIndexChange(current, previous);
}
void DolphinColumnWidget::slotEntered(const QModelIndex& index)
diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp
index ad362914a..aa65ff6bc 100644
--- a/src/dolphindetailsview.cpp
+++ b/src/dolphindetailsview.cpp
@@ -429,9 +429,7 @@ void DolphinDetailsView::wheelEvent(QWheelEvent* event)
void DolphinDetailsView::currentChanged(const QModelIndex& current, const QModelIndex& previous)
{
QTreeView::currentChanged(current, previous);
- if (current.isValid() && !m_autoScroller->isActive()) {
- scrollTo(current);
- }
+ m_autoScroller->handleCurrentIndexChange(current, previous);
// 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 4c7e9180f..183197ffb 100644
--- a/src/dolphiniconsview.cpp
+++ b/src/dolphiniconsview.cpp
@@ -302,9 +302,7 @@ void DolphinIconsView::leaveEvent(QEvent* event)
void DolphinIconsView::currentChanged(const QModelIndex& current, const QModelIndex& previous)
{
KCategorizedView::currentChanged(current, previous);
- if (current.isValid() && !m_autoScroller->isActive()) {
- scrollTo(current);
- }
+ m_autoScroller->handleCurrentIndexChange(current, previous);
}
void DolphinIconsView::resizeEvent(QResizeEvent* event)
diff --git a/src/dolphinviewautoscroller.cpp b/src/dolphinviewautoscroller.cpp
index 75dab3214..ea9b1a2d6 100644
--- a/src/dolphinviewautoscroller.cpp
+++ b/src/dolphinviewautoscroller.cpp
@@ -54,6 +54,17 @@ bool DolphinViewAutoScroller::isActive() const
return m_timer->isActive();
}
+void DolphinViewAutoScroller::handleCurrentIndexChange(const QModelIndex& current,
+ const QModelIndex& previous)
+{
+ // 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()) {
+ m_itemView->scrollTo(current);
+ }
+}
+
bool DolphinViewAutoScroller::eventFilter(QObject* watched, QEvent* event)
{
if (watched == m_itemView->viewport()) {
diff --git a/src/dolphinviewautoscroller.h b/src/dolphinviewautoscroller.h
index 3827b2326..c95155f58 100644
--- a/src/dolphinviewautoscroller.h
+++ b/src/dolphinviewautoscroller.h
@@ -23,6 +23,7 @@
#include <QObject>
class QAbstractItemView;
+class QModelIndex;
class QTimer;
/**
@@ -40,6 +41,13 @@ public:
virtual ~DolphinViewAutoScroller();
bool isActive() const;
+ /**
+ * Must be invoked by the parent item view, when QAbstractItemView::currentChanged()
+ * has been called. Assures that the current item stays visible when it has been
+ * changed by the keyboard.
+ */
+ void handleCurrentIndexChange(const QModelIndex& current, const QModelIndex& previous);
+
protected:
virtual bool eventFilter(QObject* watched, QEvent* event);