mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-19 16:31:21 +00:00
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
This commit is contained in:
parent
4c29992365
commit
69c9100f91
|
@ -213,12 +213,6 @@ void KFileItemListView::onPreviewsShownChanged(bool shown)
|
||||||
|
|
||||||
void KFileItemListView::onItemLayoutChanged(ItemLayout current, ItemLayout previous)
|
void KFileItemListView::onItemLayoutChanged(ItemLayout current, ItemLayout previous)
|
||||||
{
|
{
|
||||||
if (previous == DetailsLayout || current == DetailsLayout) {
|
|
||||||
// The details-layout requires some invisible roles that
|
|
||||||
// must be added to the model if the new layout is "details".
|
|
||||||
// If the old layout was "details" the roles will get removed.
|
|
||||||
applyRolesToModel();
|
|
||||||
}
|
|
||||||
KStandardItemListView::onItemLayoutChanged(current, previous);
|
KStandardItemListView::onItemLayoutChanged(current, previous);
|
||||||
triggerVisibleIndexRangeUpdate();
|
triggerVisibleIndexRangeUpdate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,23 +48,8 @@ void KStandardItemListView::setItemLayout(ItemLayout layout)
|
||||||
const ItemLayout previous = m_itemLayout;
|
const ItemLayout previous = m_itemLayout;
|
||||||
m_itemLayout = layout;
|
m_itemLayout = layout;
|
||||||
|
|
||||||
switch (layout) {
|
setSupportsItemExpanding(itemLayoutSupportsItemExpanding(layout));
|
||||||
case IconsLayout:
|
setScrollOrientation(layout == CompactLayout ? Qt::Horizontal : Qt::Vertical);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
onItemLayoutChanged(layout, previous);
|
onItemLayoutChanged(layout, previous);
|
||||||
|
|
||||||
|
@ -117,6 +102,11 @@ bool KStandardItemListView::itemSizeHintUpdateRequired(const QSet<QByteArray>& c
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool KStandardItemListView::itemLayoutSupportsItemExpanding(ItemLayout layout) const
|
||||||
|
{
|
||||||
|
return layout == DetailsLayout;
|
||||||
|
}
|
||||||
|
|
||||||
void KStandardItemListView::onItemLayoutChanged(ItemLayout current, ItemLayout previous)
|
void KStandardItemListView::onItemLayoutChanged(ItemLayout current, ItemLayout previous)
|
||||||
{
|
{
|
||||||
Q_UNUSED(current);
|
Q_UNUSED(current);
|
||||||
|
|
|
@ -63,6 +63,7 @@ protected:
|
||||||
virtual KItemListGroupHeaderCreatorBase* defaultGroupHeaderCreator() const;
|
virtual KItemListGroupHeaderCreatorBase* defaultGroupHeaderCreator() const;
|
||||||
virtual void initializeItemListWidget(KItemListWidget* item);
|
virtual void initializeItemListWidget(KItemListWidget* item);
|
||||||
virtual bool itemSizeHintUpdateRequired(const QSet<QByteArray>& changedRoles) const;
|
virtual bool itemSizeHintUpdateRequired(const QSet<QByteArray>& changedRoles) const;
|
||||||
|
virtual bool itemLayoutSupportsItemExpanding(ItemLayout layout) const;
|
||||||
virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous);
|
virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous);
|
||||||
virtual void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous);
|
virtual void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous);
|
||||||
virtual void onSupportsItemExpandingChanged(bool supportsExpanding);
|
virtual void onSupportsItemExpandingChanged(bool supportsExpanding);
|
||||||
|
|
|
@ -89,10 +89,7 @@ void DolphinItemListView::readSettings()
|
||||||
beginTransaction();
|
beginTransaction();
|
||||||
|
|
||||||
setEnabledSelectionToggles(GeneralSettings::showSelectionToggle());
|
setEnabledSelectionToggles(GeneralSettings::showSelectionToggle());
|
||||||
|
setSupportsItemExpanding(itemLayoutSupportsItemExpanding(itemLayout()));
|
||||||
const bool expandableFolders = (itemLayout() == KFileItemListView::DetailsLayout) &&
|
|
||||||
DetailsModeSettings::expandableFolders();
|
|
||||||
setSupportsItemExpanding(expandableFolders);
|
|
||||||
|
|
||||||
updateFont();
|
updateFont();
|
||||||
updateGridSize();
|
updateGridSize();
|
||||||
|
@ -119,19 +116,19 @@ KItemListWidgetCreatorBase* DolphinItemListView::defaultWidgetCreator() const
|
||||||
return new KItemListWidgetCreator<DolphinFileItemListWidget>();
|
return new KItemListWidgetCreator<DolphinFileItemListWidget>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DolphinItemListView::itemLayoutSupportsItemExpanding(ItemLayout layout) const
|
||||||
|
{
|
||||||
|
return layout == DetailsLayout && DetailsModeSettings::expandableFolders();
|
||||||
|
}
|
||||||
|
|
||||||
void DolphinItemListView::onItemLayoutChanged(ItemLayout current, ItemLayout previous)
|
void DolphinItemListView::onItemLayoutChanged(ItemLayout current, ItemLayout previous)
|
||||||
{
|
{
|
||||||
Q_UNUSED(previous);
|
setHeaderVisible(current == DetailsLayout);
|
||||||
|
|
||||||
if (current == DetailsLayout) {
|
|
||||||
setSupportsItemExpanding(DetailsModeSettings::expandableFolders());
|
|
||||||
setHeaderVisible(true);
|
|
||||||
} else {
|
|
||||||
setHeaderVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateFont();
|
updateFont();
|
||||||
updateGridSize();
|
updateGridSize();
|
||||||
|
|
||||||
|
KFileItemListView::onItemLayoutChanged(current, previous);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinItemListView::onPreviewsShownChanged(bool shown)
|
void DolphinItemListView::onPreviewsShownChanged(bool shown)
|
||||||
|
|
|
@ -50,6 +50,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual KItemListWidgetCreatorBase* defaultWidgetCreator() const;
|
virtual KItemListWidgetCreatorBase* defaultWidgetCreator() const;
|
||||||
|
virtual bool itemLayoutSupportsItemExpanding(ItemLayout layout) const;
|
||||||
virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous);
|
virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous);
|
||||||
virtual void onPreviewsShownChanged(bool shown);
|
virtual void onPreviewsShownChanged(bool shown);
|
||||||
virtual void onVisibleRolesChanged(const QList<QByteArray>& current,
|
virtual void onVisibleRolesChanged(const QList<QByteArray>& current,
|
||||||
|
|
Loading…
Reference in a new issue