diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2011-05-05 11:29:03 +1000 |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2011-05-05 11:29:03 +1000 |
commit | 5f46c8e70f8891cb8702bf4c5949d3595b193660 (patch) | |
tree | 92106b292ace88089bf784ad55ee3d833a6c3ffb /src/declarative/items/qsgtext.cpp | |
parent | 3ea78d14ec04e7d39dd8848eef5ba4daf527d841 (diff) | |
parent | cff3c25ee616a7aee7bf1c0f983a190415668f5f (diff) |
Merge branch 'qtquick2' of scm.dev.nokia.troll.no:qt/qtdeclarative-staging into qtquick2
Diffstat (limited to 'src/declarative/items/qsgtext.cpp')
-rw-r--r-- | src/declarative/items/qsgtext.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/declarative/items/qsgtext.cpp b/src/declarative/items/qsgtext.cpp index f796006c18..f2ec7b21fa 100644 --- a/src/declarative/items/qsgtext.cpp +++ b/src/declarative/items/qsgtext.cpp @@ -1,4 +1,4 @@ -// Commit: a5c3c11e3e2204da6c8be9af98b38929366fafb8 +// Commit: cce89db1e2555cbca8fc28072e1c6dd737cec6c4 /**************************************************************************** ** ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). @@ -106,7 +106,7 @@ QSGTextPrivate::QSGTextPrivate() imageCacheDirty(true), updateOnComponentComplete(true), richText(false), singleline(false), cacheAllTextAsImage(true), internalWidthUpdate(false), requireImplicitWidth(false), truncated(false), hAlignImplicit(true), rightToLeftText(false), - naturalWidth(0), doc(0), nodeType(NodeIsNull) + layoutTextElided(false), naturalWidth(0), doc(0), nodeType(NodeIsNull) { cacheAllTextAsImage = enableImageCache(); } @@ -219,6 +219,7 @@ void QSGTextPrivate::updateLayout() return; } + layoutTextElided = false; // Setup instance of QTextLayout for all cases other than richtext if (!richText) { layout.clearLayout(); @@ -229,10 +230,13 @@ void QSGTextPrivate::updateLayout() singleline = !tmp.contains(QChar::LineSeparator); if (singleline && !maximumLineCountValid && elideMode != QSGText::ElideNone && q->widthValid()) { QFontMetrics fm(font); - tmp = fm.elidedText(tmp,(Qt::TextElideMode)elideMode,q->width()); // XXX still worth layout...? - if (tmp != text && !truncated) { - truncated = true; - emit q->truncatedChanged(); + tmp = fm.elidedText(tmp,(Qt::TextElideMode)elideMode,q->width()); + if (tmp != text) { + layoutTextElided = true; + if (!truncated) { + truncated = true; + emit q->truncatedChanged(); + } } } layout.setText(tmp); @@ -379,6 +383,12 @@ QRect QSGTextPrivate::setupTextLayout() if (requireImplicitWidth && q->widthValid()) { // requires an extra layout + QString elidedText; + if (layoutTextElided) { + // We have provided elided text to the layout, but we must calculate unelided width. + elidedText = layout.text(); + layout.setText(text); + } layout.beginLayout(); forever { QTextLine line = layout.createLine(); @@ -392,6 +402,8 @@ QRect QSGTextPrivate::setupTextLayout() br = br.united(line.naturalTextRect()); } naturalWidth = br.width(); + if (layoutTextElided) + layout.setText(elidedText); } if (maximumLineCountValid) { |