Commit aea0945a authored by Michael Reeves's avatar Michael Reeves

convert "magic numbers" to human readable form.

parent e26e5cdd
......@@ -1337,8 +1337,8 @@ bool Diff3Line::fineDiff(bool inBTextsTotalEqual, const e_SrcSelector selector,
k2 = getLineA();
}
if((k1 == -1 && k2 != -1) || (k1 != -1 && k2 == -1)) bTextsTotalEqual = false;
if(k1 != -1 && k2 != -1)
if((!k1.isValid() && k2.isValid()) || (k1.isValid() && !k2.isValid())) bTextsTotalEqual = false;
if(k1.isValid() && k2.isValid())
{
if(v1[k1].size() != v2[k2].size() || memcmp(v1[k1].getLine(), v2[k2].getLine(), v1[k1].size() << 1) != 0)
{
......
......@@ -1225,14 +1225,14 @@ QString DiffTextWindow::getSelection()
Q_ASSERT(d->m_winIdx >= 1 && d->m_winIdx <= 3);
if(d->m_winIdx == 1) {
if(d->m_winIdx == A) {
lineIdx = d3l->getLineA();
}
else if(d->m_winIdx == 2)
else if(d->m_winIdx == B)
{
lineIdx = d3l->getLineB();
}
else if(d->m_winIdx == 3)
else if(d->m_winIdx == C)
{
lineIdx = d3l->getLineC();
}
......@@ -1348,11 +1348,11 @@ void DiffTextWindow::setSelection(LineRef firstLine, int startPos, LineRef lastL
lastLine = getNofLines() - 1;
const Diff3Line* d3l = (*d->m_pDiff3LineVector)[convertLineToDiff3LineIdx(lastLine)];
int line = -1;
if(d->m_winIdx == 1) line = d3l->getLineA();
if(d->m_winIdx == 2) line = d3l->getLineB();
if(d->m_winIdx == 3) line = d3l->getLineC();
if(line >= 0)
LineRef line;
if(d->m_winIdx == A) line = d3l->getLineA();
if(d->m_winIdx == B) line = d3l->getLineB();
if(d->m_winIdx == C) line = d3l->getLineC();
if(line.isValid())
endPos = d->m_pLineData[line].width(d->m_pOptions->m_tabSize);
}
......@@ -1810,7 +1810,7 @@ void DiffTextWindowFrame::init()
{
QString s = QDir::toNativeSeparators(pDTW->d->m_filename);
d->m_pFileSelection->setText(s);
QString winId = pDTW->d->m_winIdx == 1 ? (pDTW->d->m_bTriple ? i18n("A (Base)") : i18n("A")) : (pDTW->d->m_winIdx == 2 ? i18n("B") : i18n("C"));
QString winId = pDTW->d->m_winIdx == A ? (pDTW->d->m_bTriple ? i18n("A (Base)") : i18n("A")) : (pDTW->d->m_winIdx == B ? i18n("B") : i18n("C"));
d->m_pLabel->setText(winId + ':');
d->m_pEncoding->setText(i18n("Encoding: %1", pDTW->d->m_pTextCodec != nullptr ? QLatin1String(pDTW->d->m_pTextCodec->name()) : QString()));
d->m_pLineEndStyle->setText(i18n("Line end style: %1", pDTW->d->m_eLineEndStyle == eLineEndStyleDos ? i18n("DOS") : i18n("Unix")));
......
......@@ -463,7 +463,7 @@ void MergeResultWindow::merge(bool bAutoSolve, e_SrcSelector defaultSelector, bo
if(ml.bDelta && (!bConflictsOnly || bConflict) && (!bWhiteSpaceOnly || ml.bWhiteSpaceConflict))
{
ml.mergeEditLineList.clear();
if(defaultSelector == -1 && ml.bDelta)
if(defaultSelector == Invalid && ml.bDelta)
{
MergeEditLine mel(ml.id3l);
;
......@@ -481,9 +481,9 @@ void MergeResultWindow::merge(bool bAutoSolve, e_SrcSelector defaultSelector, bo
MergeEditLine mel(d3llit);
mel.setSource(defaultSelector, false);
LineRef srcLine = defaultSelector == 1 ? d3llit->getLineA() : defaultSelector == 2 ? d3llit->getLineB() : defaultSelector == 3 ? d3llit->getLineC() : LineRef();
LineRef srcLine = defaultSelector == A ? d3llit->getLineA() : defaultSelector == B ? d3llit->getLineB() : defaultSelector == C ? d3llit->getLineC() : LineRef();
if(srcLine != -1)
if(srcLine.isValid())
{
ml.mergeEditLineList.push_back(mel);
}
......@@ -509,14 +509,14 @@ void MergeResultWindow::merge(bool bAutoSolve, e_SrcSelector defaultSelector, bo
// Remove all lines that are empty, because no src lines are there.
LineRef oldSrcLine;
int oldSrc = -1;
e_SrcSelector oldSrc = Invalid;
MergeEditLineList::iterator melIt;
for(melIt = ml.mergeEditLineList.begin(); melIt != ml.mergeEditLineList.end();)
{
MergeEditLine& mel = *melIt;
int melsrc = mel.src();
e_SrcSelector melsrc = mel.src();
LineRef srcLine = mel.isRemoved() ? LineRef() : melsrc == 1 ? mel.id3l()->getLineA() : melsrc == 2 ? mel.id3l()->getLineB() : melsrc == 3 ? mel.id3l()->getLineC() : LineRef();
LineRef srcLine = mel.isRemoved() ? LineRef() : melsrc == A ? mel.id3l()->getLineA() : melsrc == B ? mel.id3l()->getLineB() : melsrc == C ? mel.id3l()->getLineC() : LineRef();
// At least one line remains because oldSrc != melsrc for first line in list
// Other empty lines will be removed
......@@ -1050,7 +1050,7 @@ void MergeResultWindow::choose(e_SrcSelector selector)
{
MergeEditLine& mel = *melIt;
LineRef srcLine = mel.src() == 1 ? mel.id3l()->getLineA() : mel.src() == 2 ? mel.id3l()->getLineB() : mel.src() == 3 ? mel.id3l()->getLineC() : LineRef();
LineRef srcLine = mel.src() == A ? mel.id3l()->getLineA() : mel.src() == B ? mel.id3l()->getLineB() : mel.src() == C ? mel.id3l()->getLineC() : LineRef();
if(!srcLine.isValid())
melIt = ml.mergeEditLineList.erase(melIt);
......@@ -2046,9 +2046,9 @@ void MergeResultWindow::updateSourceMask()
for(melIt = ml.mergeEditLineList.begin(); melIt != ml.mergeEditLineList.end(); ++melIt)
{
MergeEditLine& mel = *melIt;
if(mel.src() == 1) srcMask |= 1;
if(mel.src() == 2) srcMask |= 2;
if(mel.src() == 3) srcMask |= 4;
if(mel.src() == A) srcMask |= 1;
if(mel.src() == B) srcMask |= 2;
if(mel.src() == C) srcMask |= 4;
if(mel.isModified() || !mel.isEditableText()) bModified = true;
}
......
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