]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemlistcontainer.cpp
Fix scrolling during inline renaming causes rename of wrong file
[dolphin.git] / src / kitemviews / kitemlistcontainer.cpp
index 765b366d1aa219e9f8dbadaec1ed5bc749022113..b4ea62fac354249d66e4977d94807c6d05f515a0 100644 (file)
 #include <QApplication>
 #include <QGraphicsScene>
 #include <QGraphicsView>
-#include <QPropertyAnimation>
 #include <QScrollBar>
 #include <QStyle>
 #include <QStyleOption>
 
-#include <KDebug>
 
 /**
  * Replaces the default viewport of KItemListContainer by a
  */
 class KItemListContainerViewport : public QGraphicsView
 {
+    Q_OBJECT
+
 public:
     KItemListContainerViewport(QGraphicsScene* scene, QWidget* parent);
 protected:
-    virtual void wheelEvent(QWheelEvent* event);
+    void wheelEvent(QWheelEvent* event) Q_DECL_OVERRIDE;
 };
 
 KItemListContainerViewport::KItemListContainerViewport(QGraphicsScene* scene, QWidget* parent) :
@@ -185,13 +185,7 @@ void KItemListContainer::wheelEvent(QWheelEvent* event)
     KItemListSmoothScroller* smoothScroller = scrollHorizontally ?
                                               m_horizontalSmoothScroller : m_verticalSmoothScroller;
 
-    const int numDegrees = event->delta() / 8;
-    const int numSteps = numDegrees / 15;
-
-    const QScrollBar* scrollBar = smoothScroller->scrollBar();
-    smoothScroller->scrollTo(scrollBar->value() - numSteps * scrollBar->pageStep() / 4);
-
-    event->accept();
+    smoothScroller->handleWheelEvent(event);
 }
 
 void KItemListContainer::slotScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous)
@@ -271,7 +265,7 @@ void KItemListContainer::updateScrollOffsetScrollBar()
     if (view->scrollOrientation() == Qt::Vertical) {
         smoothScroller = m_verticalSmoothScroller;
         scrollOffsetScrollBar = verticalScrollBar();
-        singleStep = view->itemSize().height();
+        singleStep = view->itemSizeHint().height();
         // We cannot use view->size().height() because this height might
         // include the header widget, which is not part of the scrolled area.
         pageStep = view->verticalPageStep();
@@ -413,3 +407,4 @@ void KItemListContainer::updateScrollOffsetScrollBarPolicy()
     }
 }
 
+#include "kitemlistcontainer.moc"