]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemlistcontainer.cpp
Provide basic rubberband functionality
[dolphin.git] / src / kitemviews / kitemlistcontainer.cpp
index 28e526a6f04def5e1055c53ecd102a0bf1d2a64a..b01751e46cfd44067d09921b52c1419de164d5d0 100644 (file)
@@ -210,18 +210,32 @@ void KItemListContainer::slotViewChanged(KItemListView* current, KItemListView*
     QGraphicsScene* scene = static_cast<QGraphicsView*>(viewport())->scene();
     if (previous) {
         scene->removeItem(previous);
-        disconnect(previous, SIGNAL(offsetChanged(int,int)), this, SLOT(updateScrollBars()));
-        disconnect(previous, SIGNAL(maximumOffsetChanged(int,int)), this, SLOT(updateScrollBars()));
+        disconnect(previous, SIGNAL(offsetChanged(qreal,qreal)), this, SLOT(updateScrollBars()));
+        disconnect(previous, SIGNAL(maximumOffsetChanged(qreal,qreal)), this, SLOT(updateScrollBars()));
+        disconnect(previous, SIGNAL(scrollTo(qreal)), this, SLOT(scrollTo(qreal)));
         m_viewOffsetAnimation->setTargetObject(0);
     }
     if (current) {
         scene->addItem(current);
-        connect(current, SIGNAL(offsetChanged(int,int)), this, SLOT(updateScrollBars()));
-        connect(current, SIGNAL(maximumOffsetChanged(int,int)), this, SLOT(updateScrollBars()));
+        connect(current, SIGNAL(offsetChanged(qreal,qreal)), this, SLOT(updateScrollBars()));
+        connect(current, SIGNAL(maximumOffsetChanged(qreal,qreal)), this, SLOT(updateScrollBars()));
+        connect(current, SIGNAL(scrollTo(qreal)), this, SLOT(scrollTo(qreal)));
         m_viewOffsetAnimation->setTargetObject(current);
     }
 }
 
+void KItemListContainer::scrollTo(qreal offset)
+{
+    const KItemListView* view = m_controller->view();
+    if (!view) {
+        return;
+    }
+
+    QScrollBar* scrollBar = (view->scrollOrientation() == Qt::Vertical)
+                            ? verticalScrollBar() : horizontalScrollBar();
+    scrollBar->setValue(offset);
+}
+
 void KItemListContainer::updateScrollBars()
 {
     const KItemListView* view = m_controller->view();
@@ -311,7 +325,7 @@ void KItemListContainer::initialize()
     setViewport(graphicsView);
 
     m_viewOffsetAnimation = new QPropertyAnimation(this, "offset");
-    m_viewOffsetAnimation->setDuration(500);
+    m_viewOffsetAnimation->setDuration(300);
 
     horizontalScrollBar()->installEventFilter(this);
     verticalScrollBar()->installEventFilter(this);