Commit 58613152 authored by Daniel Teske's avatar Daniel Teske
Browse files

Support multiple deployconfiguration factories



Change-Id: Ifc54ec9fdd36804570f9bcf905260539c787d9db
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent b941e76d
......@@ -240,15 +240,16 @@ DeployConfigurationFactory *DeployConfigurationFactory::find(Target *parent, con
return 0;
}
DeployConfigurationFactory *DeployConfigurationFactory::find(Target *parent)
QList<DeployConfigurationFactory *> DeployConfigurationFactory::find(Target *parent)
{
QList<DeployConfigurationFactory *> result;
QList<DeployConfigurationFactory *> factories
= ExtensionSystem::PluginManager::instance()->getObjects<DeployConfigurationFactory>();
foreach (DeployConfigurationFactory *factory, factories) {
if (!factory->availableCreationIds(parent).isEmpty())
return factory;
result << factory;
}
return 0;
return result;
}
DeployConfigurationFactory *DeployConfigurationFactory::find(Target *parent, DeployConfiguration *dc)
......
......@@ -110,7 +110,7 @@ public:
virtual DeployConfiguration *clone(Target *parent, DeployConfiguration *product);
static DeployConfigurationFactory *find(Target *parent, const QVariantMap &map);
static DeployConfigurationFactory *find(Target *parent);
static QList<DeployConfigurationFactory *> find(Target *parent);
static DeployConfigurationFactory *find(Target *parent, DeployConfiguration *dc);
signals:
......
......@@ -63,11 +63,19 @@ struct FactoryAndId
Core::Id id;
};
class DeployFactoryAndId
{
public:
ProjectExplorer::DeployConfigurationFactory *factory;
Core::Id id;
};
} // namespace Internal
} // namespace ProjectExplorer
Q_DECLARE_METATYPE(ProjectExplorer::Internal::FactoryAndId)
Q_DECLARE_METATYPE(ProjectExplorer::Internal::DeployFactoryAndId)
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;
......@@ -381,15 +389,19 @@ void RunSettingsWidget::currentDeployConfigurationChanged(int index)
void RunSettingsWidget::aboutToShowDeployMenu()
{
m_addDeployMenu->clear();
DeployConfigurationFactory *factory = DeployConfigurationFactory::find(m_target);
if (!factory)
QList<DeployConfigurationFactory *> factories = DeployConfigurationFactory::find(m_target);
if (factories.isEmpty())
return;
QList<Core::Id> ids = factory->availableCreationIds(m_target);
foreach (Core::Id id, ids) {
QAction *action = m_addDeployMenu->addAction(factory->displayNameForId(id));
action->setData(QVariant::fromValue(id));
connect(action, SIGNAL(triggered()),
this, SLOT(addDeployConfiguration()));
foreach (DeployConfigurationFactory *factory, factories) {
QList<Core::Id> ids = factory->availableCreationIds(m_target);
foreach (Core::Id id, ids) {
QAction *action = m_addDeployMenu->addAction(factory->displayNameForId(id));
DeployFactoryAndId data = { factory, id };
action->setData(QVariant::fromValue(data));
connect(action, SIGNAL(triggered()),
this, SLOT(addDeployConfiguration()));
}
}
}
......@@ -398,19 +410,13 @@ void RunSettingsWidget::addDeployConfiguration()
QAction *act = qobject_cast<QAction *>(sender());
if (!act)
return;
Core::Id id = act->data().value<Core::Id>();
DeployConfigurationFactory *factory = DeployConfigurationFactory::find(m_target);
if (!factory)
DeployFactoryAndId data = act->data().value<DeployFactoryAndId>();
if (!data.factory->canCreate(m_target, data.id))
return;
DeployConfiguration *newDc = 0;
foreach (Core::Id id, factory->availableCreationIds(m_target)) {
if (!factory->canCreate(m_target, id))
continue;
newDc = factory->create(m_target, id);
}
DeployConfiguration *newDc = data.factory->create(m_target, data.id);
if (!newDc)
return;
QTC_CHECK(!newDc || newDc->id() == id);
QTC_CHECK(!newDc || newDc->id() == data.id);
m_target->addDeployConfiguration(newDc);
m_target->setActiveDeployConfiguration(newDc);
m_removeDeployToolButton->setEnabled(m_target->deployConfigurations().size() > 1);
......
......@@ -545,12 +545,16 @@ void Target::updateDefaultBuildConfigurations()
void Target::updateDefaultDeployConfigurations()
{
DeployConfigurationFactory *dcFactory = DeployConfigurationFactory::find(this);
if (!dcFactory) {
QList<DeployConfigurationFactory *> dcFactories = DeployConfigurationFactory::find(this);
if (dcFactories.isEmpty()) {
qWarning("No deployment configuration factory found for target id '%s'.", qPrintable(id().toString()));
return;
}
QList<Core::Id> dcIds = dcFactory->availableCreationIds(this);
QList<Core::Id> dcIds;
foreach (DeployConfigurationFactory *dcFactory, dcFactories)
dcIds.append(dcFactory->availableCreationIds(this));
QList<DeployConfiguration *> dcList = deployConfigurations();
foreach (DeployConfiguration *dc, dcList) {
......@@ -561,12 +565,14 @@ void Target::updateDefaultDeployConfigurations()
}
foreach (Core::Id id, dcIds) {
if (!dcFactory->canCreate(this, id))
continue;
DeployConfiguration *dc = dcFactory->create(this, id);
if (dc) {
QTC_CHECK(dc->id() == id);
addDeployConfiguration(dc);
foreach (DeployConfigurationFactory *dcFactory, dcFactories) {
if (dcFactory->canCreate(this, id)) {
DeployConfiguration *dc = dcFactory->create(this, id);
if (dc) {
QTC_CHECK(dc->id() == id);
addDeployConfiguration(dc);
}
}
}
}
}
......
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