diff options
| author | Peter Penz <[email protected]> | 2011-09-23 19:09:01 +0200 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2011-09-23 19:11:05 +0200 |
| commit | 56852cff392f33ee731129fd9a755544d817e590 (patch) | |
| tree | 235588444cec355da4093fc405cc8072715a3e15 /src/kitemviews/kfileitemlistview.cpp | |
| parent | ccd92b76e74a00aef0f5186af7d797a63c6b80c6 (diff) | |
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
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); |
