Fourth step
| 927 | |
| 928 | // Fourth step |
| 929 | void Diff3LineList::calcDiff3LineListTrim( |
| 930 | const std::shared_ptr<LineDataVector> &pldA, const std::shared_ptr<LineDataVector> &pldB, const std::shared_ptr<LineDataVector> &pldC, ManualDiffHelpList* pManualDiffHelpList) |
| 931 | { |
| 932 | const Diff3Line d3l_empty; |
| 933 | remove(d3l_empty); |
| 934 | |
| 935 | Diff3LineList::iterator lookAhead = begin(); |
| 936 | Diff3LineList::iterator i3A = begin(); |
| 937 | Diff3LineList::iterator i3B = begin(); |
| 938 | Diff3LineList::iterator i3C = begin(); |
| 939 | |
| 940 | qint32 line = 0; // diff3line counters |
| 941 | qint32 lineA = 0; // |
| 942 | qint32 lineB = 0; |
| 943 | qint32 lineC = 0; |
| 944 | |
| 945 | ManualDiffHelpList::iterator iMDHL = pManualDiffHelpList->begin(); |
| 946 | // The iterator lookAhead is the variable line look ahead. |
| 947 | // The iterators i3A, i3B, i3C and corresponding lineA, lineB and lineC stop at empty lines, if found. |
| 948 | // If possible, then the texts from the look ahead will be moved back to the empty places. |
| 949 | |
| 950 | for(; lookAhead != end(); ++lookAhead, ++line) |
| 951 | { |
| 952 | if(iMDHL != pManualDiffHelpList->end()) |
| 953 | { |
| 954 | if((lookAhead->getLineA().isValid() && lookAhead->getLineA() == iMDHL->getLine1(e_SrcSelector::A)) || |
| 955 | (lookAhead->getLineB().isValid() && lookAhead->getLineB() == iMDHL->getLine1(e_SrcSelector::B)) || |
| 956 | (lookAhead->getLineC().isValid() && lookAhead->getLineC() == iMDHL->getLine1(e_SrcSelector::C))) |
| 957 | { |
| 958 | i3A = lookAhead; |
| 959 | i3B = lookAhead; |
| 960 | i3C = lookAhead; |
| 961 | lineA = line; |
| 962 | lineB = line; |
| 963 | lineC = line; |
| 964 | ++iMDHL; |
| 965 | } |
| 966 | } |
| 967 | |
| 968 | if(line > lineA && lookAhead->getLineA().isValid() && i3A->getLineB().isValid() && i3A->isEqualBC() && |
| 969 | LineData::equal((*pldA)[lookAhead->getLineA()], (*pldB)[i3A->getLineB()]) && |
| 970 | pManualDiffHelpList->isValidMove(lookAhead->getLineA(), i3A->getLineB(), e_SrcSelector::A, e_SrcSelector::B) && |
| 971 | pManualDiffHelpList->isValidMove(lookAhead->getLineA(), i3A->getLineC(), e_SrcSelector::A, e_SrcSelector::C)) |
| 972 | { |
| 973 | // Empty space for A. A matches B and C in the empty line. Move it up. |
| 974 | i3A->setLineA(lookAhead->getLineA()); |
| 975 | i3A->bAEqB = true; |
| 976 | i3A->bAEqC = true; |
| 977 | |
| 978 | lookAhead->setLineA(LineRef::invalid); |
| 979 | lookAhead->bAEqB = false; |
| 980 | lookAhead->bAEqC = false; |
| 981 | ++i3A; |
| 982 | ++lineA; |
| 983 | } |
| 984 | |
| 985 | if(line > lineB && lookAhead->getLineB().isValid() && i3B->getLineA().isValid() && i3B->isEqualAC() && |
| 986 | LineData::equal((*pldB)[lookAhead->getLineB()], (*pldA)[i3B->getLineA()]) && |