Commit e844bee1 authored by jkobus's avatar jkobus Committed by Jarek Kobus

Add file descriptions, enable file folding

Change-Id: Ie90ac9fb74e9c4b8cfba16d065d1b8751125e83c
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent 325c0bed
......@@ -328,7 +328,15 @@ void DiffEditorPlugin::diff()
const QString text1 = getFileContents(fileName1, editorWidget->codec());
const QString text2 = getFileContents(fileName2, editorWidget->codec());
editorWidget->setDiff(text1, text2);
DiffEditorWidget::DiffFilesContents dfc;
dfc.leftFileName = fileName1;
dfc.leftText = text1;
dfc.rightFileName = fileName2;
dfc.rightText = text2;
QList<DiffEditorWidget::DiffFilesContents> list;
list.append(dfc);
editorWidget->setDiff(list);
}
}
......
This diff is collapsed.
......@@ -81,7 +81,6 @@ struct ChunkData {
ChunkData() : contextChunk(false) {}
QList<RowData> rows;
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
};
......@@ -90,6 +89,8 @@ struct FileData {
FileData() {}
FileData(const ChunkData &chunkData) { chunks.append(chunkData); }
QList<ChunkData> chunks;
QString leftFileName;
QString rightFileName;
};
struct DiffData {
......@@ -100,10 +101,18 @@ class DIFFEDITOR_EXPORT DiffEditorWidget : public QWidget
{
Q_OBJECT
public:
struct DiffFilesContents {
QString leftFileName;
QString leftText;
QString rightFileName;
QString rightText;
};
DiffEditorWidget(QWidget *parent = 0);
~DiffEditorWidget();
void setDiff(const QString &leftText, const QString &rightText);
void clear();
void setDiff(const QList<DiffFilesContents> &diffFileList);
QTextCodec *codec() const;
public slots:
......@@ -121,14 +130,20 @@ private slots:
void rightDocumentSizeChanged();
private:
void setDiff(const QList<Diff> &diffList);
struct DiffList {
QString leftFileName;
QString rightFileName;
QList<Diff> diffList;
};
void setDiff(const QList<DiffList> &diffList);
bool isWhitespace(const QChar &c) const;
bool isWhitespace(const Diff &diff) const;
bool isEqual(const QList<Diff> &diffList, int diffNumber) const;
QList<QTextEdit::ExtraSelection> colorPositions(const QTextCharFormat &format,
QTextCursor &cursor,
const QMap<int, int> &positions) const;
void colorDiff(const FileData &fileData);
void colorDiff(const QList<FileData> &fileDataList);
QList<TextLineData> assemblyRows(const QStringList &lines,
const QMap<int, int> &lineSpans,
const QMap<int, int> &changedPositions,
......@@ -142,13 +157,12 @@ private:
DiffViewEditorWidget *m_rightEditor;
QSplitter *m_splitter;
QList<Diff> m_diffList;
QList<DiffList> m_diffList; // list of original outputs from differ
QList<ChunkData> m_originalChunkData; // one big chunk for every file, ignoreWhitespaces taken into account
QList<FileData> m_contextFileData; // ultimate data to be shown, contextLinesNumber taken into account
int m_contextLinesNumber;
bool m_ignoreWhitespaces;
ChunkData m_originalChunkData;
FileData m_contextFileData;
bool m_foldingBlocker;
};
......
......@@ -3649,6 +3649,11 @@ void BaseTextEditorWidget::paintEvent(QPaintEvent *e)
}
}
int BaseTextEditorWidget::visibleFoldedBlockNumber() const
{
return d->visibleFoldedBlockNumber;
}
void BaseTextEditorWidget::drawCollapsedBlockPopup(QPainter &painter,
const QTextBlock &block,
QPointF offset,
......@@ -4617,8 +4622,7 @@ void BaseTextEditorWidget::toggleBlockVisible(const QTextBlock &block)
BaseTextDocumentLayout *documentLayout = qobject_cast<BaseTextDocumentLayout*>(document()->documentLayout());
QTC_ASSERT(documentLayout, return);
bool visible = block.next().isVisible();
BaseTextDocumentLayout::doFoldOrUnfold(block, !visible);
BaseTextDocumentLayout::doFoldOrUnfold(block, BaseTextDocumentLayout::isFolded(block));
documentLayout->requestUpdate();
documentLayout->emitDocumentSizeChanged();
}
......
......@@ -539,6 +539,12 @@ protected:
Reimplement this function to change the default replacement text.
*/
virtual QString foldReplacementText(const QTextBlock &block) const;
virtual void drawCollapsedBlockPopup(QPainter &painter,
const QTextBlock &block,
QPointF offset,
const QRect &clip);
int visibleFoldedBlockNumber() const;
protected slots:
virtual void slotUpdateExtraArea();
......@@ -570,11 +576,6 @@ private:
bool active,
bool hovered) const;
void drawCollapsedBlockPopup(QPainter &painter,
const QTextBlock &block,
QPointF offset,
const QRect &clip);
void toggleBlockVisible(const QTextBlock &block);
QRect foldBox();
......
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