From f406950ef50732ab69703635b9131a337e0996d7 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Wed, 18 Apr 2018 12:15:53 +0200 Subject: [PATCH] ProjectExplorer: Add toHtml(QList) and use that in kit.cpp This makes the code more reusable. Change-Id: I1b2eebf8673a4a08a2a87a1e9ff1ac845a091467 Reviewed-by: Thomas Hartmann --- src/plugins/projectexplorer/kit.cpp | 33 ++++++---------------------- src/plugins/projectexplorer/task.cpp | 25 +++++++++++++++++++++ src/plugins/projectexplorer/task.h | 2 ++ 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/plugins/projectexplorer/kit.cpp b/src/plugins/projectexplorer/kit.cpp index c0cebbd0c80..decc1d0a72d 100644 --- a/src/plugins/projectexplorer/kit.cpp +++ b/src/plugins/projectexplorer/kit.cpp @@ -532,34 +532,15 @@ IOutputParser *Kit::createOutputParser() const QString Kit::toHtml(const QList &additional) const { - QString rc; - QTextStream str(&rc); + QString result; + QTextStream str(&result); str << ""; str << "

" << displayName() << "

"; + + if (!isValid() || hasWarning() || !additional.isEmpty()) + str << "

" << toHtml(additional + validate()) << "

"; + str << ""; - - if (!isValid() || hasWarning() || !additional.isEmpty()) { - QList issues = additional; - issues.append(validate()); - str << "

"; - foreach (const Task &t, issues) { - str << ""; - 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 << "" << t.description << "
"; - } - str << "

"; - } - QList infoList = KitManager::kitInformation(); foreach (KitInformation *ki, infoList) { KitInformation::ItemList list = ki->toUserOutput(this); @@ -576,7 +557,7 @@ QString Kit::toHtml(const QList &additional) const } } str << "
"; - return rc; + return result; } void Kit::setAutoDetected(bool detected) diff --git a/src/plugins/projectexplorer/task.cpp b/src/plugins/projectexplorer/task.cpp index bc8fc334a60..7adbbed74a8 100644 --- a/src/plugins/projectexplorer/task.cpp +++ b/src/plugins/projectexplorer/task.cpp @@ -32,6 +32,8 @@ #include "projectexplorerconstants.h" +#include + namespace ProjectExplorer { @@ -149,4 +151,27 @@ uint qHash(const Task &task) return task.taskId; } +QString toHtml(const QList &issues) +{ + QString result; + QTextStream str(&result); + + for (const Task &t : issues) { + str << ""; + 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 << "" << t.description << "
"; + } + return result; +} + } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/task.h b/src/plugins/projectexplorer/task.h index be63662f807..7a29db5d4aa 100644 --- a/src/plugins/projectexplorer/task.h +++ b/src/plugins/projectexplorer/task.h @@ -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 &issues); + } //namespace ProjectExplorer Q_DECLARE_METATYPE(ProjectExplorer::Task)