From 475f8b1261a6ea106ca9dd90b625ea95fe63a4c7 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Fri, 9 Mar 2012 16:12:00 +0100 Subject: Details view: Allow to turn off expandable folders like in Dolphin 1.7 The option for turning off expandable folders has been removed with the new view-engine. Due to several requests this option has been readded again. As for 4.8.x no new user-interface strings may be introduced, the line ExpandableFolders=false must be manually added below the section "[DetailsMode]" in the file ~/.kde/share/config/dolphinrc if the expandable-folders feature should be disabled. Thanks to H.H. "cyberbeat" for the initial patch! BUG: 289090 FIXED-IN: 4.8.2 --- src/kitemviews/kfileitemlistwidget.cpp | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'src/kitemviews/kfileitemlistwidget.cpp') diff --git a/src/kitemviews/kfileitemlistwidget.cpp b/src/kitemviews/kfileitemlistwidget.cpp index c477a37ae..fb0f4df57 100644 --- a/src/kitemviews/kfileitemlistwidget.cpp +++ b/src/kitemviews/kfileitemlistwidget.cpp @@ -45,6 +45,7 @@ KFileItemListWidget::KFileItemListWidget(QGraphicsItem* parent) : m_isCut(false), m_isHidden(false), m_isExpandable(false), + m_supportsItemExpanding(false), m_dirtyLayout(true), m_dirtyContent(true), m_dirtyContentRoles(), @@ -88,6 +89,20 @@ KFileItemListWidget::Layout KFileItemListWidget::layout() const return m_layout; } +void KFileItemListWidget::setSupportsItemExpanding(bool supportsItemExpanding) +{ + if (m_supportsItemExpanding != supportsItemExpanding) { + m_supportsItemExpanding = supportsItemExpanding; + m_dirtyLayout = true; + update(); + } +} + +bool KFileItemListWidget::supportsItemExpanding() const +{ + return m_supportsItemExpanding; +} + void KFileItemListWidget::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { const_cast(this)->triggerCacheRefreshing(); @@ -119,7 +134,7 @@ void KFileItemListWidget::paint(QPainter* painter, const QStyleOptionGraphicsIte painter->drawStaticText(m_textPos[Name], m_text[Name]); bool clipAdditionalInfoBounds = false; - if (m_layout == DetailsLayout) { + if (m_supportsItemExpanding) { // Prevent a possible overlapping of the additional-information texts // with the icon. This can happen if the user has minimized the width // of the name-column to a very small value. @@ -418,7 +433,7 @@ void KFileItemListWidget::triggerCacheRefreshing() refreshCache(); const QHash values = data(); - m_isExpandable = values["isExpandable"].toBool(); + m_isExpandable = m_supportsItemExpanding && values["isExpandable"].toBool(); m_isHidden = values["name"].toString().startsWith(QLatin1Char('.')); updateExpansionArea(); @@ -432,7 +447,7 @@ void KFileItemListWidget::triggerCacheRefreshing() void KFileItemListWidget::updateExpansionArea() { - if (m_layout == DetailsLayout) { + if (m_supportsItemExpanding) { const QHash values = data(); Q_ASSERT(values.contains("expandedParentsCount")); const int expandedParentsCount = values.value("expandedParentsCount", 0).toInt(); @@ -751,8 +766,13 @@ void KFileItemListWidget::updateDetailsLayoutTextCache() const int fontHeight = option.fontMetrics.height(); const qreal columnPadding = option.padding * 3; - const qreal firstColumnInc = (m_expansionArea.left() + m_expansionArea.right() + widgetHeight) / 2 - + scaledIconSize; + qreal firstColumnInc = scaledIconSize; + if (m_supportsItemExpanding) { + firstColumnInc += (m_expansionArea.left() + m_expansionArea.right() + widgetHeight) / 2; + } else { + firstColumnInc += option.padding; + } + qreal x = firstColumnInc; const qreal y = qMax(qreal(option.padding), (widgetHeight - fontHeight) / 2); -- cgit v1.3