diff options
| author | Peter Penz <[email protected]> | 2012-04-07 00:03:06 +0200 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2012-04-07 00:03:42 +0200 |
| commit | 99f19a820b30b8f883b12f76ba1d69168f3ad1d5 (patch) | |
| tree | a93fa20f218ee554cd439c16875d3769422a1326 | |
| parent | dc555b8e56162bb908ad398341c5d7828d443bf3 (diff) | |
Icons Mode: Fix wrong width calculation of additional roles
| -rw-r--r-- | src/kitemviews/kfileitemlistwidget.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/kitemviews/kfileitemlistwidget.cpp b/src/kitemviews/kfileitemlistwidget.cpp index 935fb5da2..af7ea1523 100644 --- a/src/kitemviews/kfileitemlistwidget.cpp +++ b/src/kitemviews/kfileitemlistwidget.cpp @@ -782,19 +782,19 @@ void KFileItemListWidget::updateIconsLayoutTextCache() qreal requiredWidth = 0; QTextLayout layout(text, option.font); - layout.setTextOption(textInfo->staticText.textOption()); + QTextOption textOption; + textOption.setWrapMode(QTextOption::NoWrap); + layout.setTextOption(textOption); + layout.beginLayout(); QTextLine textLine = layout.createLine(); if (textLine.isValid()) { textLine.setLineWidth(maxWidth); requiredWidth = textLine.naturalTextWidth(); - if (textLine.textLength() < text.length()) { - // TODO: QFontMetrics::elidedText() works different regarding the given width - // in comparison to QTextLine::setLineWidth(). It might happen that the text does - // not get elided although it does not fit into the given width. As workaround - // the padding is substracted. - const QString elidedText = option.fontMetrics.elidedText(text, Qt::ElideRight, maxWidth - padding); + if (requiredWidth > maxWidth) { + const QString elidedText = option.fontMetrics.elidedText(text, Qt::ElideRight, maxWidth); textInfo->staticText.setText(elidedText); + requiredWidth = option.fontMetrics.width(elidedText); } } layout.endLayout(); |
