]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemlistview.cpp
Respect platform's icon sizes
[dolphin.git] / src / kitemviews / kitemlistview.cpp
index 1586c9d96bd705cc304e5541b5b6df89a3987f87..72b3fd8fcbfbaa43660fac359320c8227ade9063 100644 (file)
@@ -1616,6 +1616,11 @@ void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int cha
         }
 
         if (animate) {
+            if (m_animation->isStarted(widget, KItemListViewAnimation::MovingAnimation)) {
+                m_animation->start(widget,  KItemListViewAnimation::MovingAnimation, newPos);
+                applyNewPos = false;
+            }
+
             const bool itemsRemoved = (changedCount < 0);
             const bool itemsInserted = (changedCount > 0);
             if (itemsRemoved && (i >= changedIndex + changedCount + 1)) {
@@ -1748,7 +1753,7 @@ bool KItemListView::moveWidget(KItemListWidget* widget,const QPointF& newPos)
 
     if (m_itemSize.isEmpty()) {
         // The items are not aligned in a grid but either as columns or rows.
-        startMovingAnim = !supportsItemExpanding();
+        startMovingAnim = true;
     } else {
         // When having a grid the moving-animation should only be started, if it is done within
         // one row in the vertical scroll-orientation or one column in the horizontal scroll-orientation.
@@ -2313,19 +2318,32 @@ int KItemListView::showDropIndicator(const QPointF& pos)
         const QPointF mappedPos = widget->mapFromItem(this, pos);
         const QRectF rect = itemRect(widget->index());
         if (mappedPos.y() >= 0 && mappedPos.y() <= rect.height()) {
-            const qreal y = (mappedPos.y () < rect.height() / 2) ?
-                            rect.top() : rect.bottom();
+            if (m_model->supportsDropping(widget->index())) {
+                const int gap = qMax(4, m_styleOption.padding);
+                if (mappedPos.y() >= gap && mappedPos.y() <= rect.height() - gap) {
+                    return -1;
+                }
+            }
+
+            const bool isAboveItem = (mappedPos.y () < rect.height() / 2);
+            const qreal y = isAboveItem ? rect.top() : rect.bottom();
 
             const QRectF draggingInsertIndicator(rect.left(), y, rect.width(), 1);
             if (m_dropIndicator != draggingInsertIndicator) {
                 m_dropIndicator = draggingInsertIndicator;
                 update();
             }
-            return widget->index();
+
+            int index = widget->index();
+            if (!isAboveItem) {
+                ++index;
+            }
+            return index;
         }
     }
 
-    return -1;
+    const QRectF firstItemRect = itemRect(firstVisibleIndex());
+    return (pos.y() <= firstItemRect.top()) ? 0 : -1;
 }
 
 void KItemListView::hideDropIndicator()