]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemlistview.cpp
Fix selection issue when expanding a tree
[dolphin.git] / src / kitemviews / kitemlistview.cpp
index 20a5f4847c897f99353f9b5eed77c2a2c89e57a8..5dbc128b5428af11254d5f176f0f450597177677 100644 (file)
@@ -201,13 +201,19 @@ qreal KItemListView::maximumScrollOffset() const
 
 void KItemListView::setItemOffset(qreal offset)
 {
+    if (m_layouter->itemOffset() == offset) {
+        return;
+    }
+
     m_layouter->setItemOffset(offset);
     if (m_header) {
         m_header->setPos(-offset, 0);
     }
-    if (!m_layoutTimer->isActive()) {
-        doLayout(NoAnimation);
-    }
+
+    // Don't check whether the m_layoutTimer is active: Changing the
+    // item offset must always trigger a synchronous layout, otherwise
+    // the smooth-scrolling might get jerky.
+    doLayout(NoAnimation);
 }
 
 qreal KItemListView::itemOffset() const
@@ -485,11 +491,6 @@ void KItemListView::scrollToItem(int index)
     }
 }
 
-int KItemListView::itemsPerOffset() const
-{
-    return m_layouter->itemsPerOffset();
-}
-
 void KItemListView::beginTransaction()
 {
     ++m_activeTransactions;
@@ -1170,7 +1171,9 @@ void KItemListView::triggerAutoScrolling()
     // the autoscrolling may not get skipped anymore until a new rubberband is created
     m_skipAutoScrollForRubberBand = false;
 
-    setScrollOffset(scrollOffset() + m_autoScrollIncrement);
+    const qreal maxVisibleOffset = qMax(qreal(0), maximumScrollOffset() - visibleSize);
+    const qreal newScrollOffset = qMin(scrollOffset() + m_autoScrollIncrement, maxVisibleOffset);
+    setScrollOffset(newScrollOffset);
 
    // Trigger the autoscroll timer which will periodically call
    // triggerAutoScrolling()