]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphindetailsview.cpp
SVN_SILENT: minor coding style cleanups
[dolphin.git] / src / dolphindetailsview.cpp
index f92a28e79104421191e1f000a89b0ac8b3835a31..9ccb75b8ef5a19d52046a88198626479f2bb2ffd 100644 (file)
@@ -55,6 +55,7 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr
     m_ignoreScrollTo(false),
     m_controller(controller),
     m_selectionManager(0),
+    m_autoScroller(0),
     m_font(),
     m_decorationSize(),
     m_band()
@@ -76,7 +77,7 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr
     setEditTriggers(QAbstractItemView::NoEditTriggers);
 
     setMouseTracking(true);
-    new DolphinViewAutoScroller(this);
+    m_autoScroller = new DolphinViewAutoScroller(this);
 
     const ViewProperties props(controller->url());
     setSortIndicatorSection(props.sorting());
@@ -209,7 +210,6 @@ void DolphinDetailsView::mousePressEvent(QMouseEvent* event)
             setState(QAbstractItemView::DraggingState);
         } else {
             m_expandingTogglePressed = true;
-            kDebug() << "m_expandingTogglePressed " << m_expandingTogglePressed;
         }
     }
 
@@ -424,7 +424,7 @@ void DolphinDetailsView::wheelEvent(QWheelEvent* event)
 void DolphinDetailsView::currentChanged(const QModelIndex& current, const QModelIndex& previous)
 {
     QTreeView::currentChanged(current, previous);
-    if (current.isValid()) {
+    if (current.isValid() && !m_autoScroller->isActive()) {
         scrollTo(current);
     }
 
@@ -465,7 +465,6 @@ void DolphinDetailsView::setSelection(const QRect &rect, QItemSelectionModel::Se
         QTreeView::setSelection(rect, command);
         m_useDefaultIndexAt = false;
     } else {
-
         // Use our own elastic band selection algorithm
         updateElasticBandSelection();
     }
@@ -473,9 +472,9 @@ void DolphinDetailsView::setSelection(const QRect &rect, QItemSelectionModel::Se
 
 void DolphinDetailsView::scrollTo(const QModelIndex & index, ScrollHint hint)
 {
-    if (m_ignoreScrollTo)
-        return;
-    QTreeView::scrollTo(index, hint);
+    if (!m_ignoreScrollTo) {
+        QTreeView::scrollTo(index, hint);
+    }
 }
 
 void DolphinDetailsView::setSortIndicatorSection(DolphinView::Sorting sorting)
@@ -517,10 +516,12 @@ void DolphinDetailsView::updateElasticBand()
         m_band.destination = viewport()->mapFromGlobal(QCursor::pos()) + scrollPos;
         // Going above the (logical) top-left of the view causes complications during selection;
         // we may as well prevent it.
-        if (m_band.destination.y() < 0)
+        if (m_band.destination.y() < 0) {
             m_band.destination.setY(0);
-        if (m_band.destination.x() < 0)
+        }
+        if (m_band.destination.x() < 0) {
             m_band.destination.setX(0);
+        }
 
         dirtyRegion = dirtyRegion.united(elasticBandRect());
         setDirtyRegion(dirtyRegion);