]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemlistview.cpp
Fix style-issues in items when not using Oxygen
[dolphin.git] / src / kitemviews / kitemlistview.cpp
index bda559d2c499578a7c7e3e0aafb5426fe4eabde6..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()
@@ -1385,7 +1388,17 @@ void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int cha
         widget->setVisible(true);
 
         if (widget->size() != itemBounds.size()) {
+            // Resize the widget for the item to the changed size.
             if (animate) {
+                // If a dynamic item size is used then no animation is done in the direction
+                // of the dynamic size.
+                if (m_itemSize.width() <= 0) {
+                    // The width is dynamic, apply the new width without animation.
+                    widget->resize(itemBounds.width(), widget->size().height());
+                } else if (m_itemSize.height() <= 0) {
+                    // The height is dynamic, apply the new height without animation.
+                    widget->resize(widget->size().width(), itemBounds.height());
+                }
                 m_animation->start(widget, KItemListViewAnimation::ResizeAnimation, itemBounds.size());
             } else {
                 widget->resize(itemBounds.size());