VCS: Refactor annotationChanges() in VcsBaseEditor

Devirtualize the function, and use QRegularExpression with globalMatch.

Change-Id: I18c92cb37b535c616f03f45dff8b18249c961d5d
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Orgad Shaneh
2020-02-19 23:23:36 +02:00
committed by Orgad Shaneh
parent 3cdbd8683d
commit 3c0b89f697
17 changed files with 54 additions and 160 deletions

View File

@@ -48,28 +48,7 @@ BazaarEditorWidget::BazaarEditorWidget() :
// === <change> <file|dir> 'mainwindow.cpp'
setDiffFilePattern(QRegExp(QLatin1String("^=== [a-z]+ [a-z]+ '(.+)'\\s*")));
setLogEntryPattern(QRegExp(QLatin1String("^revno: (\\d+)")));
}
QSet<QString> BazaarEditorWidget::annotationChanges() const
{
QSet<QString> changes;
const QString txt = toPlainText();
if (txt.isEmpty())
return changes;
QRegExp changeNumRx(QLatin1String("^(" BZR_CHANGE_PATTERN ") "));
QTC_ASSERT(changeNumRx.isValid(), return changes);
if (changeNumRx.indexIn(txt) != -1) {
changes.insert(changeNumRx.cap(1));
changeNumRx.setPattern(QLatin1String("\n(" BZR_CHANGE_PATTERN ") "));
QTC_ASSERT(changeNumRx.isValid(), return changes);
int pos = 0;
while ((pos = changeNumRx.indexIn(txt, pos)) != -1) {
pos += changeNumRx.matchedLength();
changes.insert(changeNumRx.cap(1));
}
}
return changes;
setAnnotationEntryPattern("^(" BZR_CHANGE_PATTERN ") ");
}
QString BazaarEditorWidget::changeUnderCursor(const QTextCursor &cursorIn) const