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

@@ -75,28 +75,7 @@ GitEditorWidget::GitEditorWidget() :
setLogEntryPattern(QRegExp("^commit ([0-9a-f]{8})[0-9a-f]{32}"));
setAnnotateRevisionTextFormat(tr("&Blame %1"));
setAnnotatePreviousRevisionTextFormat(tr("Blame &Parent Revision %1"));
}
QSet<QString> GitEditorWidget::annotationChanges() const
{
QSet<QString> changes;
const QString txt = toPlainText();
if (txt.isEmpty())
return changes;
// Hunt for first change number in annotation: "<change>:"
QRegExp r("^(" CHANGE_PATTERN ") ");
QTC_ASSERT(r.isValid(), return changes);
if (r.indexIn(txt) != -1) {
changes.insert(r.cap(1));
r.setPattern("\n(" CHANGE_PATTERN ") ");
QTC_ASSERT(r.isValid(), return changes);
int pos = 0;
while ((pos = r.indexIn(txt, pos)) != -1) {
pos += r.matchedLength();
changes.insert(r.cap(1));
}
}
return changes;
setAnnotationEntryPattern("^(" CHANGE_PATTERN ") ");
}
QString GitEditorWidget::changeUnderCursor(const QTextCursor &c) const