diff options
Diffstat (limited to 'src/kitemviews/kfileitemlistview.cpp')
| -rw-r--r-- | src/kitemviews/kfileitemlistview.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
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<QByteArray, QVariant> 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); |
