summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-02-04 03:31:15 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-02-04 03:31:15 (GMT)
commit0b8ef5c78b724901cfae343920b3e9e8f4a78fda (patch)
treec978af50915187f18ad48d4543e85557c063affb /src/declarative
parenta6f90ca4d73365d37bdc4eaf8fe15cf55fe1bf83 (diff)
downloadQt-0b8ef5c78b724901cfae343920b3e9e8f4a78fda.zip
Qt-0b8ef5c78b724901cfae343920b3e9e8f4a78fda.tar.gz
Qt-0b8ef5c78b724901cfae343920b3e9e8f4a78fda.tar.bz2
Fix elision and multilength strings when resizing a Text element.
They were incorrectly wrapping when the width changed. Task-number: QTBUG-7477
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstext.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicstext.cpp b/src/declarative/graphicsitems/qmlgraphicstext.cpp
index bfb928a..b13fb7c 100644
--- a/src/declarative/graphicsitems/qmlgraphicstext.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicstext.cpp
@@ -452,7 +452,7 @@ void QmlGraphicsText::setTextFormat(TextFormat format)
the first string that fits will be used, otherwise the last will be elided.
Multi-length strings are ordered from longest to shortest, separated by the
- Unicode "String Terminator" character \c U009C (write this in QML with \c{"\\x9C"}).
+ Unicode "String Terminator" character \c U009C (write this in QML with \c{"\u009C"} or \c{"\x9C"}).
*/
QmlGraphicsText::TextElideMode QmlGraphicsText::elideMode() const
{
@@ -479,6 +479,15 @@ void QmlGraphicsText::geometryChanged(const QRectF &newGeometry,
Q_D(QmlGraphicsText);
if (newGeometry.width() != oldGeometry.width()) {
if (d->wrap || d->elideMode != QmlGraphicsText::ElideNone) {
+ //re-elide if needed
+ if (d->singleline && d->elideMode != QmlGraphicsText::ElideNone &&
+ isComponentComplete() && widthValid()) {
+
+ QFontMetrics fm(d->font);
+ QString tmp = fm.elidedText(d->text,(Qt::TextElideMode)d->elideMode,width()); // XXX still worth layout...?
+ d->layout.setText(tmp);
+ }
+
d->imgDirty = true;
d->updateSize();
}