summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2011-05-03 17:36:26 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2011-05-03 17:45:40 (GMT)
commitbbbd4b8f3949b58d4fd21854241cb46cbc024a80 (patch)
treeb5340630c018eb0e79d8331bc82410122dcefcf7 /src/gui
parent383f57dd2669b71fd14cf9b6b56213423a3d2d01 (diff)
downloadQt-bbbd4b8f3949b58d4fd21854241cb46cbc024a80.zip
Qt-bbbd4b8f3949b58d4fd21854241cb46cbc024a80.tar.gz
Qt-bbbd4b8f3949b58d4fd21854241cb46cbc024a80.tar.bz2
Fix drawing text in item view:
Put back code that was removed by mistake in e8019cf8feb402303e6d253f5ca58bebfda42679 Task-number: QTBUG-18998
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/styles/qcommonstyle.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp
index 2534d3e..95ebdb4 100644
--- a/src/gui/styles/qcommonstyle.cpp
+++ b/src/gui/styles/qcommonstyle.cpp
@@ -898,6 +898,25 @@ QSize QCommonStylePrivate::viewItemSize(const QStyleOptionViewItemV4 *option, in
return QSize(0, 0);
}
+static QSizeF viewItemTextLayout(QTextLayout &textLayout, int lineWidth)
+{
+ qreal height = 0;
+ qreal widthUsed = 0;
+ textLayout.beginLayout();
+ while (true) {
+ QTextLine line = textLayout.createLine();
+ if (!line.isValid())
+ break;
+ line.setLineWidth(lineWidth);
+ line.setPosition(QPointF(0, height));
+ height += line.height();
+ widthUsed = qMax(widthUsed, line.naturalTextWidth());
+ }
+ textLayout.endLayout();
+ return QSizeF(widthUsed, height);
+}
+
+
void QCommonStylePrivate::viewItemDrawText(QPainter *p, const QStyleOptionViewItemV4 *option, const QRect &rect) const
{
Q_Q(const QCommonStyle);
@@ -915,6 +934,8 @@ void QCommonStylePrivate::viewItemDrawText(QPainter *p, const QStyleOptionViewIt
textLayout.setFont(option->font);
textLayout.setText(option->text);
+ viewItemTextLayout(textLayout, textRect.width());
+
QString elidedText;
qreal height = 0;
qreal width = 0;