Commit 87280a11 authored by Rainer Keller's avatar Rainer Keller

Remove templates from static list if plugin is unavailable

Removing those only from combobox is not sufficient because the
template list is accessed by current index of the combobox at several
places.

Change-Id: I1127159d010d87dff55c14b7ee1ce5497a1cc05c
Reviewed-by: default avatarJarek Kobus <jaroslaw.kobus@digia.com>
parent 023e1700
......@@ -31,6 +31,8 @@
#include <utils/qtcassert.h>
#include <utils/fileutils.h>
#include <extensionsystem/pluginmanager.h>
#include <extensionsystem/pluginspec.h>
#include <QDebug>
#include <QDir>
......@@ -173,6 +175,12 @@ class TemplateInfoList
public:
TemplateInfoList()
{
QSet<QString> availablePlugins;
foreach (ExtensionSystem::PluginSpec *s, ExtensionSystem::PluginManager::plugins()) {
if (s->state() == ExtensionSystem::PluginSpec::Running && !s->hasError())
availablePlugins += s->name();
}
QMultiMap<QString, TemplateInfo> multiMap;
foreach (const QString &templateName, templateNames()) {
const QString templatePath = templateRootDirectory() + templateName;
......@@ -185,7 +193,17 @@ public:
info.templateName = templateName;
info.templatePath = templatePath;
QXmlStreamReader reader(&xmlFile);
if (parseTemplateXml(reader, &info))
if (!parseTemplateXml(reader, &info))
continue;
bool ok = true;
foreach (const QString &neededPlugin, info.requiredPlugins) {
if (!availablePlugins.contains(neededPlugin)) {
ok = false;
break;
}
}
if (ok)
multiMap.insert(info.priority, info);
}
m_templateInfoList = multiMap.values();
......
......@@ -30,8 +30,6 @@
#include "qtquickappwizardpages.h"
#include <utils/wizard.h>
#include <extensionsystem/pluginmanager.h>
#include <extensionsystem/pluginspec.h>
#include <QComboBox>
#include <QLabel>
......@@ -58,23 +56,8 @@ QtQuickComponentSetPage::QtQuickComponentSetPage(QWidget *parent)
QLabel *label = new QLabel(tr("Qt Quick component set:"), this);
d->m_versionComboBox = new QComboBox(this);
QSet<QString> availablePlugins;
foreach (ExtensionSystem::PluginSpec *s, ExtensionSystem::PluginManager::plugins()) {
if (s->state() == ExtensionSystem::PluginSpec::Running && !s->hasError())
availablePlugins += s->name();
}
foreach (const TemplateInfo &templateInfo, QtQuickApp::templateInfos()) {
bool ok = true;
foreach (const QString &neededPlugin, templateInfo.requiredPlugins) {
if (!availablePlugins.contains(neededPlugin)) {
ok = false;
break;
}
}
if (ok)
d->m_versionComboBox->addItem(templateInfo.displayName);
}
foreach (const TemplateInfo &templateInfo, QtQuickApp::templateInfos())
d->m_versionComboBox->addItem(templateInfo.displayName);
l->addWidget(label);
l->addWidget(d->m_versionComboBox);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment