diff --git a/src/libs/extensionsystem/plugindetailsview.cpp b/src/libs/extensionsystem/plugindetailsview.cpp index 224a6805b3a..5d51a1e31d7 100644 --- a/src/libs/extensionsystem/plugindetailsview.cpp +++ b/src/libs/extensionsystem/plugindetailsview.cpp @@ -29,6 +29,8 @@ #include "pluginmanager.h" #include "pluginspec.h" +#include + #include #include @@ -88,23 +90,6 @@ void PluginDetailsView::update(PluginSpec *spec) const QString platformString = tr("%1 (current: \"%2\")").arg(pluginPlatformString, PluginManager::platformName()); m_ui->platforms->setText(platformString); - QStringList depStrings; - foreach (const PluginDependency &dep, spec->dependencies()) { - QString depString = dep.name; - depString += QLatin1String(" ("); - depString += dep.version; - switch (dep.type) { - case PluginDependency::Required: - break; - case PluginDependency::Optional: - depString += QLatin1String(", optional"); - break; - case PluginDependency::Test: - depString += QLatin1String(", test"); - break; - } - depString += QLatin1Char(')'); - depStrings.append(depString); - } + const QStringList depStrings = Utils::transform(spec->dependencies(), &PluginDependency::toString); m_ui->dependencies->addItems(depStrings); } diff --git a/src/libs/extensionsystem/pluginspec.cpp b/src/libs/extensionsystem/pluginspec.cpp index b7cd3d9777f..782d3e31150 100644 --- a/src/libs/extensionsystem/pluginspec.cpp +++ b/src/libs/extensionsystem/pluginspec.cpp @@ -146,6 +146,23 @@ bool PluginDependency::operator==(const PluginDependency &other) const return name == other.name && version == other.version && type == other.type; } +static QString typeString(PluginDependency::Type type) +{ + switch (type) { + case PluginDependency::Required: + return QString(); + case PluginDependency::Optional: + return ", optional"; + case PluginDependency::Test: + return ", test"; + } +} + +QString PluginDependency::toString() const +{ + return name + " (" + version + typeString(type) + ")"; +} + /*! \internal */ diff --git a/src/libs/extensionsystem/pluginspec.h b/src/libs/extensionsystem/pluginspec.h index 7d41c911583..bc0fc43a4d1 100644 --- a/src/libs/extensionsystem/pluginspec.h +++ b/src/libs/extensionsystem/pluginspec.h @@ -63,6 +63,7 @@ struct EXTENSIONSYSTEM_EXPORT PluginDependency QString version; Type type; bool operator==(const PluginDependency &other) const; + QString toString() const; }; uint qHash(const ExtensionSystem::PluginDependency &value);