forked from qt-creator/qt-creator
Remove unused variables
Remove unused fields and one virtual method, rename alwaysShows -> contextChunk and revert its logical value. Change-Id: I11fd60202aa5b7978b772764a40c99029cac82a3 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
@@ -641,7 +641,7 @@ FileData DiffEditorWidget::calculateContextData(const ChunkData &originalData) c
|
||||
ChunkData chunkData;
|
||||
int leftOffset = leftCharCounter;
|
||||
int rightOffset = rightCharCounter;
|
||||
chunkData.alwaysShown = true;
|
||||
chunkData.contextChunk = false;
|
||||
while (i < originalData.rows.count()) {
|
||||
if (hiddenRows.contains(i))
|
||||
break;
|
||||
@@ -675,7 +675,7 @@ FileData DiffEditorWidget::calculateContextData(const ChunkData &originalData) c
|
||||
fileData.chunks.append(chunkData);
|
||||
} else {
|
||||
ChunkData chunkData;
|
||||
chunkData.alwaysShown = false;
|
||||
chunkData.contextChunk = true;
|
||||
while (i < originalData.rows.count()) {
|
||||
if (!hiddenRows.contains(i))
|
||||
break;
|
||||
@@ -719,10 +719,8 @@ void DiffEditorWidget::showDiff()
|
||||
QChar separator = QLatin1Char('\n');
|
||||
for (int i = 0; i < m_contextFileData.chunks.count(); i++) {
|
||||
ChunkData chunkData = m_contextFileData.chunks.at(i);
|
||||
if (!chunkData.alwaysShown) {
|
||||
if (chunkData.contextChunk) {
|
||||
const int skippedLines = chunkData.rows.count();
|
||||
// leftLineNumber += skippedLines;
|
||||
// rightLineNumber += skippedLines;
|
||||
m_leftEditor->setSkippedLines(blockNumber, skippedLines);
|
||||
m_rightEditor->setSkippedLines(blockNumber, skippedLines);
|
||||
m_leftEditor->setSeparator(blockNumber, true);
|
||||
@@ -769,7 +767,7 @@ void DiffEditorWidget::showDiff()
|
||||
blockNumber = 0;
|
||||
for (int i = 0; i < m_contextFileData.chunks.count(); i++) {
|
||||
ChunkData chunkData = m_contextFileData.chunks.at(i);
|
||||
if (!chunkData.alwaysShown) {
|
||||
if (chunkData.contextChunk) {
|
||||
blockNumber++;
|
||||
QTextBlock leftBlock = m_leftEditor->document()->findBlockByNumber(blockNumber);
|
||||
for (int j = 0; j < chunkData.rows.count(); j++) {
|
||||
@@ -787,7 +785,7 @@ void DiffEditorWidget::showDiff()
|
||||
blockNumber = 0;
|
||||
for (int i = 0; i < m_contextFileData.chunks.count(); i++) {
|
||||
ChunkData chunkData = m_contextFileData.chunks.at(i);
|
||||
if (!chunkData.alwaysShown) {
|
||||
if (chunkData.contextChunk) {
|
||||
QTextBlock leftBlock = m_leftEditor->document()->findBlockByNumber(blockNumber);
|
||||
TextEditor::BaseTextDocumentLayout::doFoldOrUnfold(leftBlock, false);
|
||||
QTextBlock rightBlock = m_rightEditor->document()->findBlockByNumber(blockNumber);
|
||||
@@ -889,7 +887,7 @@ void DiffEditorWidget::colorDiff(const FileData &fileData)
|
||||
|
||||
for (int i = 0; i < fileData.chunks.count(); i++) {
|
||||
ChunkData chunkData = fileData.chunks.at(i);
|
||||
if (!chunkData.alwaysShown) {
|
||||
if (chunkData.contextChunk) {
|
||||
leftChunkPos[leftPos] = leftPos + 1;
|
||||
rightChunkPos[rightPos] = rightPos + 1;
|
||||
leftPos++; // for chunk line
|
||||
|
@@ -72,34 +72,28 @@ struct RowData {
|
||||
: leftLine(l), rightLine(l), equal(true) {}
|
||||
RowData(const TextLineData &l, const TextLineData &r, bool e = false)
|
||||
: leftLine(l), rightLine(r), equal(e) {}
|
||||
RowData(const QString &txt)
|
||||
: text(txt), equal(true) {}
|
||||
TextLineData leftLine;
|
||||
TextLineData rightLine;
|
||||
QString text; // file of context description
|
||||
bool equal; // true if left and right lines are equal, taking whitespaces into account (or both invalid)
|
||||
};
|
||||
|
||||
struct ChunkData {
|
||||
ChunkData() : alwaysShown(true) {}
|
||||
ChunkData() : contextChunk(false) {}
|
||||
QList<RowData> rows;
|
||||
bool alwaysShown;
|
||||
bool contextChunk;
|
||||
// <absolute position in the file, absolute position in the file>
|
||||
QMap<int, int> changedLeftPositions; // counting from the beginning of the chunk
|
||||
QMap<int, int> changedRightPositions; // counting from the beginning of the chunk
|
||||
QString text;
|
||||
};
|
||||
|
||||
struct FileData {
|
||||
FileData() {}
|
||||
FileData(const ChunkData &chunkData) { chunks.append(chunkData); }
|
||||
QList<ChunkData> chunks;
|
||||
QString text;
|
||||
};
|
||||
|
||||
struct DiffData {
|
||||
QList<FileData> files;
|
||||
QString text;
|
||||
};
|
||||
|
||||
class DIFFEDITOR_EXPORT DiffEditorWidget : public QWidget
|
||||
@@ -110,7 +104,6 @@ public:
|
||||
~DiffEditorWidget();
|
||||
|
||||
void setDiff(const QString &leftText, const QString &rightText);
|
||||
void setDiff(const QList<Diff> &diffList);
|
||||
QTextCodec *codec() const;
|
||||
|
||||
public slots:
|
||||
@@ -128,6 +121,7 @@ private slots:
|
||||
void rightDocumentSizeChanged();
|
||||
|
||||
private:
|
||||
void setDiff(const QList<Diff> &diffList);
|
||||
bool isWhitespace(const QChar &c) const;
|
||||
bool isWhitespace(const Diff &diff) const;
|
||||
bool isEqual(const QList<Diff> &diffList, int diffNumber) const;
|
||||
|
@@ -3948,7 +3948,7 @@ void BaseTextEditorWidget::extraAreaPaintEvent(QPaintEvent *e)
|
||||
painter.setFont(f);
|
||||
painter.setPen(d->m_currentLineNumberFormat.foreground().color());
|
||||
}
|
||||
painter.drawText(QRectF(markWidth, top + lineNumberTopPositionOffset(blockNumber), extraAreaWidth - markWidth - 4, height), Qt::AlignRight, number);
|
||||
painter.drawText(QRectF(markWidth, top, extraAreaWidth - markWidth - 4, height), Qt::AlignRight, number);
|
||||
if (selected)
|
||||
painter.restore();
|
||||
}
|
||||
@@ -6200,12 +6200,6 @@ QString BaseTextEditorWidget::lineNumber(int blockNumber) const
|
||||
return QString::number(blockNumber + 1);
|
||||
}
|
||||
|
||||
int BaseTextEditorWidget::lineNumberTopPositionOffset(int blockNumber) const
|
||||
{
|
||||
Q_UNUSED(blockNumber)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int BaseTextEditorWidget::lineNumberDigits() const
|
||||
{
|
||||
int digits = 2;
|
||||
|
@@ -358,7 +358,6 @@ protected:
|
||||
static QString convertToPlainText(const QString &txt);
|
||||
|
||||
virtual QString lineNumber(int blockNumber) const;
|
||||
virtual int lineNumberTopPositionOffset(int blockNumber) const;
|
||||
virtual int lineNumberDigits() const;
|
||||
virtual bool selectionVisible(int blockNumber) const;
|
||||
virtual bool replacementVisible(int blockNumber) const;
|
||||
|
Reference in New Issue
Block a user