aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@digia.com>2013-03-21 13:15:01 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-04 18:10:04 +0200
commita487974f663bd03309f45d82b380c00eb2829dae (patch)
tree37215619035f1beeb14950269dfeaddbdd685912 /src/quick/items
parent922c96767923310eb19e81ae9b42d4d19f9ce151 (diff)
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 <eskil.abrahamsen-blomfeldt@digia.com>
Diffstat (limited to 'src/quick/items')
-rw-r--r--src/quick/items/qquicktextedit.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp
index 506b4caa52..dde3587018 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<ProtectedLayoutAccessor *>(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 {