]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Prevent repeated re-layouting of all items while previews are generated
authorFrank Reininghaus <frank78ac@googlemail.com>
Sun, 17 Feb 2013 10:21:00 +0000 (11:21 +0100)
committerFrank Reininghaus <frank78ac@googlemail.com>
Sun, 17 Feb 2013 10:30:38 +0000 (11:30 +0100)
There was some code in KStandardItemListView::itemSizeHintUpdateRequired
already that was supposed to prevent an expensive re-layouting of all
items when a preview is received. However, it didn't quite work as
intended because also the "iconOverlays" role changed.

The new approach is to only re-layout if text of a visible role changes,
because this is the only way how the space needed by an item might
change (see KStandardItemListWidgetInformant::itemSizeHint()).

BUG: 315315
FIXED-IN: 4.10.1
REVIEW: 108984

src/kitemviews/kstandarditemlistview.cpp

index 79eb86b891f865697f467ae3f2839caf7fa5c329..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)