forked from qt-creator/qt-creator
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:
@@ -532,34 +532,15 @@ IOutputParser *Kit::createOutputParser() const
|
||||
|
||||
QString Kit::toHtml(const QList<Task> &additional) const
|
||||
{
|
||||
QString rc;
|
||||
QTextStream str(&rc);
|
||||
QString result;
|
||||
QTextStream str(&result);
|
||||
str << "<html><body>";
|
||||
str << "<h3>" << displayName() << "</h3>";
|
||||
|
||||
if (!isValid() || hasWarning() || !additional.isEmpty())
|
||||
str << "<p>" << toHtml(additional + validate()) << "</p>";
|
||||
|
||||
str << "<table>";
|
||||
|
||||
if (!isValid() || hasWarning() || !additional.isEmpty()) {
|
||||
QList<Task> issues = additional;
|
||||
issues.append(validate());
|
||||
str << "<p>";
|
||||
foreach (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>";
|
||||
}
|
||||
str << "</p>";
|
||||
}
|
||||
|
||||
QList<KitInformation *> infoList = KitManager::kitInformation();
|
||||
foreach (KitInformation *ki, infoList) {
|
||||
KitInformation::ItemList list = ki->toUserOutput(this);
|
||||
@@ -576,7 +557,7 @@ QString Kit::toHtml(const QList<Task> &additional) const
|
||||
}
|
||||
}
|
||||
str << "</table></body></html>";
|
||||
return rc;
|
||||
return result;
|
||||
}
|
||||
|
||||
void Kit::setAutoDetected(bool detected)
|
||||
|
@@ -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
|
||||
|
@@ -98,6 +98,8 @@ uint PROJECTEXPLORER_EXPORT qHash(const Task &task);
|
||||
|
||||
bool PROJECTEXPLORER_EXPORT operator<(const Task &a, const Task &b);
|
||||
|
||||
QString PROJECTEXPLORER_EXPORT toHtml(const QList<Task> &issues);
|
||||
|
||||
} //namespace ProjectExplorer
|
||||
|
||||
Q_DECLARE_METATYPE(ProjectExplorer::Task)
|
||||
|
Reference in New Issue
Block a user