forked from qt-creator/qt-creator
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: Jarek Kobus <jaroslaw.kobus@digia.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user