]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kstandarditemlistview.cpp
Prevent repeated re-layouting of all items while previews are generated
[dolphin.git] / src / kitemviews / kstandarditemlistview.cpp
index f4d05dcf6b9729e94607f7e88abb109550dc7ec8..bd4f6081fc1cb9dd8be49a0e31baab3e2177f45c 100644 (file)
@@ -104,17 +104,17 @@ void KStandardItemListView::initializeItemListWidget(KItemListWidget* item)
 
 bool KStandardItemListView::itemSizeHintUpdateRequired(const QSet<QByteArray>& changedRoles) const
 {
+    // The only thing that can modify the item's size hint is the amount of space
+    // needed to display the text for the visible roles.
     // Even if the icons have a different size they are always aligned within
     // the area defined by KItemStyleOption.iconSize and hence result in no
     // change of the item-size.
-    const bool containsIconName = changedRoles.contains("iconName");
-    const bool containsIconPixmap = changedRoles.contains("iconPixmap");
-    const int count = changedRoles.count();
-
-    const bool iconChanged = (containsIconName && containsIconPixmap && count == 2) ||
-                             (containsIconName && count == 1) ||
-                             (containsIconPixmap && count == 1);
-    return !iconChanged;
+    foreach (const QByteArray& role, visibleRoles()) {
+        if (changedRoles.contains(role)) {
+            return true;
+        }
+    }
+    return false;
 }
 
 void KStandardItemListView::onItemLayoutChanged(ItemLayout current, ItemLayout previous)
@@ -141,9 +141,9 @@ void KStandardItemListView::onSupportsItemExpandingChanged(bool supportsExpandin
 void KStandardItemListView::polishEvent()
 {
     switch (m_itemLayout) {
-    case IconsLayout:   applyDefaultStyleOption(KIconLoader::SizeMedium, 2, 4, 8); break;
-    case CompactLayout: applyDefaultStyleOption(KIconLoader::SizeSmall,  2, 8, 0); break;
-    case DetailsLayout: applyDefaultStyleOption(KIconLoader::SizeSmall,  2, 0, 0); break;
+    case IconsLayout:   applyDefaultStyleOption(style()->pixelMetric(QStyle::PM_LargeIconSize), 2, 4, 8); break;
+    case CompactLayout: applyDefaultStyleOption(style()->pixelMetric(QStyle::PM_SmallIconSize),  2, 8, 0); break;
+    case DetailsLayout: applyDefaultStyleOption(style()->pixelMetric(QStyle::PM_SmallIconSize),  2, 0, 0); break;
     default:            Q_ASSERT(false); break;
     }