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/views/dolphinitemlistview.cpp | 21 +++++++++------------ src/views/dolphinitemlistview.h | 1 + 2 files changed, 10 insertions(+), 12 deletions(-) (limited to 'src/views') diff --git a/src/views/dolphinitemlistview.cpp b/src/views/dolphinitemlistview.cpp index 039b5f230..4799d7679 100644 --- a/src/views/dolphinitemlistview.cpp +++ b/src/views/dolphinitemlistview.cpp @@ -89,10 +89,7 @@ void DolphinItemListView::readSettings() beginTransaction(); setEnabledSelectionToggles(GeneralSettings::showSelectionToggle()); - - const bool expandableFolders = (itemLayout() == KFileItemListView::DetailsLayout) && - DetailsModeSettings::expandableFolders(); - setSupportsItemExpanding(expandableFolders); + setSupportsItemExpanding(itemLayoutSupportsItemExpanding(itemLayout())); updateFont(); updateGridSize(); @@ -119,19 +116,19 @@ KItemListWidgetCreatorBase* DolphinItemListView::defaultWidgetCreator() const return new KItemListWidgetCreator(); } -void DolphinItemListView::onItemLayoutChanged(ItemLayout current, ItemLayout previous) +bool DolphinItemListView::itemLayoutSupportsItemExpanding(ItemLayout layout) const { - Q_UNUSED(previous); + return layout == DetailsLayout && DetailsModeSettings::expandableFolders(); +} - if (current == DetailsLayout) { - setSupportsItemExpanding(DetailsModeSettings::expandableFolders()); - setHeaderVisible(true); - } else { - setHeaderVisible(false); - } +void DolphinItemListView::onItemLayoutChanged(ItemLayout current, ItemLayout previous) +{ + setHeaderVisible(current == DetailsLayout); updateFont(); updateGridSize(); + + KFileItemListView::onItemLayoutChanged(current, previous); } void DolphinItemListView::onPreviewsShownChanged(bool shown) diff --git a/src/views/dolphinitemlistview.h b/src/views/dolphinitemlistview.h index c2d86cc5e..18bb284ac 100644 --- a/src/views/dolphinitemlistview.h +++ b/src/views/dolphinitemlistview.h @@ -50,6 +50,7 @@ public: protected: virtual KItemListWidgetCreatorBase* defaultWidgetCreator() const; + virtual bool itemLayoutSupportsItemExpanding(ItemLayout layout) const; virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous); virtual void onPreviewsShownChanged(bool shown); virtual void onVisibleRolesChanged(const QList& current, -- cgit v1.3