]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Stupid me: The inconsistent behavior between QListView::scrollTo() and QTreeView...
authorPeter Penz <peter.penz19@gmail.com>
Tue, 24 Feb 2009 08:25:01 +0000 (08:25 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Tue, 24 Feb 2009 08:25:01 +0000 (08:25 +0000)
* Remove the workaround in DolphinIconsView::scrollTo() to bypass an issue in Qt 4.4 (-> fixed in Qt 4.5)
* Revert the "use the DolphinController"-parts of commit 930754 and just use QAbstractItemView::scrollTo() instead.

CCBUG: 185191

svn path=/trunk/KDE/kdebase/apps/; revision=930777

src/dolphincolumnview.cpp
src/dolphincolumnview.h
src/dolphincontroller.cpp
src/dolphincontroller.h
src/dolphindetailsview.cpp
src/dolphindetailsview.h
src/dolphiniconsview.cpp
src/dolphiniconsview.h
src/dolphinview.cpp

index 16d72c0f0622161a730b4471f2745303ead60b5c..4d180442b750da734adac1ee3f6ad3400239ec16 100644 (file)
@@ -59,8 +59,6 @@ DolphinColumnView::DolphinColumnView(QWidget* parent, DolphinController* control
             this, SLOT(setZoomLevel(int)));
     connect(controller, SIGNAL(activationChanged(bool)),
             this, SLOT(updateColumnsBackground(bool)));
-    connect(controller, SIGNAL(scrollToCurrentItem()),
-            this, SLOT(scrollToCurrentItem()));
 
     const DolphinView* view = controller->dolphinView();
     connect(view, SIGNAL(sortingChanged(DolphinView::Sorting)),
@@ -467,12 +465,6 @@ void DolphinColumnView::slotShowPreviewChanged()
     }
 }
 
-void DolphinColumnView::scrollToCurrentItem()
-{
-    const QModelIndex activeIndex = activeColumn()->currentIndex();
-    activeColumn()->scrollTo(activeIndex);
-}
-
 void DolphinColumnView::setActiveColumnIndex(int index)
 {
     if (m_index == index) {
index 756037874f74d9e8842b53628d00e89613eb6a76..65e4ff3e9910465d47f5692c134c4b8980ac2f4b 100644 (file)
@@ -169,7 +169,6 @@ private slots:
     void slotSortOrderChanged(Qt::SortOrder order);
     void slotShowHiddenFilesChanged();
     void slotShowPreviewChanged();
-    void scrollToCurrentItem();
 
 private:
     DolphinColumnWidget* activeColumn() const;
index cfa0d62c821b0226653f62aa9a3e30b748db715f..b128c90335e2c89804458b7a0ac88f1b86f9b47d 100644 (file)
@@ -124,11 +124,6 @@ void DolphinController::setZoomLevel(int level)
     }
 }
 
