┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kstandarditemlistview.cpp
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2013-02-17 11:21:00 +0100
committerFrank Reininghaus <[email protected]>2013-02-17 11:30:38 +0100
commitfc0c3f9d4e13d3c7ff3fb56e84458e62abf3ad4b (patch)
tree4058b907ae0e9f8be412a5b826bb17f9869e75d5 /src/kitemviews/kstandarditemlistview.cpp
parentd82d92d7dd71c1ef155b0dd5dea34c257fdad65c (diff)
Prevent repeated re-layouting of all items while previews are generated
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
Diffstat (limited to 'src/kitemviews/kstandarditemlistview.cpp')
-rw-r--r--src/kitemviews/kstandarditemlistview.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/kitemviews/kstandarditemlistview.cpp b/src/kitemviews/kstandarditemlistview.cpp
index 79eb86b89..bd4f6081f 100644
--- a/src/kitemviews/kstandarditemlistview.cpp
+++ b/src/kitemviews/kstandarditemlistview.cpp
@@ -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)