DiffEditor: refactor internal structures.

Simplify the implementation a lot.

Change-Id: I3f5daa3d2ce14c28d48c2e1e996ec4935d1dae3f
Reviewed-by: Jarek Kobus <jaroslaw.kobus@digia.com>
This commit is contained in:
jkobus
2014-03-11 15:31:19 +01:00
committed by Jarek Kobus
parent b76fb6baba
commit 9c2cdc8965
6 changed files with 77 additions and 241 deletions

View File

@@ -57,6 +57,13 @@ public:
TextLineData(TextLineType t) : textLineType(t) {}
TextLineType textLineType;
QString text;
/*
* <start position, end position>
* <-1, n> means this is a continuation from the previous line
* <n, -1> means this will be continued in the next line
* <-1, -1> the whole line is a continuation (from the previous line to the next line)
*/
QMap<int, int> changedPositions; // counting from the beginning of the line
};
class RowData {
@@ -76,9 +83,6 @@ public:
ChunkData() : contextChunk(false) {}
QList<RowData> rows;
bool contextChunk;
// start position, end position, TextLineData::Separator lines not taken into account
QMap<int, int> changedLeftPositions; // counting from the beginning of the chunk
QMap<int, int> changedRightPositions; // counting from the beginning of the chunk
};
class FileData {
@@ -94,6 +98,9 @@ ChunkData calculateOriginalData(const QList<Diff> &leftDiffList,
const QList<Diff> &rightDiffList);
FileData calculateContextData(const ChunkData &originalData,
int contextLinesNumber);
void addChangedPositions(int positionOffset,
const QMap<int, int> &originalChangedPositions,
QMap<int, int> *changedPositions);
QList<QTextEdit::ExtraSelection> colorPositions(const QTextCharFormat &format,
QTextCursor &cursor,
const QMap<int, int> &positions);