diff options
| author | Peter Penz <[email protected]> | 2012-03-09 16:12:00 +0100 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2012-03-09 16:19:19 +0100 |
| commit | 475f8b1261a6ea106ca9dd90b625ea95fe63a4c7 (patch) | |
| tree | 2a90bd16adf04fb8151edc4359323f4fb56ec7e4 /src/kitemviews | |
| parent | 08a485349f2bd73682ac806b97d3630c3a7dd3fd (diff) | |
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
Diffstat (limited to 'src/kitemviews')
| -rw-r--r-- | src/kitemviews/kfileitemlistview.cpp | 13 | ||||
| -rw-r--r-- | src/kitemviews/kfileitemlistview.h | 1 | ||||
| -rw-r--r-- | src/kitemviews/kfileitemlistwidget.cpp | 30 | ||||
| -rw-r--r-- | src/kitemviews/kfileitemlistwidget.h | 4 | ||||
| -rw-r--r-- | src/kitemviews/kitemlistview.cpp | 22 | ||||
| -rw-r--r-- | src/kitemviews/kitemlistview.h | 24 |
6 files changed, 63 insertions, 31 deletions
diff --git a/src/kitemviews/kfileitemlistview.cpp b/src/kitemviews/kfileitemlistview.cpp index 27ef7fdb5..796a45099 100644 --- a/src/kitemviews/kfileitemlistview.cpp +++ b/src/kitemviews/kfileitemlistview.cpp @@ -106,8 +106,6 @@ void KFileItemListView::setItemLayout(Layout layout) applyRolesToModel(); } updateLayoutOfVisibleItems(); - - setSupportsItemExpanding(m_itemLayout == DetailsLayout); } } @@ -324,6 +322,8 @@ void KFileItemListView::initializeItemListWidget(KItemListWidget* item) case DetailsLayout: fileItemListWidget->setLayout(KFileItemListWidget::DetailsLayout); break; default: Q_ASSERT(false); break; } + + fileItemListWidget->setSupportsItemExpanding(supportsItemExpanding()); } bool KFileItemListView::itemSizeHintUpdateRequired(const QSet<QByteArray>& changedRoles) const @@ -388,6 +388,13 @@ void KFileItemListView::onStyleOptionChanged(const KItemListStyleOption& current triggerIconSizeUpdate(); } +void KFileItemListView::onSupportsItemExpandingChanged(bool supportsExpanding) +{ + Q_UNUSED(supportsExpanding); + applyRolesToModel(); + updateLayoutOfVisibleItems(); +} + void KFileItemListView::onTransactionBegin() { m_modelRolesUpdater->setPaused(true); @@ -569,7 +576,7 @@ void KFileItemListView::applyRolesToModel() roles.insert("iconName"); roles.insert("name"); roles.insert("isDir"); - if (m_itemLayout == DetailsLayout) { + if (supportsItemExpanding()) { roles.insert("isExpanded"); roles.insert("isExpandable"); roles.insert("expandedParentsCount"); diff --git a/src/kitemviews/kfileitemlistview.h b/src/kitemviews/kfileitemlistview.h index 897015641..12d0d452b 100644 --- a/src/kitemviews/kfileitemlistview.h +++ b/src/kitemviews/kfileitemlistview.h @@ -92,6 +92,7 @@ protected: virtual void onScrollOffsetChanged(qreal current, qreal previous); virtual void onVisibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous); virtual void onStyleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous); + virtual void onSupportsItemExpandingChanged(bool supportsExpanding); virtual void onTransactionBegin(); virtual void onTransactionEnd(); virtual void resizeEvent(QGraphicsSceneResizeEvent* event); 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<KFileItemListWidget*>(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<QByteArray, QVariant> 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<QByteArray, QVariant> 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); diff --git a/src/kitemviews/kfileitemlistwidget.h b/src/kitemviews/kfileitemlistwidget.h index 2feeca810..495831335 100644 --- a/src/kitemviews/kfileitemlistwidget.h +++ b/src/kitemviews/kfileitemlistwidget.h @@ -46,6 +46,9 @@ public: void setLayout(Layout layout); Layout layout() const; + void setSupportsItemExpanding(bool supportsItemExpanding); + bool supportsItemExpanding() const; + virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0); virtual QRectF iconRect() const; @@ -131,6 +134,7 @@ private: bool m_isCut; bool m_isHidden; bool m_isExpandable; + bool m_supportsItemExpanding; bool m_dirtyLayout; bool m_dirtyContent; diff --git a/src/kitemviews/kitemlistview.cpp b/src/kitemviews/kitemlistview.cpp index a54e06ddc..f1822826d 100644 --- a/src/kitemviews/kitemlistview.cpp +++ b/src/kitemviews/kitemlistview.cpp @@ -524,6 +524,15 @@ QHash<QByteArray, QSizeF> KItemListView::visibleRolesSizes(const KItemRangeList& return QHash<QByteArray, QSizeF>(); } +void KItemListView::setSupportsItemExpanding(bool supportsExpanding) +{ + if (m_supportsItemExpanding != supportsExpanding) { + m_supportsItemExpanding = supportsExpanding; + updateSiblingsInformation(); + onSupportsItemExpandingChanged(supportsExpanding); + } +} + bool KItemListView::supportsItemExpanding() const { return m_supportsItemExpanding; @@ -725,6 +734,11 @@ void KItemListView::onStyleOptionChanged(const KItemListStyleOption& current, co Q_UNUSED(previous); } +void KItemListView::onSupportsItemExpandingChanged(bool supportsExpanding) +{ + Q_UNUSED(supportsExpanding); +} + void KItemListView::onTransactionBegin() { } @@ -792,14 +806,6 @@ QList<KItemListWidget*> KItemListView::visibleItemListWidgets() const return m_visibleItems.values(); } -void KItemListView::setSupportsItemExpanding(bool supportsExpanding) -{ - if (m_supportsItemExpanding != supportsExpanding) { - m_supportsItemExpanding = supportsExpanding; - updateSiblingsInformation(); - } -} - void KItemListView::slotItemsInserted(const KItemRangeList& itemRanges) { updateVisibleRolesSizes(itemRanges); diff --git a/src/kitemviews/kitemlistview.h b/src/kitemviews/kitemlistview.h index b416888eb..8f6e11e38 100644 --- a/src/kitemviews/kitemlistview.h +++ b/src/kitemviews/kitemlistview.h @@ -201,15 +201,15 @@ public: virtual QHash<QByteArray, QSizeF> visibleRolesSizes(const KItemRangeList& itemRanges) const; /** - * @return True if the view supports the expanding of items. Per default - * false is returned. If expanding of items is supported - * (see setSupportsItemExpanding()),the methods - * KItemModelBase::setExpanded(), KItemModelBase::isExpanded(), - * KItemModelBase::isExpandable() and KItemModelBase::expandedParentsCount() - * must be reimplemented. The view-implementation - * has to take care itself how to visually represent the expanded items provided - * by the model. + * If set to true, items having child-items can be expanded to show the child-items as + * part of the view. Per default the expanding of items is is disabled. If expanding of + * items is enabled, the methods KItemModelBase::setExpanded(), KItemModelBase::isExpanded(), + * KItemModelBase::isExpandable() and KItemModelBase::expandedParentsCount() + * must be reimplemented. The view-implementation + * has to take care itself how to visually represent the expanded items provided + * by the model. */ + void setSupportsItemExpanding(bool supportsExpanding); bool supportsItemExpanding() const; /** @@ -327,6 +327,7 @@ protected: virtual void onScrollOffsetChanged(qreal current, qreal previous); virtual void onVisibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous); virtual void onStyleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous); + virtual void onSupportsItemExpandingChanged(bool supportsExpanding); virtual void onTransactionBegin(); virtual void onTransactionEnd(); @@ -341,13 +342,6 @@ protected: QList<KItemListWidget*> visibleItemListWidgets() const; - /** - * Must be called by the derived class if it supports the expanding - * of items. - * @see supportsItemExpanding() - */ - void setSupportsItemExpanding(bool supportsExpanding); - protected slots: virtual void slotItemsInserted(const KItemRangeList& itemRanges); virtual void slotItemsRemoved(const KItemRangeList& itemRanges); |
