summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-04-15 02:41:36 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-04-15 02:41:36 (GMT)
commit5645cd7d7a97edb248a67d094993900f1dba4be8 (patch)
treeb939a4e93eb1eabdff4c4c0d21d2f676d3dafb93
parent2d9bc3296168de084fab45a4008edab8c290c3ff (diff)
downloadQt-5645cd7d7a97edb248a67d094993900f1dba4be8.zip
Qt-5645cd7d7a97edb248a67d094993900f1dba4be8.tar.gz
Qt-5645cd7d7a97edb248a67d094993900f1dba4be8.tar.bz2
Make sure richtext wraps correctly with a fixed height set.
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp20
2 files changed, 21 insertions, 1 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp
index b65212b..3a35dd5 100644
--- a/src/declarative/graphicsitems/qdeclarativetext.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetext.cpp
@@ -677,7 +677,7 @@ void QDeclarativeTextPrivate::updateSize()
QTextOption option((Qt::Alignment)int(hAlign | vAlign));
option.setWrapMode(QTextOption::WrapMode(wrapMode));
doc->setDefaultTextOption(option);
- if (wrapMode != QDeclarativeText::NoWrap && !q->heightValid() && q->widthValid())
+ if (wrapMode != QDeclarativeText::NoWrap && q->widthValid())
doc->setTextWidth(q->width());
else
doc->setTextWidth(doc->idealWidth()); // ### Text does not align if width is not set (QTextDoc bug)
diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
index 2d10756..6637415 100644
--- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
+++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
@@ -286,8 +286,28 @@ void tst_qdeclarativetext::wrap()
QVERIFY(textObject != 0);
QCOMPARE(textObject->width(), 30.);
QVERIFY(textObject->height() > textHeight);
+
+ qreal oldHeight = textObject->height();
+ textObject->setWidth(100);
+ QVERIFY(textObject->height() < oldHeight);
}
+ // richtext again with a fixed height
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import Qt 4.7\nText { wrapMode: Text.WordWrap; width: 30; height: 50; text: \"" + richText.at(i) + "\" }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeText *textObject = qobject_cast<QDeclarativeText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->width(), 30.);
+ QVERIFY(textObject->implicitHeight() > textHeight);
+
+ qreal oldHeight = textObject->implicitHeight();
+ textObject->setWidth(100);
+ QVERIFY(textObject->implicitHeight() < oldHeight);
+ }
}
void tst_qdeclarativetext::elide()