diff options
author | Matthew Vogt <matthew.vogt@nokia.com> | 2012-03-08 14:11:46 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-09 07:30:00 +0100 |
commit | 2cdf6cbb9c43d52f914e9e7d01cc43e055ebf226 (patch) | |
tree | bde106a4b28b59994d4ddc7deea29a16288c887b | |
parent | 6d93b4af1ea53bc9418e64c57ceae2185788e0df (diff) |
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 <roberto.raggi@nokia.com>
-rw-r--r-- | src/qml/qml/qqmlscript.cpp | 1 | ||||
-rw-r--r-- | src/qml/qml/rewriter/textwriter.cpp | 34 | ||||
-rw-r--r-- | 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 db59a7266f..8e22e488ed 100644 --- a/src/qml/qml/qqmlscript.cpp +++ b/src/qml/qml/qqmlscript.cpp @@ -50,6 +50,7 @@ #include <private/qqmlrewrite_p.h> #include <QStack> +#include <QStringList> #include <QCoreApplication> #include <QtDebug> diff --git a/src/qml/qml/rewriter/textwriter.cpp b/src/qml/qml/rewriter/textwriter.cpp index f14c4af521..458fee68a1 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 94e2d08730..6c36a2f00d 100644 --- a/src/qml/qml/rewriter/textwriter_p.h +++ b/src/qml/qml/rewriter/textwriter_p.h @@ -46,7 +46,6 @@ #include <QtCore/QString> #include <QtCore/QList> -#include <QtGui/QTextCursor> 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 |