@@ -156,14 +156,10 @@ void QDocumentSearch::searchMatches(const QDocumentCursor& subHighlightScope, bo
156156 l.setFlag (QDocumentLine::FormatsApplied, false );
157157
158158 const QString &s = boundaries.endLine != ln ? l.text () : l.text ().left (boundaries.end );
159- # if QT_VERSION > 0x050500
159+
160160 QRegularExpressionMatch match=m_regularExpression.match (s, hc.columnNumber ());
161161 int column = match.capturedStart ();
162162 int length = match.capturedLength ();
163- #else
164- int column=m_regexp.indexIn (s, hc.columnNumber ());
165- int length=m_regexp.matchedLength ();
166- #endif
167163
168164 /*
169165 qDebug("searching %s in %s => %i",
@@ -209,18 +205,13 @@ void QDocumentSearch::searchMatches(const QDocumentCursor& subHighlightScope, bo
209205 if ((endOffset>=0 )&&(i+1 ==endLine)){
210206 txt=txt.left (endOffset);
211207 }
212- # if QT_VERSION > 0x050500
208+
213209 QRegularExpressionMatch match=m_regularExpression.match (txt,offset);
214210 if (match.hasMatch ()){
215211 m_editor->addMarkDelayed (i,Qt::darkYellow," search" );
216212 needsUpdate=true ;
217213 }
218- #else
219- if (m_regexp.indexIn (txt,offset)>-1 ){
220- m_editor->addMarkDelayed (i,Qt::darkYellow," search" );
221- needsUpdate=true ;
222- }
223- #endif
214+
224215 offset=0 ;
225216 }
226217 if (needsUpdate)
@@ -290,7 +281,6 @@ void QDocumentSearch::recreateRegExp(){
290281 :
291282 Qt::CaseInsensitive;
292283
293- #if QT_VERSION >= 0x050500
294284 QRegularExpression::PatternOptions patternOption= cs==Qt::CaseInsensitive ? QRegularExpression::CaseInsensitiveOption : QRegularExpression::NoPatternOption ;
295285 patternOption |= QRegularExpression::UseUnicodePropertiesOption;
296286 if ( hasOption (RegExp) )
@@ -303,23 +293,6 @@ void QDocumentSearch::recreateRegExp(){
303293 } else {
304294 m_regularExpression = QRegularExpression (QRegularExpression::escape (m_string), patternOption);
305295 }
306- #else
307- if ( hasOption (RegExp) )
308- {
309- m_regexp = QRegExp (m_string, cs, QRegExp::RegExp);
310- } else if ( hasOption (WholeWords) ) {
311- // todo: screw this? it prevents searching of "world!" and similar things
312- // (qtextdocument just checks the surrounding character when searching for whole words, this would also allow wholewords|regexp search)
313- m_regexp = QRegExp (
314- QString (" \\ b%1\\ b" ).arg (QRegExp::escape (m_string)),
315- cs,
316- QRegExp::RegExp
317- );
318- } else {
319- m_regexp = QRegExp (m_string, cs, QRegExp::FixedString);
320- }
321- m_regexp.setMinimal ( m_option & QDocumentSearch::NonGreedy); // allow greedy or non-greedy capture
322- #endif
323296}
324297
325298
@@ -492,15 +465,9 @@ QString QDocumentSearch::replaceTextExpanded() const
492465 QString replacement = hasOption (EscapeSeq)?escapeCpp (m_replace):m_replace;
493466
494467 if (hasOption (RegExp))
495- #if QT_VERSION>0x050500
496468 for ( int i=m_match.lastCapturedIndex ();i >=0 ; --i )
497469 replacement.replace (QString (" \\ " ) + QString::number (i),
498470 m_match.captured (i));
499- #else
500- for ( int i = m_regexp.captureCount (); i >= 0 ; --i )
501- replacement.replace (QString (" \\ " ) + QString::number (i),
502- m_regexp.cap (i));
503- #endif
504471
505472 return replacement;
506473}
@@ -614,8 +581,6 @@ int QDocumentSearch::next(bool backward, bool all, bool again, bool allowWrapAro
614581 // replace
615582 if (hasOption (Replace) && again && !all) {
616583 bool replaceSelectedText = false ;
617- #if QT_VERSION > 0x050500
618- qDebug ()<<m_match.hasMatch () << m_match.captured ();
619584 if (m_match.hasMatch () && m_match.captured ()==m_cursor.selectedText ()) {
620585 replaceSelectedText = true ;
621586 } else if (m_regularExpression.pattern ().contains (" (?=" ) || m_regularExpression.pattern ().contains (" (?!" )) {
@@ -637,28 +602,6 @@ int QDocumentSearch::next(bool backward, bool all, bool again, bool allowWrapAro
637602 start = end;
638603 }
639604 }
640- #else
641- if (m_regexp.exactMatch (m_cursor.selectedText ())) {
642- replaceSelectedText = true ;
643- } else if (m_regexp.pattern ().contains (" (?=" ) || m_regexp.pattern ().contains (" (?!" )) {
644- // special handling for lookahead: The selected text is not enough to match the regexp
645- // because the lookahead context is missing. Therefore we have to find matches to the
646- // whole line until we find the original selection. Only then, we know that the original
647- // selection is match and should be replaced.
648- int start = 0 ;
649- while (true ) {
650- start = m_regexp.indexIn (m_cursor.line ().text (), start);
651- if (start < 0 )
652- break ;
653- int end = start + m_regexp.matchedLength ();
654- if ((start == m_cursor.startColumnNumber () && end == m_cursor.endColumnNumber ()) ||
655- (end == m_cursor.startColumnNumber () && start == m_cursor.endColumnNumber ())) {
656- replaceSelectedText = true ;
657- }
658- start = end;
659- }
660- }
661- #endif
662605 if (replaceSelectedText) {
663606 replaceCursorText (backward);
664607 updateReplacementOverlays ();
@@ -759,7 +702,7 @@ int QDocumentSearch::next(bool backward, bool all, bool again, bool allowWrapAro
759702
760703 int column;
761704 int length;
762- # if QT_VERSION > 0x050500
705+
763706 if (backward) {
764707 column=s.lastIndexOf (m_regularExpression,m_cursor.columnNumber ()-coloffset,&m_match);
765708 length=m_match.capturedLength ();
@@ -769,13 +712,6 @@ int QDocumentSearch::next(bool backward, bool all, bool again, bool allowWrapAro
769712 length=m_match.capturedLength ();
770713 }
771714
772-
773- #else
774- if (backward) column=m_regexp.lastIndexIn (s,m_cursor.columnNumber ()-coloffset);
775- else column=m_regexp.indexIn (s, m_cursor.columnNumber ());
776- length=m_regexp.matchedLength ();
777- #endif
778-
779715 QDocumentCursor::MoveOperation nextMove = move;
780716
781717 bool matches = column != -1 && (backward || column >= m_cursor.columnNumber () );
0 commit comments