const ItemLayout previous = m_itemLayout;
m_itemLayout = layout;
- switch (layout) {
- case IconsLayout:
- setScrollOrientation(Qt::Vertical);
- setSupportsItemExpanding(false);
- break;
- case DetailsLayout:
- setScrollOrientation(Qt::Vertical);
- setSupportsItemExpanding(true);
- break;
- case CompactLayout:
- setScrollOrientation(Qt::Horizontal);
- setSupportsItemExpanding(false);
- break;
- default:
- Q_ASSERT(false);
- break;
- }
+ setSupportsItemExpanding(itemLayoutSupportsItemExpanding(layout));
+ setScrollOrientation(layout == CompactLayout ? Qt::Horizontal : Qt::Vertical);
onItemLayoutChanged(layout, previous);
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;
+}
+
+bool KStandardItemListView::itemLayoutSupportsItemExpanding(ItemLayout layout) const
+{
+ return layout == DetailsLayout;
}
void KStandardItemListView::onItemLayoutChanged(ItemLayout current, ItemLayout previous)