Make DeployConfigurationFactory more similar to RunConfigFactories

This follows some of the recent changes to RunConfigurations:
- pass Id from factory to DeployConfiguration constructors
- de-object-ify DeployConfigurationFactory
- use addSupportedTargetDeviceType(Id) instead of
  addSupportedTargetDeviceType(List<Id>)

Also, use stepList()->appendStep() instead of stepList()->insertStep(pos...)
with manual pos tracking in some cases.

Change-Id: I09c6a9d0f66f9f85b1c13361104f7878028e1ea8
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2018-04-30 16:50:51 +02:00
parent 8f6a560ed7
commit cf43803032
14 changed files with 56 additions and 89 deletions

View File

@@ -44,23 +44,20 @@ using namespace ProjectExplorer;
namespace Android {
namespace Internal {
// Qt 5.2 has a new form of deployment
const char ANDROID_DEPLOYCONFIGURATION_ID[] = "Qt4ProjectManager.AndroidDeployConfiguration2";
AndroidDeployConfiguration::AndroidDeployConfiguration(Target *parent)
: DeployConfiguration(parent, ANDROID_DEPLOYCONFIGURATION_ID)
AndroidDeployConfiguration::AndroidDeployConfiguration(Target *parent, Core::Id id)
: DeployConfiguration(parent, id)
{}
void AndroidDeployConfiguration::initialize()
{
stepList()->insertStep(0, new AndroidDeployQtStep(stepList()));
stepList()->appendStep(new AndroidDeployQtStep(stepList()));
}
AndroidDeployConfigurationFactory::AndroidDeployConfigurationFactory()
{
setObjectName("AndroidDeployConfigurationFactory");
registerDeployConfiguration<AndroidDeployConfiguration>(ANDROID_DEPLOYCONFIGURATION_ID);
setSupportedTargetDeviceTypes({Constants::ANDROID_DEVICE_TYPE});
registerDeployConfiguration<AndroidDeployConfiguration>
("Qt4ProjectManager.AndroidDeployConfiguration2");
addSupportedTargetDeviceType(Constants::ANDROID_DEVICE_TYPE);
setDefaultDisplayName(AndroidDeployConfiguration::tr("Deploy to Android device"));
}

View File

@@ -35,14 +35,12 @@ class AndroidDeployConfiguration : public ProjectExplorer::DeployConfiguration
Q_OBJECT
public:
explicit AndroidDeployConfiguration(ProjectExplorer::Target *parent);
AndroidDeployConfiguration(ProjectExplorer::Target *parent, Core::Id id);
void initialize() override;
};
class AndroidDeployConfigurationFactory : public ProjectExplorer::DeployConfigurationFactory
{
Q_OBJECT
public:
AndroidDeployConfigurationFactory();

View File

@@ -30,7 +30,6 @@
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/target.h>
#include <qmakeprojectmanager/qmakeproject.h>
#include <qmakeprojectmanager/qmakeprojectmanagerconstants.h>
using namespace ProjectExplorer;
@@ -38,25 +37,23 @@ using namespace ProjectExplorer;
namespace Ios {
namespace Internal {
const char IOS_DEPLOYCONFIGURATION_ID[] = "Qt4ProjectManager.IosDeployConfiguration";
IosDeployConfiguration::IosDeployConfiguration(Target *parent)
: DeployConfiguration(parent, IOS_DEPLOYCONFIGURATION_ID)
IosDeployConfiguration::IosDeployConfiguration(Target *parent, Core::Id id)
: DeployConfiguration(parent, id)
{
}
void IosDeployConfiguration::initialize()
{
stepList()->insertStep(0, new IosDeployStep(stepList()));
stepList()->appendStep(new IosDeployStep(stepList()));
}
IosDeployConfigurationFactory::IosDeployConfigurationFactory()
{
setObjectName("IosDeployConfigurationFactory");
registerDeployConfiguration<IosDeployConfiguration>(IOS_DEPLOYCONFIGURATION_ID);
registerDeployConfiguration<IosDeployConfiguration>("Qt4ProjectManager.IosDeployConfiguration");
setSupportedProjectType(QmakeProjectManager::Constants::QMAKEPROJECT_ID);
setSupportedTargetDeviceTypes({Constants::IOS_DEVICE_TYPE, Constants::IOS_SIMULATOR_TYPE});
setDefaultDisplayName(tr("Deploy on iOS"));
addSupportedTargetDeviceType(Constants::IOS_DEVICE_TYPE);
addSupportedTargetDeviceType(Constants::IOS_SIMULATOR_TYPE);
setDefaultDisplayName(IosDeployConfiguration::tr("Deploy on iOS"));
}
} // namespace Internal

View File

@@ -35,14 +35,12 @@ class IosDeployConfiguration : public ProjectExplorer::DeployConfiguration
Q_OBJECT
public:
explicit IosDeployConfiguration(ProjectExplorer::Target *parent);
IosDeployConfiguration(ProjectExplorer::Target *parent, Core::Id id);
void initialize() override;
};
class IosDeployConfigurationFactory : public ProjectExplorer::DeployConfigurationFactory
{
Q_OBJECT
public:
IosDeployConfigurationFactory();
};

View File

@@ -38,7 +38,6 @@ namespace ProjectExplorer {
const char BUILD_STEP_LIST_COUNT[] = "ProjectExplorer.BuildConfiguration.BuildStepListCount";
const char BUILD_STEP_LIST_PREFIX[] = "ProjectExplorer.BuildConfiguration.BuildStepList.";
const char DEFAULT_DEPLOYCONFIGURATION_ID[] = "ProjectExplorer.DefaultDeployConfiguration";
DeployConfiguration::DeployConfiguration(Target *target, Core::Id id)
: ProjectConfiguration(target, id),
@@ -144,7 +143,6 @@ static QList<DeployConfigurationFactory *> g_deployConfigurationFactories;
DeployConfigurationFactory::DeployConfigurationFactory()
{
setObjectName("DeployConfigurationFactory");
g_deployConfigurationFactories.append(this);
}
@@ -252,9 +250,9 @@ QList<DeployConfigurationFactory *> DeployConfigurationFactory::find(Target *par
});
}
void DeployConfigurationFactory::setSupportedTargetDeviceTypes(const QList<Core::Id> &ids)
void DeployConfigurationFactory::addSupportedTargetDeviceType(Core::Id id)
{
m_supportedTargetDeviceTypes = ids;
m_supportedTargetDeviceTypes.append(id);
}
void DeployConfigurationFactory::setDefaultDisplayName(const QString &defaultDisplayName)
@@ -273,17 +271,10 @@ void DeployConfigurationFactory::setSupportedProjectType(Core::Id id)
DefaultDeployConfigurationFactory::DefaultDeployConfigurationFactory()
{
struct DefaultDeployConfiguration : DeployConfiguration
{
DefaultDeployConfiguration(Target *t)
: DeployConfiguration(t, DEFAULT_DEPLOYCONFIGURATION_ID)
{}
};
registerDeployConfiguration<DefaultDeployConfiguration>(DEFAULT_DEPLOYCONFIGURATION_ID);
setSupportedTargetDeviceTypes({Constants::DESKTOP_DEVICE_TYPE});
registerDeployConfiguration<DeployConfiguration>("ProjectExplorer.DefaultDeployConfiguration");
addSupportedTargetDeviceType(Constants::DESKTOP_DEVICE_TYPE);
//: Display name of the default deploy configuration
setDefaultDisplayName(DeployConfigurationFactory::tr("Deploy Configuration"));
setDefaultDisplayName(DeployConfiguration::tr("Deploy Configuration"));
}
bool DefaultDeployConfigurationFactory::canHandle(Target *parent) const

View File

@@ -72,13 +72,11 @@ private:
BuildStepList m_stepList;
};
class PROJECTEXPLORER_EXPORT DeployConfigurationFactory : public QObject
class PROJECTEXPLORER_EXPORT DeployConfigurationFactory
{
Q_OBJECT
public:
DeployConfigurationFactory();
~DeployConfigurationFactory();
virtual ~DeployConfigurationFactory();
// used to show the list of possible additons to a target, returns a list of types
QList<Core::Id> availableCreationIds(Target *parent) const;
@@ -92,7 +90,7 @@ public:
static DeployConfiguration *restore(Target *parent, const QVariantMap &map);
static DeployConfiguration *clone(Target *parent, const DeployConfiguration *dc);
void setSupportedTargetDeviceTypes(const QList<Core::Id> &ids);
void addSupportedTargetDeviceType(Core::Id id);
void setDefaultDisplayName(const QString &defaultDisplayName);
void setSupportedProjectType(Core::Id id);
@@ -106,8 +104,8 @@ protected:
template <class DeployConfig>
void registerDeployConfiguration(Core::Id deployConfigBaseId)
{
m_creator = [this](Target *t) {
auto dc = new DeployConfig(t);
m_creator = [this, deployConfigBaseId](Target *t) {
auto dc = new DeployConfig(t, deployConfigBaseId);
dc->setDefaultDisplayName(m_defaultDisplayName);
return dc;
};
@@ -115,6 +113,9 @@ protected:
}
private:
DeployConfigurationFactory(const DeployConfigurationFactory &) = delete;
DeployConfigurationFactory operator=(const DeployConfigurationFactory &) = delete;
DeployConfigurationCreator m_creator;
Core::Id m_deployConfigBaseId;
Core::Id m_supportedProjectType;

View File

@@ -35,18 +35,15 @@
namespace QbsProjectManager {
namespace Internal {
const char QBS_DEPLOYCONFIG_ID[] = "Qbs.Deploy";
QbsDeployConfiguration::QbsDeployConfiguration(ProjectExplorer::Target *target) :
ProjectExplorer::DeployConfiguration(target, QBS_DEPLOYCONFIG_ID)
QbsDeployConfiguration::QbsDeployConfiguration(ProjectExplorer::Target *target, Core::Id id) :
ProjectExplorer::DeployConfiguration(target, id)
{
}
QbsDeployConfigurationFactory::QbsDeployConfigurationFactory()
{
setObjectName("QbsDeployConfiguration");
registerDeployConfiguration<QbsDeployConfiguration>(QBS_DEPLOYCONFIG_ID);
setSupportedTargetDeviceTypes({ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE});
registerDeployConfiguration<QbsDeployConfiguration>("Qbs.Deploy");
addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
setSupportedProjectType(Constants::PROJECT_ID);
setDefaultDisplayName(QCoreApplication::translate("Qbs", "Qbs Install"));
}

View File

@@ -35,13 +35,11 @@ class QbsDeployConfiguration : public ProjectExplorer::DeployConfiguration
Q_OBJECT
public:
explicit QbsDeployConfiguration(ProjectExplorer::Target *target);
QbsDeployConfiguration(ProjectExplorer::Target *target, Core::Id id);
};
class QbsDeployConfigurationFactory : public ProjectExplorer::DeployConfigurationFactory
{
Q_OBJECT
public:
QbsDeployConfigurationFactory();
};

View File

@@ -37,8 +37,6 @@ const char QNX_QNX_QT[] = "Qt4ProjectManager.QtVersion.QNX.QNX";
const char QNX_QNX_FEATURE[] = "QtSupport.Wizards.FeatureQNX";
const char QNX_QNX_DEPLOYCONFIGURATION_ID[] = "Qt4ProjectManager.QNX.QNXDeployConfiguration";
const char QNX_QNX_RUNCONFIGURATION_PREFIX[] = "Qt4ProjectManager.QNX.QNXRunConfiguration.";
const char QNX_QNX_OS_TYPE[] = "QnxOsType";

View File

@@ -40,8 +40,8 @@ using namespace RemoteLinux;
namespace Qnx {
namespace Internal {
QnxDeployConfiguration::QnxDeployConfiguration(Target *target)
: DeployConfiguration(target, Constants::QNX_QNX_DEPLOYCONFIGURATION_ID)
QnxDeployConfiguration::QnxDeployConfiguration(Target *target, Core::Id id)
: DeployConfiguration(target, id)
{
}
@@ -59,9 +59,10 @@ NamedWidget *QnxDeployConfiguration::createConfigWidget()
QnxDeployConfigurationFactory::QnxDeployConfigurationFactory()
{
registerDeployConfiguration<QnxDeployConfiguration>(Constants::QNX_QNX_DEPLOYCONFIGURATION_ID);
setDefaultDisplayName(tr("Deploy to QNX Device"));
setSupportedTargetDeviceTypes({QnxDeviceFactory::deviceType()});
registerDeployConfiguration<QnxDeployConfiguration>
("Qt4ProjectManager.QNX.QNXDeployConfiguration");
setDefaultDisplayName(QnxDeployConfiguration::tr("Deploy to QNX Device"));
addSupportedTargetDeviceType(QnxDeviceFactory::deviceType());
}
} // namespace Internal

View File

@@ -35,15 +35,13 @@ class QnxDeployConfiguration : public ProjectExplorer::DeployConfiguration
Q_OBJECT
public:
explicit QnxDeployConfiguration(ProjectExplorer::Target *target);
QnxDeployConfiguration(ProjectExplorer::Target *target, Core::Id id);
void initialize() override;
ProjectExplorer::NamedWidget *createConfigWidget() override;
};
class QnxDeployConfigurationFactory : public ProjectExplorer::DeployConfigurationFactory
{
Q_OBJECT
public:
QnxDeployConfigurationFactory();
};

View File

@@ -43,15 +43,15 @@ namespace RemoteLinux {
using namespace Internal;
RemoteLinuxDeployConfiguration::RemoteLinuxDeployConfiguration(Target *target)
: DeployConfiguration(target, genericDeployConfigurationId())
RemoteLinuxDeployConfiguration::RemoteLinuxDeployConfiguration(Target *target, Core::Id id)
: DeployConfiguration(target, id)
{}
void RemoteLinuxDeployConfiguration::initialize()
{
stepList()->insertStep(0, new RemoteLinuxCheckForFreeDiskSpaceStep(stepList()));
stepList()->insertStep(1, new RemoteLinuxKillAppStep(stepList()));
stepList()->insertStep(2, new GenericDirectUploadStep(stepList()));
stepList()->appendStep(new RemoteLinuxCheckForFreeDiskSpaceStep(stepList()));
stepList()->appendStep(new RemoteLinuxKillAppStep(stepList()));
stepList()->appendStep(new GenericDirectUploadStep(stepList()));
}
NamedWidget *RemoteLinuxDeployConfiguration::createConfigWidget()
@@ -68,10 +68,9 @@ namespace Internal {
RemoteLinuxDeployConfigurationFactory::RemoteLinuxDeployConfigurationFactory()
{
setObjectName("RemoteLinuxDeployConfiguration");
registerDeployConfiguration<RemoteLinuxDeployConfiguration>
(RemoteLinuxDeployConfiguration::genericDeployConfigurationId());
setSupportedTargetDeviceTypes({RemoteLinux::Constants::GenericLinuxOsType});
addSupportedTargetDeviceType(RemoteLinux::Constants::GenericLinuxOsType);
setDefaultDisplayName(QCoreApplication::translate("RemoteLinux",
"Deploy to Remote Linux Host"));
}

View File

@@ -38,7 +38,7 @@ class REMOTELINUX_EXPORT RemoteLinuxDeployConfiguration
Q_OBJECT
public:
explicit RemoteLinuxDeployConfiguration(ProjectExplorer::Target *target);
RemoteLinuxDeployConfiguration(ProjectExplorer::Target *target, Core::Id id);
static Core::Id genericDeployConfigurationId();
@@ -63,8 +63,6 @@ namespace Internal {
class RemoteLinuxDeployConfigurationFactory : public ProjectExplorer::DeployConfigurationFactory
{
Q_OBJECT
public:
RemoteLinuxDeployConfigurationFactory();
};

View File

@@ -39,50 +39,46 @@ using namespace ProjectExplorer;
namespace WinRt {
namespace Internal {
const char appxDeployConfigurationC[] = "WinRTAppxDeployConfiguration";
const char phoneDeployConfigurationC[] = "WinRTPhoneDeployConfiguration";
const char emulatorDeployConfigurationC[] = "WinRTEmulatorDeployConfiguration";
struct WinRtAppDeployConfiguration : DeployConfiguration
{
WinRtAppDeployConfiguration(Target *target) : DeployConfiguration(target, appxDeployConfigurationC) {}
WinRtAppDeployConfiguration(Target *target, Core::Id id) : DeployConfiguration(target, id) {}
void initialize() { stepList()->appendStep(new WinRtPackageDeploymentStep(stepList())); }
};
WinRtAppDeployConfigurationFactory::WinRtAppDeployConfigurationFactory()
{
registerDeployConfiguration<WinRtAppDeployConfiguration>(appxDeployConfigurationC);
registerDeployConfiguration<WinRtAppDeployConfiguration>("WinRTAppxDeployConfiguration");
setDefaultDisplayName(QCoreApplication::translate("WinRt::Internal::WinRtDeployConfiguration",
"Run windeployqt"));
setSupportedTargetDeviceTypes({Constants::WINRT_DEVICE_TYPE_LOCAL});
addSupportedTargetDeviceType(Constants::WINRT_DEVICE_TYPE_LOCAL);
}
struct WinRtPhoneDeployConfiguration : DeployConfiguration
{
WinRtPhoneDeployConfiguration(Target *target) : DeployConfiguration(target, phoneDeployConfigurationC) {}
WinRtPhoneDeployConfiguration(Target *target, Core::Id id) : DeployConfiguration(target, id) {}
void initialize() { stepList()->appendStep(new WinRtPackageDeploymentStep(stepList())); }
};
WinRtPhoneDeployConfigurationFactory::WinRtPhoneDeployConfigurationFactory()
{
registerDeployConfiguration<WinRtPhoneDeployConfiguration>(phoneDeployConfigurationC);
registerDeployConfiguration<WinRtPhoneDeployConfiguration>("WinRTPhoneDeployConfiguration");
setDefaultDisplayName(QCoreApplication::translate("WinRt::Internal::WinRtDeployConfiguration",
"Deploy to Windows Phone"));
setSupportedTargetDeviceTypes({Constants::WINRT_DEVICE_TYPE_PHONE});
addSupportedTargetDeviceType(Constants::WINRT_DEVICE_TYPE_PHONE);
}
struct WinRtEmulatorDeployConfiguration : DeployConfiguration
{
WinRtEmulatorDeployConfiguration(Target *target) : DeployConfiguration(target, emulatorDeployConfigurationC) {}
WinRtEmulatorDeployConfiguration(Target *target, Core::Id id) : DeployConfiguration(target, id) {}
void initialize() { stepList()->appendStep(new WinRtPackageDeploymentStep(stepList())); }
};
WinRtEmulatorDeployConfigurationFactory::WinRtEmulatorDeployConfigurationFactory()
{
registerDeployConfiguration<WinRtEmulatorDeployConfiguration>(emulatorDeployConfigurationC);
registerDeployConfiguration<WinRtEmulatorDeployConfiguration>("WinRTEmulatorDeployConfiguration");
setDefaultDisplayName(QCoreApplication::translate("WinRt::Internal::WinRtDeployConfiguration",
"Deploy to Windows Phone Emulator"));
setSupportedTargetDeviceTypes({Constants::WINRT_DEVICE_TYPE_EMULATOR});
addSupportedTargetDeviceType(Constants::WINRT_DEVICE_TYPE_EMULATOR);
}
WinRtDeployStepFactory::WinRtDeployStepFactory()