]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemlistview.cpp
KItemList: fix warnings
[dolphin.git] / src / kitemviews / kitemlistview.cpp
index 239e399a45b9060701bb4adb5a65177701d12f33..eb74b96558c8de617e33d88c5f0c6e279762c789 100644 (file)
@@ -77,7 +77,6 @@ KItemListView::KItemListView(QGraphicsWidget* parent) :
     m_visibleItems(),
     m_visibleGroups(),
     m_visibleCells(),
-    m_sizeHintResolver(nullptr),
     m_layouter(nullptr),
     m_animation(nullptr),
     m_oldScrollOffset(0),
@@ -93,7 +92,8 @@ KItemListView::KItemListView(QGraphicsWidget* parent) :
     m_header(nullptr),
     m_headerWidget(nullptr),
     m_indicatorAnimation(nullptr),
-    m_dropIndicator()
+    m_dropIndicator(),
+    m_sizeHintResolver(nullptr)
 {
     setAcceptHoverEvents(true);
     setAcceptTouchEvents(true);
@@ -1858,6 +1858,8 @@ void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int cha
         Q_ASSERT(widget->index() == i);
         widget->setVisible(true);
 
+        bool animateIconResizing = animate;
+
         if (widget->size() != itemBounds.size()) {
             // Resize the widget for the item to the changed size.
             if (animate) {
@@ -1874,11 +1876,13 @@ void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int cha
             } else {
                 widget->resize(itemBounds.size());
             }
+        } else {
+            animateIconResizing = false;
         }
 
         const int newIconSize = widget->styleOption().iconSize;
         if (widget->iconSize() != newIconSize) {
-            if (animate) {
+            if (animateIconResizing) {
                 m_animation->start(widget, KItemListViewAnimation::IconResizeAnimation, newIconSize);
             } else {
                 widget->setIconSize(newIconSize);
@@ -2405,7 +2409,9 @@ void KItemListView::applyAutomaticColumnWidths()
     qreal firstColumnWidth = m_headerWidget->columnWidth(firstRole);
     QSizeF dynamicItemSize = m_itemSize;
 
-    qreal requiredWidth = columnWidthsSum() + m_headerWidget->leadingPadding();
+    qreal requiredWidth = columnWidthsSum() + m_headerWidget->leadingPadding()
+        + m_headerWidget->leadingPadding(); // Adding the padding a second time so we have the same padding symmetrically on both sides of the view.
+        // This improves UX, looks better and increases the chances of users figuring out that the padding area can be used for deselecting and dropping files.
     const qreal availableWidth = size().width();
     if (requiredWidth < availableWidth) {
         // Stretch the first column to use the whole remaining width