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);
triggerVisibleIndexRangeUpdate();
}
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);
return false;
}
+bool KStandardItemListView::itemLayoutSupportsItemExpanding(ItemLayout layout) const
+{
+ return layout == DetailsLayout;
+}
+
void KStandardItemListView::onItemLayoutChanged(ItemLayout current, ItemLayout previous)
{
Q_UNUSED(current);
virtual KItemListGroupHeaderCreatorBase* defaultGroupHeaderCreator() const;
virtual void initializeItemListWidget(KItemListWidget* item);
virtual bool itemSizeHintUpdateRequired(const QSet<QByteArray>& changedRoles) const;
+ virtual bool itemLayoutSupportsItemExpanding(ItemLayout layout) const;
virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous);
virtual void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous);
virtual void onSupportsItemExpandingChanged(bool supportsExpanding);
beginTransaction();
setEnabledSelectionToggles(GeneralSettings::showSelectionToggle());
-
- const bool expandableFolders = (itemLayout() == KFileItemListView::DetailsLayout) &&
- DetailsModeSettings::expandableFolders();
- setSupportsItemExpanding(expandableFolders);
+ setSupportsItemExpanding(itemLayoutSupportsItemExpanding(itemLayout()));
updateFont();
updateGridSize();
return new KItemListWidgetCreator<DolphinFileItemListWidget>();
}
-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)
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<QByteArray>& current,