Commit 1a1d5c23 authored by Michael Reeves's avatar Michael Reeves

move getLineInfo to Diff3Line

parent ef103957
......@@ -1401,6 +1401,45 @@ bool Diff3Line::fineDiff(const int selector, const LineData* v1, const LineData*
return bTextsTotalEqual;
}
void Diff3Line::getLineInfo(const int winIdx, const bool isTriple, int& lineIdx,
DiffList*& pFineDiff1, DiffList*& pFineDiff2, // return values
int& changed, int& changed2) const
{
changed = 0;
changed2 = 0;
bool bAEqualB = this->bAEqB || (bWhiteLineA && bWhiteLineB);
bool bAEqualC = this->bAEqC || (bWhiteLineA && bWhiteLineC);
bool bBEqualC = this->bBEqC || (bWhiteLineB && bWhiteLineC);
Q_ASSERT(winIdx >= 1 && winIdx <= 3);
if(winIdx == 1) {
lineIdx = getLineA();
pFineDiff1 = pFineAB;
pFineDiff2 = pFineCA;
changed |= ((getLineB() == -1) != (lineIdx == -1) ? 1 : 0) +
((getLineC() == -1) != (lineIdx == -1) && isTriple ? 2 : 0);
changed2 |= (bAEqualB ? 0 : 1) + (bAEqualC || !isTriple ? 0 : 2);
}
else if(winIdx == 2)
{
lineIdx = getLineB();
pFineDiff1 = pFineBC;
pFineDiff2 = pFineAB;
changed |= ((getLineC() == -1) != (lineIdx == -1) && isTriple ? 1 : 0) +
((getLineA() == -1) != (lineIdx == -1) ? 2 : 0);
changed2 |= (bBEqualC || !isTriple ? 0 : 1) + (bAEqualB ? 0 : 2);
}
else if(winIdx == 3)
{
lineIdx = getLineC();
pFineDiff1 = pFineCA;
pFineDiff2 = pFineBC;
changed |= ((getLineA() == -1) != (lineIdx == -1) ? 1 : 0) +
((getLineB() == -1) != (lineIdx == -1) ? 2 : 0);
changed2 |= (bAEqualC ? 0 : 1) + (bBEqualC ? 0 : 2);
}
}
bool Diff3LineList::fineDiff(const int selector, const LineData* v1, const LineData* v2)
{
// Finetuning: Diff each line with deltas
......
......@@ -179,6 +179,10 @@ class Diff3Line
bool fineDiff(const int selector, const LineData* v1, const LineData* v2);
void mergeOneLine(e_MergeDetails& mergeDetails, bool& bConflict, bool& bLineRemoved, int& src, bool bTwoInputs) const;
void getLineInfo(const int winIdx, const bool isTriple, int& lineIdx,
DiffList*& pFineDiff1, DiffList*& pFineDiff2, // return values
int& changed, int& changed2) const;
private:
void setFineDiff(const int selector, DiffList* pDiffList)
{
......
......@@ -1171,40 +1171,7 @@ void DiffTextWindowData::getLineInfo(
DiffList*& pFineDiff1, DiffList*& pFineDiff2, // return values
int& changed, int& changed2)
{
changed = 0;
changed2 = 0;
bool bAEqB = d3l.bAEqB || (d3l.bWhiteLineA && d3l.bWhiteLineB);
bool bAEqC = d3l.bAEqC || (d3l.bWhiteLineA && d3l.bWhiteLineC);
bool bBEqC = d3l.bBEqC || (d3l.bWhiteLineB && d3l.bWhiteLineC);
Q_ASSERT(m_winIdx >= 1 && m_winIdx <= 3);
if(m_winIdx == 1) {
lineIdx = d3l.getLineA();
pFineDiff1 = d3l.pFineAB;
pFineDiff2 = d3l.pFineCA;
changed |= ((d3l.getLineB() == -1) != (lineIdx == -1) ? 1 : 0) +
((d3l.getLineC() == -1) != (lineIdx == -1) && m_bTriple ? 2 : 0);
changed2 |= (bAEqB ? 0 : 1) + (bAEqC || !m_bTriple ? 0 : 2);
}
else if(m_winIdx == 2)
{
lineIdx = d3l.getLineB();
pFineDiff1 = d3l.pFineBC;
pFineDiff2 = d3l.pFineAB;
changed |= ((d3l.getLineC() == -1) != (lineIdx == -1) && m_bTriple ? 1 : 0) +
((d3l.getLineA() == -1) != (lineIdx == -1) ? 2 : 0);
changed2 |= (bBEqC || !m_bTriple ? 0 : 1) + (bAEqB ? 0 : 2);
}
else if(m_winIdx == 3)
{
lineIdx = d3l.getLineC();
pFineDiff1 = d3l.pFineCA;
pFineDiff2 = d3l.pFineBC;
changed |= ((d3l.getLineA() == -1) != (lineIdx == -1) ? 1 : 0) +
((d3l.getLineB() == -1) != (lineIdx == -1) ? 2 : 0);
changed2 |= (bAEqC ? 0 : 1) + (bBEqC ? 0 : 2);
}
d3l.getLineInfo(m_winIdx, m_bTriple, lineIdx, pFineDiff1, pFineDiff2, changed, changed2);
}
void DiffTextWindow::resizeEvent(QResizeEvent* e)
......
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