forked from qt-creator/qt-creator
DiffEditor: Use DiffSide in DiffEditorInput
Change-Id: I195c37f29884f1d066acbb54c8ace07f8801f829 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -222,10 +222,10 @@ void DiffEditorWidgetController::setFontSettings(const FontSettings &fontSetting
|
||||
m_fileLineFormat = fontSettings.toTextCharFormat(C_DIFF_FILE_LINE);
|
||||
m_chunkLineFormat = fontSettings.toTextCharFormat(C_DIFF_CONTEXT_LINE);
|
||||
m_spanLineFormat = fontSettings.toTextCharFormat(C_LINE_NUMBER);
|
||||
m_leftLineFormat = fontSettings.toTextCharFormat(C_DIFF_SOURCE_LINE);
|
||||
m_leftCharFormat = fontSettings.toTextCharFormat(C_DIFF_SOURCE_CHAR);
|
||||
m_rightLineFormat = fontSettings.toTextCharFormat(C_DIFF_DEST_LINE);
|
||||
m_rightCharFormat = fontSettings.toTextCharFormat(C_DIFF_DEST_CHAR);
|
||||
m_lineFormat[LeftSide] = fontSettings.toTextCharFormat(C_DIFF_SOURCE_LINE);
|
||||
m_charFormat[LeftSide] = fontSettings.toTextCharFormat(C_DIFF_SOURCE_CHAR);
|
||||
m_lineFormat[RightSide] = fontSettings.toTextCharFormat(C_DIFF_DEST_LINE);
|
||||
m_charFormat[RightSide] = fontSettings.toTextCharFormat(C_DIFF_DEST_CHAR);
|
||||
}
|
||||
|
||||
void DiffEditorWidgetController::addCodePasterAction(QMenu *menu, int fileIndex, int chunkIndex)
|
||||
@@ -336,10 +336,8 @@ DiffEditorInput::DiffEditorInput(DiffEditorWidgetController *controller)
|
||||
, m_fileLineFormat(&controller->m_fileLineFormat)
|
||||
, m_chunkLineFormat(&controller->m_chunkLineFormat)
|
||||
, m_spanLineFormat(&controller->m_spanLineFormat)
|
||||
, m_leftLineFormat(&controller->m_leftLineFormat)
|
||||
, m_rightLineFormat(&controller->m_rightLineFormat)
|
||||
, m_leftCharFormat(&controller->m_leftCharFormat)
|
||||
, m_rightCharFormat(&controller->m_rightCharFormat)
|
||||
, m_lineFormat{&controller->m_lineFormat[LeftSide], &controller->m_lineFormat[RightSide]}
|
||||
, m_charFormat{&controller->m_charFormat[LeftSide], &controller->m_charFormat[RightSide]}
|
||||
{ }
|
||||
|
||||
|
||||
|
@@ -52,10 +52,8 @@ public:
|
||||
QTextCharFormat m_fileLineFormat;
|
||||
QTextCharFormat m_chunkLineFormat;
|
||||
QTextCharFormat m_spanLineFormat;
|
||||
QTextCharFormat m_leftLineFormat;
|
||||
QTextCharFormat m_rightLineFormat;
|
||||
QTextCharFormat m_leftCharFormat;
|
||||
QTextCharFormat m_rightCharFormat;
|
||||
std::array<QTextCharFormat, SideCount> m_lineFormat{};
|
||||
std::array<QTextCharFormat, SideCount> m_charFormat{};
|
||||
|
||||
private:
|
||||
bool isInProgress() const;
|
||||
@@ -88,10 +86,8 @@ public:
|
||||
QTextCharFormat *m_fileLineFormat = nullptr;
|
||||
QTextCharFormat *m_chunkLineFormat = nullptr;
|
||||
QTextCharFormat *m_spanLineFormat = nullptr;
|
||||
QTextCharFormat *m_leftLineFormat = nullptr;
|
||||
QTextCharFormat *m_rightLineFormat = nullptr;
|
||||
QTextCharFormat *m_leftCharFormat = nullptr;
|
||||
QTextCharFormat *m_rightCharFormat = nullptr;
|
||||
std::array<QTextCharFormat *, SideCount> m_lineFormat{};
|
||||
std::array<QTextCharFormat *, SideCount> m_charFormat{};
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -338,11 +338,11 @@ SideBySideDiffOutput SideDiffData::diffOutput(QFutureInterface<void> &fi, int pr
|
||||
|
||||
if (!rowData.equal) {
|
||||
if (rowData.line[LeftSide].textLineType == TextLineData::TextLine)
|
||||
leftFormats[blockNumber].append({input.m_leftLineFormat});
|
||||
leftFormats[blockNumber].append({input.m_lineFormat[LeftSide]});
|
||||
else
|
||||
leftFormats[blockNumber].append({input.m_spanLineFormat});
|
||||
if (rowData.line[RightSide].textLineType == TextLineData::TextLine)
|
||||
rightFormats[blockNumber].append({input.m_rightLineFormat});
|
||||
rightFormats[blockNumber].append({input.m_lineFormat[RightSide]});
|
||||
else
|
||||
rightFormats[blockNumber].append({input.m_spanLineFormat});
|
||||
}
|
||||
@@ -350,13 +350,13 @@ SideBySideDiffOutput SideDiffData::diffOutput(QFutureInterface<void> &fi, int pr
|
||||
for (auto it = leftLineData.changedPositions.cbegin(),
|
||||
end = leftLineData.changedPositions.cend(); it != end; ++it) {
|
||||
leftFormats[blockNumber].append(
|
||||
{input.m_leftCharFormat, it.key(), it.value()});
|
||||
{input.m_charFormat[LeftSide], it.key(), it.value()});
|
||||
}
|
||||
|
||||
for (auto it = rightLineData.changedPositions.cbegin(),
|
||||
end = rightLineData.changedPositions.cend(); it != end; ++it) {
|
||||
rightFormats[blockNumber].append(
|
||||
{input.m_rightCharFormat, it.key(), it.value()});
|
||||
{input.m_charFormat[RightSide], it.key(), it.value()});
|
||||
}
|
||||
|
||||
leftText += separator;
|
||||
|
@@ -346,14 +346,14 @@ QString UnifiedDiffData::setChunk(const DiffEditorInput &input, const ChunkData
|
||||
const int blockDelta = line.count('\n'); // no new line
|
||||
// could have been added
|
||||
for (int k = 0; k < blockDelta; k++)
|
||||
(*selections)[*blockNumber + blockCount + 1 + k].append({input.m_leftLineFormat});
|
||||
(*selections)[*blockNumber + blockCount + 1 + k].append({input.m_lineFormat[LeftSide]});
|
||||
|
||||
for (auto it = lineData.changedPositions.cbegin(),
|
||||
end = lineData.changedPositions.cend(); it != end; ++it) {
|
||||
const int startPos = it.key() < 0 ? 1 : it.key() + 1;
|
||||
const int endPos = it.value() < 0 ? it.value() : it.value() + 1;
|
||||
(*selections)[*blockNumber + blockCount + 1].append(
|
||||
{input.m_leftCharFormat, startPos, endPos});
|
||||
{input.m_charFormat[LeftSide], startPos, endPos});
|
||||
}
|
||||
|
||||
if (!line.isEmpty()) {
|
||||
@@ -385,14 +385,14 @@ QString UnifiedDiffData::setChunk(const DiffEditorInput &input, const ChunkData
|
||||
// could have been added
|
||||
|
||||
for (int k = 0; k < blockDelta; k++)
|
||||
(*selections)[*blockNumber + blockCount + 1 + k].append({input.m_rightLineFormat});
|
||||
(*selections)[*blockNumber + blockCount + 1 + k].append({input.m_lineFormat[RightSide]});
|
||||
|
||||
for (auto it = lineData.changedPositions.cbegin(),
|
||||
end = lineData.changedPositions.cend(); it != end; ++it) {
|
||||
const int startPos = it.key() < 0 ? 1 : it.key() + 1;
|
||||
const int endPos = it.value() < 0 ? it.value() : it.value() + 1;
|
||||
(*selections)[*blockNumber + blockCount + 1].append(
|
||||
{input.m_rightCharFormat, startPos, endPos});
|
||||
{input.m_charFormat[RightSide], startPos, endPos});
|
||||
}
|
||||
|
||||
if (!line.isEmpty()) {
|
||||
|
Reference in New Issue
Block a user