summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Penz <peter.penz19@gmail.com>2012-03-09 15:12:00 (GMT)
committerPeter Penz <peter.penz19@gmail.com>2012-03-09 15:18:00 (GMT)
commite04cb14b19e05282f58d5d39d790b3c334366172 (patch)
tree0a700e028a7dade920e781d026a171a90a5dc126
parentb62c74ec4cc891bc5fafeeafe67dbcc1d17fd445 (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
-rw-r--r--dolphin/src/kitemviews/kfileitemlistview.cpp13
-rw-r--r--dolphin/src/kitemviews/kfileitemlistview.h1
-rw-r--r--dolphin/src/kitemviews/kfileitemlistwidget.cpp30
-rw-r--r--dolphin/src/kitemviews/kfileitemlistwidget.h4
-rw-r--r--dolphin/src/kitemviews/kitemlistview.cpp22
-rw-r--r--dolphin/src/kitemviews/kitemlistview.h24
-rw-r--r--dolphin/src/settings/dolphin_detailsmodesettings.kcfg4
-rw-r--r--dolphin/src/settings/viewmodes/viewsettingstab.cpp47
-rw-r--r--dolphin/src/settings/viewmodes/viewsettingstab.h2
-rw-r--r--dolphin/src/views/dolphinitemlistcontainer.cpp8
10 files changed, 119 insertions, 36 deletions
diff --git a/dolphin/src/kitemviews/kfileitemlistview.cpp b/dolphin/src/kitemviews/kfileitemlistview.cpp
index 27ef7fd..796a450 100644
--- a/dolphin/src/kitemviews/kfileitemlistview.cpp
+++ b/dolphin/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/dolphin/src/kitemviews/kfileitemlistview.h b/dolphin/src/kitemviews/kfileitemlistview.h
index 8970156..12d0d45 100644
--- a/dolphin/src/kitemviews/kfileitemlistview.h
+++ b/dolphin/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/dolphin/src/kitemviews/kfileitemlistwidget.cpp b/dolphin/src/kitemviews/kfileitemlistwidget.cpp
index c477a37..fb0f4df 100644
--- a/dolphin/src/kitemviews/kfileitemlistwidget.cpp
+++ b/dolphin/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/dolphin/src/kitemviews/kfileitemlistwidget.h b/dolphin/src/kitemviews/kfileitemlistwidget.h
index 2feeca8..4958313 100644
--- a/dolphin/src/kitemviews/kfileitemlistwidget.h
+++ b/dolphin/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/dolphin/src/kitemviews/kitemlistview.cpp b/dolphin/src/kitemviews/kitemlistview.cpp
index a54e06d..f182282 100644
--- a/dolphin/src/kitemviews/kitemlistview.cpp
+++ b/dolphin/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/dolphin/src/kitemviews/kitemlistview.h b/dolphin/src/kitemviews/kitemlistview.h
index b416888..8f6e11e 100644
--- a/dolphin/src/kitemviews/kitemlistview.h
+++ b/dolphin/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);
diff --git a/dolphin/src/settings/dolphin_detailsmodesettings.kcfg b/dolphin/src/settings/dolphin_detailsmodesettings.kcfg
index 0fb1bf0..64e9989 100644
--- a/dolphin/src/settings/dolphin_detailsmodesettings.kcfg
+++ b/dolphin/src/settings/dolphin_detailsmodesettings.kcfg
@@ -40,5 +40,9 @@
<label>Position of columns</label>
<default>0,1,2,3,4,5,6,7,8</default>
</entry>
+ <entry name="ExpandableFolders" type="Bool">
+ <label>Expandable folders</label>
+ <default>true</default>
+ </entry>
</group>
</kcfg>
diff --git a/dolphin/src/settings/viewmodes/viewsettingstab.cpp b/dolphin/src/settings/viewmodes/viewsettingstab.cpp
index 5dd7000..c734344 100644
--- a/dolphin/src/settings/viewmodes/viewsettingstab.cpp
+++ b/dolphin/src/settings/viewmodes/viewsettingstab.cpp
@@ -27,6 +27,7 @@
#include <KComboBox>
#include <KLocale>
+#include <QCheckBox>
#include <QGroupBox>
#include <QLabel>
#include <QSlider>
@@ -40,7 +41,8 @@ ViewSettingsTab::ViewSettingsTab(Mode mode, QWidget* parent) :
m_defaultSizeSlider(0),
m_previewSizeSlider(0),
m_fontRequester(0),
- m_textWidthBox(0)
+ m_textWidthBox(0),
+ m_expandableFolders(0)
{
QVBoxLayout* topLayout = new QVBoxLayout(this);
@@ -79,7 +81,8 @@ ViewSettingsTab::ViewSettingsTab(Mode mode, QWidget* parent) :
textGroupLayout->addWidget(fontLabel, 0, 0, Qt::AlignRight);
textGroupLayout->addWidget(m_fontRequester, 0, 1);
- if (m_mode == IconsMode) {
+ switch (m_mode) {
+ case IconsMode: {
QLabel* textWidthLabel = new QLabel(i18nc("@label:listbox", "Text width:"), textGroup);
m_textWidthBox = new KComboBox(textGroup);
m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Small"));
@@ -89,10 +92,19 @@ ViewSettingsTab::ViewSettingsTab(Mode mode, QWidget* parent) :
textGroupLayout->addWidget(textWidthLabel, 2, 0, Qt::AlignRight);
textGroupLayout->addWidget(m_textWidthBox, 2, 1);
+ break;
+ }
+ case DetailsMode:
+ // Disabled for 4.8.x: No new UI-strings are allowed
+ // m_expandableFolders = new QCheckBox(i18nc("@option:check", "Expandable folders"), this);
+ break;
+ default:
+ break;
}
topLayout->addWidget(iconSizeGroup);
topLayout->addWidget(textGroup);
+ topLayout->addWidget(m_expandableFolders);
topLayout->addStretch(1);
loadSettings();
@@ -100,8 +112,17 @@ ViewSettingsTab::ViewSettingsTab(Mode mode, QWidget* parent) :
connect(m_defaultSizeSlider, SIGNAL(valueChanged(int)), this, SIGNAL(changed()));
connect(m_previewSizeSlider, SIGNAL(valueChanged(int)), this, SIGNAL(changed()));
connect(m_fontRequester, SIGNAL(changed()), this, SIGNAL(changed()));
- if (m_mode == IconsMode) {
+
+ switch (m_mode) {
+ case IconsMode:
connect(m_textWidthBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed()));
+ break;
+ case DetailsMode:
+ // Disabled for 4.8.x: No new UI-strings are allowed
+ //connect(m_expandableFolders, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
+ break;
+ default:
+ break;
}
}
@@ -114,8 +135,16 @@ void ViewSettingsTab::applySettings()
const QFont font = m_fontRequester->currentFont();
const bool useSystemFont = (m_fontRequester->mode() == DolphinFontRequester::SystemFont);
- if (m_mode == IconsMode) {
+ switch (m_mode) {
+ case IconsMode:
IconsModeSettings::setTextWidthIndex(m_textWidthBox->currentIndex());
+ break;
+ case DetailsMode:
+ // Disabled for 4.8.x: No new UI-strings are allowed
+ //DetailsModeSettings::setExpandableFolders(m_expandableFolders->isChecked());
+ break;
+ default:
+ break;
}
ViewModeSettings settings(viewMode());
@@ -151,8 +180,16 @@ void ViewSettingsTab::restoreDefaultSettings()
void ViewSettingsTab::loadSettings()
{
- if (m_mode == IconsMode) {
+ switch (m_mode) {
+ case IconsMode:
m_textWidthBox->setCurrentIndex(IconsModeSettings::textWidthIndex());
+ break;
+ case DetailsMode:
+ // Disabled for 4.8.x: No new UI-strings are allowed
+ // m_expandableFolders->setChecked(DetailsModeSettings::expandableFolders());
+ break;
+ default:
+ break;
}
ViewModeSettings settings(viewMode());
diff --git a/dolphin/src/settings/viewmodes/viewsettingstab.h b/dolphin/src/settings/viewmodes/viewsettingstab.h
index 2e0f439..b21fc10 100644
--- a/dolphin/src/settings/viewmodes/viewsettingstab.h
+++ b/dolphin/src/settings/viewmodes/viewsettingstab.h
@@ -25,6 +25,7 @@
class DolphinFontRequester;
class KComboBox;
+class QCheckBox;
class QSlider;
/**
@@ -63,6 +64,7 @@ private:
DolphinFontRequester* m_fontRequester;
KComboBox* m_textWidthBox;
+ QCheckBox* m_expandableFolders;
};
#endif
diff --git a/dolphin/src/views/dolphinitemlistcontainer.cpp b/dolphin/src/views/dolphinitemlistcontainer.cpp
index 3b0a9c6..1ece520 100644
--- a/dolphin/src/views/dolphinitemlistcontainer.cpp
+++ b/dolphin/src/views/dolphinitemlistcontainer.cpp
@@ -134,14 +134,17 @@ void DolphinItemListContainer::setItemLayout(KFileItemListView::Layout layout)
case KFileItemListView::IconsLayout:
m_fileItemListView->setScrollOrientation(Qt::Vertical);
m_fileItemListView->setHeaderShown(false);
+ m_fileItemListView->setSupportsItemExpanding(false);
break;
case KFileItemListView::DetailsLayout:
m_fileItemListView->setScrollOrientation(Qt::Vertical);
m_fileItemListView->setHeaderShown(true);
+ m_fileItemListView->setSupportsItemExpanding(DetailsModeSettings::expandableFolders());
break;
case KFileItemListView::CompactLayout:
m_fileItemListView->setScrollOrientation(Qt::Horizontal);
m_fileItemListView->setHeaderShown(false);
+ m_fileItemListView->setSupportsItemExpanding(false);
break;
default:
Q_ASSERT(false);
@@ -176,6 +179,11 @@ void DolphinItemListContainer::readSettings()
beginTransaction();
m_fileItemListView->setEnabledSelectionToggles(GeneralSettings::showSelectionToggle());
+
+ const bool expandableFolders = (itemLayout() && KFileItemListView::DetailsLayout) &&
+ DetailsModeSettings::expandableFolders();
+ m_fileItemListView->setSupportsItemExpanding(expandableFolders);
+
updateAutoActivationDelay();
updateFont();
updateGridSize();