itemSize,
m_layouter->itemMargin());
- const bool updateAlternateBackgrounds = (m_visibleRoles.count() > 1) &&
- (( m_itemSize.isEmpty() && !itemSize.isEmpty()) ||
- (!m_itemSize.isEmpty() && itemSize.isEmpty()));
+ const bool alternateBackgroundsChanged = (m_visibleRoles.count() > 1) &&
+ (( m_itemSize.isEmpty() && !itemSize.isEmpty()) ||
+ (!m_itemSize.isEmpty() && itemSize.isEmpty()));
m_itemSize = itemSize;
- if (updateAlternateBackgrounds) {
+ if (alternateBackgroundsChanged) {
// For an empty item size alternate backgrounds are drawn if more than
// one role is shown. Assure that the backgrounds for visible items are
// updated when changing the size in this context.
- QHashIterator<int, KItemListWidget*> it(m_visibleItems);
- while (it.hasNext()) {
- it.next();
- updateAlternateBackgroundForWidget(it.value());
- }
+ updateAlternateBackgrounds();
}
if (itemSize.isEmpty()) {
const QList<QByteArray> previousRoles = m_visibleRoles;
m_visibleRoles = roles;
- const bool updateAlternateBackgrounds = m_itemSize.isEmpty() &&
- ((roles.count() > 1 && previousRoles.count() <= 1) ||
- (roles.count() <= 1 && previousRoles.count() > 1));
+ const bool alternateBackgroundsChanged = m_itemSize.isEmpty() &&
+ ((roles.count() > 1 && previousRoles.count() <= 1) ||
+ (roles.count() <= 1 && previousRoles.count() > 1));
QHashIterator<int, KItemListWidget*> it(m_visibleItems);
while (it.hasNext()) {
KItemListWidget* widget = it.value();
widget->setVisibleRoles(roles);
widget->setVisibleRolesSizes(m_stretchedVisibleRolesSizes);
- if (updateAlternateBackgrounds) {
+ if (alternateBackgroundsChanged) {
updateAlternateBackgroundForWidget(widget);
}
}
endTransaction();
updateSiblingsInformation();
}
+
+ if (useAlternateBackgrounds()) {
+ updateAlternateBackgrounds();
+ }
}
void KItemListView::slotItemsRemoved(const KItemRangeList& itemRanges)
endTransaction();
updateSiblingsInformation();
}
+
+ if (useAlternateBackgrounds()) {
+ updateAlternateBackgrounds();
+ }
}
void KItemListView::slotItemsMoved(const KItemRange& itemRange, const QList<int>& movedToIndexes)
// Changing the group mode requires to update the alternate backgrounds
// as with the enabled group mode the altering is done on base of the first
// group item.
- QHashIterator<int, KItemListWidget*> it(m_visibleItems);
- while (it.hasNext()) {
- it.next();
- updateAlternateBackgroundForWidget(it.value());
- }
+ updateAlternateBackgrounds();
}
-
updateSiblingsInformation();
doLayout(NoAnimation);
}
return mid;
}
+void KItemListView::updateAlternateBackgrounds()
+{
+ QHashIterator<int, KItemListWidget*> it(m_visibleItems);
+ while (it.hasNext()) {
+ it.next();
+ updateAlternateBackgroundForWidget(it.value());
+ }
+}
+
void KItemListView::updateAlternateBackgroundForWidget(KItemListWidget* widget)
{
bool enabled = useAlternateBackgrounds();