From 3991e9d24eb2aba2ea7228f925cfa0a60e55463f Mon Sep 17 00:00:00 2001 From: Frank Reininghaus Date: Wed, 24 Jul 2013 22:30:54 +0200 Subject: Make sure that widgets are initialized when changing the view mode The problem was that DolphinItemListView overrides the virtual function onItemLayoutChanged() without calling the base class implementation. Therefore, KStandardItemListView::updateLayoutOfVisibleItems(), which calls initializeItemListWidget(), is never called. This patch refactors the "change item layout"/"supports item expanding" code a bit to make it more robust and fix the problem that the view looks "messed up" when switching from Details View without expandable folders to Icons View. I'm only pushing this patch to master (going to be KDE 4.12). The patch is a bit too intrusive for the KDE/4.11 branch for my taste at this point of the release cycle, and the bug is not a real showstopper. If it works well in master, one could consider backporting it to a 4.11.x bug fix release. Thanks to Emmanuel Pescosta for helping to analyze this issue. BUG: 302703 REVIEW: 111632 FIXED-IN: 4.12.0 --- src/kitemviews/kstandarditemlistview.cpp | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) (limited to 'src/kitemviews/kstandarditemlistview.cpp') diff --git a/src/kitemviews/kstandarditemlistview.cpp b/src/kitemviews/kstandarditemlistview.cpp index bd4f6081f..135cd0b7d 100644 --- a/src/kitemviews/kstandarditemlistview.cpp +++ b/src/kitemviews/kstandarditemlistview.cpp @@ -48,23 +48,8 @@ void KStandardItemListView::setItemLayout(ItemLayout layout) 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); @@ -117,6 +102,11 @@ bool KStandardItemListView::itemSizeHintUpdateRequired(const QSet& c return false; } +bool KStandardItemListView::itemLayoutSupportsItemExpanding(ItemLayout layout) const +{ + return layout == DetailsLayout; +} + void KStandardItemListView::onItemLayoutChanged(ItemLayout current, ItemLayout previous) { Q_UNUSED(current); -- cgit v1.3