From 56852cff392f33ee731129fd9a755544d817e590 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Fri, 23 Sep 2011 19:09:01 +0200 Subject: Allow resizing of columns by the user Still open: - Column content is not clipped correctly - First column is not automatically increased to the available width like in Dolphin 1.7 --- src/kitemviews/kfileitemlistview.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/kitemviews/kfileitemlistview.cpp') diff --git a/src/kitemviews/kfileitemlistview.cpp b/src/kitemviews/kfileitemlistview.cpp index c1d98c810..6ff83b793 100644 --- a/src/kitemviews/kfileitemlistview.cpp +++ b/src/kitemviews/kfileitemlistview.cpp @@ -396,7 +396,20 @@ QSizeF KFileItemListView::visibleRoleSizeHint(int index, const QByteArray& role) const QVariant value = model()->data(index).value(role); const QString text = value.toString(); if (!text.isEmpty()) { - width = qMax(width, qreal(option.margin * 2 + option.fontMetrics.width(text))); + const qreal columnMargin = option.margin * 3; + width = qMax(width, qreal(2 * columnMargin + option.fontMetrics.width(text))); + } + + if (role == "name") { + const QHash values = model()->data(index); + Q_ASSERT(values.contains("expansionLevel")); + + // Increase the width by the expansion-toggle and the current expansion level + const int expansionLevel = values.value("expansionLevel", 0).toInt(); + width += option.margin + expansionLevel * itemSize().height() + KIconLoader::SizeSmall; + + // Increase the width by the required space for the icon + width += option.margin * 2 + option.iconSize; } return QSizeF(width, height); -- cgit v1.3.1