summaryrefslogtreecommitdiff
path: root/src/plugins/vcsbase/vcsbaseeditor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/vcsbase/vcsbaseeditor.cpp')
-rw-r--r--src/plugins/vcsbase/vcsbaseeditor.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp
index 0471968dcf..aae366dcb4 100644
--- a/src/plugins/vcsbase/vcsbaseeditor.cpp
+++ b/src/plugins/vcsbase/vcsbaseeditor.cpp
@@ -50,6 +50,7 @@
#include <QDebug>
#include <QFileInfo>
#include <QFile>
+#include <QRegularExpression>
#include <QRegExp>
#include <QSet>
#include <QTextCodec>
@@ -556,6 +557,8 @@ public:
QRegExp m_diffFilePattern;
QRegExp m_logEntryPattern;
+ QRegularExpression m_annotationEntryPattern;
+ QRegularExpression m_annotationSeparatorPattern;
QList<int> m_entrySections; // line number where this section starts
int m_cursorLine = -1;
int m_firstLineNumber = -1;
@@ -661,6 +664,20 @@ void VcsBaseEditorWidget::setLogEntryPattern(const QRegExp &pattern)
d->m_logEntryPattern = pattern;
}
+void VcsBaseEditorWidget::setAnnotationEntryPattern(const QString &pattern)
+{
+ const QRegularExpression re(pattern, QRegularExpression::MultilineOption);
+ QTC_ASSERT(re.isValid() && re.captureCount() >= 1, return);
+ d->m_annotationEntryPattern = re;
+}
+
+void VcsBaseEditorWidget::setAnnotationSeparatorPattern(const QString &pattern)
+{
+ const QRegularExpression re(pattern);
+ QTC_ASSERT(re.isValid() && re.captureCount() >= 1, return);
+ d->m_annotationSeparatorPattern = re;
+}
+
bool VcsBaseEditorWidget::supportChangeLinks() const
{
switch (d->m_parameters->type) {
@@ -1537,6 +1554,26 @@ void VcsBaseEditorWidget::addChangeActions(QMenu *, const QString &)
{
}
+QSet<QString> VcsBaseEditorWidget::annotationChanges() const
+{
+ QSet<QString> changes;
+ QString text = toPlainText();
+ QStringRef txt(&text);
+ if (txt.isEmpty())
+ return changes;
+ if (d->m_annotationSeparatorPattern.isValid()) {
+ const QRegularExpressionMatch match = d->m_annotationSeparatorPattern.match(txt);
+ if (match.hasMatch())
+ txt.truncate(match.capturedStart());
+ }
+ QRegularExpressionMatchIterator i = d->m_annotationEntryPattern.globalMatch(txt);
+ while (i.hasNext()) {
+ const QRegularExpressionMatch match = i.next();
+ changes.insert(match.captured(1));
+ }
+ return changes;
+}
+
QString VcsBaseEditorWidget::decorateVersion(const QString &revision) const
{
return revision;