]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemlistcontainer.cpp
Merge branch 'Applications/16.04'
[dolphin.git] / src / kitemviews / kitemlistcontainer.cpp
index 39e62962e206c337a00dfa331549f3911f56b4c4..69a0a5f27999d7f48a5b886d4b583470c2bb1508 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
@@ -45,6 +43,8 @@
  */
 class KItemListContainerViewport : public QGraphicsView
 {
+    Q_OBJECT
+
 public:
     KItemListContainerViewport(QGraphicsScene* scene, QWidget* parent);
 protected:
@@ -185,11 +185,25 @@ 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);
+    if (!event->pixelDelta().isNull()) {
+        const int numPixels =  event->pixelDelta().y();
+        if (event->modifiers().testFlag(Qt::ShiftModifier)) {
+            const int scrollingDirection = numPixels > 0 ? 1 : -1;
+            smoothScroller->scrollTo(scrollBar->value() - scrollBar->pageStep() * scrollingDirection);
+        } else {
+            smoothScroller->scrollTo(scrollBar->value() - numPixels);
+        }
+    } else {
+        const int numDegrees = event->angleDelta().y() / 8;
+        const int numSteps = qApp->wheelScrollLines() * numDegrees / 15;
+        if (event->modifiers().testFlag(Qt::ShiftModifier)) {
+            const int scrollingDirection = numSteps > 0 ? 1 : -1;
+            smoothScroller->scrollTo(scrollBar->value() - scrollBar->pageStep() * scrollingDirection);
+        } else {
+            smoothScroller->scrollTo(scrollBar->value() - numSteps * scrollBar->pageStep() / 12);
+        }
+    }
 
     event->accept();
 }