-void DolphinController::triggerScrollToCurrentItem()
-{
-    emit scrollToCurrentItem();
-}
-
 void DolphinController::handleKeyPressEvent(QKeyEvent* event)
 {
     Q_ASSERT(m_itemView != 0);
index ba10360602c7fe850c55cf8105444d17bb4055b4..29dd7dfb1bfcc56dd7fa9d03226e88914a2a640e 100644 (file)
@@ -73,7 +73,6 @@ class QWidget;
  * - setShowPreview()
  * - indicateActivationChange()
  * - setZoomLevel()
- * - triggerScrollToCurrentItem()
  */
 class LIBDOLPHINPRIVATE_EXPORT DolphinController : public QObject
 {
@@ -190,12 +189,6 @@ public:
     void setZoomLevel(int level);
     int zoomLevel() const;
 
-    /**
-     * Triggers the view implementation to assure having a fully visible
-     * current item. The signal scrollToCurrentItem() will be emitted.
-     */
-    void triggerScrollToCurrentItem();
-
     /**
      * Tells the view implementation to zoom out by emitting the signal zoomOut()
      * and is invoked by the abstract Dolphin view.
@@ -376,12 +369,6 @@ signals:
      */
     void hideToolTip();
 
-    /**
-     * Is emitted if the view implementation should scroll to the current item, so
-     * that it is fully visible.
-     */
-    void scrollToCurrentItem();
-
 private slots:
     void updateMouseButtonState();
 
index fbd7e41d5c612e4bd2c1b0026e469ca7d14241bb..dd58e584248bbf57e73e1f722375bb9fb004783c 100644 (file)
@@ -128,8 +128,6 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr
             this, SLOT(updateColumnVisibility()));
     connect(controller, SIGNAL(activationChanged(bool)),
             this, SLOT(slotActivationChanged(bool)));
-    connect(controller, SIGNAL(scrollToCurrentItem()),
-            this, SLOT(scrollToCurrentItem()));
 
     if (settings->useSystemFont()) {
         m_font = KGlobalSettings::generalFont();
@@ -868,11 +866,6 @@ void DolphinDetailsView::setFoldersExpandable(bool expandable)
     setItemsExpandable(expandable);
 }
 
-void DolphinDetailsView::scrollToCurrentItem()
-{
-    scrollTo(currentIndex());
-}
-
 void DolphinDetailsView::updateDecorationSize(bool showPreview)
 {
     DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
index e60400b445cf783127f75653262dcada8a389a91..38aea12deef7463f0b9ac286d3a9651bdaea3b0e 100644 (file)
@@ -159,8 +159,6 @@ private slots:
      */
     void setFoldersExpandable(bool expandable);
 
-    void scrollToCurrentItem();
-
 private:
     /**
      * Updates the size of the decoration dependent on the
index 4b861df449a4ba09d6947c04d8dab71a05253975..4c7e9180f8aaf8a80baaea0ba4aa3542167da5a4 100644 (file)
@@ -40,7 +40,6 @@
 
 DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controller) :
     KCategorizedView(parent),
-    m_enableScrollTo(false),
     m_controller(controller),
     m_selectionManager(0),
     m_autoScroller(0),
@@ -88,8 +87,6 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
             controller, SLOT(emitViewportEntered()));
     connect(controller, SIGNAL(zoomLevelChanged(int)),
             this, SLOT(setZoomLevel(int)));
-    connect(controller, SIGNAL(scrollToCurrentItem()),
-            this, SLOT(scrollToCurrentItem()));
 
     const DolphinView* view = controller->dolphinView();
     connect(view, SIGNAL(showPreviewChanged()),
@@ -138,19 +135,6 @@ DolphinIconsView::~DolphinIconsView()
     m_categoryDrawer = 0;
 }
 
-void DolphinIconsView::scrollTo(const QModelIndex& index, ScrollHint hint)
-{
-    // Enable the QListView implementation of scrollTo() only if it has been
-    // triggered by a key press. Otherwise QAbstractItemView wants to scroll to the current
-    // index each time the layout has been changed. This becomes an issue when
-    // previews are loaded and the scrollbar is used: the scrollbar will always
-    // be reset to 0 on each new preview.
-    if (m_enableScrollTo || (state() != QAbstractItemView::NoState)) {
-        KCategorizedView::scrollTo(index, hint);
-        m_enableScrollTo = false;
-    }
-}
-
 void DolphinIconsView::dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
 {
     KCategorizedView::dataChanged(topLeft, bottomRight);
@@ -263,7 +247,6 @@ void DolphinIconsView::dropEvent(QDropEvent* event)
 
 void DolphinIconsView::keyPressEvent(QKeyEvent* event)
 {
-    m_enableScrollTo = true; // see DolphinIconsView::scrollTo()
     KCategorizedView::keyPressEvent(event);
     m_controller->handleKeyPressEvent(event);
 }
@@ -392,13 +375,6 @@ void DolphinIconsView::slotGlobalSettingsChanged(int category)
     }
 }
 
-void DolphinIconsView::scrollToCurrentItem()
-{
-    m_enableScrollTo = true;
-    scrollTo(currentIndex());
-    m_enableScrollTo = false;
-}
-
 void DolphinIconsView::updateGridSize(bool showPreview, int additionalInfoCount)
 {
     const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
index 8a1f1f8dd661aa8ce0c85a1d41c2cbbfb91f7d22..8cb2fd3af7d1edda4861db2289e5879669cd33e3 100644 (file)
@@ -49,7 +49,6 @@ class LIBDOLPHINPRIVATE_EXPORT DolphinIconsView : public KCategorizedView
 public:
     explicit DolphinIconsView(QWidget* parent, DolphinController* controller);
     virtual ~DolphinIconsView();
-    virtual void scrollTo(const QModelIndex& index, ScrollHint hint = EnsureVisible);
 
 protected slots:
     virtual void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
@@ -76,7 +75,6 @@ private slots:
     void setZoomLevel(int level);
     void requestActivation();
     void slotGlobalSettingsChanged(int category);
-    void scrollToCurrentItem();
 
 private:
     /**
@@ -92,7 +90,6 @@ private:
     int additionalInfoCount() const;
 
 private:
-    bool m_enableScrollTo;
     DolphinController* m_controller;
     SelectionManager* m_selectionManager;
     DolphinViewAutoScroller* m_autoScroller;
index 638e6e7cb0fb33a55657b83d04d1382d5df4e8b9..52dac968bbf4cec52192775f3216ea8ec318987a 100644 (file)
@@ -1160,10 +1160,7 @@ void DolphinView::slotRefreshItems()
 {
     if (m_assureVisibleCurrentIndex) {
         m_assureVisibleCurrentIndex = false;
-        // Invoking itemView()->scrollTo(itemView()->currentIndex()) is
-        // not sufficient, as QListView and QTreeView have an inconsistent
-        // default behavior.
-        m_controller->triggerScrollToCurrentItem();
+        itemView()->scrollTo(itemView()->currentIndex());
     }
 }