From a487974f663bd03309f45d82b380c00eb2829dae Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Thu, 21 Mar 2013 13:15:01 +0100 Subject: [PATCH] QQuickTextEdit: render inline images after change 48798 The refactoring in QQuickTextEdit from this change: https://codereview.qt-project.org/#change,48798 accidentally broke rendering of inline images. Revive the ProtectedLayoutAccessor trick to get the proper format and properly extract the image from it. Change-Id: I445914efcea1012daa79d594aa1e828b1039b988 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/quick/items/qquicktextedit.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp index 506b4ca..dde3587 100644 --- a/src/quick/items/qquicktextedit.cpp +++ b/src/quick/items/qquicktextedit.cpp @@ -125,6 +125,17 @@ TextEdit { // into text nodes corresponding to a text block each so that the glyph node grouping doesn't become pointless. static const int nodeBreakingSize = 300; +namespace { + class ProtectedLayoutAccessor: public QAbstractTextDocumentLayout + { + public: + inline QTextCharFormat formatAccessor(int pos) + { + return format(pos); + } + }; +} + QQuickTextEdit::QQuickTextEdit(QQuickItem *parent) : QQuickImplicitSizeItem(*(new QQuickTextEditPrivate), parent) { @@ -1772,9 +1783,11 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData * node->setMatrix(transformMatrix); } const int pos = textFrame->firstPosition() - 1; + ProtectedLayoutAccessor *a = static_cast(d->document->documentLayout()); + QTextCharFormat format = a->formatAccessor(pos); QTextBlock block = textFrame->firstCursorPosition().block(); node->m_engine->setCurrentLine(block.layout()->lineForTextPosition(pos - block.position())); - node->m_engine->addTextObject(QPointF(0, 0), block.charFormat(), QQuickTextNodeEngine::Unselected, d->document, + node->m_engine->addTextObject(QPointF(0, 0), format, QQuickTextNodeEngine::Unselected, d->document, pos, textFrame->frameFormat().position()); } else { -- 2.7.4