return format(pos);
}
};
+
+ class RootNode : public QSGTransformNode
+ {
+ public:
+ RootNode() : cursorNode(0), frameDecorationsNode(0)
+ { }
+
+ void resetFrameDecorations(QQuickTextNode* newNode)
+ {
+ if (frameDecorationsNode) {
+ removeChildNode(frameDecorationsNode);
+ delete frameDecorationsNode;
+ }
+ frameDecorationsNode = newNode;
+ newNode->setFlag(QSGNode::OwnedByParent);
+ }
+
+ void resetCursorNode(QSGSimpleRectNode* newNode)
+ {
+ if (cursorNode)
+ removeChildNode(cursorNode);
+ delete cursorNode;
+ cursorNode = newNode;
+ appendChildNode(cursorNode);
+ cursorNode->setFlag(QSGNode::OwnedByParent);
+ }
+
+ QSGSimpleRectNode *cursorNode;
+ QQuickTextNode* frameDecorationsNode;
+
+ };
}
QQuickTextEdit::QQuickTextEdit(QQuickItem *parent)
d->updateType = QQuickTextEditPrivate::UpdateNone;
- QSGTransformNode *rootNode = static_cast<QSGTransformNode *>(oldNode);
+ RootNode *rootNode = static_cast<RootNode *>(oldNode);
TextNodeIterator nodeIterator = d->textNodeMap.begin();
while (nodeIterator != d->textNodeMap.end() && !(*nodeIterator)->dirty())
++nodeIterator;
if (!oldNode || nodeIterator < d->textNodeMap.end()) {
if (!oldNode)
- rootNode = new QSGTransformNode;
+ rootNode = new RootNode;
int firstDirtyPos = 0;
if (nodeIterator != d->textNodeMap.end()) {
}
// FIXME: the text decorations could probably be handled separately (only updated for affected textFrames)
- if (d->frameDecorationsNode) {
- rootNode->removeChildNode(d->frameDecorationsNode);
- delete d->frameDecorationsNode;
- }
- d->frameDecorationsNode = d->createTextNode();
+ rootNode->resetFrameDecorations(d->createTextNode());
QQuickTextNode *node = 0;
while (!frames.isEmpty()) {
QTextFrame *textFrame = frames.takeFirst();
frames.append(textFrame->childFrames());
- d->frameDecorationsNode->m_engine->addFrameDecorations(d->document, textFrame);
+ rootNode->frameDecorationsNode->m_engine->addFrameDecorations(d->document, textFrame);
if (textFrame->lastPosition() < firstDirtyPos || (firstCleanNode && textFrame->firstPosition() >= firstCleanNode->startPos()))
}
d->addCurrentTextNodeToRoot(rootNode, node, nodeIterator, nodeStart);
}
- d->frameDecorationsNode->m_engine->addToSceneGraph(d->frameDecorationsNode, QQuickText::Normal, QColor());
+ rootNode->frameDecorationsNode->m_engine->addToSceneGraph(rootNode->frameDecorationsNode, QQuickText::Normal, QColor());
// Now prepend the frame decorations since we want them rendered first, with the text nodes and cursor in front.
- rootNode->prependChildNode(d->frameDecorationsNode);
+ rootNode->prependChildNode(rootNode->frameDecorationsNode);
Q_ASSERT(nodeIterator == d->textNodeMap.end() || (*nodeIterator) == firstCleanNode);
// Update the position of the subsequent text blocks.
QColor color = (!d->cursorVisible || !d->control->cursorOn())
? QColor(0, 0, 0, 0)
: d->color;
- if (d->cursorNode)
- rootNode->removeChildNode(d->cursorNode);
- delete d->cursorNode;
- d->cursorNode = new QSGSimpleRectNode(cursorRectangle(), color);
- rootNode->appendChildNode(d->cursorNode);
+ rootNode->resetCursorNode(new QSGSimpleRectNode(cursorRectangle(), color));
}
return rootNode;
QQuickTextEditPrivate()
: color(QRgb(0xFF000000)), selectionColor(QRgb(0xFF000080)), selectedTextColor(QRgb(0xFFFFFFFF))
, textMargin(0.0), xoff(0), yoff(0), font(sourceFont), cursorComponent(0), cursorItem(0), document(0), control(0)
- , quickDocument(0), frameDecorationsNode(0), cursorNode(0)
- , lastSelectionStart(0), lastSelectionEnd(0), lineCount(0)
+ , quickDocument(0), lastSelectionStart(0), lastSelectionEnd(0), lineCount(0)
, hAlign(QQuickTextEdit::AlignLeft), vAlign(QQuickTextEdit::AlignTop)
, format(QQuickTextEdit::PlainText), wrapMode(QQuickTextEdit::NoWrap)
, renderType(QQuickTextEdit::QtRendering)
QQuickTextControl *control;
QQuickTextDocument *quickDocument;
QList<Node*> textNodeMap;
- QQuickTextNode *frameDecorationsNode;
- QSGSimpleRectNode *cursorNode;
int lastSelectionStart;
int lastSelectionEnd;