forked from qt-creator/qt-creator
Utils: Split up OutputFormatter class
An OutputFormatter takes some string and prints it into a text edit. In addition, it can ask any number of registered OutputLineParsers whether they think any special formatting should be applied to the current line. This mechanism is now properly modeled by our class design, rather than being hidden in a monolithic class where everything had the same type, no matter what its purpose was. Prospective contributors can now simply be pointed to the OutputLineParser class and will see at one glance what they have to do. Change-Id: I9844499f062c94fb038ce73fd6f26576910148c2 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
|
||||
namespace VcsBase {
|
||||
|
||||
VcsOutputFormatter::VcsOutputFormatter() :
|
||||
VcsOutputLineParser::VcsOutputLineParser() :
|
||||
m_regexp(
|
||||
"(https?://\\S*)" // https://codereview.org/c/1234
|
||||
"|(v[0-9]+\\.[0-9]+\\.[0-9]+[\\-A-Za-z0-9]*)" // v0.1.2-beta3
|
||||
@@ -43,8 +43,8 @@ VcsOutputFormatter::VcsOutputFormatter() :
|
||||
{
|
||||
}
|
||||
|
||||
Utils::OutputFormatter::Result VcsOutputFormatter::handleMessage(const QString &text,
|
||||
Utils::OutputFormat format)
|
||||
Utils::OutputLineParser::Result VcsOutputLineParser::handleLine(const QString &text,
|
||||
Utils::OutputFormat format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
QRegularExpressionMatchIterator it = m_regexp.globalMatch(text);
|
||||
@@ -62,7 +62,7 @@ Utils::OutputFormatter::Result VcsOutputFormatter::handleMessage(const QString &
|
||||
return {Status::Done, linkSpecs};
|
||||
}
|
||||
|
||||
bool VcsOutputFormatter::handleLink(const QString &href)
|
||||
bool VcsOutputLineParser::handleLink(const QString &href)
|
||||
{
|
||||
if (href.startsWith("http://") || href.startsWith("https://"))
|
||||
QDesktopServices::openUrl(QUrl(href));
|
||||
@@ -71,7 +71,7 @@ bool VcsOutputFormatter::handleLink(const QString &href)
|
||||
return true;
|
||||
}
|
||||
|
||||
void VcsOutputFormatter::fillLinkContextMenu(
|
||||
void VcsOutputLineParser::fillLinkContextMenu(
|
||||
QMenu *menu, const QString &workingDirectory, const QString &href)
|
||||
{
|
||||
if (href.isEmpty() || href.startsWith("http://") || href.startsWith("https://")) {
|
||||
|
||||
Reference in New Issue
Block a user