summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-02-23 00:03:43 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-02-23 00:03:43 (GMT)
commit14447cbbf7ee93e03286112b5b27d20961fd9551 (patch)
tree4eb8a92abef1d07f6adac8f9fa3ae4237461e64f
parenta7643e04dc89ed9f84ef8f0010ca1f55f9cfd669 (diff)
downloadQt-14447cbbf7ee93e03286112b5b27d20961fd9551.zip
Qt-14447cbbf7ee93e03286112b5b27d20961fd9551.tar.gz
Qt-14447cbbf7ee93e03286112b5b27d20961fd9551.tar.bz2
Make uncached text painting work for richtext too.
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstext.cpp13
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstext_p_p.h2
2 files changed, 12 insertions, 3 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicstext.cpp b/src/declarative/graphicsitems/qmlgraphicstext.cpp
index ab2f9a3..409fa3a 100644
--- a/src/declarative/graphicsitems/qmlgraphicstext.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicstext.cpp
@@ -554,6 +554,7 @@ void QmlGraphicsTextPrivate::updateSize()
else
doc->setTextWidth(doc->idealWidth()); // ### Text does not align if width is not set (QTextDoc bug)
dy -= (int)doc->size().height();
+ cachedLayoutSize = doc->size().toSize();
}
int yoff = 0;
@@ -769,7 +770,7 @@ void QmlGraphicsText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidg
{
Q_D(QmlGraphicsText);
- if (d->cache || d->richText || d->style != Normal) {
+ if (d->cache || d->style != Normal) {
d->checkImgCache();
if (d->imgCache.isNull())
return;
@@ -846,7 +847,15 @@ void QmlGraphicsText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidg
p->save();
p->setClipRect(boundingRect(), Qt::IntersectClip);
}
- d->drawWrappedText(p, QPointF(0,y), false);
+ if (d->richText) {
+ QAbstractTextDocumentLayout::PaintContext context;
+ context.palette.setColor(QPalette::Text, d->color);
+ p->translate(0, y);
+ d->doc->documentLayout()->draw(p, context);
+ p->translate(0, -y);
+ } else {
+ d->drawWrappedText(p, QPointF(0,y), false);
+ }
if (needClip)
p->restore();
}
diff --git a/src/declarative/graphicsitems/qmlgraphicstext_p_p.h b/src/declarative/graphicsitems/qmlgraphicstext_p_p.h
index 46d2d0e..f67d57c 100644
--- a/src/declarative/graphicsitems/qmlgraphicstext_p_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicstext_p_p.h
@@ -75,7 +75,7 @@ public:
dirty(true), wrap(false), richText(false), singleline(false), cache(true), doc(0),
format(QmlGraphicsText::AutoText)
{
-#ifdef QML_NO_TEXT_CACHE
+#if defined(QML_NO_TEXT_CACHE)
cache = false;
#endif
}