Renamed TextWriter to ChangeSet

This commit is contained in:
Roberto Raggi
2009-11-24 11:29:43 +01:00
parent 735f307c85
commit e43bd82afb
4 changed files with 26 additions and 26 deletions

View File

@@ -39,11 +39,11 @@
** **
****************************************************************************/ ****************************************************************************/
#include "textwriter.h" #include "changeset.h"
namespace Utils { namespace Utils {
TextWriter::TextWriter() ChangeSet::ChangeSet()
:string(0), cursor(0) :string(0), cursor(0)
{ {
} }
@@ -53,7 +53,7 @@ static bool overlaps(int posA, int lengthA, int posB, int lengthB) {
|| (posA < posB && posA + lengthA > posB); || (posA < posB && posA + lengthA > posB);
} }
bool TextWriter::hasOverlap(int pos, int length) bool ChangeSet::hasOverlap(int pos, int length)
{ {
{ {
QListIterator<Replace> i(replaceList); QListIterator<Replace> i(replaceList);
@@ -74,7 +74,7 @@ bool TextWriter::hasOverlap(int pos, int length)
} }
} }
bool TextWriter::hasMoveInto(int pos, int length) bool ChangeSet::hasMoveInto(int pos, int length)
{ {
QListIterator<Move> i(moveList); QListIterator<Move> i(moveList);
while (i.hasNext()) { while (i.hasNext()) {
@@ -85,7 +85,7 @@ bool TextWriter::hasMoveInto(int pos, int length)
return false; return false;
} }
void TextWriter::replace(int pos, int length, const QString &replacement) void ChangeSet::replace(int pos, int length, const QString &replacement)
{ {
Q_ASSERT(!hasOverlap(pos, length)); Q_ASSERT(!hasOverlap(pos, length));
Q_ASSERT(!hasMoveInto(pos, length)); Q_ASSERT(!hasMoveInto(pos, length));
@@ -97,7 +97,7 @@ void TextWriter::replace(int pos, int length, const QString &replacement)
replaceList += cmd; replaceList += cmd;
} }
void TextWriter::move(int pos, int length, int to) void ChangeSet::move(int pos, int length, int to)
{ {
Q_ASSERT(!hasOverlap(pos, length)); Q_ASSERT(!hasOverlap(pos, length));
@@ -108,7 +108,7 @@ void TextWriter::move(int pos, int length, int to)
moveList += cmd; moveList += cmd;
} }
void TextWriter::doReplace(const Replace &replace) void ChangeSet::doReplace(const Replace &replace)
{ {
int diff = replace.replacement.size() - replace.length; int diff = replace.replacement.size() - replace.length;
{ {
@@ -144,7 +144,7 @@ void TextWriter::doReplace(const Replace &replace)
} }
} }
void TextWriter::doMove(const Move &move) void ChangeSet::doMove(const Move &move)
{ {
QString text; QString text;
if (string) { if (string) {
@@ -174,21 +174,21 @@ void TextWriter::doMove(const Move &move)
} }
} }
void TextWriter::write(QString *s) void ChangeSet::write(QString *s)
{ {
string = s; string = s;
write_helper(); write_helper();
string = 0; string = 0;
} }
void TextWriter::write(QTextCursor *textCursor) void ChangeSet::write(QTextCursor *textCursor)
{ {
cursor = textCursor; cursor = textCursor;
write_helper(); write_helper();
cursor = 0; cursor = 0;
} }
void TextWriter::write_helper() void ChangeSet::write_helper()
{ {
if (cursor) if (cursor)
cursor->beginEditBlock(); cursor->beginEditBlock();

View File

@@ -39,8 +39,8 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef TEXTWRITER_H #ifndef CHANGESET_H
#define TEXTWRITER_H #define CHANGESET_H
#include "utils_global.h" #include "utils_global.h"
@@ -50,23 +50,23 @@
namespace Utils { namespace Utils {
class QTCREATOR_UTILS_EXPORT TextWriter class QTCREATOR_UTILS_EXPORT ChangeSet
{ {
QString *string; QString *string;
QTextCursor *cursor; QTextCursor *cursor;
struct Replace { struct Replace {
int pos; int pos;
int length; int length;
QString replacement; QString replacement;
}; };
QList<Replace> replaceList; QList<Replace> replaceList;
struct Move { struct Move {
int pos; int pos;
int length; int length;
int to; int to;
}; };
QList<Move> moveList; QList<Move> moveList;
@@ -80,7 +80,7 @@ class QTCREATOR_UTILS_EXPORT TextWriter
void write_helper(); void write_helper();
public: public:
TextWriter(); ChangeSet();
void replace(int pos, int length, const QString &replacement); void replace(int pos, int length, const QString &replacement);
void move(int pos, int length, int to); void move(int pos, int length, int to);
@@ -91,4 +91,4 @@ public:
} // namespace Utils } // namespace Utils
#endif // TEXTWRITER_H #endif // CHANGESET_H

View File

@@ -37,7 +37,7 @@ SOURCES += reloadpromptutils.cpp \
fancymainwindow.cpp \ fancymainwindow.cpp \
detailsbutton.cpp \ detailsbutton.cpp \
detailswidget.cpp \ detailswidget.cpp \
textwriter.cpp changeset.cpp
win32 { win32 {
SOURCES += abstractprocess_win.cpp \ SOURCES += abstractprocess_win.cpp \
consoleprocess_win.cpp \ consoleprocess_win.cpp \
@@ -82,7 +82,7 @@ HEADERS += utils_global.h \
fancymainwindow.h \ fancymainwindow.h \
detailsbutton.h \ detailsbutton.h \
detailswidget.h \ detailswidget.h \
textwriter.h changeset.h
FORMS += filewizardpage.ui \ FORMS += filewizardpage.ui \
projectintropage.ui \ projectintropage.ui \
newclasswidget.ui \ newclasswidget.ui \

View File

@@ -35,7 +35,7 @@
#include <cplusplus/CppDocument.h> #include <cplusplus/CppDocument.h>
#include <ASTfwd.h> #include <ASTfwd.h>
#include <utils/textwriter.h> #include <utils/changeset.h>
#include <QtCore/QSharedPointer> #include <QtCore/QSharedPointer>
#include <QtGui/QTextCursor> #include <QtGui/QTextCursor>
@@ -114,7 +114,7 @@ private:
CPlusPlus::Document::Ptr _doc; CPlusPlus::Document::Ptr _doc;
CPlusPlus::Snapshot _snapshot; CPlusPlus::Snapshot _snapshot;
QTextCursor _textCursor; QTextCursor _textCursor;
Utils::TextWriter _textWriter; Utils::ChangeSet _textWriter;
CPPEditor *_editor; CPPEditor *_editor;
}; };