]> cloud.milkyroute.net Git - dolphin.git/commitdiff
When restoring the index, we don't necessarily want to scroll to it.
authorSimon Paul St James <kdedevel@etotheipiplusone.com>
Sun, 26 Oct 2008 17:25:14 +0000 (17:25 +0000)
committerSimon Paul St James <kdedevel@etotheipiplusone.com>
Sun, 26 Oct 2008 17:25:14 +0000 (17:25 +0000)
BUG:165551

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

src/dolphindetailsview.cpp
src/dolphindetailsview.h

index 6563cb6586b3ff7da7c26f3a2d88edd6f0021e18..3ccca4622f193de73646635f40cdc0f4b9548ba7 100644 (file)
@@ -55,7 +55,8 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr
     m_selectionManager(0),
     m_font(),
     m_decorationSize(),
-    m_band()   
+    m_band(),
+    m_ignoreScrollTo(false)
 {
     const DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
     Q_ASSERT(settings != 0);
@@ -228,9 +229,11 @@ void DolphinDetailsView::mousePressEvent(QMouseEvent* event)
             clearSelection();
         }
 
-        // restore the current index, other columns are handled as viewport area
+        // restore the current index, other columns are handled as viewport area.
+        // setCurrentIndex(...) implicitly calls scrollTo(...), which we want to ignore.
+        m_ignoreScrollTo = true;
         selectionModel()->setCurrentIndex(current, QItemSelectionModel::Current);
-        
+        m_ignoreScrollTo = false;
 
         if ((event->button() == Qt::LeftButton) && !m_expandingTogglePressed) {
             // Inform Qt about what we are doing - otherwise it starts dragging items around!
@@ -466,6 +469,13 @@ void DolphinDetailsView::setSelection(const QRect &rect, QItemSelectionModel::Se
     }
 }
 
+void DolphinDetailsView::scrollTo(const QModelIndex & index, ScrollHint hint)
+{
+    if (m_ignoreScrollTo)
+        return;
+    QTreeView::scrollTo(index, hint);
+}
+
 void DolphinDetailsView::setSortIndicatorSection(DolphinView::Sorting sorting)
 {
     QHeaderView* headerView = header();
index 7b08e25a1531028a58f54c31c63d74254f12aedc..e974635e58cb1844aaee25699b9cee2cba0bb08f 100644 (file)
@@ -65,6 +65,7 @@ protected:
     virtual bool eventFilter(QObject* watched, QEvent* event);
     virtual QModelIndex indexAt (const QPoint& point) const;
     virtual void setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags command);
+    virtual void scrollTo (const QModelIndex & index, ScrollHint hint = EnsureVisible);
 
 private slots:
     /**
@@ -176,6 +177,7 @@ private:
     bool m_expandingTogglePressed : 1;
     bool m_keyPressed : 1;        // true if a key is pressed currently; info used by currentChanged()
     bool m_useDefaultIndexAt : 1; // true, if QTreeView::indexAt() should be used
+    bool m_ignoreScrollTo : 1;    // true if calls to scrollTo(...) should do nothing.
 
     DolphinController* m_controller;
     SelectionManager* m_selectionManager;