ProjectExplorer: Add toHtml(QList<Task>) and use that in kit.cpp

This makes the code more reusable.

Change-Id: I1b2eebf8673a4a08a2a87a1e9ff1ac845a091467
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Tobias Hunger
2018-04-18 12:15:53 +02:00
parent c77af6bdf3
commit f406950ef5
3 changed files with 34 additions and 26 deletions

View File

@@ -32,6 +32,8 @@
#include "projectexplorerconstants.h"
#include <QTextStream>
namespace ProjectExplorer
{
@@ -149,4 +151,27 @@ uint qHash(const Task &task)
return task.taskId;
}
QString toHtml(const QList<Task> &issues)
{
QString result;
QTextStream str(&result);
for (const Task &t : issues) {
str << "<b>";
switch (t.type) {
case Task::Error:
str << QCoreApplication::translate("ProjectExplorer::Kit", "Error:") << " ";
break;
case Task::Warning:
str << QCoreApplication::translate("ProjectExplorer::Kit", "Warning:") << " ";
break;
case Task::Unknown:
default:
break;
}
str << "</b>" << t.description << "<br>";
}
return result;
}
} // namespace ProjectExplorer