forked from qt-creator/qt-creator
ProjectExplorer: Allow specifying deploy config widgets in the factory
Keep the generality of creating any widget, but also add a convenience function handling the single special case that was ever used. Change-Id: Iab4cbe62de04b9fcc6cb0bb305eaf9a48649d991 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "buildsteplist.h"
|
||||
#include "buildconfiguration.h"
|
||||
#include "deploymentdataview.h"
|
||||
#include "kitinformation.h"
|
||||
#include "project.h"
|
||||
#include "projectexplorer.h"
|
||||
@@ -67,6 +68,13 @@ const BuildStepList *DeployConfiguration::stepList() const
|
||||
return &m_stepList;
|
||||
}
|
||||
|
||||
NamedWidget *DeployConfiguration::createConfigWidget() const
|
||||
{
|
||||
if (!m_configWidgetCreator)
|
||||
return nullptr;
|
||||
return m_configWidgetCreator(target());
|
||||
}
|
||||
|
||||
QVariantMap DeployConfiguration::toMap() const
|
||||
{
|
||||
QVariantMap map(ProjectConfiguration::toMap());
|
||||
@@ -75,11 +83,6 @@ QVariantMap DeployConfiguration::toMap() const
|
||||
return map;
|
||||
}
|
||||
|
||||
NamedWidget *DeployConfiguration::createConfigWidget()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool DeployConfiguration::isEnabled() const
|
||||
{
|
||||
return false;
|
||||
@@ -176,6 +179,16 @@ bool DeployConfigurationFactory::canHandle(Target *target) const
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeployConfigurationFactory::setConfigWidgetCreator(const std::function<NamedWidget *(Target *)> &configWidgetCreator)
|
||||
{
|
||||
m_configWidgetCreator = configWidgetCreator;
|
||||
}
|
||||
|
||||
void DeployConfigurationFactory::setUseDeploymentDataView()
|
||||
{
|
||||
m_configWidgetCreator = [](Target *target) { return new DeploymentDataView(target); };
|
||||
}
|
||||
|
||||
bool DeployConfigurationFactory::canCreate(Target *parent, Core::Id id) const
|
||||
{
|
||||
if (!canHandle(parent))
|
||||
@@ -197,6 +210,7 @@ DeployConfiguration *DeployConfigurationFactory::create(Target *parent, Core::Id
|
||||
if (!info.condition || info.condition(parent))
|
||||
dc->stepList()->appendStep(info.deployStepId);
|
||||
}
|
||||
dc->m_configWidgetCreator = m_configWidgetCreator;
|
||||
return dc;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user