Mercurial > hg > easyhg-kdiff3
comparison kdiff3/src-QT4/mergeresultwindow.cpp @ 77:1184fc843210
KDiff3-0.9.92
author | joachim99 |
---|---|
date | Mon, 16 Apr 2007 21:26:08 +0000 |
parents | 08ea9b86c12c |
children | fcd146072e0c |
comparison
equal
deleted
inserted
replaced
76:257ccb866dc3 | 77:1184fc843210 |
---|---|
1 /*************************************************************************** | 1 /*************************************************************************** |
2 mergeresultwindow.cpp - description | 2 mergeresultwindow.cpp - description |
3 ------------------- | 3 ------------------- |
4 begin : Sun Apr 14 2002 | 4 begin : Sun Apr 14 2002 |
5 copyright : (C) 2002-2006 by Joachim Eibl | 5 copyright : (C) 2002-2007 by Joachim Eibl |
6 email : joachim.eibl at gmx.de | 6 email : joachim.eibl at gmx.de |
7 ***************************************************************************/ | 7 ***************************************************************************/ |
8 | 8 |
9 /*************************************************************************** | 9 /*************************************************************************** |
10 * * | 10 * * |
564 if( eEndPoint==eEnd ) | 564 if( eEndPoint==eEnd ) |
565 { | 565 { |
566 if (eDir==eUp) i = m_mergeLineList.begin(); // first mergeline | 566 if (eDir==eUp) i = m_mergeLineList.begin(); // first mergeline |
567 else i = --m_mergeLineList.end(); // last mergeline | 567 else i = --m_mergeLineList.end(); // last mergeline |
568 | 568 |
569 while ( i!=m_mergeLineList.end() && ! i->bDelta ) | 569 while ( isItAtEnd(eDir==eUp, i) && ! i->bDelta ) |
570 { | 570 { |
571 if ( eDir==eUp ) ++i; // search downwards | 571 if ( eDir==eUp ) ++i; // search downwards |
572 else --i; // search upwards | 572 else --i; // search upwards |
573 } | 573 } |
574 } | 574 } |
575 else if ( eEndPoint == eDelta && i!=m_mergeLineList.end()) | 575 else if ( eEndPoint == eDelta && isItAtEnd(eDir!=eUp, i) ) |
576 { | 576 { |
577 do | 577 do |
578 { | 578 { |
579 if ( eDir==eUp ) --i; | 579 if ( eDir==eUp ) --i; |
580 else ++i; | 580 else ++i; |
581 } | 581 } |
582 while ( i!=m_mergeLineList.end() && ( i->bDelta == false || checkOverviewIgnore(i) || bSkipWhiteConflicts && i->bWhiteSpaceConflict ) ); | 582 while ( isItAtEnd(eDir!=eUp, i) && ( i->bDelta == false || checkOverviewIgnore(i) || bSkipWhiteConflicts && i->bWhiteSpaceConflict ) ); |
583 } | 583 } |
584 else if ( eEndPoint == eConflict && i!=m_mergeLineList.end() ) | 584 else if ( eEndPoint == eConflict && isItAtEnd(eDir!=eUp, i) ) |
585 { | 585 { |
586 do | 586 do |
587 { | 587 { |
588 if ( eDir==eUp ) --i; | 588 if ( eDir==eUp ) --i; |
589 else ++i; | 589 else ++i; |
590 } | 590 } |
591 while ( i!=m_mergeLineList.end() && (i->bConflict == false || bSkipWhiteConflicts && i->bWhiteSpaceConflict ) ); | 591 while ( isItAtEnd(eDir!=eUp, i) && (i->bConflict == false || bSkipWhiteConflicts && i->bWhiteSpaceConflict ) ); |
592 } | 592 } |
593 else if ( i!=m_mergeLineList.end() && eEndPoint == eUnsolvedConflict ) | 593 else if ( isItAtEnd(eDir!=eUp, i) && eEndPoint == eUnsolvedConflict ) |
594 { | 594 { |
595 do | 595 do |
596 { | 596 { |
597 if ( eDir==eUp ) --i; | 597 if ( eDir==eUp ) --i; |
598 else ++i; | 598 else ++i; |
599 } | 599 } |
600 while ( i!=m_mergeLineList.end() && ! i->mergeEditLineList.begin()->isConflict() ); | 600 while ( isItAtEnd(eDir!=eUp, i) && ! i->mergeEditLineList.begin()->isConflict() ); |
601 } | 601 } |
602 | 602 |
603 if ( isVisible() ) | 603 if ( isVisible() ) |
604 setFocus(); | 604 setFocus(); |
605 | 605 |
613 MergeLineList::iterator i = m_currentMergeLineIt; | 613 MergeLineList::iterator i = m_currentMergeLineIt; |
614 if (i == m_mergeLineList.begin()) return false; | 614 if (i == m_mergeLineList.begin()) return false; |
615 do | 615 do |
616 { | 616 { |
617 --i; | 617 --i; |
618 if ( i->bDelta && !( bSkipWhiteConflicts && i->bWhiteSpaceConflict ) ) return true; | 618 if ( i->bDelta && !checkOverviewIgnore(i) && !( bSkipWhiteConflicts && i->bWhiteSpaceConflict ) ) return true; |
619 } | 619 } |
620 while (i!=m_mergeLineList.begin()); | 620 while (i!=m_mergeLineList.begin()); |
621 | 621 |
622 return false; | 622 return false; |
623 } | 623 } |
631 if (i!=m_mergeLineList.end()) | 631 if (i!=m_mergeLineList.end()) |
632 { | 632 { |
633 ++i; | 633 ++i; |
634 for( ; i!=m_mergeLineList.end(); ++i ) | 634 for( ; i!=m_mergeLineList.end(); ++i ) |
635 { | 635 { |
636 if ( i->bDelta && !( bSkipWhiteConflicts && i->bWhiteSpaceConflict ) ) return true; | 636 if ( i->bDelta && !checkOverviewIgnore(i) && !( bSkipWhiteConflicts && i->bWhiteSpaceConflict ) ) return true; |
637 } | 637 } |
638 } | 638 } |
639 return false; | 639 return false; |
640 } | 640 } |
641 | 641 |
643 { | 643 { |
644 if (m_mergeLineList.empty()) return false; | 644 if (m_mergeLineList.empty()) return false; |
645 MergeLineList::iterator i = m_currentMergeLineIt; | 645 MergeLineList::iterator i = m_currentMergeLineIt; |
646 if (i == m_mergeLineList.begin()) return false; | 646 if (i == m_mergeLineList.begin()) return false; |
647 | 647 |
648 bool bSkipWhiteConflicts = ! m_pOptionDialog->m_bShowWhiteSpace; | |
649 | |
648 do | 650 do |
649 { | 651 { |
650 --i; | 652 --i; |
651 if ( i->bConflict ) return true; | 653 if ( i->bConflict && !(bSkipWhiteConflicts && i->bWhiteSpaceConflict) ) return true; |
652 } | 654 } |
653 while (i!=m_mergeLineList.begin()); | 655 while (i!=m_mergeLineList.begin()); |
654 | 656 |
655 return false; | 657 return false; |
656 } | 658 } |
657 | 659 |
658 bool MergeResultWindow::isConflictBelowCurrent() | 660 bool MergeResultWindow::isConflictBelowCurrent() |
659 { | 661 { |
660 MergeLineList::iterator i = m_currentMergeLineIt; | 662 MergeLineList::iterator i = m_currentMergeLineIt; |
661 if (m_mergeLineList.empty()) return false; | 663 if (m_mergeLineList.empty()) return false; |
662 | 664 |
665 bool bSkipWhiteConflicts = ! m_pOptionDialog->m_bShowWhiteSpace; | |
666 | |
663 if (i!=m_mergeLineList.end()) | 667 if (i!=m_mergeLineList.end()) |
664 { | 668 { |
665 ++i; | 669 ++i; |
666 for( ; i!=m_mergeLineList.end(); ++i ) | 670 for( ; i!=m_mergeLineList.end(); ++i ) |
667 { | 671 { |
668 if ( i->bConflict ) return true; | 672 if ( i->bConflict && !(bSkipWhiteConflicts && i->bWhiteSpaceConflict) ) return true; |
669 } | 673 } |
670 } | 674 } |
671 return false; | 675 return false; |
676 } | |
677 | |
678 bool MergeResultWindow::isUnsolvedConflictAtCurrent() | |
679 { | |
680 if (m_mergeLineList.empty()) return false; | |
681 MergeLineList::iterator i = m_currentMergeLineIt; | |
682 return i->mergeEditLineList.begin()->isConflict(); | |
672 } | 683 } |
673 | 684 |
674 bool MergeResultWindow::isUnsolvedConflictAboveCurrent() | 685 bool MergeResultWindow::isUnsolvedConflictAboveCurrent() |
675 { | 686 { |
676 if (m_mergeLineList.empty()) return false; | 687 if (m_mergeLineList.empty()) return false; |
801 if ( m_pTotalDiffStatus->bBinaryAEqB && m_pTotalDiffStatus->bBinaryAEqC ) | 812 if ( m_pTotalDiffStatus->bBinaryAEqB && m_pTotalDiffStatus->bBinaryAEqC ) |
802 totalInfo += i18n("All input files are binary equal."); | 813 totalInfo += i18n("All input files are binary equal."); |
803 else if ( m_pTotalDiffStatus->bTextAEqB && m_pTotalDiffStatus->bTextAEqC ) | 814 else if ( m_pTotalDiffStatus->bTextAEqB && m_pTotalDiffStatus->bTextAEqC ) |
804 totalInfo += i18n("All input files contain the same text."); | 815 totalInfo += i18n("All input files contain the same text."); |
805 else { | 816 else { |
806 if ( m_pTotalDiffStatus->bBinaryAEqB ) totalInfo += i18n("Files A and B are binary equal.\n"); | 817 if ( m_pTotalDiffStatus->bBinaryAEqB ) totalInfo += i18n("Files %1 and %2 are binary equal.\n").arg("A").arg("B"); |
807 else if ( m_pTotalDiffStatus->bTextAEqB ) totalInfo += i18n("Files A and B have equal text. \n"); | 818 else if ( m_pTotalDiffStatus->bTextAEqB ) totalInfo += i18n("Files %1 and %2 have equal text.\n").arg("A").arg("B"); |
808 if ( m_pTotalDiffStatus->bBinaryAEqC ) totalInfo += i18n("Files A and C are binary equal.\n"); | 819 if ( m_pTotalDiffStatus->bBinaryAEqC ) totalInfo += i18n("Files %1 and %2 are binary equal.\n").arg("A").arg("C"); |
809 else if ( m_pTotalDiffStatus->bTextAEqC ) totalInfo += i18n("Files A and C have equal text. \n"); | 820 else if ( m_pTotalDiffStatus->bTextAEqC ) totalInfo += i18n("Files %1 and %2 have equal text.\n").arg("A").arg("C"); |
810 if ( m_pTotalDiffStatus->bBinaryBEqC ) totalInfo += i18n("Files B and C are binary equal.\n"); | 821 if ( m_pTotalDiffStatus->bBinaryBEqC ) totalInfo += i18n("Files %1 and %2 are binary equal.\n").arg("B").arg("C"); |
811 else if ( m_pTotalDiffStatus->bTextBEqC ) totalInfo += i18n("Files B and C have equal text. \n"); | 822 else if ( m_pTotalDiffStatus->bTextBEqC ) totalInfo += i18n("Files %1 and %2 have equal text.\n").arg("B").arg("C"); |
812 } | 823 } |
813 | 824 |
814 int nrOfUnsolvedConflicts = getNrOfUnsolvedConflicts(); | 825 int nrOfUnsolvedConflicts = getNrOfUnsolvedConflicts(); |
815 | 826 |
816 KMessageBox::information( this, | 827 KMessageBox::information( this, |
981 int nofUnsolved = getNrOfUnsolvedConflicts(&wsc); | 992 int nofUnsolved = getNrOfUnsolvedConflicts(&wsc); |
982 m_pStatusBar->showMessage( i18n("Number of remaining unsolved conflicts: %1 (of which %2 are whitespace)") | 993 m_pStatusBar->showMessage( i18n("Number of remaining unsolved conflicts: %1 (of which %2 are whitespace)") |
983 .arg(nofUnsolved).arg(wsc) ); | 994 .arg(nofUnsolved).arg(wsc) ); |
984 } | 995 } |
985 | 996 |
986 | 997 static QString calcHistoryLead(const QString& s ) |
987 static void findHistoryRange( bool bThreeFiles, const Diff3LineList* pD3LList, | 998 { |
999 // Return the start of the line until the first white char after the first non white char. | |
1000 int i; | |
1001 for( i=0; i<s.length(); ++i ) | |
1002 { | |
1003 if (s[i]!=' ' && s[i]!='\t') | |
1004 { | |
1005 for( ; i<s.length(); ++i ) | |
1006 { | |
1007 if (s[i]==' ' || s[i]=='\t') | |
1008 { | |
1009 return s.left(i); | |
1010 } | |
1011 } | |
1012 return s; // Very unlikely | |
1013 } | |
1014 } | |
1015 return ""; // Must be an empty string, not a null string. | |
1016 } | |
1017 | |
1018 static void findHistoryRange( const QRegExp& historyStart, bool bThreeFiles, const Diff3LineList* pD3LList, | |
988 Diff3LineList::const_iterator& iBegin, Diff3LineList::const_iterator& iEnd, int& idxBegin, int& idxEnd ) | 1019 Diff3LineList::const_iterator& iBegin, Diff3LineList::const_iterator& iEnd, int& idxBegin, int& idxEnd ) |
989 { | 1020 { |
990 QRegExp historyStart(".*\\$Log.*\\$.*"); | |
991 QString historyLead; | 1021 QString historyLead; |
992 // Search for start of history | 1022 // Search for start of history |
993 for( iBegin = pD3LList->begin(), idxBegin=0; iBegin!=pD3LList->end(); ++iBegin, ++idxBegin ) | 1023 for( iBegin = pD3LList->begin(), idxBegin=0; iBegin!=pD3LList->end(); ++iBegin, ++idxBegin ) |
994 { | 1024 { |
995 if ( historyStart.exactMatch( iBegin->getString(A) ) && | 1025 if ( historyStart.exactMatch( iBegin->getString(A) ) && |
996 historyStart.exactMatch( iBegin->getString(B) ) && | 1026 historyStart.exactMatch( iBegin->getString(B) ) && |
997 ( !bThreeFiles || historyStart.exactMatch( iBegin->getString(C) ) ) ) | 1027 ( !bThreeFiles || historyStart.exactMatch( iBegin->getString(C) ) ) ) |
998 { | 1028 { |
999 historyLead = iBegin->getString(A).section(' ', 0, 0, QString::SectionIncludeLeadingSep); | 1029 historyLead = calcHistoryLead( iBegin->getString(A) ); |
1000 break; | 1030 break; |
1001 } | 1031 } |
1002 } | 1032 } |
1003 // Search for end of history | 1033 // Search for end of history |
1004 for( iEnd = iBegin, idxEnd = idxBegin; iEnd!=pD3LList->end(); ++iEnd, ++idxEnd ) | 1034 for( iEnd = iBegin, idxEnd = idxBegin; iEnd!=pD3LList->end(); ++iEnd, ++idxEnd ) |
1005 { | 1035 { |
1006 QString sA = iEnd->getString(A); | 1036 QString sA = iEnd->getString(A); |
1007 QString sB = iEnd->getString(B); | 1037 QString sB = iEnd->getString(B); |
1008 QString sC = iEnd->getString(C); | 1038 QString sC = iEnd->getString(C); |
1009 if ( ! ((sA.isNull() || historyLead == sA.section(' ',0,0,QString::SectionIncludeLeadingSep)) && | 1039 if ( ! ((sA.isNull() || historyLead == calcHistoryLead(sA) ) && |
1010 (sB.isNull() || historyLead == sB.section(' ',0,0,QString::SectionIncludeLeadingSep)) && | 1040 (sB.isNull() || historyLead == calcHistoryLead(sB) ) && |
1011 (!bThreeFiles || sC.isNull() || historyLead == sC.section(' ',0,0,QString::SectionIncludeLeadingSep)) | 1041 (!bThreeFiles || sC.isNull() || historyLead == calcHistoryLead(sC) ) |
1012 )) | 1042 )) |
1013 { | 1043 { |
1014 break; // End of the history | 1044 break; // End of the history |
1015 } | 1045 } |
1016 } | 1046 } |
1105 Diff3LineList::const_iterator id3l = iHistoryBegin; | 1135 Diff3LineList::const_iterator id3l = iHistoryBegin; |
1106 QString historyLead; | 1136 QString historyLead; |
1107 { | 1137 { |
1108 const LineData* pld = id3l->getLineData(src); | 1138 const LineData* pld = id3l->getLineData(src); |
1109 QString s( pld->pLine, pld->size ); | 1139 QString s( pld->pLine, pld->size ); |
1110 historyLead = s.section(' ',0,0,QString::SectionIncludeLeadingSep); | 1140 historyLead = calcHistoryLead(s); |
1111 } | 1141 } |
1112 QRegExp historyStart( m_pOptionDialog->m_historyStartRegExp ); | 1142 QRegExp historyStart( m_pOptionDialog->m_historyStartRegExp ); |
1113 ++id3l; // Skip line with "$Log ... $" | 1143 ++id3l; // Skip line with "$Log ... $" |
1114 QRegExp newHistoryEntry( m_pOptionDialog->m_historyEntryStartRegExp ); | 1144 QRegExp newHistoryEntry( m_pOptionDialog->m_historyEntryStartRegExp ); |
1115 QStringList parenthesesGroups; | 1145 QStringList parenthesesGroups; |
1121 for(; id3l != iHistoryEnd; ++id3l ) | 1151 for(; id3l != iHistoryEnd; ++id3l ) |
1122 { | 1152 { |
1123 const LineData* pld = id3l->getLineData(src); | 1153 const LineData* pld = id3l->getLineData(src); |
1124 if ( !pld ) continue; | 1154 if ( !pld ) continue; |
1125 QString s( pld->pLine, pld->size ); | 1155 QString s( pld->pLine, pld->size ); |
1126 if (historyLead.isNull()) historyLead = s.section(' ',0,0,QString::SectionIncludeLeadingSep); | 1156 if (historyLead.isNull()) historyLead = calcHistoryLead(s); |
1127 QString sLine = s.mid(historyLead.length()); | 1157 QString sLine = s.mid(historyLead.length()); |
1128 if ( ( !bUseRegExp && !sLine.trimmed().isEmpty() && bPrevLineIsEmpty ) | 1158 if ( ( !bUseRegExp && !sLine.trimmed().isEmpty() && bPrevLineIsEmpty ) |
1129 || bUseRegExp && newHistoryEntry.exactMatch( sLine ) | 1159 || bUseRegExp && newHistoryEntry.exactMatch( sLine ) |
1130 ) | 1160 ) |
1131 { | 1161 { |
1231 Diff3LineList::const_iterator iD3LHistoryEnd; | 1261 Diff3LineList::const_iterator iD3LHistoryEnd; |
1232 int d3lHistoryBeginLineIdx = -1; | 1262 int d3lHistoryBeginLineIdx = -1; |
1233 int d3lHistoryEndLineIdx = -1; | 1263 int d3lHistoryEndLineIdx = -1; |
1234 | 1264 |
1235 // Search for history start, history end in the diff3LineList | 1265 // Search for history start, history end in the diff3LineList |
1236 findHistoryRange( m_pldC!=0, m_pDiff3LineList, iD3LHistoryBegin, iD3LHistoryEnd, d3lHistoryBeginLineIdx, d3lHistoryEndLineIdx ); | 1266 findHistoryRange( QRegExp(m_pOptionDialog->m_historyStartRegExp), m_pldC!=0, m_pDiff3LineList, iD3LHistoryBegin, iD3LHistoryEnd, d3lHistoryBeginLineIdx, d3lHistoryEndLineIdx ); |
1237 | 1267 |
1238 if ( iD3LHistoryBegin != m_pDiff3LineList->end() ) | 1268 if ( iD3LHistoryBegin != m_pDiff3LineList->end() ) |
1239 { | 1269 { |
1240 // Now collect the historyMap information | 1270 // Now collect the historyMap information |
1241 HistoryMap historyMap; | 1271 HistoryMap historyMap; |
1255 Diff3LineList::const_iterator iD3LHistoryOrigEnd = iD3LHistoryEnd; | 1285 Diff3LineList::const_iterator iD3LHistoryOrigEnd = iD3LHistoryEnd; |
1256 | 1286 |
1257 bool bHistoryMergeSorting = m_pOptionDialog->m_bHistoryMergeSorting && ! m_pOptionDialog->m_historyEntryStartSortKeyOrder.isEmpty() && | 1287 bool bHistoryMergeSorting = m_pOptionDialog->m_bHistoryMergeSorting && ! m_pOptionDialog->m_historyEntryStartSortKeyOrder.isEmpty() && |
1258 ! m_pOptionDialog->m_historyEntryStartRegExp.isEmpty(); | 1288 ! m_pOptionDialog->m_historyEntryStartRegExp.isEmpty(); |
1259 | 1289 |
1260 // Remove parts from the historyMap and hitList that stay in place | 1290 if ( m_pOptionDialog->m_maxNofHistoryEntries==-1 ) |
1261 if ( bHistoryMergeSorting ) | 1291 { |
1262 { | 1292 // Remove parts from the historyMap and hitList that stay in place |
1263 while ( ! historyMap.empty() ) | 1293 if ( bHistoryMergeSorting ) |
1264 { | 1294 { |
1265 HistoryMap::iterator hMapIt = historyMap.begin(); | 1295 while ( ! historyMap.empty() ) |
1266 if( hMapIt->second.staysInPlace( m_pldC!=0, iD3LHistoryEnd ) ) | 1296 { |
1267 historyMap.erase(hMapIt); | 1297 HistoryMap::iterator hMapIt = historyMap.begin(); |
1268 else | 1298 if( hMapIt->second.staysInPlace( m_pldC!=0, iD3LHistoryEnd ) ) |
1269 break; | 1299 historyMap.erase(hMapIt); |
1270 } | 1300 else |
1271 } | 1301 break; |
1272 else | 1302 } |
1273 { | 1303 } |
1274 while ( ! hitList.empty() ) | 1304 else |
1275 { | 1305 { |
1276 HistoryMap::iterator hMapIt = hitList.back(); | 1306 while ( ! hitList.empty() ) |
1277 if( hMapIt->second.staysInPlace( m_pldC!=0, iD3LHistoryEnd ) ) | 1307 { |
1278 hitList.pop_back(); | 1308 HistoryMap::iterator hMapIt = hitList.back(); |
1279 else | 1309 if( hMapIt->second.staysInPlace( m_pldC!=0, iD3LHistoryEnd ) ) |
1280 break; | 1310 hitList.pop_back(); |
1281 } | 1311 else |
1282 } | 1312 break; |
1283 while (iD3LHistoryOrigEnd != iD3LHistoryEnd) | 1313 } |
1284 { | 1314 } |
1285 --iD3LHistoryOrigEnd; | 1315 while (iD3LHistoryOrigEnd != iD3LHistoryEnd) |
1286 --d3lHistoryEndLineIdx; | 1316 { |
1317 --iD3LHistoryOrigEnd; | |
1318 --d3lHistoryEndLineIdx; | |
1319 } | |
1287 } | 1320 } |
1288 | 1321 |
1289 MergeLineList::iterator iMLLStart = splitAtDiff3LineIdx(d3lHistoryBeginLineIdx); | 1322 MergeLineList::iterator iMLLStart = splitAtDiff3LineIdx(d3lHistoryBeginLineIdx); |
1290 MergeLineList::iterator iMLLEnd = splitAtDiff3LineIdx(d3lHistoryEndLineIdx); | 1323 MergeLineList::iterator iMLLEnd = splitAtDiff3LineIdx(d3lHistoryEndLineIdx); |
1291 // Now join all MergeLines in the history | 1324 // Now join all MergeLines in the history |
1300 } | 1333 } |
1301 } | 1334 } |
1302 iMLLStart->mergeEditLineList.clear(); | 1335 iMLLStart->mergeEditLineList.clear(); |
1303 // Now insert the complete history into the first MergeLine of the history | 1336 // Now insert the complete history into the first MergeLine of the history |
1304 iMLLStart->mergeEditLineList.push_back( MergeEditLine( iD3LHistoryBegin, m_pldC == 0 ? B : C ) ); | 1337 iMLLStart->mergeEditLineList.push_back( MergeEditLine( iD3LHistoryBegin, m_pldC == 0 ? B : C ) ); |
1305 QString lead = iD3LHistoryBegin->getString(A).section(' ',0,0,QString::SectionIncludeLeadingSep); | 1338 QString lead = calcHistoryLead( iD3LHistoryBegin->getString(A) ); |
1306 MergeEditLine mel( m_pDiff3LineList->end() ); | 1339 MergeEditLine mel( m_pDiff3LineList->end() ); |
1307 mel.setString( lead ); | 1340 mel.setString( lead ); |
1308 iMLLStart->mergeEditLineList.push_back(mel); | 1341 iMLLStart->mergeEditLineList.push_back(mel); |
1309 | 1342 |
1343 int historyCount = 0; | |
1310 if ( bHistoryMergeSorting ) | 1344 if ( bHistoryMergeSorting ) |
1311 { | 1345 { |
1312 // Create a sorted history | 1346 // Create a sorted history |
1313 HistoryMap::reverse_iterator hmit; | 1347 HistoryMap::reverse_iterator hmit; |
1314 for ( hmit = historyMap.rbegin(); hmit != historyMap.rend(); ++hmit ) | 1348 for ( hmit = historyMap.rbegin(); hmit != historyMap.rend(); ++hmit ) |
1315 { | 1349 { |
1350 if ( historyCount==m_pOptionDialog->m_maxNofHistoryEntries ) | |
1351 break; | |
1352 ++historyCount; | |
1316 HistoryMapEntry& hme = hmit->second; | 1353 HistoryMapEntry& hme = hmit->second; |
1317 MergeEditLineList& mell = hme.choice(m_pldC!=0); | 1354 MergeEditLineList& mell = hme.choice(m_pldC!=0); |
1318 if (!mell.empty()) | 1355 if (!mell.empty()) |
1319 iMLLStart->mergeEditLineList.splice( iMLLStart->mergeEditLineList.end(), mell, mell.begin(), mell.end() ); | 1356 iMLLStart->mergeEditLineList.splice( iMLLStart->mergeEditLineList.end(), mell, mell.begin(), mell.end() ); |
1320 } | 1357 } |
1323 { | 1360 { |
1324 // Create history in order of appearance | 1361 // Create history in order of appearance |
1325 std::list< HistoryMap::iterator >::iterator hlit; | 1362 std::list< HistoryMap::iterator >::iterator hlit; |
1326 for ( hlit = hitList.begin(); hlit != hitList.end(); ++hlit ) | 1363 for ( hlit = hitList.begin(); hlit != hitList.end(); ++hlit ) |
1327 { | 1364 { |
1365 if ( historyCount==m_pOptionDialog->m_maxNofHistoryEntries ) | |
1366 break; | |
1367 ++historyCount; | |
1328 HistoryMapEntry& hme = (*hlit)->second; | 1368 HistoryMapEntry& hme = (*hlit)->second; |
1329 MergeEditLineList& mell = hme.choice(m_pldC!=0); | 1369 MergeEditLineList& mell = hme.choice(m_pldC!=0); |
1330 if (!mell.empty()) | 1370 if (!mell.empty()) |
1331 iMLLStart->mergeEditLineList.splice( iMLLStart->mergeEditLineList.end(), mell, mell.begin(), mell.end() ); | 1371 iMLLStart->mergeEditLineList.splice( iMLLStart->mergeEditLineList.end(), mell, mell.begin(), mell.end() ); |
1332 } | 1372 } |
1498 if ( isRemoved() ) { return QString(); } | 1538 if ( isRemoved() ) { return QString(); } |
1499 | 1539 |
1500 if ( ! isModified() ) | 1540 if ( ! isModified() ) |
1501 { | 1541 { |
1502 int src = m_src; | 1542 int src = m_src; |
1543 if ( src == 0 ) { return QString(); } | |
1503 const Diff3Line& d3l = *m_id3l; | 1544 const Diff3Line& d3l = *m_id3l; |
1504 if ( src == 0 ) { return QString(); } | |
1505 | |
1506 const LineData* pld = 0; | 1545 const LineData* pld = 0; |
1507 assert( src == A || src == B || src == C ); | 1546 assert( src == A || src == B || src == C ); |
1508 if ( src == A && d3l.lineA!=-1 ) pld = &mrw->m_pldA[ d3l.lineA ]; | 1547 if ( src == A && d3l.lineA!=-1 ) pld = &mrw->m_pldA[ d3l.lineA ]; |
1509 else if ( src == B && d3l.lineB!=-1 ) pld = &mrw->m_pldB[ d3l.lineB ]; | 1548 else if ( src == B && d3l.lineB!=-1 ) pld = &mrw->m_pldB[ d3l.lineB ]; |
1510 else if ( src == C && d3l.lineC!=-1 ) pld = &mrw->m_pldC[ d3l.lineC ]; | 1549 else if ( src == C && d3l.lineC!=-1 ) pld = &mrw->m_pldC[ d3l.lineC ]; |
2209 if (i<s.length()) { | 2248 if (i<s.length()) { |
2210 indentation = s.left(i); | 2249 indentation = s.left(i); |
2211 break; | 2250 break; |
2212 } | 2251 } |
2213 } | 2252 } |
2214 --melIt1; | 2253 // Go back one line |
2215 if ( melIt1 == mlIt1->mergeEditLineList.end() ) { | 2254 if ( melIt1 != mlIt1->mergeEditLineList.begin() ) |
2255 --melIt1; | |
2256 else | |
2257 { | |
2258 if ( mlIt1 == m_mergeLineList.begin() ) break; | |
2216 --mlIt1; | 2259 --mlIt1; |
2217 if ( mlIt1 == m_mergeLineList.end() ) break; | |
2218 melIt1 = mlIt1->mergeEditLineList.end(); | 2260 melIt1 = mlIt1->mergeEditLineList.end(); |
2219 --melIt1; | 2261 --melIt1; |
2220 } | 2262 } |
2221 } | 2263 } |
2222 } | 2264 } |
2686 else | 2728 else |
2687 { str.prepend("\n"); } | 2729 { str.prepend("\n"); } |
2688 } | 2730 } |
2689 | 2731 |
2690 textOutStream << str; | 2732 textOutStream << str; |
2691 } | 2733 ++line; |
2692 | 2734 } |
2693 ++line; | |
2694 } | 2735 } |
2695 } | 2736 } |
2696 textOutStream.flush(); | 2737 textOutStream.flush(); |
2697 bool bSuccess = file.writeFile( dataArray.data(), dataArray.size() ); | 2738 bool bSuccess = file.writeFile( dataArray.data(), dataArray.size() ); |
2698 if ( ! bSuccess ) | 2739 if ( ! bSuccess ) |