forked from qt-creator/qt-creator
Remove the limitation that output formatters have to be exclusive
Introduce an aggregating output formatter that forwards its input to a sub-formatter that feels responsible for it, or otherwise lets the base class handle it. Our output panes now use such an aggregating formatter. In particular, this means that in the future, we won't have to stuff all run control output formatting into the Qt output formatter anymore. Change-Id: I5498f200a61db10ccff3ec8974c6825da7f7072d Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -42,14 +42,17 @@ VcsOutputFormatter::VcsOutputFormatter() :
|
||||
{
|
||||
}
|
||||
|
||||
void VcsOutputFormatter::doAppendMessage(const QString &text, Utils::OutputFormat format)
|
||||
VcsOutputFormatter::Status VcsOutputFormatter::handleMessage(const QString &text,
|
||||
Utils::OutputFormat format)
|
||||
{
|
||||
QRegularExpressionMatchIterator it = m_regexp.globalMatch(text);
|
||||
if (!it.hasNext())
|
||||
return Status::NotHandled;
|
||||
int begin = 0;
|
||||
while (it.hasNext()) {
|
||||
const QRegularExpressionMatch match = it.next();
|
||||
const QTextCharFormat normalFormat = charFormat(format);
|
||||
OutputFormatter::doAppendMessage(text.mid(begin, match.capturedStart() - begin), format);
|
||||
appendMessageDefault(text.mid(begin, match.capturedStart() - begin), format);
|
||||
QTextCursor tc = plainTextEdit()->textCursor();
|
||||
QStringView url = match.capturedView();
|
||||
begin = match.capturedEnd();
|
||||
@@ -61,15 +64,17 @@ void VcsOutputFormatter::doAppendMessage(const QString &text, Utils::OutputForma
|
||||
tc.insertText(url.toString(), linkFormat(normalFormat, url.toString()));
|
||||
tc.movePosition(QTextCursor::End);
|
||||
}
|
||||
OutputFormatter::doAppendMessage(text.mid(begin), format);
|
||||
appendMessageDefault(text.mid(begin), format);
|
||||
return Status::Done;
|
||||
}
|
||||
|
||||
void VcsOutputFormatter::handleLink(const QString &href)
|
||||
bool VcsOutputFormatter::handleLink(const QString &href)
|
||||
{
|
||||
if (href.startsWith("http://") || href.startsWith("https://"))
|
||||
QDesktopServices::openUrl(QUrl(href));
|
||||
else if (!href.isEmpty())
|
||||
emit referenceClicked(href);
|
||||
return true;
|
||||
}
|
||||
|
||||
void VcsOutputFormatter::fillLinkContextMenu(
|
||||
|
||||
Reference in New Issue
Block a user