diff options
| author | Emmanuel Pescosta <[email protected]> | 2014-08-22 23:17:02 +0200 |
|---|---|---|
| committer | Emmanuel Pescosta <[email protected]> | 2014-08-22 23:17:02 +0200 |
| commit | d4fb129710d7fadf8e21f2cfd2588a794f774e41 (patch) | |
| tree | 03f73790c290013aa7026ebea723e7e18741c999 /src/kitemviews/kstandarditemlistwidget.cpp | |
| parent | ee946d362c64ee35af932b3cad54d23ad786fe55 (diff) | |
| parent | 7b0c9bbc58fc543a116104155fc8f3d81113d3a8 (diff) | |
Merge branch 'master' into frameworks
Conflicts:
dolphin/src/dolphinmainwindow.cpp
dolphin/src/dolphinmainwindow.h
dolphin/src/dolphinrecenttabsmenu.cpp
dolphin/src/dolphinviewcontainer.cpp
kfind/CMakeLists.txt
Diffstat (limited to 'src/kitemviews/kstandarditemlistwidget.cpp')
| -rw-r--r-- | src/kitemviews/kstandarditemlistwidget.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/kitemviews/kstandarditemlistwidget.cpp b/src/kitemviews/kstandarditemlistwidget.cpp index 88286120a..8633a2571 100644 --- a/src/kitemviews/kstandarditemlistwidget.cpp +++ b/src/kitemviews/kstandarditemlistwidget.cpp @@ -1136,14 +1136,24 @@ void KStandardItemListWidget::updateIconsLayoutTextCache() const int textLength = line.textStart() + line.textLength(); if (textLength < nameText.length()) { // Elide the last line of the text - QString lastTextLine = nameText.mid(line.textStart()); - lastTextLine = m_customizedFontMetrics.elidedText(lastTextLine, - Qt::ElideRight, - maxWidth); - const QString elidedText = nameText.left(line.textStart()) + lastTextLine; - nameTextInfo->staticText.setText(elidedText); + qreal elidingWidth = maxWidth; + qreal lastLineWidth; + do { + QString lastTextLine = nameText.mid(line.textStart()); + lastTextLine = m_customizedFontMetrics.elidedText(lastTextLine, + Qt::ElideRight, + elidingWidth); + const QString elidedText = nameText.left(line.textStart()) + lastTextLine; + nameTextInfo->staticText.setText(elidedText); + + lastLineWidth = m_customizedFontMetrics.boundingRect(lastTextLine).width(); + + // We do the text eliding in a loop with decreasing width (1 px / iteration) + // to avoid problems related to different width calculation code paths + // within Qt. (see bug 337104) + elidingWidth -= 1.0; + } while (lastLineWidth > maxWidth); - const qreal lastLineWidth = m_customizedFontMetrics.boundingRect(lastTextLine).width(); nameWidth = qMax(nameWidth, lastLineWidth); } break; |
