diff options
Diffstat (limited to 'src')
-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 |