From: Andrew den Exter Date: Tue, 3 Apr 2012 06:10:33 +0000 (+1000) Subject: Fix visibility of trailing preedit text. X-Git-Tag: 071012131707~697 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1b6c1c3f85483f1d19375ce44de4e61b7d209f14;p=profile%2Fivi%2Fqtdeclarative.git Fix visibility of trailing preedit text. The block iterator doesn't take into account pre-edit text so we need to explicitly add pre-edit if it is positioned after the last fragment in a block. Change-Id: I1d26ee3ff86ea27674fc4f165b23ac5692a9ec17 Reviewed-by: Eskil Abrahamsen Blomfeldt --- diff --git a/src/quick/items/qquicktextnode.cpp b/src/quick/items/qquicktextnode.cpp index 5be4963..89c0aec 100644 --- a/src/quick/items/qquicktextnode.cpp +++ b/src/quick/items/qquicktextnode.cpp @@ -1219,12 +1219,6 @@ void QQuickTextNode::addTextDocument(const QPointF &position, QTextDocument *tex int textPos = block.position(); QTextBlock::iterator blockIterator = block.begin(); - if (blockIterator.atEnd() && preeditLength) { - engine.setPosition(blockPosition); - textPos = engine.addText(block, block.charFormat(), textColor, colorChanges, - textPos, textPos + preeditLength, - selectionStart, selectionEnd); - } while (!blockIterator.atEnd()) { QTextFragment fragment = blockIterator.fragment(); @@ -1275,6 +1269,19 @@ void QQuickTextNode::addTextDocument(const QPointF &position, QTextDocument *tex ++blockIterator; } + if (preeditLength >= 0 && textPos <= block.position() + preeditPosition) { + engine.setPosition(blockPosition); + textPos = block.position() + preeditPosition; + QTextLine line = block.layout()->lineForTextPosition(textPos); + if (!engine.currentLine().isValid() + || line.lineNumber() != engine.currentLine().lineNumber()) { + engine.setCurrentLine(line); + } + textPos = engine.addText(block, block.charFormat(), textColor, colorChanges, + textPos, textPos + preeditLength, + selectionStart, selectionEnd); + } + engine.setCurrentLine(QTextLine()); // Reset current line because the text layout changed ++it; }