applyRolesToModel();
}
updateLayoutOfVisibleItems();
-
- setSupportsItemExpanding(m_itemLayout == DetailsLayout);
}
}
case DetailsLayout: fileItemListWidget->setLayout(KFileItemListWidget::DetailsLayout); break;
default: Q_ASSERT(false); break;
}
+
+ fileItemListWidget->setSupportsItemExpanding(supportsItemExpanding());
}
bool KFileItemListView::itemSizeHintUpdateRequired(const QSet<QByteArray>& changedRoles) const
triggerIconSizeUpdate();
}
+void KFileItemListView::onSupportsItemExpandingChanged(bool supportsExpanding)
+{
+ Q_UNUSED(supportsExpanding);
+ applyRolesToModel();
+ updateLayoutOfVisibleItems();
+}
+
void KFileItemListView::onTransactionBegin()
{
m_modelRolesUpdater->setPaused(true);
roles.insert("iconName");
roles.insert("name");
roles.insert("isDir");
- if (m_itemLayout == DetailsLayout) {
+ if (supportsItemExpanding()) {
roles.insert("isExpanded");
roles.insert("isExpandable");
roles.insert("expandedParentsCount");
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);
m_isCut(false),
m_isHidden(false),
m_isExpandable(false),
+ m_supportsItemExpanding(false),
m_dirtyLayout(true),
m_dirtyContent(true),
m_dirtyContentRoles(),
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();
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.
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();
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();
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);
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;
bool m_isCut;
bool m_isHidden;
bool m_isExpandable;
+ bool m_supportsItemExpanding;
bool m_dirtyLayout;
bool m_dirtyContent;
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;
Q_UNUSED(previous);
}
+void KItemListView::onSupportsItemExpandingChanged(bool supportsExpanding)
+{
+ Q_UNUSED(supportsExpanding);
+}
+
void KItemListView::onTransactionBegin()
{
}
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);
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;
/**
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();
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);
<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>
#include <KComboBox>
#include <KLocale>
+#include <QCheckBox>
#include <QGroupBox>
#include <QLabel>
#include <QSlider>
m_defaultSizeSlider(0),
m_previewSizeSlider(0),
m_fontRequester(0),
- m_textWidthBox(0)
+ m_textWidthBox(0),
+ m_expandableFolders(0)
{
QVBoxLayout* topLayout = new QVBoxLayout(this);
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"));
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();
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;
}
}
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());
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());
class DolphinFontRequester;
class KComboBox;
+class QCheckBox;
class QSlider;
/**
DolphinFontRequester* m_fontRequester;
KComboBox* m_textWidthBox;
+ QCheckBox* m_expandableFolders;
};
#endif
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);
beginTransaction();
m_fileItemListView->setEnabledSelectionToggles(GeneralSettings::showSelectionToggle());
+
+ const bool expandableFolders = (itemLayout() && KFileItemListView::DetailsLayout) &&
+ DetailsModeSettings::expandableFolders();
+ m_fileItemListView->setSupportsItemExpanding(expandableFolders);
+
updateAutoActivationDelay();
updateFont();
updateGridSize();