From 2cdf6cbb9c43d52f914e9e7d01cc43e055ebf226 Mon Sep 17 00:00:00 2001 From: Matthew Vogt Date: Thu, 8 Mar 2012 14:11:46 +1000 Subject: [PATCH] Remove unused QTextCursor code from rewriter. The rewriter previously supported rewriting operations on either a QString or a QTextCursor. In order to remove the dependency on QtGui, remove the unused QTextCursor support. Task-number: QTBUG-24559 Change-Id: I7a4acceff8097a8bd8c022db23b6b89d356e305a Reviewed-by: Roberto Raggi --- src/qml/qml/qqmlscript.cpp | 1 + src/qml/qml/rewriter/textwriter.cpp | 34 ++++++---------------------------- src/qml/qml/rewriter/textwriter_p.h | 4 ---- 3 files changed, 7 insertions(+), 32 deletions(-) diff --git a/src/qml/qml/qqmlscript.cpp b/src/qml/qml/qqmlscript.cpp index db59a72..8e22e48 100644 --- a/src/qml/qml/qqmlscript.cpp +++ b/src/qml/qml/qqmlscript.cpp @@ -50,6 +50,7 @@ #include #include +#include #include #include diff --git a/src/qml/qml/rewriter/textwriter.cpp b/src/qml/qml/rewriter/textwriter.cpp index f14c4af..458fee6 100644 --- a/src/qml/qml/rewriter/textwriter.cpp +++ b/src/qml/qml/rewriter/textwriter.cpp @@ -46,7 +46,7 @@ QT_QML_BEGIN_NAMESPACE using namespace QQmlJS; TextWriter::TextWriter() - :string(0), cursor(0) + :string(0) { } @@ -72,8 +72,8 @@ bool TextWriter::hasOverlap(int pos, int length) if (overlaps(pos, length, cmd.pos, cmd.length)) return true; } - return false; } + return false; } bool TextWriter::hasMoveInto(int pos, int length) @@ -137,25 +137,12 @@ void TextWriter::doReplace(const Replace &replace) } } - if (string) { - string->replace(replace.pos, replace.length, replace.replacement); - } else if (cursor) { - cursor->setPosition(replace.pos); - cursor->setPosition(replace.pos + replace.length, QTextCursor::KeepAnchor); - cursor->insertText(replace.replacement); - } + string->replace(replace.pos, replace.length, replace.replacement); } void TextWriter::doMove(const Move &move) { - QString text; - if (string) { - text = string->mid(move.pos, move.length); - } else if (cursor) { - cursor->setPosition(move.pos); - cursor->setPosition(move.pos + move.length, QTextCursor::KeepAnchor); - text = cursor->selectedText(); - } + QString text(string->mid(move.pos, move.length)); Replace cut; cut.pos = move.pos; @@ -183,17 +170,10 @@ void TextWriter::write(QString *s) string = 0; } -void TextWriter::write(QTextCursor *textCursor) -{ - cursor = textCursor; - write_helper(); - cursor = 0; -} - void TextWriter::write_helper() { - if (cursor) - cursor->beginEditBlock(); + Q_ASSERT(string); + { Replace cmd; while (!replaceList.isEmpty()) { @@ -210,8 +190,6 @@ void TextWriter::write_helper() doMove(cmd); } } - if (cursor) - cursor->endEditBlock(); } QT_QML_END_NAMESPACE diff --git a/src/qml/qml/rewriter/textwriter_p.h b/src/qml/qml/rewriter/textwriter_p.h index 94e2d08..6c36a2f 100644 --- a/src/qml/qml/rewriter/textwriter_p.h +++ b/src/qml/qml/rewriter/textwriter_p.h @@ -46,7 +46,6 @@ #include #include -#include QT_BEGIN_HEADER QT_QML_BEGIN_NAMESPACE @@ -56,7 +55,6 @@ namespace QQmlJS { class TextWriter { QString *string; - QTextCursor *cursor; struct Replace { int pos; @@ -89,8 +87,6 @@ public: void move(int pos, int length, int to); void write(QString *s); - void write(QTextCursor *textCursor); - }; } // end of namespace QQmlJS -- 2.7.4