Commit e43bd82a authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Renamed TextWriter to ChangeSet

parent 735f307c
......@@ -39,11 +39,11 @@
**
****************************************************************************/
#include "textwriter.h"
#include "changeset.h"
namespace Utils {
TextWriter::TextWriter()
ChangeSet::ChangeSet()
:string(0), cursor(0)
{
}
......@@ -53,7 +53,7 @@ static bool overlaps(int posA, int lengthA, int posB, int lengthB) {
|| (posA < posB && posA + lengthA > posB);
}
bool TextWriter::hasOverlap(int pos, int length)
bool ChangeSet::hasOverlap(int pos, int length)
{
{
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);
while (i.hasNext()) {
......@@ -85,7 +85,7 @@ bool TextWriter::hasMoveInto(int pos, int length)
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(!hasMoveInto(pos, length));
......@@ -97,7 +97,7 @@ void TextWriter::replace(int pos, int length, const QString &replacement)
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));
......@@ -108,7 +108,7 @@ void TextWriter::move(int pos, int length, int to)
moveList += cmd;
}
void TextWriter::doReplace(const Replace &replace)
void ChangeSet::doReplace(const Replace &replace)
{
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;
if (string) {
......@@ -174,21 +174,21 @@ void TextWriter::doMove(const Move &move)
}
}
void TextWriter::write(QString *s)
void ChangeSet::write(QString *s)
{
string = s;
write_helper();
string = 0;
}
void TextWriter::write(QTextCursor *textCursor)
void ChangeSet::write(QTextCursor *textCursor)
{
cursor = textCursor;
write_helper();
cursor = 0;
}
void TextWriter::write_helper()
void ChangeSet::write_helper()
{
if (cursor)
cursor->beginEditBlock();
......
......@@ -39,8 +39,8 @@
**
****************************************************************************/
#ifndef TEXTWRITER_H
#define TEXTWRITER_H
#ifndef CHANGESET_H
#define CHANGESET_H
#include "utils_global.h"
......@@ -50,23 +50,23 @@
namespace Utils {
class QTCREATOR_UTILS_EXPORT TextWriter
class QTCREATOR_UTILS_EXPORT ChangeSet
{
QString *string;
QTextCursor *cursor;
struct Replace {
int pos;
int length;
QString replacement;
int pos;
int length;
QString replacement;
};
QList<Replace> replaceList;
struct Move {
int pos;
int length;
int to;
int pos;
int length;
int to;
};
QList<Move> moveList;
......@@ -80,7 +80,7 @@ class QTCREATOR_UTILS_EXPORT TextWriter
void write_helper();
public:
TextWriter();
ChangeSet();
void replace(int pos, int length, const QString &replacement);
void move(int pos, int length, int to);
......@@ -91,4 +91,4 @@ public:
} // namespace Utils
#endif // TEXTWRITER_H
#endif // CHANGESET_H
......@@ -37,7 +37,7 @@ SOURCES += reloadpromptutils.cpp \
fancymainwindow.cpp \
detailsbutton.cpp \
detailswidget.cpp \
textwriter.cpp
changeset.cpp
win32 {
SOURCES += abstractprocess_win.cpp \
consoleprocess_win.cpp \
......@@ -82,7 +82,7 @@ HEADERS += utils_global.h \
fancymainwindow.h \
detailsbutton.h \
detailswidget.h \
textwriter.h
changeset.h
FORMS += filewizardpage.ui \
projectintropage.ui \
newclasswidget.ui \
......
......@@ -35,7 +35,7 @@
#include <cplusplus/CppDocument.h>
#include <ASTfwd.h>
#include <utils/textwriter.h>
#include <utils/changeset.h>
#include <QtCore/QSharedPointer>
#include <QtGui/QTextCursor>
......@@ -114,7 +114,7 @@ private:
CPlusPlus::Document::Ptr _doc;
CPlusPlus::Snapshot _snapshot;
QTextCursor _textCursor;
Utils::TextWriter _textWriter;
Utils::ChangeSet _textWriter;
CPPEditor *_editor;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment