diff options
author | Tobias Hunger <tobias.hunger@nokia.com> | 2010-07-16 14:00:41 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@nokia.com> | 2010-08-02 14:21:05 +0200 |
commit | ee4a04a20b2af6d6ffb5f8b1d938d18ca21ef157 (patch) | |
tree | 5f5e905180d2f80865c7adbc46e6767fb18de408 /src/plugins | |
parent | cc93a08b1b3605f05a61e47c0e5a4aeb5dbdf913 (diff) | |
download | qt-creator-ee4a04a20b2af6d6ffb5f8b1d938d18ca21ef157.tar.gz |
Refactor deployment
* Add a DeployConfiguration class to hold settings related
to deployment.
* Add BuildStepsList to hold a list of buildsteps
* Update BuildConfiguration to use BuildStepLists instead of
manageing lists of buildsteps itself.
* Update BuildManager to use BuildStepLists in its interfaces
* Fix fallout introduced by API changes
* Update .user file to new way of storing settings
Task-number: QTCREATORBUG-1427
Task-number: QTCREATORBUG-1428
Task-number: QTCREATORBUG-1811
Task-number: QTCREATORBUG-1930
Diffstat (limited to 'src/plugins')
81 files changed, 2463 insertions, 1051 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp index 029aba3d94..21cf5d2a81 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp @@ -34,6 +34,7 @@ #include "cmaketarget.h" #include <projectexplorer/projectexplorerconstants.h> +#include <projectexplorer/buildsteplist.h> #include <utils/qtcassert.h> #include <QtGui/QInputDialog> @@ -61,6 +62,7 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(CMakeTarget *parent, CMakeBuild m_buildDirectory(source->m_buildDirectory), m_msvcVersion(source->m_msvcVersion) { + Q_ASSERT(parent); cloneSteps(source); } @@ -217,11 +219,14 @@ CMakeBuildConfiguration *CMakeBuildConfigurationFactory::create(ProjectExplorer: CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(cmtarget); bc->setDisplayName(buildConfigurationName); - MakeStep *makeStep = new MakeStep(bc); - bc->insertStep(ProjectExplorer::BuildStep::Build, 0, makeStep); + ProjectExplorer::BuildStepList *buildSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); + ProjectExplorer::BuildStepList *cleanSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_CLEAN); - MakeStep *cleanMakeStep = new MakeStep(bc); - bc->insertStep(ProjectExplorer::BuildStep::Clean, 0, cleanMakeStep); + MakeStep *makeStep = new MakeStep(buildSteps); + buildSteps->insertStep(0, makeStep); + + MakeStep *cleanMakeStep = new MakeStep(cleanSteps); + cleanSteps->insertStep(0, cleanMakeStep); cleanMakeStep->setAdditionalArguments(QStringList() << "clean"); cleanMakeStep->setClean(true); diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp index 7335905ffb..924454fbfa 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp @@ -38,6 +38,7 @@ #include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/buildenvironmentwidget.h> +#include <projectexplorer/buildsteplist.h> #include <cpptools/cppmodelmanagerinterface.h> #include <extensionsystem/pluginmanager.h> #include <utils/qtcassert.h> @@ -410,7 +411,7 @@ QString CMakeProject::displayName() const QString CMakeProject::id() const { - return QLatin1String("CMakeProjectManager.CMakeProject"); + return QLatin1String(Constants::CMAKEPROJECT_ID); } Core::IFile *CMakeProject::file() const @@ -521,7 +522,7 @@ bool CMakeProject::fromMap(const QVariantMap &map) if (!hasUserFile && hasBuildTarget("all")) { MakeStep *makeStep = qobject_cast<MakeStep *>( - activeTarget()->activeBuildConfiguration()->steps(ProjectExplorer::BuildStep::Build).at(0)); + activeTarget()->activeBuildConfiguration()->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD)->at(0)); Q_ASSERT(makeStep); makeStep->setBuildTarget("all", true); } diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h b/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h index 7011db96f0..5a92bf4d91 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h +++ b/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h @@ -38,6 +38,10 @@ const char * const CMAKEMIMETYPE = "text/x-cmake"; // TOOD check that this is c const char * const CMAKE_EDITOR_ID = "CMakeProject.CMakeEditor"; const char * const CMAKE_EDITOR_DISPLAY_NAME = "CMake Editor"; const char * const C_CMAKEEDITOR = "CMakeProject.Context.CMakeEditor"; + +// Project +const char * const CMAKEPROJECT_ID = "CMakeProjectManager.CMakeProject"; + } // namespace Constants } // namespace CMakeProjectManager diff --git a/src/plugins/cmakeprojectmanager/cmaketarget.cpp b/src/plugins/cmakeprojectmanager/cmaketarget.cpp index 96eaf8ead1..d38772e49b 100644 --- a/src/plugins/cmakeprojectmanager/cmaketarget.cpp +++ b/src/plugins/cmakeprojectmanager/cmaketarget.cpp @@ -34,7 +34,10 @@ #include "cmakerunconfiguration.h" #include "cmakebuildconfiguration.h" +#include <projectexplorer/buildsteplist.h> +#include <projectexplorer/deployconfiguration.h> #include <projectexplorer/customexecutablerunconfiguration.h> +#include <projectexplorer/projectexplorerconstants.h> #include <QtGui/QApplication> #include <QtGui/QStyle> @@ -58,7 +61,8 @@ QString displayNameForId(const QString &id) { CMakeTarget::CMakeTarget(CMakeProject *parent) : ProjectExplorer::Target(parent, QLatin1String(DEFAULT_CMAKE_TARGET_ID)), - m_buildConfigurationFactory(new CMakeBuildConfigurationFactory(this)) + m_buildConfigurationFactory(new CMakeBuildConfigurationFactory(this)), + m_deployConfigurationFactory(new ProjectExplorer::DeployConfigurationFactory(this)) { setDisplayName(displayNameForId(id())); setIcon(qApp->style()->standardIcon(QStyle::SP_ComputerIcon)); @@ -81,7 +85,12 @@ CMakeBuildConfiguration *CMakeTarget::activeBuildConfiguration() const CMakeBuildConfigurationFactory *CMakeTarget::buildConfigurationFactory() const { - return m_buildConfigurationFactory; + return m_buildConfigurationFactory; +} + +ProjectExplorer::DeployConfigurationFactory *CMakeTarget::deployConfigurationFactory() const +{ + return m_deployConfigurationFactory; } QString CMakeTarget::defaultBuildDirectory() const @@ -187,16 +196,21 @@ CMakeTarget *CMakeTargetFactory::create(ProjectExplorer::Project *parent, const CMakeBuildConfiguration *bc(new CMakeBuildConfiguration(t)); bc->setDisplayName("all"); + ProjectExplorer::BuildStepList *buildSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); + ProjectExplorer::BuildStepList *cleanSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_CLEAN); + // Now create a standard build configuration - bc->insertStep(ProjectExplorer::BuildStep::Build, 0, new MakeStep(bc)); + buildSteps->insertStep(0, new MakeStep(buildSteps)); - MakeStep *cleanMakeStep = new MakeStep(bc); - bc->insertStep(ProjectExplorer::BuildStep::Clean, 0, cleanMakeStep); + MakeStep *cleanMakeStep = new MakeStep(cleanSteps); + cleanSteps->insertStep(0, cleanMakeStep); cleanMakeStep->setAdditionalArguments(QStringList() << "clean"); cleanMakeStep->setClean(true); t->addBuildConfiguration(bc); + t->addDeployConfiguration(t->deployConfigurationFactory()->create(t, ProjectExplorer::Constants::DEFAULT_DEPLOYCONFIGURATION_ID)); + t->updateRunConfigurations(); return t; diff --git a/src/plugins/cmakeprojectmanager/cmaketarget.h b/src/plugins/cmakeprojectmanager/cmaketarget.h index 4812505fd8..c4d20f85ed 100644 --- a/src/plugins/cmakeprojectmanager/cmaketarget.h +++ b/src/plugins/cmakeprojectmanager/cmaketarget.h @@ -58,6 +58,7 @@ public: CMakeBuildConfiguration *activeBuildConfiguration() const; CMakeBuildConfigurationFactory *buildConfigurationFactory() const; + ProjectExplorer::DeployConfigurationFactory *deployConfigurationFactory() const; QString defaultBuildDirectory() const; @@ -69,6 +70,7 @@ private slots: private: CMakeBuildConfigurationFactory *m_buildConfigurationFactory; + ProjectExplorer::DeployConfigurationFactory *m_deployConfigurationFactory; }; class CMakeTargetFactory : public ProjectExplorer::ITargetFactory diff --git a/src/plugins/cmakeprojectmanager/makestep.cpp b/src/plugins/cmakeprojectmanager/makestep.cpp index e888a4356b..a60b62e0da 100644 --- a/src/plugins/cmakeprojectmanager/makestep.cpp +++ b/src/plugins/cmakeprojectmanager/makestep.cpp @@ -34,6 +34,7 @@ #include "cmaketarget.h" #include "cmakebuildconfiguration.h" +#include <projectexplorer/buildsteplist.h> #include <projectexplorer/projectexplorer.h> #include <projectexplorer/gnumakeparser.h> @@ -57,22 +58,22 @@ const char * const ADDITIONAL_ARGUMENTS_KEY("CMakeProjectManager.MakeStep.Additi // TODO: Move progress information into an IOutputParser! -MakeStep::MakeStep(BuildConfiguration *bc) : - AbstractProcessStep(bc, QLatin1String(MS_ID)), m_clean(false), +MakeStep::MakeStep(BuildStepList *bsl) : + AbstractProcessStep(bsl, QLatin1String(MS_ID)), m_clean(false), m_futureInterface(0) { ctor(); } -MakeStep::MakeStep(BuildConfiguration *bc, const QString &id) : - AbstractProcessStep(bc, id), m_clean(false), +MakeStep::MakeStep(BuildStepList *bsl, const QString &id) : + AbstractProcessStep(bsl, id), m_clean(false), m_futureInterface(0) { ctor(); } -MakeStep::MakeStep(BuildConfiguration *bc, MakeStep *bs) : - AbstractProcessStep(bc, bs), +MakeStep::MakeStep(BuildStepList *bsl, MakeStep *bs) : + AbstractProcessStep(bsl, bs), m_clean(bs->m_clean), m_futureInterface(0), m_buildTargets(bs->m_buildTargets), @@ -317,42 +318,41 @@ MakeStepFactory::~MakeStepFactory() { } -bool MakeStepFactory::canCreate(BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QString &id) const +bool MakeStepFactory::canCreate(BuildStepList *parent, const QString &id) const { - Q_UNUSED(type) - if (!qobject_cast<CMakeBuildConfiguration *>(parent)) + if (parent->target()->project()->id() != QLatin1String(Constants::CMAKEPROJECT_ID)) return false; return QLatin1String(MS_ID) == id; } -BuildStep *MakeStepFactory::create(BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QString &id) +BuildStep *MakeStepFactory::create(BuildStepList *parent, const QString &id) { - if (!canCreate(parent, type, id)) + if (!canCreate(parent, id)) return 0; return new MakeStep(parent); } -bool MakeStepFactory::canClone(BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, BuildStep *source) const +bool MakeStepFactory::canClone(BuildStepList *parent, BuildStep *source) const { - return canCreate(parent, type, source->id()); + return canCreate(parent, source->id()); } -BuildStep *MakeStepFactory::clone(BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, BuildStep *source) +BuildStep *MakeStepFactory::clone(BuildStepList *parent, BuildStep *source) { - if (!canClone(parent, type, source)) + if (!canClone(parent, source)) return 0; return new MakeStep(parent, static_cast<MakeStep *>(source)); } -bool MakeStepFactory::canRestore(BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QVariantMap &map) const +bool MakeStepFactory::canRestore(BuildStepList *parent, const QVariantMap &map) const { QString id(ProjectExplorer::idFromMap(map)); - return canCreate(parent, type, id); + return canCreate(parent, id); } -BuildStep *MakeStepFactory::restore(BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QVariantMap &map) +BuildStep *MakeStepFactory::restore(BuildStepList *parent, const QVariantMap &map) { - if (!canRestore(parent, type, map)) + if (!canRestore(parent, map)) return 0; MakeStep *bs(new MakeStep(parent)); if (bs->fromMap(map)) @@ -361,12 +361,11 @@ BuildStep *MakeStepFactory::restore(BuildConfiguration *parent, ProjectExplorer: return 0; } -QStringList MakeStepFactory::availableCreationIds(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type) const +QStringList MakeStepFactory::availableCreationIds(ProjectExplorer::BuildStepList *parent) const { - Q_UNUSED(type) - if (!qobject_cast<CMakeBuildConfiguration *>(parent)) - return QStringList(); - return QStringList() << QLatin1String(MS_ID); + if (parent->target()->project()->id() == QLatin1String(Constants::CMAKEPROJECT_ID)) + return QStringList() << QLatin1String(MS_ID); + return QStringList(); } QString MakeStepFactory::displayNameForId(const QString &id) const diff --git a/src/plugins/cmakeprojectmanager/makestep.h b/src/plugins/cmakeprojectmanager/makestep.h index be759bc2e6..c0ac7bfe97 100644 --- a/src/plugins/cmakeprojectmanager/makestep.h +++ b/src/plugins/cmakeprojectmanager/makestep.h @@ -52,7 +52,7 @@ class MakeStep : public ProjectExplorer::AbstractProcessStep // This is for modifying internal data public: - MakeStep(ProjectExplorer::BuildConfiguration *bc); + MakeStep(ProjectExplorer::BuildStepList *bsl); virtual ~MakeStep(); CMakeBuildConfiguration *cmakeBuildConfiguration() const; @@ -73,8 +73,8 @@ public: QVariantMap toMap() const; protected: - MakeStep(ProjectExplorer::BuildConfiguration *bc, MakeStep *bs); - MakeStep(ProjectExplorer::BuildConfiguration *bc, const QString &id); + MakeStep(ProjectExplorer::BuildStepList *bsl, MakeStep *bs); + MakeStep(ProjectExplorer::BuildStepList *bsl, const QString &id); bool fromMap(const QVariantMap &map); @@ -119,14 +119,14 @@ public: explicit MakeStepFactory(QObject *parent = 0); virtual ~MakeStepFactory(); - virtual bool canCreate(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QString &id) const; - virtual ProjectExplorer::BuildStep *create(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QString &id); - virtual bool canClone(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, ProjectExplorer::BuildStep *source) const; - virtual ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, ProjectExplorer::BuildStep *source); - virtual bool canRestore(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QVariantMap &map) const; - virtual ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QVariantMap &map); + virtual bool canCreate(ProjectExplorer::BuildStepList *parent, const QString &id) const; + virtual ProjectExplorer::BuildStep *create(ProjectExplorer::BuildStepList *parent, const QString &id); + virtual bool canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *source) const; + virtual ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *source); + virtual bool canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const; + virtual ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map); - virtual QStringList availableCreationIds(ProjectExplorer::BuildConfiguration *bc, ProjectExplorer::BuildStep::Type type) const; + virtual QStringList availableCreationIds(ProjectExplorer::BuildStepList *bc) const; virtual QString displayNameForId(const QString &id) const; }; diff --git a/src/plugins/genericprojectmanager/genericbuildconfiguration.cpp b/src/plugins/genericprojectmanager/genericbuildconfiguration.cpp index ab83eb0354..69d3cb5cb8 100644 --- a/src/plugins/genericprojectmanager/genericbuildconfiguration.cpp +++ b/src/plugins/genericprojectmanager/genericbuildconfiguration.cpp @@ -33,6 +33,8 @@ #include "genericproject.h" #include "generictarget.h" +#include <projectexplorer/buildsteplist.h> +#include <projectexplorer/projectexplorerconstants.h> #include <utils/qtcassert.h> #include <QtGui/QInputDialog> @@ -182,8 +184,10 @@ BuildConfiguration *GenericBuildConfigurationFactory::create(ProjectExplorer::Ta GenericBuildConfiguration *bc = new GenericBuildConfiguration(target); bc->setDisplayName(buildConfigurationName); - GenericMakeStep *makeStep = new GenericMakeStep(bc); - bc->insertStep(ProjectExplorer::BuildStep::Build, 0, makeStep); + ProjectExplorer::BuildStepList *buildSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); + Q_ASSERT(buildSteps); + GenericMakeStep *makeStep = new GenericMakeStep(buildSteps); + buildSteps->insertStep(0, makeStep); makeStep->setBuildTarget("all", /* on = */ true); target->addBuildConfiguration(bc); // also makes the name unique... diff --git a/src/plugins/genericprojectmanager/genericmakestep.cpp b/src/plugins/genericprojectmanager/genericmakestep.cpp index 884b86338b..4432bcaf2e 100644 --- a/src/plugins/genericprojectmanager/genericmakestep.cpp +++ b/src/plugins/genericprojectmanager/genericmakestep.cpp @@ -35,6 +35,7 @@ #include "genericbuildconfiguration.h" #include <extensionsystem/pluginmanager.h> +#include <projectexplorer/buildsteplist.h> #include <projectexplorer/toolchain.h> #include <projectexplorer/projectexplorer.h> #include <projectexplorer/gnumakeparser.h> @@ -60,20 +61,20 @@ const char * const MAKE_ARGUMENTS_KEY("GenericProjectManager.GenericMakeStep.Mak const char * const MAKE_COMMAND_KEY("GenericProjectManager.GenericMakeStep.MakeCommand"); } -GenericMakeStep::GenericMakeStep(ProjectExplorer::BuildConfiguration *bc) : - AbstractProcessStep(bc, QLatin1String(GENERIC_MS_ID)) +GenericMakeStep::GenericMakeStep(ProjectExplorer::BuildStepList *parent) : + AbstractProcessStep(parent, QLatin1String(GENERIC_MS_ID)) { ctor(); } -GenericMakeStep::GenericMakeStep(ProjectExplorer::BuildConfiguration *bc, const QString &id) : - AbstractProcessStep(bc, id) +GenericMakeStep::GenericMakeStep(ProjectExplorer::BuildStepList *parent, const QString &id) : + AbstractProcessStep(parent, id) { ctor(); } -GenericMakeStep::GenericMakeStep(ProjectExplorer::BuildConfiguration *bc, GenericMakeStep *bs) : - AbstractProcessStep(bc, bs), +GenericMakeStep::GenericMakeStep(ProjectExplorer::BuildStepList *parent, GenericMakeStep *bs) : + AbstractProcessStep(parent, bs), m_buildTargets(bs->m_buildTargets), m_makeArguments(bs->m_makeArguments), m_makeCommand(bs->m_makeCommand) @@ -307,57 +308,50 @@ GenericMakeStepFactory::~GenericMakeStepFactory() { } -bool GenericMakeStepFactory::canCreate(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, +bool GenericMakeStepFactory::canCreate(ProjectExplorer::BuildStepList *parent, const QString &id) const { - Q_UNUSED(type) - if (!qobject_cast<GenericBuildConfiguration *>(parent)) + if (parent->target()->project()->id() != QLatin1String(Constants::GENERICPROJECT_ID)) return false; return id == QLatin1String(GENERIC_MS_ID); } -ProjectExplorer::BuildStep *GenericMakeStepFactory::create(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, +ProjectExplorer::BuildStep *GenericMakeStepFactory::create(ProjectExplorer::BuildStepList *parent, const QString &id) { - if (!canCreate(parent, type, id)) + if (!canCreate(parent, id)) return 0; return new GenericMakeStep(parent); } -bool GenericMakeStepFactory::canClone(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, +bool GenericMakeStepFactory::canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *source) const { const QString id(source->id()); - return canCreate(parent, type, id); + return canCreate(parent, id); } -ProjectExplorer::BuildStep *GenericMakeStepFactory::clone(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, +ProjectExplorer::BuildStep *GenericMakeStepFactory::clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *source) { - if (!canClone(parent, type, source)) + if (!canClone(parent, source)) return 0; GenericMakeStep *old(qobject_cast<GenericMakeStep *>(source)); Q_ASSERT(old); return new GenericMakeStep(parent, old); } -bool GenericMakeStepFactory::canRestore(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, +bool GenericMakeStepFactory::canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const { QString id(ProjectExplorer::idFromMap(map)); - return canCreate(parent, type, id); + return canCreate(parent, id); } -ProjectExplorer::BuildStep *GenericMakeStepFactory::restore(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, +ProjectExplorer::BuildStep *GenericMakeStepFactory::restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) { - if (!canRestore(parent, type, map)) + if (!canRestore(parent, map)) return 0; GenericMakeStep *bs(new GenericMakeStep(parent)); if (bs->fromMap(map)) @@ -366,11 +360,9 @@ ProjectExplorer::BuildStep *GenericMakeStepFactory::restore(ProjectExplorer::Bui return 0; } -QStringList GenericMakeStepFactory::availableCreationIds(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type) const +QStringList GenericMakeStepFactory::availableCreationIds(ProjectExplorer::BuildStepList *parent) const { - Q_UNUSED(type) - if (!qobject_cast<GenericBuildConfiguration *>(parent)) + if (parent->target()->project()->id() != QLatin1String(Constants::GENERICPROJECT_ID)) return QStringList(); return QStringList() << QLatin1String(GENERIC_MS_ID); } diff --git a/src/plugins/genericprojectmanager/genericmakestep.h b/src/plugins/genericprojectmanager/genericmakestep.h index 28e9e20d15..1326e53005 100644 --- a/src/plugins/genericprojectmanager/genericmakestep.h +++ b/src/plugins/genericprojectmanager/genericmakestep.h @@ -54,7 +54,7 @@ class GenericMakeStep : public ProjectExplorer::AbstractProcessStep friend class GenericMakeStepFactory; public: - GenericMakeStep(ProjectExplorer::BuildConfiguration *bc); + GenericMakeStep(ProjectExplorer::BuildStepList *parent); virtual ~GenericMakeStep(); GenericBuildConfiguration *genericBuildConfiguration() const; @@ -73,8 +73,8 @@ public: QVariantMap toMap() const; protected: - GenericMakeStep(ProjectExplorer::BuildConfiguration *bc, GenericMakeStep *bs); - GenericMakeStep(ProjectExplorer::BuildConfiguration *bc, const QString &id); + GenericMakeStep(ProjectExplorer::BuildStepList *parent, GenericMakeStep *bs); + GenericMakeStep(ProjectExplorer::BuildStepList *parent, const QString &id); virtual bool fromMap(const QVariantMap &map); private: @@ -113,27 +113,20 @@ public: explicit GenericMakeStepFactory(QObject *parent = 0); virtual ~GenericMakeStepFactory(); - virtual bool canCreate(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, + virtual bool canCreate(ProjectExplorer::BuildStepList *parent, const QString &id) const; - virtual ProjectExplorer::BuildStep *create(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, + virtual ProjectExplorer::BuildStep *create(ProjectExplorer::BuildStepList *parent, const QString &id); - virtual bool canClone(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, + virtual bool canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *source) const; - virtual ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, + virtual ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *source); - virtual bool canRestore(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, + virtual bool canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const; - virtual ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, + virtual ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map); - virtual QStringList availableCreationIds(ProjectExplorer::BuildConfiguration *bc, - ProjectExplorer::BuildStep::Type type) const; + virtual QStringList availableCreationIds(ProjectExplorer::BuildStepList *bc) const; virtual QString displayNameForId(const QString &id) const; }; diff --git a/src/plugins/genericprojectmanager/genericproject.cpp b/src/plugins/genericprojectmanager/genericproject.cpp index ef224384f7..833324cd7c 100644 --- a/src/plugins/genericprojectmanager/genericproject.cpp +++ b/src/plugins/genericprojectmanager/genericproject.cpp @@ -375,7 +375,7 @@ QString GenericProject::displayName() const QString GenericProject::id() const { - return QLatin1String("GenericProjectManager.GenericProject"); + return QLatin1String(Constants::GENERICPROJECT_ID); } Core::IFile *GenericProject::file() const diff --git a/src/plugins/genericprojectmanager/genericprojectconstants.h b/src/plugins/genericprojectmanager/genericprojectconstants.h index 248fb2ab3f..53201610e7 100644 --- a/src/plugins/genericprojectmanager/genericprojectconstants.h +++ b/src/plugins/genericprojectmanager/genericprojectconstants.h @@ -54,6 +54,9 @@ const char *const INCLUDES_MIMETYPE = "application/vnd.nokia.qt.generic.include const char *const CONFIG_EDITOR = ".config Editor"; const char *const CONFIG_MIMETYPE = "application/vnd.nokia.qt.generic.config"; +// Project +const char *const GENERICPROJECT_ID = "GenericProjectManager.GenericProject"; + } // namespace Constants } // namespace GenericProjectManager diff --git a/src/plugins/genericprojectmanager/generictarget.cpp b/src/plugins/genericprojectmanager/generictarget.cpp index c6d373db02..7afede186e 100644 --- a/src/plugins/genericprojectmanager/generictarget.cpp +++ b/src/plugins/genericprojectmanager/generictarget.cpp @@ -33,7 +33,10 @@ #include "genericproject.h" #include "genericmakestep.h" +#include <projectexplorer/buildsteplist.h> #include <projectexplorer/customexecutablerunconfiguration.h> +#include <projectexplorer/deployconfiguration.h> +#include <projectexplorer/projectexplorerconstants.h> #include <QtGui/QApplication> #include <QtGui/QStyle> @@ -51,7 +54,8 @@ using namespace GenericProjectManager::Internal; GenericTarget::GenericTarget(GenericProject *parent) : ProjectExplorer::Target(parent, QLatin1String(GENERIC_DESKTOP_TARGET_ID)), - m_buildConfigurationFactory(new GenericBuildConfigurationFactory(this)) + m_buildConfigurationFactory(new GenericBuildConfigurationFactory(this)), + m_deployConfigurationFactory(new ProjectExplorer::DeployConfigurationFactory(this)) { setDisplayName(QApplication::translate("GenericProjectManager::GenericTarget", GENERIC_DESKTOP_TARGET_DISPLAY_NAME, @@ -73,6 +77,11 @@ GenericBuildConfigurationFactory *GenericTarget::buildConfigurationFactory() con return m_buildConfigurationFactory; } +ProjectExplorer::DeployConfigurationFactory *GenericTarget::deployConfigurationFactory() const +{ + return m_deployConfigurationFactory; +} + GenericBuildConfiguration *GenericTarget::activeBuildConfiguration() const { return static_cast<GenericBuildConfiguration *>(Target::activeBuildConfiguration()); @@ -136,8 +145,9 @@ GenericTarget *GenericTargetFactory::create(ProjectExplorer::Project *parent, co GenericBuildConfiguration *bc = new GenericBuildConfiguration(t); bc->setDisplayName("all"); - GenericMakeStep *makeStep = new GenericMakeStep(bc); - bc->insertStep(ProjectExplorer::BuildStep::Build, 0, makeStep); + ProjectExplorer::BuildStepList *buildSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); + GenericMakeStep *makeStep = new GenericMakeStep(buildSteps); + buildSteps->insertStep(0, makeStep); makeStep->setBuildTarget("all", /* on = */ true); @@ -145,6 +155,8 @@ GenericTarget *GenericTargetFactory::create(ProjectExplorer::Project *parent, co t->addBuildConfiguration(bc); + t->addDeployConfiguration(t->deployConfigurationFactory()->create(t, ProjectExplorer::Constants::DEFAULT_DEPLOYCONFIGURATION_ID)); + // Add a runconfiguration. The CustomExecutableRC one will query the user // for its settings, so it is a good choice here. t->addRunConfiguration(new ProjectExplorer::CustomExecutableRunConfiguration(t)); diff --git a/src/plugins/genericprojectmanager/generictarget.h b/src/plugins/genericprojectmanager/generictarget.h index f768d6a539..123284b33b 100644 --- a/src/plugins/genericprojectmanager/generictarget.h +++ b/src/plugins/genericprojectmanager/generictarget.h @@ -64,6 +64,7 @@ public: GenericProject *genericProject() const; GenericBuildConfigurationFactory *buildConfigurationFactory() const; + ProjectExplorer::DeployConfigurationFactory *deployConfigurationFactory() const; GenericBuildConfiguration *activeBuildConfiguration() const; protected: @@ -71,6 +72,7 @@ protected: private: GenericBuildConfigurationFactory *m_buildConfigurationFactory; + ProjectExplorer::DeployConfigurationFactory *m_deployConfigurationFactory; }; class GenericTargetFactory : public ProjectExplorer::ITargetFactory diff --git a/src/plugins/projectexplorer/abstractprocessstep.cpp b/src/plugins/projectexplorer/abstractprocessstep.cpp index 806da13131..fcde4a2a46 100644 --- a/src/plugins/projectexplorer/abstractprocessstep.cpp +++ b/src/plugins/projectexplorer/abstractprocessstep.cpp @@ -43,16 +43,16 @@ using namespace ProjectExplorer; -AbstractProcessStep::AbstractProcessStep(BuildConfiguration *bc, const QString &id) : - BuildStep(bc, id), m_timer(0), m_futureInterface(0), +AbstractProcessStep::AbstractProcessStep(BuildStepList *bsl, const QString &id) : + BuildStep(bsl, id), m_timer(0), m_futureInterface(0), m_enabled(true), m_ignoreReturnValue(false), m_process(0), m_eventLoop(0), m_outputParserChain(0) { } -AbstractProcessStep::AbstractProcessStep(BuildConfiguration *bc, +AbstractProcessStep::AbstractProcessStep(BuildStepList *bsl, AbstractProcessStep *bs) : - BuildStep(bc, bs), m_timer(0), m_futureInterface(0), + BuildStep(bsl, bs), m_timer(0), m_futureInterface(0), m_enabled(bs->m_enabled), m_ignoreReturnValue(bs->m_ignoreReturnValue), m_process(0), m_eventLoop(0), m_outputParserChain(0) { diff --git a/src/plugins/projectexplorer/abstractprocessstep.h b/src/plugins/projectexplorer/abstractprocessstep.h index 603708132b..8f5ce79215 100644 --- a/src/plugins/projectexplorer/abstractprocessstep.h +++ b/src/plugins/projectexplorer/abstractprocessstep.h @@ -117,8 +117,8 @@ public: ProjectExplorer::IOutputParser *outputParser() const; protected: - AbstractProcessStep(BuildConfiguration *bc, const QString &id); - AbstractProcessStep(BuildConfiguration *bc, AbstractProcessStep *bs); + AbstractProcessStep(BuildStepList *bsl, const QString &id); + AbstractProcessStep(BuildStepList *bsl, AbstractProcessStep *bs); /// Called after the process is started /// the default implementation adds a process started message to the output message diff --git a/src/plugins/projectexplorer/buildconfiguration.cpp b/src/plugins/projectexplorer/buildconfiguration.cpp index 57db6aa0b5..2f06037d89 100644 --- a/src/plugins/projectexplorer/buildconfiguration.cpp +++ b/src/plugins/projectexplorer/buildconfiguration.cpp @@ -29,100 +29,81 @@ #include "buildconfiguration.h" -#include <utils/qtcassert.h> -#include <coreplugin/icore.h> -#include <extensionsystem/pluginmanager.h> -#include <projectexplorer/projectexplorer.h> -#include <projectexplorer/buildmanager.h> - -#include <QtCore/QMetaEnum> -#include <QtCore/QMetaObject> +#include "buildmanager.h" +#include "buildsteplist.h" +#include "projectexplorer.h" +#include "projectexplorerconstants.h" +#include "target.h" + #include <QtCore/QProcess> using namespace ProjectExplorer; namespace { -IBuildStepFactory *findCloneFactory(BuildConfiguration *parent, BuildStep::Type type, BuildStep *source) -{ - QList<IBuildStepFactory *> factories = ExtensionSystem::PluginManager::instance()->getObjects<IBuildStepFactory>(); - foreach(IBuildStepFactory *factory, factories) - if (factory->canClone(parent, type, source)) - return factory; - return 0; -} - -IBuildStepFactory *findRestoreFactory(BuildConfiguration *parent, BuildStep::Type type, const QVariantMap &map) -{ - QList<IBuildStepFactory *> factories = ExtensionSystem::PluginManager::instance()->getObjects<IBuildStepFactory>(); - foreach(IBuildStepFactory *factory, factories) - if (factory->canRestore(parent, type, map)) - return factory; - return 0; -} - -const char * const STEPS_COUNT_KEY("ProjectExplorer.BuildConfiguration.%1StepsCount"); -const char * const STEPS_PREFIX("ProjectExplorer.BuildConfiguration.%1Step."); +const char * const BUILD_STEP_LIST_COUNT("ProjectExplorer.BuildConfiguration.BuildStepListCount"); +const char * const BUILD_STEP_LIST_PREFIX("ProjectExplorer.BuildConfiguration.BuildStepList."); const char * const CLEAR_SYSTEM_ENVIRONMENT_KEY("ProjectExplorer.BuildConfiguration.ClearSystemEnvironment"); const char * const USER_ENVIRONMENT_CHANGES_KEY("ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"); } // namespace BuildConfiguration::BuildConfiguration(Target *target, const QString &id) : - ProjectConfiguration(id), - m_target(target), + ProjectConfiguration(target, id), m_clearSystemEnvironment(false) { - Q_ASSERT(m_target); + Q_ASSERT(target); + BuildStepList *bsl = new BuildStepList(this, QLatin1String(Constants::BUILDSTEPS_BUILD)); + //: Display name of the build build step list. Used as part of the labels in the project window. + bsl->setDisplayName(tr("Build")); + m_stepLists.append(bsl); + bsl = new BuildStepList(this, QLatin1String(Constants::BUILDSTEPS_CLEAN)); + //: Display name of the clean build step list. Used as part of the labels in the project window. + bsl->setDisplayName(tr("Clean")); + m_stepLists.append(bsl); } BuildConfiguration::BuildConfiguration(Target *target, BuildConfiguration *source) : - ProjectConfiguration(source), - m_target(target), + ProjectConfiguration(target, source), m_clearSystemEnvironment(source->m_clearSystemEnvironment), m_userEnvironmentChanges(source->m_userEnvironmentChanges) { - Q_ASSERT(m_target); + Q_ASSERT(target); + // Do not clone stepLists here, do that in the derived constructor instead + // otherwise BuildStepFactories might reject to set up a BuildStep for us + // since we are not yet the derived class! } BuildConfiguration::~BuildConfiguration() +{ } + +QStringList BuildConfiguration::knownStepLists() const { - for (int i = 0; i < BuildStep::LastStepType; ++i) { - qDeleteAll(m_steps[i]); - } + QStringList result; + foreach (BuildStepList *list, m_stepLists) + result.append(list->id()); + return result; +} + +BuildStepList *BuildConfiguration::stepList(const QString &id) const +{ + foreach (BuildStepList *list, m_stepLists) + if (id == list->id()) + return list; + return 0; } QVariantMap BuildConfiguration::toMap() const { QVariantMap map(ProjectConfiguration::toMap()); - // Save build steps - QMetaEnum typeEnum = BuildStep::staticMetaObject.enumerator(BuildStep::staticMetaObject.indexOfEnumerator("Type")); - for (int type = 0; type < BuildStep::LastStepType; ++type) { - const QString key(typeEnum.key(type)); - map.insert(QString::fromLatin1(STEPS_COUNT_KEY).arg(key), m_steps[type].count()); - for (int step = 0; step < m_steps[type].count(); ++step) - map.insert(QString::fromLatin1(STEPS_PREFIX).arg(key) + QString::number(step), m_steps[type].at(step)->toMap()); - } - map.insert(QLatin1String(CLEAR_SYSTEM_ENVIRONMENT_KEY), m_clearSystemEnvironment); map.insert(QLatin1String(USER_ENVIRONMENT_CHANGES_KEY), EnvironmentItem::toStringList(m_userEnvironmentChanges)); - return map; -} + map.insert(QLatin1String(BUILD_STEP_LIST_COUNT), m_stepLists.count()); + for (int i = 0; i < m_stepLists.count(); ++i) + map.insert(QLatin1String(BUILD_STEP_LIST_PREFIX) % QString::number(i), m_stepLists.at(i)->toMap()); -void BuildConfiguration::cloneSteps(BuildConfiguration *source) -{ - Q_ASSERT(source); - for (int i = 0; i < BuildStep::LastStepType; ++i) { - foreach (BuildStep *originalbs, source->steps(BuildStep::Type(i))) { - IBuildStepFactory *factory(findCloneFactory(this, BuildStep::Type(i), originalbs)); - if (!factory) - continue; - BuildStep *clonebs(factory->clone(this, BuildStep::Type(i), originalbs)); - if (clonebs) - m_steps[i].append(clonebs); - } - } + return map; } bool BuildConfiguration::fromMap(const QVariantMap &map) @@ -130,74 +111,38 @@ bool BuildConfiguration::fromMap(const QVariantMap &map) if (!ProjectConfiguration::fromMap(map)) return false; - QMetaEnum typeEnum = BuildStep::staticMetaObject.enumerator(BuildStep::staticMetaObject.indexOfEnumerator("Type")); - for (int type = 0; type < BuildStep::LastStepType; ++type) { - const QString key(typeEnum.key(type)); - int maxSteps = map.value(QString::fromLatin1(STEPS_COUNT_KEY).arg(key), 0).toInt(); - for (int step = 0; step < maxSteps; ++step) { - QVariantMap bsData(map.value(QString::fromLatin1(STEPS_PREFIX).arg(key) + QString::number(step)).toMap()); - if (bsData.isEmpty()) { - qWarning() << "No step data found for" << key << step << "(continuing)."; - continue; - } - IBuildStepFactory *factory(findRestoreFactory(this, BuildStep::Type(type), bsData)); - if (!factory) { - qWarning() << "No factory for step" << key << step << "found (continuing)."; - continue; - } - BuildStep *bs(factory->restore(this, BuildStep::Type(type), bsData)); - if (!bs) { - qWarning() << "Restoration of step" << key << step << "failed (continuing)."; - continue; - } - insertStep(BuildStep::Type(type), m_steps[type].count(), bs); - } - } - m_clearSystemEnvironment = map.value(QLatin1String(CLEAR_SYSTEM_ENVIRONMENT_KEY)).toBool(); m_userEnvironmentChanges = EnvironmentItem::fromStringList(map.value(QLatin1String(USER_ENVIRONMENT_CHANGES_KEY)).toStringList()); - return true; -} - -QList<BuildStep *> BuildConfiguration::steps(BuildStep::Type type) const -{ - Q_ASSERT(type >= 0 && type < BuildStep::LastStepType); - return m_steps[type]; -} - -void BuildConfiguration::insertStep(BuildStep::Type type, int position, BuildStep *step) -{ - Q_ASSERT(type >= 0 && type < BuildStep::LastStepType); - m_steps[type].insert(position, step); -} + qDeleteAll(m_stepLists); + m_stepLists.clear(); -bool BuildConfiguration::removeStep(BuildStep::Type type, int position) -{ - Q_ASSERT(type >= 0 && type < BuildStep::LastStepType); + int maxI = map.value(QLatin1String(BUILD_STEP_LIST_COUNT), 0).toInt(); + for (int i = 0; i < maxI; ++i) { + QVariantMap data = map.value(QLatin1String(BUILD_STEP_LIST_PREFIX) % QString::number(i)).toMap(); + if (data.isEmpty()) { + qWarning() << "No data for build step list" << i << "found!"; + continue; + } + BuildStepList *list = new BuildStepList(this, data); + if (list->isNull()) { + qWarning() << "Failed to restore build step list" << i; + delete list; + return false; + } + m_stepLists.append(list); + } - ProjectExplorer::BuildManager *bm = - ProjectExplorer::ProjectExplorerPlugin::instance()->buildManager(); - if (bm->isBuilding(m_steps[type].at(position))) - return false; + // TODO: We currently assume there to be at least a clean, build and deploy list! + Q_ASSERT(knownStepLists().contains(QLatin1String(ProjectExplorer::Constants::BUILDSTEPS_BUILD))); + Q_ASSERT(knownStepLists().contains(QLatin1String(ProjectExplorer::Constants::BUILDSTEPS_CLEAN))); - delete m_steps[type].at(position); - m_steps[type].removeAt(position); return true; } -void BuildConfiguration::moveStepUp(BuildStep::Type type, int position) -{ - Q_ASSERT(type >= 0 && type < BuildStep::LastStepType); - if (position <= 0 || m_steps[type].size() <= 1) - return; - m_steps[type].swap(position - 1, position); - -} - Target *BuildConfiguration::target() const { - return m_target; + return static_cast<Target *>(parent()); } Environment BuildConfiguration::baseEnvironment() const @@ -248,15 +193,23 @@ void BuildConfiguration::setUserEnvironmentChanges(const QList<ProjectExplorer:: emit environmentChanged(); } +void BuildConfiguration::cloneSteps(BuildConfiguration *source) +{ + qDeleteAll(m_stepLists); + m_stepLists.clear(); + foreach (BuildStepList *bsl, source->m_stepLists) { + BuildStepList *newBsl = new BuildStepList(this, bsl); + m_stepLists.append(newBsl); + } +} + /// // IBuildConfigurationFactory /// IBuildConfigurationFactory::IBuildConfigurationFactory(QObject *parent) : QObject(parent) -{ -} +{ } IBuildConfigurationFactory::~IBuildConfigurationFactory() -{ -} +{ } diff --git a/src/plugins/projectexplorer/buildconfiguration.h b/src/plugins/projectexplorer/buildconfiguration.h index d095206106..ef0f52d3d2 100644 --- a/src/plugins/projectexplorer/buildconfiguration.h +++ b/src/plugins/projectexplorer/buildconfiguration.h @@ -38,11 +38,11 @@ #include <QtCore/QList> #include <QtCore/QObject> -#include "buildstep.h" #include "projectconfiguration.h" namespace ProjectExplorer { +class BuildStepList; class Target; class IOutputParser; @@ -54,15 +54,8 @@ public: // ctors are protected virtual ~BuildConfiguration(); - QList<BuildStep *> steps(BuildStep::Type type) const; - void insertStep(BuildStep::Type type, int position, BuildStep *step); - bool removeStep(BuildStep::Type type, int position); - void moveStepUp(BuildStep::Type type, int position); - virtual QString buildDirectory() const = 0; - Target *target() const; - // TODO: Maybe the BuildConfiguration is not the best place for the environment virtual Environment baseEnvironment() const; QString baseEnvironmentText() const; @@ -72,6 +65,9 @@ public: bool useSystemEnvironment() const; void setUseSystemEnvironment(bool b); + QStringList knownStepLists() const; + BuildStepList *stepList(const QString &id) const; + virtual QVariantMap toMap() const; // Creates a suitable outputparser for custom build steps @@ -81,6 +77,8 @@ public: // with the generic project manager virtual IOutputParser *createOutputParser() const = 0; + Target *target() const; + signals: void environmentChanged(); void buildDirectoryChanged(); @@ -88,16 +86,15 @@ signals: protected: BuildConfiguration(Target *target, const QString &id); BuildConfiguration(Target *target, BuildConfiguration *source); + void cloneSteps(BuildConfiguration *source); virtual bool fromMap(const QVariantMap &map); private: - QList<BuildStep *> m_steps[BuildStep::LastStepType]; - Target *m_target; - bool m_clearSystemEnvironment; QList<EnvironmentItem> m_userEnvironmentChanges; + QList<BuildStepList *> m_stepLists; }; class PROJECTEXPLORER_EXPORT IBuildConfigurationFactory : diff --git a/src/plugins/projectexplorer/buildmanager.cpp b/src/plugins/projectexplorer/buildmanager.cpp index 3b18945b1a..2236755c4c 100644 --- a/src/plugins/projectexplorer/buildmanager.cpp +++ b/src/plugins/projectexplorer/buildmanager.cpp @@ -31,6 +31,7 @@ #include "buildprogress.h" #include "buildstep.h" +#include "buildsteplist.h" #include "compileoutputwindow.h" #include "projectexplorerconstants.h" #include "projectexplorer.h" @@ -409,47 +410,16 @@ bool BuildManager::buildQueueAppend(QList<BuildStep *> steps) return true; } -bool BuildManager::buildProjects(const QList<BuildConfiguration *> &configurations) +bool BuildManager::buildList(BuildStepList *bsl) { - QList<BuildStep *> steps; - foreach(BuildConfiguration *bc, configurations) - steps.append(bc->steps(BuildStep::Build)); - - bool success = buildQueueAppend(steps); - if (!success) { - m_outputWindow->popup(false); - return false; - } - - if (ProjectExplorerPlugin::instance()->projectExplorerSettings().showCompilerOutput) - m_outputWindow->popup(false); - startBuildQueue(); - return true; -} - -bool BuildManager::deployProjects(const QList<BuildConfiguration *> &configurations) -{ - QList<BuildStep *> steps; - foreach(BuildConfiguration *bc, configurations) - steps.append(bc->steps(BuildStep::Deploy)); - - bool success = buildQueueAppend(steps); - if (!success) { - m_outputWindow->popup(false); - return false; - } - - if (ProjectExplorerPlugin::instance()->projectExplorerSettings().showCompilerOutput) - m_outputWindow->popup(false); - startBuildQueue(); - return true; + return buildLists(QList<BuildStepList *>() << bsl); } -bool BuildManager::cleanProjects(const QList<BuildConfiguration *> &configurations) +bool BuildManager::buildLists(QList<BuildStepList *> bsls) { QList<BuildStep *> steps; - foreach(BuildConfiguration *bc, configurations) - steps.append(bc->steps(BuildStep::Clean)); + foreach(BuildStepList *list, bsls) + steps.append(list->steps()); bool success = buildQueueAppend(steps); if (!success) { @@ -463,21 +433,6 @@ bool BuildManager::cleanProjects(const QList<BuildConfiguration *> &configuratio return true; } -bool BuildManager::buildProject(BuildConfiguration *configuration) -{ - return buildProjects(QList<BuildConfiguration *>() << configuration); -} - -bool BuildManager::deployProject(BuildConfiguration *configuration) -{ - return deployProjects(QList<BuildConfiguration *>() << configuration); -} - -bool BuildManager::cleanProject(BuildConfiguration *configuration) -{ - return cleanProjects(QList<BuildConfiguration *>() << configuration); -} - void BuildManager::appendStep(BuildStep *step) { bool success = buildQueueAppend(QList<BuildStep *>() << step); diff --git a/src/plugins/projectexplorer/buildmanager.h b/src/plugins/projectexplorer/buildmanager.h index e622c29492..59c6fc89da 100644 --- a/src/plugins/projectexplorer/buildmanager.h +++ b/src/plugins/projectexplorer/buildmanager.h @@ -49,6 +49,7 @@ namespace Internal { } class BuildStep; +class BuildStepList; class Project; class ProjectExplorerPlugin; class BuildConfiguration; @@ -73,12 +74,8 @@ public: bool tasksAvailable() const; - bool buildProject(BuildConfiguration *bc); - bool buildProjects(const QList<BuildConfiguration *> &configurations); - bool deployProject(BuildConfiguration *bc); - bool deployProjects(const QList<BuildConfiguration *> &configurations); - bool cleanProject(BuildConfiguration *configuration); - bool cleanProjects(const QList<BuildConfiguration *> &configurations); + bool buildLists(QList<BuildStepList *> bsls); + bool buildList(BuildStepList *bsl); bool isBuilding(Project *p); bool isBuilding(BuildStep *step); diff --git a/src/plugins/projectexplorer/buildsettingspropertiespage.cpp b/src/plugins/projectexplorer/buildsettingspropertiespage.cpp index ff1138134f..16e518b7dc 100644 --- a/src/plugins/projectexplorer/buildsettingspropertiespage.cpp +++ b/src/plugins/projectexplorer/buildsettingspropertiespage.cpp @@ -31,6 +31,7 @@ #include "buildstep.h" #include "buildstepspage.h" #include "project.h" +#include "projectexplorerconstants.h" #include "target.h" #include "buildconfiguration.h" #include "buildconfigurationmodel.h" @@ -187,12 +188,14 @@ void BuildSettingsWidget::setupUi() SLOT(updateAddButtonMenu())); } -void BuildSettingsWidget::addSubWidget(const QString &name, BuildConfigWidget *widget) +void BuildSettingsWidget::addSubWidget(BuildConfigWidget *widget) { widget->setContentsMargins(0, 10, 0, 0); QLabel *label = new QLabel(this); - label->setText(name); + label->setText(widget->displayName()); + connect(widget, SIGNAL(displayNameChanged(QString)), + label, SLOT(setText(QString))); QFont f = label->font(); f.setBold(true); f.setPointSizeF(f.pointSizeF() * 1.2); @@ -247,15 +250,14 @@ void BuildSettingsWidget::updateBuildSettings() // Add pages BuildConfigWidget *generalConfigWidget = m_target->project()->createConfigWidget(); - addSubWidget(generalConfigWidget->displayName(), generalConfigWidget); + addSubWidget(generalConfigWidget); - addSubWidget(tr("Build Steps"), new BuildStepsPage(m_target, BuildStep::Build)); - addSubWidget(tr("Deploy Steps"), new BuildStepsPage(m_target, BuildStep::Deploy)); - addSubWidget(tr("Clean Steps"), new BuildStepsPage(m_target, BuildStep::Clean)); + addSubWidget(new BuildStepsPage(m_target, QLatin1String(Constants::BUILDSTEPS_BUILD))); + addSubWidget(new BuildStepsPage(m_target, QLatin1String(Constants::BUILDSTEPS_CLEAN))); QList<BuildConfigWidget *> subConfigWidgets = m_target->project()->subConfigWidgets(); foreach (BuildConfigWidget *subConfigWidget, subConfigWidgets) - addSubWidget(subConfigWidget->displayName(), subConfigWidget); + addSubWidget(subConfigWidget); foreach (BuildConfigWidget *widget, subWidgets()) widget->init(m_buildConfiguration); diff --git a/src/plugins/projectexplorer/buildsettingspropertiespage.h b/src/plugins/projectexplorer/buildsettingspropertiespage.h index 444e381b14..bb661615d7 100644 --- a/src/plugins/projectexplorer/buildsettingspropertiespage.h +++ b/src/plugins/projectexplorer/buildsettingspropertiespage.h @@ -87,7 +87,7 @@ public: ~BuildSettingsWidget(); void clear(); - void addSubWidget(const QString &name, BuildConfigWidget *widget); + void addSubWidget(BuildConfigWidget *widget); QList<BuildConfigWidget *> subWidgets() const; void setupUi(); diff --git a/src/plugins/projectexplorer/buildstep.cpp b/src/plugins/projectexplorer/buildstep.cpp index db700902d3..459407f63e 100644 --- a/src/plugins/projectexplorer/buildstep.cpp +++ b/src/plugins/projectexplorer/buildstep.cpp @@ -29,20 +29,22 @@ #include "buildstep.h" +#include "buildconfiguration.h" +#include "buildsteplist.h" +#include "target.h" + using namespace ProjectExplorer; -BuildStep::BuildStep(BuildConfiguration *bc, const QString &id) : - ProjectConfiguration(id), - m_buildConfiguration(bc) +BuildStep::BuildStep(BuildStepList *bsl, const QString &id) : + ProjectConfiguration(bsl, id) { - Q_ASSERT(bc); + Q_ASSERT(bsl); } -BuildStep::BuildStep(BuildConfiguration *bc, BuildStep *bs) : - ProjectConfiguration(bs), - m_buildConfiguration(bc) +BuildStep::BuildStep(BuildStepList *bsl, BuildStep *bs) : + ProjectConfiguration(bsl, bs) { - Q_ASSERT(bc); + Q_ASSERT(bsl); } BuildStep::~BuildStep() @@ -51,7 +53,15 @@ BuildStep::~BuildStep() BuildConfiguration *BuildStep::buildConfiguration() const { - return m_buildConfiguration; + BuildConfiguration *bc = qobject_cast<BuildConfiguration *>(parent()->parent()); + if (!bc) + bc = target()->activeBuildConfiguration(); + return bc; +} + +Target *BuildStep::target() const +{ + return qobject_cast<Target *>(parent()->parent()->parent()); } bool BuildStep::immutable() const @@ -61,9 +71,7 @@ bool BuildStep::immutable() const IBuildStepFactory::IBuildStepFactory(QObject *parent) : QObject(parent) -{ -} +{ } IBuildStepFactory::~IBuildStepFactory() -{ -} +{ } diff --git a/src/plugins/projectexplorer/buildstep.h b/src/plugins/projectexplorer/buildstep.h index 065289121f..ce3ffbf656 100644 --- a/src/plugins/projectexplorer/buildstep.h +++ b/src/plugins/projectexplorer/buildstep.h @@ -40,6 +40,8 @@ namespace ProjectExplorer { class BuildConfiguration; +class BuildStepList; +class Target; /* // BuildSteps are the primary way plugin developers can customize @@ -68,18 +70,10 @@ class PROJECTEXPLORER_EXPORT BuildStep : public ProjectConfiguration Q_OBJECT protected: - BuildStep(BuildConfiguration *bc, const QString &id); - BuildStep(BuildConfiguration *bc, BuildStep *bs); + BuildStep(BuildStepList *bsl, const QString &id); + BuildStep(BuildStepList *bsl, BuildStep *bs); public: - enum Type { - Build = 0, - Clean, - Deploy, - LastStepType - }; - Q_ENUMS(Type) - virtual ~BuildStep(); // This function is run in the gui thread, @@ -103,6 +97,7 @@ public: virtual bool immutable() const; BuildConfiguration *buildConfiguration() const; + Target *target() const; enum OutputFormat { NormalOutput, ErrorOutput, MessageOutput, ErrorMessageOutput }; @@ -113,9 +108,6 @@ signals: // window. // It should be in plain text, with the format in the parameter void addOutput(const QString &string, ProjectExplorer::BuildStep::OutputFormat format); - -private: - BuildConfiguration *m_buildConfiguration; }; class PROJECTEXPLORER_EXPORT IBuildStepFactory : @@ -128,17 +120,17 @@ public: virtual ~IBuildStepFactory(); // used to show the list of possible additons to a target, returns a list of types - virtual QStringList availableCreationIds(BuildConfiguration *parent, BuildStep::Type type) const = 0; + virtual QStringList availableCreationIds(BuildStepList *parent) const = 0; // used to translate the types to names to display to the user virtual QString displayNameForId(const QString &id) const = 0; - virtual bool canCreate(BuildConfiguration *parent, BuildStep::Type type, const QString &id) const = 0; - virtual BuildStep *create(BuildConfiguration *parent, BuildStep::Type type, const QString &id) = 0; + virtual bool canCreate(BuildStepList *parent, const QString &id) const = 0; + virtual BuildStep *create(BuildStepList *parent, const QString &id) = 0; // used to recreate the runConfigurations when restoring settings - virtual bool canRestore(BuildConfiguration *parent, BuildStep::Type type, const QVariantMap &map) const = 0; - virtual BuildStep *restore(BuildConfiguration *parent, BuildStep::Type type, const QVariantMap &map) = 0; - virtual bool canClone(BuildConfiguration *parent, BuildStep::Type type, BuildStep *product) const = 0; - virtual BuildStep *clone(BuildConfiguration *parent, BuildStep::Type type, BuildStep *product) = 0; + virtual bool canRestore(BuildStepList *parent, const QVariantMap &map) const = 0; + virtual BuildStep *restore(BuildStepList *parent, const QVariantMap &map) = 0; + virtual bool canClone(BuildStepList *parent, BuildStep *product) const = 0; + virtual BuildStep *clone(BuildStepList *parent, BuildStep *product) = 0; }; class PROJECTEXPLORER_EXPORT BuildConfigWidget @@ -154,6 +146,9 @@ public: // This is called to set up the config widget before showing it virtual void init(BuildConfiguration *bc) = 0; + +signals: + void displayNameChanged(const QString &); }; class PROJECTEXPLORER_EXPORT BuildStepConfigWidget diff --git a/src/plugins/projectexplorer/buildsteplist.cpp b/src/plugins/projectexplorer/buildsteplist.cpp new file mode 100644 index 0000000000..b0e27824fb --- /dev/null +++ b/src/plugins/projectexplorer/buildsteplist.cpp @@ -0,0 +1,221 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "buildsteplist.h" + +#include "buildconfiguration.h" +#include "buildmanager.h" +#include "buildstep.h" +#include "deployconfiguration.h" +#include "projectexplorer.h" +#include "target.h" + +#include <extensionsystem/pluginmanager.h> + +using namespace ProjectExplorer; + +namespace { + +IBuildStepFactory *findCloneFactory(BuildStepList *parent, BuildStep *source) +{ + QList<IBuildStepFactory *> factories = ExtensionSystem::PluginManager::instance()->getObjects<IBuildStepFactory>(); + foreach(IBuildStepFactory *factory, factories) + if (factory->canClone(parent, source)) + return factory; + return 0; +} + +IBuildStepFactory *findRestoreFactory(BuildStepList *parent, const QVariantMap &map) +{ + QList<IBuildStepFactory *> factories = ExtensionSystem::PluginManager::instance()->getObjects<IBuildStepFactory>(); + foreach(IBuildStepFactory *factory, factories) + if (factory->canRestore(parent, map)) + return factory; + return 0; +} + +const char * const STEPS_COUNT_KEY("ProjectExplorer.BuildStepList.StepsCount"); +const char * const STEPS_PREFIX("ProjectExplorer.BuildStepList.Step."); + +} // namespace + +BuildStepList::BuildStepList(QObject *parent, const QString &id) : + ProjectConfiguration(parent, id), + m_isNull(false) +{ + Q_ASSERT(parent); +} + +BuildStepList::BuildStepList(QObject *parent, BuildStepList *source) : + ProjectConfiguration(parent, source), + m_isNull(source->m_isNull) +{ + Q_ASSERT(parent); + // do not clone the steps here: + // The BC is not fully set up yet and thus some of the buildstepfactories + // will fail to clone the buildsteps! +} + +BuildStepList::BuildStepList(QObject *parent, const QVariantMap &data) : + ProjectConfiguration(parent, QLatin1String("UNKNOWN")) +{ + Q_ASSERT(parent); + m_isNull = !fromMap(data); +} + +BuildStepList::~BuildStepList() +{ + qDeleteAll(m_steps); +} + +QVariantMap BuildStepList::toMap() const +{ + QVariantMap map(ProjectConfiguration::toMap()); + // Save build steps + map.insert(QString::fromLatin1(STEPS_COUNT_KEY), m_steps.count()); + for (int i = 0; i < m_steps.count(); ++i) + map.insert(QString::fromLatin1(STEPS_PREFIX) + QString::number(i), m_steps.at(i)->toMap()); + + return map; +} + +bool BuildStepList::isNull() const +{ + return m_isNull; +} + +int BuildStepList::count() const +{ + return m_steps.count(); +} + +bool BuildStepList::isEmpty() const +{ + return m_steps.isEmpty(); +} + +bool BuildStepList::contains(const QString &id) const +{ + foreach (BuildStep *bs, steps()) { + if (bs->id() == id) + return true; + } + return false; +} + +void BuildStepList::cloneSteps(BuildStepList *source) +{ + Q_ASSERT(source); + foreach (BuildStep *originalbs, source->steps()) { + IBuildStepFactory *factory(findCloneFactory(this, originalbs)); + if (!factory) + continue; + BuildStep *clonebs(factory->clone(this, originalbs)); + if (clonebs) + m_steps.append(clonebs); + } +} + +bool BuildStepList::fromMap(const QVariantMap &map) +{ + if (!ProjectConfiguration::fromMap(map)) + return false; + + int maxSteps = map.value(QString::fromLatin1(STEPS_COUNT_KEY), 0).toInt(); + for (int i = 0; i < maxSteps; ++i) { + QVariantMap bsData(map.value(QString::fromLatin1(STEPS_PREFIX) + QString::number(i)).toMap()); + if (bsData.isEmpty()) { + qWarning() << "No step data found for" << i << "(continuing)."; + continue; + } + IBuildStepFactory *factory(findRestoreFactory(this, bsData)); + if (!factory) { + qWarning() << "No factory for step" << i << "found (continuing)."; + continue; + } + BuildStep *bs(factory->restore(this, bsData)); + if (!bs) { + qWarning() << "Restoration of step" << i << "failed (continuing)."; + continue; + } + insertStep(m_steps.count(), bs); + } + + return ProjectConfiguration::fromMap(map); +} + +QList<BuildStep *> BuildStepList::steps() const +{ + return m_steps; +} + +void BuildStepList::insertStep(int position, BuildStep *step) +{ + m_steps.insert(position, step); + emit stepInserted(position); +} + +bool BuildStepList::removeStep(int position) +{ + ProjectExplorer::BuildManager *bm = + ProjectExplorer::ProjectExplorerPlugin::instance()->buildManager(); + BuildStep *bs = at(position); + if (bm->isBuilding(bs)) + return false; + + emit aboutToRemoveStep(position); + m_steps.removeAt(position); + delete bs; + emit stepRemoved(position); + return true; +} + +void BuildStepList::moveStepUp(int position) +{ + m_steps.swap(position - 1, position); + emit stepMoved(position, position - 1); +} + +BuildStep *BuildStepList::at(int position) +{ + return m_steps.at(position); +} + +Target *BuildStepList::target() const +{ + Q_ASSERT(parent()); + BuildConfiguration *bc = qobject_cast<BuildConfiguration *>(parent()); + if (bc) + return bc->target(); + DeployConfiguration *dc = qobject_cast<DeployConfiguration *>(parent()); + if (dc) + return dc->target(); + Q_ASSERT(false); + return 0; +} diff --git a/src/plugins/projectexplorer/buildsteplist.h b/src/plugins/projectexplorer/buildsteplist.h new file mode 100644 index 0000000000..837756f941 --- /dev/null +++ b/src/plugins/projectexplorer/buildsteplist.h @@ -0,0 +1,89 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef PROJECTEXPLORER_BUILDSTEPLIST_H +#define PROJECTEXPLORER_BUILDSTEPLIST_H + +#include "projectexplorer_export.h" + +#include "projectconfiguration.h" + +#include <QtCore/QVariantMap> + +namespace ProjectExplorer { + +class BuildStep; +class Target; + +class PROJECTEXPLORER_EXPORT BuildStepList : public ProjectConfiguration +{ + Q_OBJECT + +public: + BuildStepList(QObject *parent, const QString &id); + BuildStepList(QObject *parent, BuildStepList *source); + BuildStepList(QObject *parent, const QVariantMap &data); + virtual ~BuildStepList(); + + QList<BuildStep *> steps() const; + bool isNull() const; + int count() const; + bool isEmpty() const; + bool contains(const QString &id) const; + + void insertStep(int position, BuildStep *step); + bool removeStep(int position); + void moveStepUp(int position); + BuildStep *at(int position); + + Target *target() const; + + virtual QVariantMap toMap() const; + +signals: + void stepInserted(int position); + void aboutToRemoveStep(int position); + void stepRemoved(int position); + void stepMoved(int from, int to); + +protected: + void cloneSteps(BuildStepList *source); + + virtual bool fromMap(const QVariantMap &map); + +private: + QList<BuildStep *> m_steps; + bool m_isNull; +}; + +} // namespace ProjectExplorer + +Q_DECLARE_METATYPE(ProjectExplorer::BuildStepList *); + +#endif // PROJECTEXPLORER_BUILDSTEPLIST_H diff --git a/src/plugins/projectexplorer/buildstepspage.cpp b/src/plugins/projectexplorer/buildstepspage.cpp index f6df541a56..7ea0a07265 100644 --- a/src/plugins/projectexplorer/buildstepspage.cpp +++ b/src/plugins/projectexplorer/buildstepspage.cpp @@ -28,8 +28,11 @@ **************************************************************************/ #include "buildstepspage.h" + #include "buildconfiguration.h" +#include "buildsteplist.h" #include "detailsbutton.h" +#include "projectexplorerconstants.h" #include <coreplugin/coreconstants.h> #include <coreplugin/icore.h> @@ -50,16 +53,15 @@ using namespace ProjectExplorer; using namespace ProjectExplorer::Internal; -BuildStepsPage::BuildStepsPage(Target *target, BuildStep::Type type) : - BuildConfigWidget(), - m_type(type), +BuildStepListWidget::BuildStepListWidget(QWidget *parent) : + NamedWidget(parent), + m_buildStepList(0), m_addButton(0) { - Q_UNUSED(target); setStyleSheet("background: red"); } -BuildStepsPage::~BuildStepsPage() +BuildStepListWidget::~BuildStepListWidget() { foreach(const BuildStepsWidgetStruct &s, m_buildSteps) { delete s.widget; @@ -68,7 +70,7 @@ BuildStepsPage::~BuildStepsPage() m_buildSteps.clear(); } -void BuildStepsPage::updateSummary() +void BuildStepListWidget::updateSummary() { BuildStepConfigWidget *widget = qobject_cast<BuildStepConfigWidget *>(sender()); if (widget) { @@ -81,23 +83,9 @@ void BuildStepsPage::updateSummary() } } -QString BuildStepsPage::displayName() const +void BuildStepListWidget::init(BuildStepList *bsl) { - switch(m_type) { - case BuildStep::Build: - return tr("Build Steps"); - case BuildStep::Deploy: - return tr("Deploy Steps"); - case BuildStep::Clean: - return tr("Clean Steps"); - default: - return tr("Unknown Steps"); - } -} - -void BuildStepsPage::init(BuildConfiguration *bc) -{ - QTC_ASSERT(bc, return); + Q_ASSERT(bsl); setupUi(); @@ -107,16 +95,17 @@ void BuildStepsPage::init(BuildConfiguration *bc) } m_buildSteps.clear(); - m_configuration = bc; + m_buildStepList = bsl; + //: %1 is the name returned by BuildStepList::displayName + setDisplayName(tr("%1 Steps").arg(m_buildStepList->displayName())); - const QList<BuildStep *> &steps = m_configuration->steps(m_type); - int i = 0; - foreach (BuildStep *bs, steps) { - addBuildStepWidget(i, bs); - ++i; - } + for (int i = 0; i < bsl->count(); ++i) + addBuildStepWidget(i, m_buildStepList->at(i)); - m_noStepsLabel->setVisible(steps.isEmpty()); + m_noStepsLabel->setVisible(bsl->isEmpty()); + m_noStepsLabel->setText(tr("No %1 Steps").arg(m_buildStepList->displayName())); + + m_addButton->setText(tr("Add %1 Step").arg(m_buildStepList->displayName())); // make sure widget is updated foreach(BuildStepsWidgetStruct s, m_buildSteps) { @@ -132,13 +121,13 @@ void BuildStepsPage::init(BuildConfiguration *bc) setStyleSheet(buttonStyle); } -void BuildStepsPage::updateAddBuildStepMenu() +void BuildStepListWidget::updateAddBuildStepMenu() { QMap<QString, QPair<QString, IBuildStepFactory *> > map; //Build up a list of possible steps and save map the display names to the (internal) name and factories. QList<IBuildStepFactory *> factories = ExtensionSystem::PluginManager::instance()->getObjects<IBuildStepFactory>(); foreach (IBuildStepFactory *factory, factories) { - QStringList ids = factory->availableCreationIds(m_configuration, m_type); + QStringList ids = factory->availableCreationIds(m_buildStepList); foreach (const QString &id, ids) { map.insert(factory->displayNameForId(id), QPair<QString, IBuildStepFactory *>(id, factory)); } @@ -160,7 +149,7 @@ void BuildStepsPage::updateAddBuildStepMenu() } } -void BuildStepsPage::addBuildStepWidget(int pos, BuildStep *step) +void BuildStepListWidget::addBuildStepWidget(int pos, BuildStep *step) { // create everything BuildStepsWidgetStruct s; @@ -222,13 +211,13 @@ void BuildStepsPage::addBuildStepWidget(int pos, BuildStep *step) m_removeMapper, SLOT(map())); } -void BuildStepsPage::addBuildStep() +void BuildStepListWidget::addBuildStep() { if (QAction *action = qobject_cast<QAction *>(sender())) { QPair<QString, IBuildStepFactory *> pair = m_addBuildStepHash.value(action); - BuildStep *newStep = pair.second->create(m_configuration, m_type, pair.first); - int pos = m_configuration->steps(m_type).count(); - m_configuration->insertStep(m_type, pos, newStep); + BuildStep *newStep = pair.second->create(m_buildStepList, pair.first); + int pos = m_buildStepList->count(); + m_buildStepList->insertStep(pos, newStep); addBuildStepWidget(pos, newStep); const BuildStepsWidgetStruct s = m_buildSteps.at(pos); @@ -239,9 +228,9 @@ void BuildStepsPage::addBuildStep() updateBuildStepButtonsState(); } -void BuildStepsPage::stepMoveUp(int pos) +void BuildStepListWidget::stepMoveUp(int pos) { - m_configuration->moveStepUp(m_type, pos); + m_buildStepList->moveStepUp(pos); m_vbox->insertWidget(pos - 1, m_buildSteps.at(pos).detailsWidget); @@ -250,14 +239,14 @@ void BuildStepsPage::stepMoveUp(int pos) updateBuildStepButtonsState(); } -void BuildStepsPage::stepMoveDown(int pos) +void BuildStepListWidget::stepMoveDown(int pos) { stepMoveUp(pos + 1); } -void BuildStepsPage::stepRemove(int pos) +void BuildStepListWidget::stepRemove(int pos) { - if (m_configuration->removeStep(m_type, pos)) { + if (m_buildStepList->removeStep(pos)) { BuildStepsWidgetStruct s = m_buildSteps.at(pos); delete s.widget; delete s.detailsWidget; @@ -265,7 +254,7 @@ void BuildStepsPage::stepRemove(int pos) updateBuildStepButtonsState(); - bool hasSteps = m_configuration->steps(m_type).isEmpty(); + bool hasSteps = m_buildStepList->isEmpty(); m_noStepsLabel->setVisible(hasSteps); } else { QMessageBox::warning(Core::ICore::instance()->mainWindow(), @@ -275,7 +264,7 @@ void BuildStepsPage::stepRemove(int pos) } } -void BuildStepsPage::setupUi() +void BuildStepListWidget::setupUi() { if (0 != m_addButton) return; @@ -301,19 +290,6 @@ void BuildStepsPage::setupUi() QHBoxLayout *hboxLayout = new QHBoxLayout(); hboxLayout->setContentsMargins(0, 4, 0, 0); m_addButton = new QPushButton(this); - switch (m_type) { - case BuildStep::Clean: - m_addButton->setText(tr("Add Clean Step")); - break; - case BuildStep::Build: - m_addButton->setText(tr("Add Build Step")); - break; - case BuildStep::Deploy: - m_addButton->setText(tr("Add Deploy Step")); - break; - default: - m_addButton->setText(tr("Add Step")); - } m_addButton->setMenu(new QMenu(this)); hboxLayout->addWidget(m_addButton); @@ -329,21 +305,69 @@ void BuildStepsPage::setupUi() this, SLOT(updateAddBuildStepMenu())); } -void BuildStepsPage::updateBuildStepButtonsState() +void BuildStepListWidget::updateBuildStepButtonsState() { - const QList<BuildStep *> &steps = m_configuration->steps(m_type); for(int i = 0; i < m_buildSteps.count(); ++i) { BuildStepsWidgetStruct s = m_buildSteps.at(i); - s.removeButton->setEnabled(!steps.at(i)->immutable()); + s.removeButton->setEnabled(!m_buildStepList->at(i)->immutable()); m_removeMapper->setMapping(s.removeButton, i); - s.upButton->setEnabled((i > 0) && !(steps.at(i)->immutable() && steps.at(i - 1))); + s.upButton->setEnabled((i > 0) + && !(m_buildStepList->at(i)->immutable() + && m_buildStepList->at(i - 1))); m_upMapper->setMapping(s.upButton, i); - s.downButton->setEnabled((i + 1 < steps.count()) && !(steps.at(i)->immutable() && steps.at(i + 1)->immutable())); + s.downButton->setEnabled((i + 1 < m_buildStepList->count()) + && !(m_buildStepList->at(i)->immutable() + && m_buildStepList->at(i + 1)->immutable())); m_downMapper->setMapping(s.downButton, i); // Only show buttons when needed - s.downButton->setVisible(steps.count() != 1); - s.upButton->setVisible(steps.count() != 1); + s.downButton->setVisible(m_buildStepList->count() != 1); + s.upButton->setVisible(m_buildStepList->count() != 1); } } + +BuildStepsPage::BuildStepsPage(Target *target, const QString &id) : + BuildConfigWidget(), + m_id(id), + m_widget(new BuildStepListWidget(this)) +{ + Q_UNUSED(target); + QVBoxLayout *layout = new QVBoxLayout(this); + layout->setMargin(0); + layout->setSpacing(0); + layout->addWidget(m_widget); +} + +BuildStepsPage::~BuildStepsPage() +{ } + +QString BuildStepsPage::displayName() const +{ + if (m_id == QLatin1String(Constants::BUILDSTEPS_BUILD)) + return tr("Build Steps"); + if (m_id == QLatin1String(Constants::BUILDSTEPS_CLEAN)) + return tr("Clean Steps"); + return QString(); +} + +void BuildStepsPage::init(BuildConfiguration *bc) +{ + m_widget->init(bc->stepList(m_id)); +} + +DeployConfigurationStepsWidget::DeployConfigurationStepsWidget(QWidget *parent) : + DeployConfigurationWidget(parent), + m_widget(new BuildStepListWidget(this)) +{ + QVBoxLayout *layout = new QVBoxLayout(this); + layout->setMargin(0); + layout->setSpacing(0); + layout->addWidget(m_widget); +} + +void DeployConfigurationStepsWidget::init(DeployConfiguration *dc) +{ + m_widget->init(dc->stepList()); + setDisplayName(m_widget->displayName()); +} diff --git a/src/plugins/projectexplorer/buildstepspage.h b/src/plugins/projectexplorer/buildstepspage.h index 58be605c0a..dea421dfb3 100644 --- a/src/plugins/projectexplorer/buildstepspage.h +++ b/src/plugins/projectexplorer/buildstepspage.h @@ -31,7 +31,9 @@ #define BUILDSTEPSPAGE_H #include "buildstep.h" -#include "buildconfiguration.h" +#include "deployconfiguration.h" +#include "namedwidget.h" + #include <utils/detailswidget.h> QT_BEGIN_NAMESPACE @@ -49,10 +51,6 @@ class BuildConfiguration; namespace Internal { -namespace Ui { - class BuildStepsPage; -} - struct BuildStepsWidgetStruct { BuildStepConfigWidget *widget; @@ -62,16 +60,15 @@ struct BuildStepsWidgetStruct QToolButton *removeButton; }; -class BuildStepsPage : public BuildConfigWidget +class BuildStepListWidget : public NamedWidget { Q_OBJECT public: - explicit BuildStepsPage(Target *target, BuildStep::Type type); - virtual ~BuildStepsPage(); + BuildStepListWidget(QWidget *parent = 0); + virtual ~BuildStepListWidget(); - QString displayName() const; - void init(BuildConfiguration *bc); + void init(BuildStepList *bsl); private slots: void updateAddBuildStepMenu(); @@ -86,11 +83,10 @@ private: void updateBuildStepButtonsState(); void addBuildStepWidget(int pos, BuildStep *step); - BuildConfiguration * m_configuration; + BuildStepList *m_buildStepList; QHash<QAction *, QPair<QString, ProjectExplorer::IBuildStepFactory *> > m_addBuildStepHash; - BuildStep::Type m_type; - QList<BuildStepsWidgetStruct> m_buildSteps; + QList<Internal::BuildStepsWidgetStruct> m_buildSteps; QVBoxLayout *m_vbox; @@ -104,6 +100,37 @@ private: int m_leftMargin; }; +namespace Ui { + class BuildStepsPage; +} + +class BuildStepsPage : public BuildConfigWidget +{ + Q_OBJECT + +public: + BuildStepsPage(Target *target, const QString &id); + virtual ~BuildStepsPage(); + + QString displayName() const; + void init(BuildConfiguration *bc); + +private: + QString m_id; + BuildStepListWidget *m_widget; +}; + +class DeployConfigurationStepsWidget : public DeployConfigurationWidget +{ +public: + explicit DeployConfigurationStepsWidget(QWidget *parent = 0); + + void init(DeployConfiguration *dc); + +private: + BuildStepListWidget *m_widget; +}; + } // Internal } // ProjectExplorer diff --git a/src/plugins/projectexplorer/deployconfiguration.cpp b/src/plugins/projectexplorer/deployconfiguration.cpp new file mode 100644 index 0000000000..175ff45fcf --- /dev/null +++ b/src/plugins/projectexplorer/deployconfiguration.cpp @@ -0,0 +1,203 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "deployconfiguration.h" + +#include "buildmanager.h" +#include "buildsteplist.h" +#include "buildstepspage.h" +#include "projectexplorer.h" +#include "projectexplorerconstants.h" +#include "target.h" + +using namespace ProjectExplorer; + +namespace { + +const char * const BUILD_STEP_LIST_COUNT("ProjectExplorer.BuildConfiguration.BuildStepListCount"); +const char * const BUILD_STEP_LIST_PREFIX("ProjectExplorer.BuildConfiguration.BuildStepList."); + +} // namespace + +DeployConfiguration::DeployConfiguration(Target *target, const QString &id) : + ProjectConfiguration(target, id), + m_stepList(0) +{ + Q_ASSERT(target); + m_stepList = new BuildStepList(this, QLatin1String(Constants::BUILDSTEPS_DEPLOY)); + //: Display name of the deploy build step list. Used as part of the labels in the project window. + m_stepList->setDisplayName(tr("Deploy")); + setDisplayName(tr("No deployment")); +} + +DeployConfiguration::DeployConfiguration(Target *target, DeployConfiguration *source) : + ProjectConfiguration(target, source) +{ + Q_ASSERT(target); + // Do not clone stepLists here, do that in the derived constructor instead + // otherwise BuildStepFactories might reject to set up a BuildStep for us + // since we are not yet the derived class! +} + +DeployConfiguration::~DeployConfiguration() +{ + delete m_stepList; +} + +BuildStepList *DeployConfiguration::stepList() const +{ + return m_stepList; +} + +QVariantMap DeployConfiguration::toMap() const +{ + QVariantMap map(ProjectConfiguration::toMap()); + map.insert(QLatin1String(BUILD_STEP_LIST_COUNT), 1); + map.insert(QLatin1String(BUILD_STEP_LIST_PREFIX) % QLatin1String("0"), m_stepList->toMap()); + + return map; +} + +DeployConfigurationWidget *DeployConfiguration::configurationWidget() const +{ + return 0; +} + +bool DeployConfiguration::fromMap(const QVariantMap &map) +{ + if (!ProjectConfiguration::fromMap(map)) + return false; + + int maxI = map.value(QLatin1String(BUILD_STEP_LIST_COUNT), 0).toInt(); + Q_ASSERT(maxI == 1); + QVariantMap data = map.value(QLatin1String(BUILD_STEP_LIST_PREFIX) % QLatin1String("0")).toMap(); + if (!data.isEmpty()) { + m_stepList = new BuildStepList(this, data); + if (m_stepList->isNull()) { + qWarning() << "Failed to restore deploy step list"; + delete m_stepList; + m_stepList = 0; + return false; + } + } else { + qWarning() << "No data for deploy step list found!"; + } + + // TODO: We assume that we have hold the deploy list + Q_ASSERT(m_stepList && m_stepList->id() == QLatin1String(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY)); + + return true; +} + +Target *DeployConfiguration::target() const +{ + return static_cast<Target *>(parent()); +} + +void DeployConfiguration::cloneSteps(DeployConfiguration *source) +{ + if (source == this) + return; + delete m_stepList; + m_stepList = new BuildStepList(this, source->stepList()); +} + +/// +// DeployConfigurationFactory +/// + +DeployConfigurationFactory::DeployConfigurationFactory(QObject *parent) : + QObject(parent) +{ } + +DeployConfigurationFactory::~DeployConfigurationFactory() +{ } + +QStringList DeployConfigurationFactory::availableCreationIds(Target *parent) const +{ + Q_UNUSED(parent); + return QStringList() << QLatin1String(Constants::DEFAULT_DEPLOYCONFIGURATION_ID); +} + +QString DeployConfigurationFactory::displayNameForId(const QString &id) const +{ + if (id == QLatin1String(Constants::DEFAULT_DEPLOYCONFIGURATION_ID)) + //: Display name of the default deploy configuration + return tr("Deploy Configuration"); + return QString(); +} + +bool DeployConfigurationFactory::canCreate(Target *parent, const QString &id) const +{ + Q_UNUSED(parent); + return id == QLatin1String(Constants::DEFAULT_DEPLOYCONFIGURATION_ID); +} + +DeployConfiguration *DeployConfigurationFactory::create(Target *parent, const QString &id) +{ + if (!canCreate(parent, id)) + return 0; + return new DeployConfiguration(parent, id); +} + +bool DeployConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const +{ + return canCreate(parent, idFromMap(map)); +} + +DeployConfiguration *DeployConfigurationFactory::restore(Target *parent, const QVariantMap &map) +{ + if (!canRestore(parent, map)) + return 0; + DeployConfiguration *dc = new DeployConfiguration(parent, idFromMap(map)); + if (!dc->fromMap(map)) { + delete dc; + return 0; + } + return dc; +} + +bool DeployConfigurationFactory::canClone(Target *parent, DeployConfiguration *product) const +{ + return canCreate(parent, product->id()); +} + +DeployConfiguration *DeployConfigurationFactory::clone(Target *parent, DeployConfiguration *product) +{ + if (!canClone(parent, product)) + return 0; + return new DeployConfiguration(parent, product); +} + +/// +// DeployConfigurationWidget +/// + +DeployConfigurationWidget::DeployConfigurationWidget(QWidget *parent) : NamedWidget(parent) +{ } diff --git a/src/plugins/projectexplorer/deployconfiguration.h b/src/plugins/projectexplorer/deployconfiguration.h new file mode 100644 index 0000000000..95dca80f8d --- /dev/null +++ b/src/plugins/projectexplorer/deployconfiguration.h @@ -0,0 +1,122 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef PROJECTEXPLORER_DEPLOYCONFIGURATION_H +#define PROJECTEXPLORER_DEPLOYCONFIGURATION_H + +#include "projectexplorer_export.h" +#include "environment.h" +#include "namedwidget.h" + +#include <QtCore/QString> +#include <QtCore/QStringList> +#include <QtCore/QList> +#include <QtCore/QObject> + +#include "projectconfiguration.h" + +namespace ProjectExplorer { + +class BuildStepList; +class Target; +class DeployConfigurationFactory; +class DeployConfigurationWidget; + +class PROJECTEXPLORER_EXPORT DeployConfiguration : public ProjectConfiguration +{ + Q_OBJECT + +public: + // ctors are protected + virtual ~DeployConfiguration(); + + BuildStepList *stepList() const; + + virtual QVariantMap toMap() const; + + virtual DeployConfigurationWidget *configurationWidget() const; + + Target *target() const; + +protected: + DeployConfiguration(Target *target, const QString &id); + DeployConfiguration(Target *target, DeployConfiguration *source); + + void cloneSteps(DeployConfiguration *source); + + virtual bool fromMap(const QVariantMap &map); + +private: + friend class DeployConfigurationFactory; + + BuildStepList *m_stepList; +}; + +class PROJECTEXPLORER_EXPORT DeployConfigurationFactory : + public QObject +{ + Q_OBJECT + +public: + explicit DeployConfigurationFactory(QObject *parent = 0); + virtual ~DeployConfigurationFactory(); + + // used to show the list of possible additons to a target, returns a list of types + virtual QStringList availableCreationIds(Target *parent) const; + // used to translate the types to names to display to the user + virtual QString displayNameForId(const QString &id) const; + + virtual bool canCreate(Target *parent, const QString &id) const; + virtual DeployConfiguration *create(Target *parent, const QString &id); + // used to recreate the runConfigurations when restoring settings + virtual bool canRestore(Target *parent, const QVariantMap &map) const; + virtual DeployConfiguration *restore(Target *parent, const QVariantMap &map); + virtual bool canClone(Target *parent, DeployConfiguration *product) const; + virtual DeployConfiguration *clone(Target *parent, DeployConfiguration *product); + +signals: + void availableCreationIdsChanged(); +}; + +class PROJECTEXPLORER_EXPORT DeployConfigurationWidget : public NamedWidget +{ + Q_OBJECT + +public: + explicit DeployConfigurationWidget(QWidget *parent = 0); + + // This is called to set up the config widget before showing it + virtual void init(DeployConfiguration *dc) = 0; +}; + +} // namespace ProjectExplorer + +Q_DECLARE_METATYPE(ProjectExplorer::DeployConfiguration *); + +#endif // PROJECTEXPLORER_DEPLOYCONFIGURATION_H diff --git a/src/plugins/projectexplorer/deployconfigurationmodel.cpp b/src/plugins/projectexplorer/deployconfigurationmodel.cpp new file mode 100644 index 0000000000..301364f2fd --- /dev/null +++ b/src/plugins/projectexplorer/deployconfigurationmodel.cpp @@ -0,0 +1,181 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "deployconfigurationmodel.h" +#include "target.h" +#include "deployconfiguration.h" + +using namespace ProjectExplorer; + +/// +/// DeployConfigurationsModel +/// + +class DeployConfigurationComparer +{ +public: + bool operator()(DeployConfiguration *a, DeployConfiguration *b) + { + return a->displayName() < b->displayName(); + } +}; + +DeployConfigurationModel::DeployConfigurationModel(Target *target, QObject *parent) + : QAbstractListModel(parent), + m_target(target) +{ + m_deployConfigurations = m_target->deployConfigurations(); + qSort(m_deployConfigurations.begin(), m_deployConfigurations.end(), DeployConfigurationComparer()); + + connect(target, SIGNAL(addedDeployConfiguration(ProjectExplorer::DeployConfiguration*)), + this, SLOT(addedDeployConfiguration(ProjectExplorer::DeployConfiguration*))); + connect(target, SIGNAL(removedDeployConfiguration(ProjectExplorer::DeployConfiguration*)), + this, SLOT(removedDeployConfiguration(ProjectExplorer::DeployConfiguration*))); + + foreach (DeployConfiguration *dc, m_deployConfigurations) + connect(dc, SIGNAL(displayNameChanged()), + this, SLOT(displayNameChanged())); +} + +int DeployConfigurationModel::rowCount(const QModelIndex &parent) const +{ + return parent.isValid() ? 0 : m_deployConfigurations.size(); +} + +int DeployConfigurationModel::columnCount(const QModelIndex &parent) const +{ + return parent.isValid() ? 0 : 1; +} + +void DeployConfigurationModel::displayNameChanged() +{ + DeployConfiguration *dc = qobject_cast<DeployConfiguration *>(sender()); + if (!dc) + return; + + DeployConfigurationComparer compare; + // Find the old position + int oldPos = m_deployConfigurations.indexOf(dc); + + if (oldPos >= 1 && compare(m_deployConfigurations.at(oldPos), m_deployConfigurations.at(oldPos - 1))) { + // We need to move up + int newPos = oldPos - 1; + while (newPos >= 0 && compare(m_deployConfigurations.at(oldPos), m_deployConfigurations.at(newPos))) { + --newPos; + } + ++newPos; + + beginMoveRows(QModelIndex(), oldPos, oldPos, QModelIndex(), newPos); + m_deployConfigurations.insert(newPos, dc); + m_deployConfigurations.removeAt(oldPos + 1); + endMoveRows(); + // Not only did we move, we also changed... + emit dataChanged(index(newPos, 0), index(newPos,0)); + } else if (oldPos < m_deployConfigurations.size() - 1 + && compare(m_deployConfigurations.at(oldPos + 1), m_deployConfigurations.at(oldPos))) { + // We need to move down + int newPos = oldPos + 1; + while (newPos < m_deployConfigurations.size() + && compare(m_deployConfigurations.at(newPos), m_deployConfigurations.at(oldPos))) { + ++newPos; + } + beginMoveRows(QModelIndex(), oldPos, oldPos, QModelIndex(), newPos); + m_deployConfigurations.insert(newPos, dc); + m_deployConfigurations.removeAt(oldPos); + endMoveRows(); + + // We need to subtract one since removing at the old place moves the newIndex down + emit dataChanged(index(newPos - 1, 0), index(newPos - 1, 0)); + } else { + emit dataChanged(index(oldPos, 0), index(oldPos, 0)); + } +} + +QVariant DeployConfigurationModel::data(const QModelIndex &index, int role) const +{ + if (role == Qt::DisplayRole) { + const int row = index.row(); + if (row < m_deployConfigurations.size()) { + return m_deployConfigurations.at(row)->displayName(); + } + } + + return QVariant(); +} + +DeployConfiguration *DeployConfigurationModel::deployConfigurationAt(int i) +{ + if (i > m_deployConfigurations.size() || i < 0) + return 0; + return m_deployConfigurations.at(i); +} + +DeployConfiguration *DeployConfigurationModel::deployConfigurationFor(const QModelIndex &idx) +{ + if (idx.row() > m_deployConfigurations.size() || idx.row() < 0) + return 0; + return m_deployConfigurations.at(idx.row()); +} + +QModelIndex DeployConfigurationModel::indexFor(DeployConfiguration *rc) +{ + int idx = m_deployConfigurations.indexOf(rc); + if (idx == -1) + return QModelIndex(); + return index(idx, 0); +} + +void DeployConfigurationModel::addedDeployConfiguration(ProjectExplorer::DeployConfiguration *dc) +{ + // Find the right place to insert + DeployConfigurationComparer compare; + int i = 0; + for (; i < m_deployConfigurations.size(); ++i) { + if (compare(dc, m_deployConfigurations.at(i))) { + break; + } + } + + beginInsertRows(QModelIndex(), i, i); + m_deployConfigurations.insert(i, dc); + endInsertRows(); + + connect(dc, SIGNAL(displayNameChanged()), + this, SLOT(displayNameChanged())); +} + +void DeployConfigurationModel::removedDeployConfiguration(ProjectExplorer::DeployConfiguration *dc) +{ + int i = m_deployConfigurations.indexOf(dc); + if (i < 0) + return; + beginRemoveRows(QModelIndex(), i, i); + m_deployConfigurations.removeAt(i); + endRemoveRows(); +} diff --git a/src/plugins/projectexplorer/deployconfigurationmodel.h b/src/plugins/projectexplorer/deployconfigurationmodel.h new file mode 100644 index 0000000000..26f5534709 --- /dev/null +++ b/src/plugins/projectexplorer/deployconfigurationmodel.h @@ -0,0 +1,68 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef PROJECTEXPLORER_DEPLOYCONFIGURATIONMODEL_H +#define PROJECTEXPLORER_DEPLOYCONFIGURATIONMODEL_H + +#include <QtCore/QAbstractItemModel> + +namespace ProjectExplorer { + +class Target; +class DeployConfiguration; + +/*! A model to represent the run configurations of a target. + To be used in for the drop down of comboboxes + Does automatically adjust itself to added and removed RunConfigurations +*/ +class DeployConfigurationModel : public QAbstractListModel +{ + Q_OBJECT +public: + DeployConfigurationModel(Target *target, QObject *parent = 0); + + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + + DeployConfiguration *deployConfigurationAt(int i); + DeployConfiguration *deployConfigurationFor(const QModelIndex &idx); + QModelIndex indexFor(DeployConfiguration *rc); +private slots: + void addedDeployConfiguration(ProjectExplorer::DeployConfiguration*); + void removedDeployConfiguration(ProjectExplorer::DeployConfiguration*); + void displayNameChanged(); +private: + Target *m_target; + QList<DeployConfiguration *> m_deployConfigurations; +}; + +} // namespace ProjectExplorer + +#endif // PROJECTEXPLORER_DEPLOYCONFIGURATIONMODEL_H diff --git a/src/plugins/projectexplorer/namedwidget.cpp b/src/plugins/projectexplorer/namedwidget.cpp new file mode 100644 index 0000000000..c1b3f56562 --- /dev/null +++ b/src/plugins/projectexplorer/namedwidget.cpp @@ -0,0 +1,52 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "namedwidget.h" + +using namespace ProjectExplorer; + +/// +// NamedWidget +/// + +NamedWidget::NamedWidget(QWidget *parent) : QWidget(parent) +{ } + +QString NamedWidget::displayName() const +{ + return m_displayName; +} + +void NamedWidget::setDisplayName(const QString &displayName) +{ + if (m_displayName == displayName) + return; + m_displayName = displayName; + emit displayNameChanged(m_displayName); +} diff --git a/src/plugins/projectexplorer/namedwidget.h b/src/plugins/projectexplorer/namedwidget.h new file mode 100644 index 0000000000..5e7947c354 --- /dev/null +++ b/src/plugins/projectexplorer/namedwidget.h @@ -0,0 +1,60 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef PROJECTEXPLORER_NAMEDWIDGET_H +#define PROJECTEXPLORER_NAMEDWIDGET_H + +#include "projectexplorer_export.h" + +#include <QtGui/QWidget> + +namespace ProjectExplorer { + +class PROJECTEXPLORER_EXPORT NamedWidget : public QWidget +{ + Q_OBJECT + +public: + NamedWidget(QWidget *parent = 0); + + QString displayName() const; + +signals: + void displayNameChanged(const QString &); + +protected: + void setDisplayName(const QString &displayName); + +private: + QString m_displayName; +}; + +} // namespace ProjectExplorer + +#endif // PROJECTEXPLORER_NAMEDWIDGET_H diff --git a/src/plugins/projectexplorer/processstep.cpp b/src/plugins/projectexplorer/processstep.cpp index 7254dc59c7..d47a83266d 100644 --- a/src/plugins/projectexplorer/processstep.cpp +++ b/src/plugins/projectexplorer/processstep.cpp @@ -50,20 +50,20 @@ const char * const PROCESS_ARGUMENTS_KEY("ProjectExplorer.ProcessStep.Arguments" const char * const PROCESS_ENABLED_KEY("ProjectExplorer.ProcessStep.Enabled"); } -ProcessStep::ProcessStep(BuildConfiguration *bc) : - AbstractProcessStep(bc, QLatin1String(PROCESS_STEP_ID)) +ProcessStep::ProcessStep(BuildStepList *bsl) : + AbstractProcessStep(bsl, QLatin1String(PROCESS_STEP_ID)) { ctor(); } -ProcessStep::ProcessStep(BuildConfiguration *bc, const QString &id) : - AbstractProcessStep(bc, id) +ProcessStep::ProcessStep(BuildStepList *bsl, const QString &id) : + AbstractProcessStep(bsl, id) { ctor(); } -ProcessStep::ProcessStep(BuildConfiguration *bc, ProcessStep *bs) : - AbstractProcessStep(bc, bs), +ProcessStep::ProcessStep(BuildStepList *bsl, ProcessStep *bs) : + AbstractProcessStep(bsl, bs), m_name(bs->m_name), m_command(bs->m_command), m_arguments(bs->m_arguments), @@ -85,16 +85,17 @@ ProcessStep::~ProcessStep() bool ProcessStep::init() { - setEnvironment(buildConfiguration()->environment()); + BuildConfiguration *bc = buildConfiguration(); + setEnvironment(bc->environment()); QString wd = workingDirectory(); if (wd.isEmpty()) wd = "$BUILDDIR"; - AbstractProcessStep::setWorkingDirectory(wd.replace("$BUILDDIR", buildConfiguration()->buildDirectory())); + AbstractProcessStep::setWorkingDirectory(wd.replace("$BUILDDIR", bc->buildDirectory())); AbstractProcessStep::setCommand(m_command); AbstractProcessStep::setEnabled(m_enabled); AbstractProcessStep::setArguments(m_arguments); - setOutputParser(buildConfiguration()->createOutputParser()); + setOutputParser(bc->createOutputParser()); return AbstractProcessStep::init(); } @@ -185,41 +186,40 @@ ProcessStepFactory::~ProcessStepFactory() { } -bool ProcessStepFactory::canCreate(BuildConfiguration *parent, BuildStep::Type type, const QString &id) const +bool ProcessStepFactory::canCreate(BuildStepList *parent, const QString &id) const { Q_UNUSED(parent); - Q_UNUSED(type); return id == QLatin1String(PROCESS_STEP_ID); } -BuildStep *ProcessStepFactory::create(BuildConfiguration *parent, BuildStep::Type type, const QString &id) +BuildStep *ProcessStepFactory::create(BuildStepList *parent, const QString &id) { - if (!canCreate(parent, type, id)) + if (!canCreate(parent, id)) return 0; return new ProcessStep(parent); } -bool ProcessStepFactory::canClone(BuildConfiguration *parent, BuildStep::Type type, BuildStep *bs) const +bool ProcessStepFactory::canClone(BuildStepList *parent, BuildStep *bs) const { - return canCreate(parent, type, bs->id()); + return canCreate(parent, bs->id()); } -BuildStep *ProcessStepFactory::clone(BuildConfiguration *parent, BuildStep::Type type, BuildStep *bs) +BuildStep *ProcessStepFactory::clone(BuildStepList *parent, BuildStep *bs) { - if (!canClone(parent, type, bs)) + if (!canClone(parent, bs)) return 0; return new ProcessStep(parent, static_cast<ProcessStep *>(bs)); } -bool ProcessStepFactory::canRestore(BuildConfiguration *parent, BuildStep::Type type, const QVariantMap &map) const +bool ProcessStepFactory::canRestore(BuildStepList *parent, const QVariantMap &map) const { QString id(ProjectExplorer::idFromMap(map)); - return canCreate(parent, type, id); + return canCreate(parent, id); } -BuildStep *ProcessStepFactory::restore(BuildConfiguration *parent, BuildStep::Type type, const QVariantMap &map) +BuildStep *ProcessStepFactory::restore(BuildStepList *parent, const QVariantMap &map) { - if (!canRestore(parent, type, map)) + if (!canRestore(parent, map)) return 0; ProcessStep *bs(new ProcessStep(parent)); @@ -229,10 +229,9 @@ BuildStep *ProcessStepFactory::restore(BuildConfiguration *parent, BuildStep::Ty return 0; } -QStringList ProcessStepFactory::availableCreationIds(BuildConfiguration *parent, BuildStep::Type type) const +QStringList ProcessStepFactory::availableCreationIds(BuildStepList *parent) const { Q_UNUSED(parent); - Q_UNUSED(type); return QStringList() << QLatin1String(PROCESS_STEP_ID); } QString ProcessStepFactory::displayNameForId(const QString &id) const diff --git a/src/plugins/projectexplorer/processstep.h b/src/plugins/projectexplorer/processstep.h index 62358cbf80..b2525d024f 100644 --- a/src/plugins/projectexplorer/processstep.h +++ b/src/plugins/projectexplorer/processstep.h @@ -46,15 +46,15 @@ public: ProcessStepFactory(); ~ProcessStepFactory(); - virtual QStringList availableCreationIds(BuildConfiguration *parent, BuildStep::Type type) const; + virtual QStringList availableCreationIds(BuildStepList *parent) const; virtual QString displayNameForId(const QString &id) const; - virtual bool canCreate(BuildConfiguration *parent, BuildStep::Type type, const QString &id) const; - virtual BuildStep *create(BuildConfiguration *parent, BuildStep::Type type, const QString &id); - virtual bool canRestore(BuildConfiguration *parent, BuildStep::Type type, const QVariantMap &map) const; - virtual BuildStep *restore(BuildConfiguration *parent, BuildStep::Type type, const QVariantMap &map); - virtual bool canClone(BuildConfiguration *parent, BuildStep::Type type, BuildStep *product) const; - virtual BuildStep *clone(BuildConfiguration *parent, BuildStep::Type type, BuildStep *product); + virtual bool canCreate(BuildStepList *parent, const QString &id) const; + virtual BuildStep *create(BuildStepList *parent, const QString &id); + virtual bool canRestore(BuildStepList *parent, const QVariantMap &map) const; + virtual BuildStep *restore(BuildStepList *parent, const QVariantMap &map); + virtual bool canClone(BuildStepList *parent, BuildStep *product) const; + virtual BuildStep *clone(BuildStepList *parent, BuildStep *product); }; class ProcessStep : public ProjectExplorer::AbstractProcessStep @@ -63,7 +63,7 @@ class ProcessStep : public ProjectExplorer::AbstractProcessStep friend class ProcessStepFactory; public: - explicit ProcessStep(BuildConfiguration *bc); + explicit ProcessStep(BuildStepList *bsl); virtual ~ProcessStep(); virtual bool init(); @@ -85,8 +85,8 @@ public: QVariantMap toMap() const; protected: - ProcessStep(BuildConfiguration *bc, ProcessStep *bs); - ProcessStep(BuildConfiguration *bc, const QString &id); + ProcessStep(BuildStepList *bsl, ProcessStep *bs); + ProcessStep(BuildStepList *bsl, const QString &id); bool fromMap(const QVariantMap &map); diff --git a/src/plugins/projectexplorer/project.cpp b/src/plugins/projectexplorer/project.cpp index 12c47ee454..ae819f3504 100644 --- a/src/plugins/projectexplorer/project.cpp +++ b/src/plugins/projectexplorer/project.cpp @@ -40,8 +40,6 @@ #include <extensionsystem/pluginmanager.h> #include <utils/qtcassert.h> -#include <QtCore/QDebug> - using namespace ProjectExplorer; using namespace ProjectExplorer::Internal; @@ -51,6 +49,7 @@ const char * const TARGET_KEY_PREFIX("ProjectExplorer.Project.Target."); const char * const TARGET_COUNT_KEY("ProjectExplorer.Project.TargetCount"); const char * const EDITOR_SETTINGS_KEY("ProjectExplorer.Project.EditorSettings"); + } // namespace // ------------------------------------------------------------------------- diff --git a/src/plugins/projectexplorer/projectconfiguration.cpp b/src/plugins/projectexplorer/projectconfiguration.cpp index ca8c0f7c1a..4c76cf9531 100644 --- a/src/plugins/projectexplorer/projectconfiguration.cpp +++ b/src/plugins/projectexplorer/projectconfiguration.cpp @@ -36,23 +36,23 @@ const char * const CONFIGURATION_ID_KEY("ProjectExplorer.ProjectConfiguration.Id const char * const DISPLAY_NAME_KEY("ProjectExplorer.ProjectConfiguration.DisplayName"); } -ProjectConfiguration::ProjectConfiguration(const QString &id) : +ProjectConfiguration::ProjectConfiguration(QObject *parent, const QString &id) : + QObject(parent), m_id(id) { Q_ASSERT(!m_id.isEmpty()); } -ProjectConfiguration::ProjectConfiguration(ProjectConfiguration *config) +ProjectConfiguration::ProjectConfiguration(QObject *parent, const ProjectConfiguration *source) : + QObject(parent) { - Q_ASSERT(config); - m_id = config->m_id; - m_displayName = tr("Clone of %1").arg(config->displayName()); - Q_ASSERT(!m_id.isEmpty()); + Q_ASSERT(source); + m_id = source->m_id; + m_displayName = tr("Clone of %1").arg(source->displayName()); } ProjectConfiguration::~ProjectConfiguration() -{ -} +{ } QString ProjectConfiguration::id() const { diff --git a/src/plugins/projectexplorer/projectconfiguration.h b/src/plugins/projectexplorer/projectconfiguration.h index 21bb41d39a..4de8fcc869 100644 --- a/src/plugins/projectexplorer/projectconfiguration.h +++ b/src/plugins/projectexplorer/projectconfiguration.h @@ -59,13 +59,15 @@ signals: void displayNameChanged(); protected: - ProjectConfiguration(const QString &id); - ProjectConfiguration(ProjectConfiguration *config); + ProjectConfiguration(QObject *parent, const QString &id); + ProjectConfiguration(QObject *parent, const ProjectConfiguration *source); // Note: Make sure subclasses call the superclasses toMap() method! virtual bool fromMap(const QVariantMap &map); private: + Q_DISABLE_COPY(ProjectConfiguration) + QString m_id; QString m_displayName; }; diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 2b5a1ea591..64ae1cb378 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -29,6 +29,8 @@ #include "projectexplorer.h" +#include "buildsteplist.h" +#include "deployconfiguration.h" #include "project.h" #include "projectexplorersettings.h" #include "target.h" @@ -1482,221 +1484,141 @@ bool ProjectExplorerPlugin::saveModifiedFiles() //NBS handle case where there is no activeBuildConfiguration // because someone delete all build configurations -void ProjectExplorerPlugin::buildProjectOnly() +void ProjectExplorerPlugin::deploy(QList<Project *> projects) { - if (debug) - qDebug() << "ProjectExplorerPlugin::buildProjectOnly"; - - if (saveModifiedFiles()) - buildManager()->buildProject(session()->startupProject()->activeTarget()->activeBuildConfiguration()); + QStringList steps; + if (d->m_projectExplorerSettings.buildBeforeDeploy) + steps << Constants::BUILDSTEPS_BUILD; + steps << Constants::BUILDSTEPS_DEPLOY; + queue(projects, steps); } -void ProjectExplorerPlugin::buildProject() +int ProjectExplorerPlugin::queue(QList<Project *> projects, QStringList stepIds) { - if (debug) - qDebug() << "ProjectExplorerPlugin::buildProject"; + if (debug) { + QStringList projectNames; + foreach (Project *p, projects) + projectNames << p->displayName(); + qDebug() << "Building" << stepIds << "for projects" << projectNames; + } - if (saveModifiedFiles()) { - QList<BuildConfiguration *> configurations; - foreach (Project *pro, d->m_session->projectOrder(session()->startupProject())) - if (pro->activeTarget()->activeBuildConfiguration()) - configurations << pro->activeTarget()->activeBuildConfiguration(); + if (!saveModifiedFiles()) + return -1; - d->m_buildManager->buildProjects(configurations); + QList<BuildStepList *> stepLists; + foreach (Project *pro, projects) { + if (!pro || !pro->activeTarget()) + continue; + foreach (const QString id, stepIds) { + BuildStepList *bsl = 0; + if (id == QLatin1String(Constants::BUILDSTEPS_DEPLOY) + && pro->activeTarget()->activeDeployConfiguration()) + bsl = pro->activeTarget()->activeDeployConfiguration()->stepList(); + else if (pro->activeTarget()->activeBuildConfiguration()) + bsl = pro->activeTarget()->activeBuildConfiguration()->stepList(id); + + if (!bsl || bsl->isEmpty()) + continue; + stepLists << bsl; + } } + + if (stepLists.isEmpty()) + return 0; + if (!d->m_buildManager->buildLists(stepLists)) + return -1; + return stepLists.count(); } -void ProjectExplorerPlugin::buildProjectContextMenu() +void ProjectExplorerPlugin::buildProjectOnly() { - if (debug) - qDebug() << "ProjectExplorerPlugin::buildProjectContextMenu"; + queue(QList<Project *>() << session()->startupProject(), QStringList() << Constants::BUILDSTEPS_BUILD); +} - if (saveModifiedFiles()) { - QList<BuildConfiguration *> configurations; - foreach (Project *pro, d->m_session->projectOrder(d->m_currentProject)) - if (pro->activeTarget()->activeBuildConfiguration()) - configurations << pro->activeTarget()->activeBuildConfiguration(); +void ProjectExplorerPlugin::buildProject() +{ + queue(d->m_session->projectOrder(session()->startupProject()), + QStringList() << Constants::BUILDSTEPS_BUILD); +} - d->m_buildManager->buildProjects(configurations); - } +void ProjectExplorerPlugin::buildProjectContextMenu() +{ + queue(d->m_session->projectOrder(d->m_currentProject), + QStringList() << Constants::BUILDSTEPS_BUILD); } void ProjectExplorerPlugin::buildSession() { - if (debug) - qDebug() << "ProjectExplorerPlugin::buildSession"; - - if (saveModifiedFiles()) { - QList<BuildConfiguration *> configurations; - foreach (Project *pro, d->m_session->projectOrder()) - if (pro->activeTarget()->activeBuildConfiguration()) - configurations << pro->activeTarget()->activeBuildConfiguration(); - d->m_buildManager->buildProjects(configurations); - } + queue(d->m_session->projectOrder(), + QStringList() << Constants::BUILDSTEPS_BUILD); } void ProjectExplorerPlugin::rebuildProjectOnly() { - if (debug) - qDebug() << "ProjectExplorerPlugin::rebuildProjectOnly"; - - if (saveModifiedFiles()) { - d->m_buildManager->cleanProject(session()->startupProject()->activeTarget()->activeBuildConfiguration()); - d->m_buildManager->buildProject(session()->startupProject()->activeTarget()->activeBuildConfiguration()); - } + queue(QList<Project *>() << session()->startupProject(), + QStringList() << Constants::BUILDSTEPS_CLEAN << Constants::BUILDSTEPS_BUILD); } void ProjectExplorerPlugin::rebuildProject() { - if (debug) - qDebug() << "ProjectExplorerPlugin::rebuildProject"; - - if (saveModifiedFiles()) { - const QList<Project *> &projects = d->m_session->projectOrder(session()->startupProject()); - QList<BuildConfiguration *> configurations; - foreach (Project *pro, projects) - if (pro->activeTarget()->activeBuildConfiguration()) - configurations << pro->activeTarget()->activeBuildConfiguration(); - - d->m_buildManager->cleanProjects(configurations); - d->m_buildManager->buildProjects(configurations); - } + queue(d->m_session->projectOrder(session()->startupProject()), + QStringList() << Constants::BUILDSTEPS_CLEAN << Constants::BUILDSTEPS_BUILD); } void ProjectExplorerPlugin::rebuildProjectContextMenu() { - if (debug) - qDebug() << "ProjectExplorerPlugin::rebuildProjectContextMenu"; - - if (saveModifiedFiles()) { - const QList<Project *> &projects = d->m_session->projectOrder(d->m_currentProject); - QList<BuildConfiguration *> configurations; - foreach (Project *pro, projects) - if (pro->activeTarget()->activeBuildConfiguration()) - configurations << pro->activeTarget()->activeBuildConfiguration(); - - d->m_buildManager->cleanProjects(configurations); - d->m_buildManager->buildProjects(configurations); - } + queue(d->m_session->projectOrder(d->m_currentProject), + QStringList() << Constants::BUILDSTEPS_CLEAN << Constants::BUILDSTEPS_BUILD); } void ProjectExplorerPlugin::rebuildSession() { - if (debug) - qDebug() << "ProjectExplorerPlugin::rebuildSession"; - - if (saveModifiedFiles()) { - const QList<Project *> & projects = d->m_session->projectOrder(); - QList<BuildConfiguration *> configurations; - foreach (Project *pro, projects) - if (pro->activeTarget()->activeBuildConfiguration()) - configurations << pro->activeTarget()->activeBuildConfiguration(); - - d->m_buildManager->cleanProjects(configurations); - d->m_buildManager->buildProjects(configurations); - } + queue(d->m_session->projectOrder(), + QStringList() << Constants::BUILDSTEPS_CLEAN << Constants::BUILDSTEPS_BUILD); } void ProjectExplorerPlugin::deployProjectOnly() { - if (!saveModifiedFiles()) - return; - d->m_buildManager->deployProject(session()->startupProject()->activeTarget()->activeBuildConfiguration()); + deploy(QList<Project *>() << session()->startupProject()); } void ProjectExplorerPlugin::deployProject() { - if (!saveModifiedFiles()) - return; - - const QList<Project *> &projects = d->m_session->projectOrder(session()->startupProject()); - QList<BuildConfiguration *> configurations; - foreach (Project *pro, projects) - if (pro->activeTarget()->activeBuildConfiguration()) - configurations << pro->activeTarget()->activeBuildConfiguration(); - - d->m_buildManager->deployProjects(configurations); + deploy(d->m_session->projectOrder(session()->startupProject())); } void ProjectExplorerPlugin::deployProjectContextMenu() { - if (!saveModifiedFiles()) - return; - - QList<BuildConfiguration *> configurations; - foreach (Project *pro, d->m_session->projectOrder(d->m_currentProject)) - if (pro->activeTarget()->activeBuildConfiguration()) - configurations << pro->activeTarget()->activeBuildConfiguration(); - - d->m_buildManager->deployProjects(configurations); + deploy(d->m_session->projectOrder(d->m_currentProject)); } void ProjectExplorerPlugin::deploySession() { - if (!saveModifiedFiles()) - return; - - const QList<Project *> & projects = d->m_session->projectOrder(); - QList<BuildConfiguration *> configurations; - foreach (Project *pro, projects) - if (pro->activeTarget()->activeBuildConfiguration()) - configurations << pro->activeTarget()->activeBuildConfiguration(); - - d->m_buildManager->deployProjects(configurations); + deploy(d->m_session->projectOrder()); } void ProjectExplorerPlugin::cleanProjectOnly() { - if (debug) - qDebug() << "ProjectExplorerPlugin::cleanProjectOnly"; - - if (saveModifiedFiles()) - d->m_buildManager->cleanProject(session()->startupProject()->activeTarget()->activeBuildConfiguration()); + queue(QList<Project *>() << session()->startupProject(), + QStringList() << Constants::BUILDSTEPS_CLEAN << Constants::BUILDSTEPS_CLEAN); } void ProjectExplorerPlugin::cleanProject() { - if (debug) - qDebug() << "ProjectExplorerPlugin::cleanProject"; - - if (saveModifiedFiles()) { - const QList<Project *> & projects = d->m_session->projectOrder(session()->startupProject()); - QList<BuildConfiguration *> configurations; - foreach (Project *pro, projects) - if (pro->activeTarget()->activeBuildConfiguration()) - configurations << pro->activeTarget()->activeBuildConfiguration(); - d->m_buildManager->cleanProjects(configurations); - } + queue(d->m_session->projectOrder(session()->startupProject()), + QStringList() << Constants::BUILDSTEPS_CLEAN << Constants::BUILDSTEPS_CLEAN); } void ProjectExplorerPlugin::cleanProjectContextMenu() { - if (debug) - qDebug() << "ProjectExplorerPlugin::cleanProjectContextMenu"; - - if (saveModifiedFiles()) { - const QList<Project *> & projects = d->m_session->projectOrder(d->m_currentProject); - QList<BuildConfiguration *> configurations; - foreach (Project *pro, projects) - if (pro->activeTarget()->activeBuildConfiguration()) - configurations << pro->activeTarget()->activeBuildConfiguration(); - d->m_buildManager->cleanProjects(configurations); - } + queue(d->m_session->projectOrder(d->m_currentProject), + QStringList() << Constants::BUILDSTEPS_CLEAN << Constants::BUILDSTEPS_CLEAN); } void ProjectExplorerPlugin::cleanSession() { - if (debug) - qDebug() << "ProjectExplorerPlugin::cleanSession"; - - if (saveModifiedFiles()) { - const QList<Project *> & projects = d->m_session->projectOrder(); - QList<BuildConfiguration *> configurations; - foreach (Project *pro, projects) - if (pro->activeTarget()->activeBuildConfiguration()) - configurations << pro->activeTarget()->activeBuildConfiguration(); - d->m_buildManager->cleanProjects(configurations); - } + queue(d->m_session->projectOrder(), + QStringList() << Constants::BUILDSTEPS_CLEAN << Constants::BUILDSTEPS_CLEAN); } void ProjectExplorerPlugin::runProject() @@ -1722,8 +1644,8 @@ bool ProjectExplorerPlugin::hasDeploySettings(Project *pro) { const QList<Project *> & projects = d->m_session->projectOrder(pro); foreach(Project *project, projects) - if (project->activeTarget()->activeBuildConfiguration() && - !project->activeTarget()->activeBuildConfiguration()->steps(BuildStep::Deploy).isEmpty()) + if (project->activeTarget()->activeDeployConfiguration() && + !project->activeTarget()->activeDeployConfiguration()->stepList()->isEmpty()) return true; return false; } @@ -1738,32 +1660,20 @@ void ProjectExplorerPlugin::runProjectImpl(Project *pro, QString mode) return; } - if (!saveModifiedFiles()) - return; - - bool delayRun = false; - // Deploy/build first? + QStringList stepIds; if (d->m_projectExplorerSettings.deployBeforeRun) { - const QList<Project *> & projects = d->m_session->projectOrder(pro); - QList<BuildConfiguration *> configurations; - foreach(Project *project, projects) - if (project->activeTarget()->activeBuildConfiguration()) - configurations << project->activeTarget()->activeBuildConfiguration(); - - if (d->m_projectExplorerSettings.buildBeforeDeploy && hasBuildSettings(pro)) { - if (!d->m_buildManager->buildProjects(configurations)) - return; - delayRun = true; - } - if (hasDeploySettings(pro)) { - if (!d->m_buildManager->deployProjects(configurations)) - return; - delayRun = true; - } + if (d->m_projectExplorerSettings.buildBeforeDeploy) + stepIds << Constants::BUILDSTEPS_BUILD; + stepIds << Constants::BUILDSTEPS_DEPLOY; } + const QList<Project *> &projects = d->m_session->projectOrder(pro); + int queueCount = queue(projects, stepIds); + + if (queueCount < 0) // something went wrong + return; - // Actually run (delayed) - if (delayRun) { + if (queueCount > 0) { + // delay running till after our queued steps were processed d->m_runMode = mode; d->m_delayedRunConfiguration = pro->activeTarget()->activeRunConfiguration(); } else { diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index 973dc53535..20f0098968 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -207,6 +207,8 @@ private slots: #endif private: + void deploy(QList<Project *>); + int queue(QList<Project *>, QStringList stepIds); void updateContextMenuActions(Node *node); bool parseArguments(const QStringList &arguments, QString *error); void runProjectImpl(Project *pro, QString mode); diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro index d20089a7ee..42d142824c 100644 --- a/src/plugins/projectexplorer/projectexplorer.pro +++ b/src/plugins/projectexplorer/projectexplorer.pro @@ -13,7 +13,11 @@ HEADERS += projectexplorer.h \ projectexplorer_export.h \ projectwindow.h \ buildmanager.h \ + buildsteplist.h \ compileoutputwindow.h \ + deployconfiguration.h \ + deployconfigurationmodel.h \ + namedwidget.h \ target.h \ targetsettingspanel.h \ task.h \ @@ -93,7 +97,11 @@ HEADERS += projectexplorer.h \ SOURCES += projectexplorer.cpp \ projectwindow.cpp \ buildmanager.cpp \ + buildsteplist.cpp \ compileoutputwindow.cpp \ + deployconfiguration.cpp \ + deployconfigurationmodel.cpp \ + namedwidget.cpp \ target.cpp \ targetsettingspanel.cpp \ ioutputparser.cpp \ diff --git a/src/plugins/projectexplorer/projectexplorerconstants.h b/src/plugins/projectexplorer/projectexplorerconstants.h index e25693ca97..7a5a644492 100644 --- a/src/plugins/projectexplorer/projectexplorerconstants.h +++ b/src/plugins/projectexplorer/projectexplorerconstants.h @@ -207,6 +207,14 @@ const char * const PROJECT_WIZARD_CATEGORY = "I.Projects"; // (after Qt) const char * const PROJECT_WIZARD_TR_SCOPE = "ProjectExplorer"; const char * const PROJECT_WIZARD_TR_CATEGORY = QT_TRANSLATE_NOOP("ProjectExplorer", "Other Project"); +// Build step lists ids: +const char * const BUILDSTEPS_CLEAN = "ProjectExplorer.BuildSteps.Clean"; +const char * const BUILDSTEPS_BUILD = "ProjectExplorer.BuildSteps.Build"; +const char * const BUILDSTEPS_DEPLOY = "ProjectExplorer.BuildSteps.Deploy"; + +// Deploy Configuration id: +const char * const DEFAULT_DEPLOYCONFIGURATION_ID = "ProjectExplorer.DefaultDeployConfiguration"; + } // namespace Constants } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index d411ce67cc..7d52e7bdfe 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -136,17 +136,15 @@ IRunConfigurationFactory * findRunConfigurationFactory(RunConfigurationFactoryMa // RunConfiguration RunConfiguration::RunConfiguration(Target *target, const QString &id) : - ProjectConfiguration(id), - m_target(target) + ProjectConfiguration(target, id) { - Q_ASSERT(m_target); + Q_ASSERT(target); } RunConfiguration::RunConfiguration(Target *target, RunConfiguration *source) : - ProjectConfiguration(source), - m_target(target) + ProjectConfiguration(target, source) { - Q_ASSERT(m_target); + Q_ASSERT(target); } RunConfiguration::~RunConfiguration() @@ -176,7 +174,7 @@ BuildConfiguration *RunConfiguration::activeBuildConfiguration() const Target *RunConfiguration::target() const { - return m_target; + return static_cast<Target *>(parent()); } ProjectExplorer::OutputFormatter *RunConfiguration::createOutputFormatter() const diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index c1532590f6..352d6326d2 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -96,9 +96,6 @@ protected: /// convenience method to get current build configuration. BuildConfiguration *activeBuildConfiguration() const; - -private: - Target *m_target; }; /** diff --git a/src/plugins/projectexplorer/runsettingspropertiespage.cpp b/src/plugins/projectexplorer/runsettingspropertiespage.cpp index 624b623ed5..9528b0c644 100644 --- a/src/plugins/projectexplorer/runsettingspropertiespage.cpp +++ b/src/plugins/projectexplorer/runsettingspropertiespage.cpp @@ -28,6 +28,10 @@ **************************************************************************/ #include "runsettingspropertiespage.h" + +#include "buildstepspage.h" +#include "deployconfiguration.h" +#include "deployconfigurationmodel.h" #include "runconfigurationmodel.h" #include "runconfiguration.h" #include "target.h" @@ -39,7 +43,6 @@ #include <extensionsystem/pluginmanager.h> #include <utils/qtcassert.h> -#include <QtCore/QDebug> #include <QtCore/QPair> #include <QtGui/QMenu> @@ -123,31 +126,64 @@ QIcon RunSettingsPanel::icon() const RunSettingsWidget::RunSettingsWidget(Target *target) : m_target(target), m_runConfigurationsModel(new RunConfigurationModel(target, this)), + m_deployConfigurationModel(new DeployConfigurationModel(target, this)), m_runConfigurationWidget(0), + m_deployConfigurationWidget(0), + m_deployLayout(0), + m_deploySteps(0), m_ignoreChange(false) { Q_ASSERT(m_target); m_ui = new Ui::RunSettingsPropertiesPage; m_ui->setupUi(this); - m_addMenu = new QMenu(m_ui->addToolButton); - m_ui->addToolButton->setMenu(m_addMenu); - m_ui->addToolButton->setText(tr("Add")); - m_ui->removeToolButton->setText(tr("Remove")); + m_ui->deployWidget->setContentsMargins(0, 0, 0, 25); + + m_deployLayout = new QVBoxLayout(m_ui->deployWidget); + m_deployLayout->setMargin(0); + m_deployLayout->setSpacing(5); + + m_ui->deployConfigurationCombo->setModel(m_deployConfigurationModel); + m_addDeployMenu = new QMenu(m_ui->addDeployToolButton); + m_ui->addDeployToolButton->setMenu(m_addDeployMenu); + + // deploy part + updateDeployConfiguration(m_target->activeDeployConfiguration()); + + m_ui->addDeployToolButton->setEnabled(m_target->activeDeployConfiguration()); + m_ui->deployConfigurationCombo->setEnabled(m_target->activeDeployConfiguration()); + m_ui->removeDeployToolButton->setEnabled(m_target->deployConfigurations().count() > 1); + + connect(m_addDeployMenu, SIGNAL(aboutToShow()), + this, SLOT(aboutToShowDeployMenu())); + connect(m_ui->deployConfigurationCombo, SIGNAL(currentIndexChanged(int)), + this, SLOT(currentDeployConfigurationChanged(int))); + connect(m_ui->removeDeployToolButton, SIGNAL(clicked(bool)), + this, SLOT(removeDeployConfiguration())); + + connect(m_target, SIGNAL(activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration*)), + this, SLOT(activeDeployConfigurationChanged())); + + // run part + m_addRunMenu = new QMenu(m_ui->addRunToolButton); + m_ui->addRunToolButton->setMenu(m_addRunMenu); m_ui->runConfigurationCombo->setModel(m_runConfigurationsModel); m_ui->runConfigurationCombo->setCurrentIndex( m_runConfigurationsModel->indexFor(m_target->activeRunConfiguration()).row()); - m_ui->removeToolButton->setEnabled(m_target->runConfigurations().size() > 1); + m_ui->removeRunToolButton->setEnabled(m_target->runConfigurations().size() > 1); m_runConfigurationWidget = m_target->activeRunConfiguration()->createConfigurationWidget(); - layout()->addWidget(m_runConfigurationWidget); + QVBoxLayout *runLayout = new QVBoxLayout(m_ui->runWidget); + runLayout->setMargin(0); + runLayout->setSpacing(0); + runLayout->addWidget(m_runConfigurationWidget); - connect(m_addMenu, SIGNAL(aboutToShow()), + connect(m_addRunMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowAddMenu())); connect(m_ui->runConfigurationCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(currentRunConfigurationChanged(int))); - connect(m_ui->removeToolButton, SIGNAL(clicked(bool)), + connect(m_ui->removeRunToolButton, SIGNAL(clicked(bool)), this, SLOT(removeRunConfiguration())); connect(m_target, SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)), @@ -170,13 +206,13 @@ RunSettingsWidget::~RunSettingsWidget() void RunSettingsWidget::aboutToShowAddMenu() { - m_addMenu->clear(); + m_addRunMenu->clear(); QList<IRunConfigurationFactory *> factories = ExtensionSystem::PluginManager::instance()->getObjects<IRunConfigurationFactory>(); foreach (IRunConfigurationFactory *factory, factories) { QStringList ids = factory->availableCreationIds(m_target); foreach (const QString &id, ids) { - QAction *action = m_addMenu->addAction(factory->displayNameForId(id));; + QAction *action = m_addRunMenu->addAction(factory->displayNameForId(id));; FactoryAndId fai; fai.factory = factory; fai.id = id; @@ -200,14 +236,14 @@ void RunSettingsWidget::addRunConfiguration() return; m_target->addRunConfiguration(newRC); m_target->setActiveRunConfiguration(newRC); - m_ui->removeToolButton->setEnabled(m_target->runConfigurations().size() > 1); + m_ui->removeRunToolButton->setEnabled(m_target->runConfigurations().size() > 1); } void RunSettingsWidget::removeRunConfiguration() { RunConfiguration *rc = m_target->activeRunConfiguration(); m_target->removeRunConfiguration(rc); - m_ui->removeToolButton->setEnabled(m_target->runConfigurations().size() > 1); + m_ui->removeRunToolButton->setEnabled(m_target->runConfigurations().size() > 1); } void RunSettingsWidget::activeRunConfigurationChanged() @@ -245,3 +281,76 @@ void RunSettingsWidget::currentRunConfigurationChanged(int index) m_runConfigurationWidget = selectedRunConfiguration->createConfigurationWidget(); layout()->addWidget(m_runConfigurationWidget); } + +void RunSettingsWidget::currentDeployConfigurationChanged(int index) +{ + if (index == -1) + updateDeployConfiguration(0); + else + m_target->setActiveDeployConfiguration(m_deployConfigurationModel->deployConfigurationAt(index)); +} + +void RunSettingsWidget::aboutToShowDeployMenu() +{ + m_addDeployMenu->clear(); + DeployConfigurationFactory *factory = m_target->deployConfigurationFactory(); + QStringList ids = factory->availableCreationIds(m_target); + foreach (const QString &id, ids) { + QAction *action = m_addDeployMenu->addAction(factory->displayNameForId(id));; + action->setData(QVariant(id)); + connect(action, SIGNAL(triggered()), + this, SLOT(addDeployConfiguration())); + } +} + +void RunSettingsWidget::addDeployConfiguration() +{ + QAction *act = qobject_cast<QAction *>(sender()); + if (!act) + return; + QString id = act->data().toString(); + DeployConfiguration *newDc = m_target->deployConfigurationFactory()->create(m_target, id); + if (!newDc) + return; + m_target->addDeployConfiguration(newDc); + m_target->setActiveDeployConfiguration(newDc); + m_ui->removeDeployToolButton->setEnabled(m_target->deployConfigurations().size() > 1); +} + +void RunSettingsWidget::removeDeployConfiguration() +{ + DeployConfiguration *dc = m_target->activeDeployConfiguration(); + m_target->removeDeployConfiguration(dc); + m_ui->removeDeployToolButton->setEnabled(m_target->deployConfigurations().size() > 1); +} + +void RunSettingsWidget::activeDeployConfigurationChanged() +{ + updateDeployConfiguration(m_target->activeDeployConfiguration()); +} + +void RunSettingsWidget::updateDeployConfiguration(DeployConfiguration *dc) +{ + delete m_deployConfigurationWidget; + m_deployConfigurationWidget = 0; + delete m_deploySteps; + m_deploySteps = 0; + + m_ui->deployConfigurationCombo->setCurrentIndex(-1); + + if (!dc) + return; + + QModelIndex actDc = m_deployConfigurationModel->indexFor(dc); + m_ui->deployConfigurationCombo->setCurrentIndex(actDc.row()); + + m_deployConfigurationWidget = dc->configurationWidget(); + if (m_deployConfigurationWidget) { + m_deployConfigurationWidget->init(dc); + m_deployLayout->addWidget(m_deployConfigurationWidget); + } + + m_deploySteps = new BuildStepListWidget; + m_deploySteps->init(dc->stepList()); + m_deployLayout->addWidget(m_deploySteps); +} diff --git a/src/plugins/projectexplorer/runsettingspropertiespage.h b/src/plugins/projectexplorer/runsettingspropertiespage.h index 5491a2afbd..1ce5c2f539 100644 --- a/src/plugins/projectexplorer/runsettingspropertiespage.h +++ b/src/plugins/projectexplorer/runsettingspropertiespage.h @@ -37,11 +37,14 @@ QT_BEGIN_NAMESPACE class QMenu; class QLabel; +class QVBoxLayout; QT_END_NAMESPACE namespace ProjectExplorer { -class RunConfiguration; +class DeployConfiguration; +class DeployConfigurationWidget; +class DeployConfigurationModel; class RunConfigurationModel; namespace Internal { @@ -53,6 +56,7 @@ class RunSettingsPropertiesPage; } class RunSettingsWidget; +class BuildStepListWidget; class RunSettingsPanelFactory : public ITargetPanelFactory { @@ -91,12 +95,24 @@ private slots: void addRunConfiguration(); void removeRunConfiguration(); void activeRunConfigurationChanged(); + void currentDeployConfigurationChanged(int index); + void aboutToShowDeployMenu(); + void addDeployConfiguration(); + void removeDeployConfiguration(); + void activeDeployConfigurationChanged(); + private: + void updateDeployConfiguration(DeployConfiguration *); Target *m_target; RunConfigurationModel *m_runConfigurationsModel; + DeployConfigurationModel *m_deployConfigurationModel; Ui::RunSettingsPropertiesPage *m_ui; QWidget *m_runConfigurationWidget; - QMenu *m_addMenu; + DeployConfigurationWidget *m_deployConfigurationWidget; + QVBoxLayout *m_deployLayout; + BuildStepListWidget *m_deploySteps; + QMenu *m_addRunMenu; + QMenu *m_addDeployMenu; bool m_ignoreChange; }; diff --git a/src/plugins/projectexplorer/runsettingspropertiespage.ui b/src/plugins/projectexplorer/runsettingspropertiespage.ui index dbd7386597..8b2d408e20 100644 --- a/src/plugins/projectexplorer/runsettingspropertiespage.ui +++ b/src/plugins/projectexplorer/runsettingspropertiespage.ui @@ -6,79 +6,109 @@ <rect> <x>0</x> <y>0</y> - <width>480</width> - <height>32</height> + <width>474</width> + <height>191</height> </rect> </property> - <layout class="QVBoxLayout" name="verticalLayout"> + <layout class="QGridLayout" name="gridLayout"> <property name="margin"> <number>0</number> </property> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QLabel" name="label"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Run configuration:</string> - </property> - <property name="buddy"> - <cstring>runConfigurationCombo</cstring> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="runConfigurationCombo"> - <property name="maximumSize"> - <size> - <width>500</width> - <height>16777215</height> - </size> - </property> - <property name="sizeAdjustPolicy"> - <enum>QComboBox::AdjustToContents</enum> - </property> - <property name="minimumContentsLength"> - <number>15</number> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="addToolButton"> - <property name="text"> - <string>+</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="removeToolButton"> - <property name="text"> - <string>-</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>39</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> + <property name="spacing"> + <number>6</number> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="deployLabel"> + <property name="text"> + <string>Deployment:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QComboBox" name="deployConfigurationCombo"/> + </item> + <item row="0" column="2"> + <widget class="QPushButton" name="addDeployToolButton"> + <property name="text"> + <string>Add</string> + </property> + </widget> + </item> + <item row="0" column="3"> + <widget class="QPushButton" name="removeDeployToolButton"> + <property name="text"> + <string>Remove</string> + </property> + </widget> + </item> + <item row="1" column="0" colspan="5"> + <widget class="QWidget" name="deployWidget" native="true"/> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="runLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Run configuration:</string> + </property> + <property name="buddy"> + <cstring>runConfigurationCombo</cstring> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QComboBox" name="runConfigurationCombo"> + <property name="maximumSize"> + <size> + <width>500</width> + <height>16777215</height> + </size> + </property> + <property name="sizeAdjustPolicy"> + <enum>QComboBox::AdjustToContents</enum> + </property> + <property name="minimumContentsLength"> + <number>15</number> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QPushButton" name="addRunToolButton"> + <property name="text"> + <string>Add</string> + </property> + </widget> + </item> + <item row="2" column="3"> + <widget class="QPushButton" name="removeRunToolButton"> + <property name="text"> + <string>Remove</string> + </property> + </widget> + </item> + <item row="2" column="4"> + <spacer name="runHorizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>17</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="3" column="0" colspan="5"> + <widget class="QWidget" name="runWidget" native="true"/> </item> </layout> </widget> + <layoutdefault spacing="0" margin="0"/> <resources/> <connections/> </ui> diff --git a/src/plugins/projectexplorer/target.cpp b/src/plugins/projectexplorer/target.cpp index d12354ae95..e35bf3452a 100644 --- a/src/plugins/projectexplorer/target.cpp +++ b/src/plugins/projectexplorer/target.cpp @@ -30,6 +30,7 @@ #include "target.h" #include "buildconfiguration.h" +#include "deployconfiguration.h" #include "project.h" #include "runconfiguration.h" @@ -42,6 +43,10 @@ const char * const ACTIVE_BC_KEY("ProjectExplorer.Target.ActiveBuildConfiguratio const char * const BC_KEY_PREFIX("ProjectExplorer.Target.BuildConfiguration."); const char * const BC_COUNT_KEY("ProjectExplorer.Target.BuildConfigurationCount"); +const char * const ACTIVE_DC_KEY("ProjectExplorer.Target.ActiveDeployConfiguration"); +const char * const DC_KEY_PREFIX("ProjectExplorer.Target.DeployConfiguration."); +const char * const DC_COUNT_KEY("ProjectExplorer.Target.DeployConfigurationCount"); + const char * const ACTIVE_RC_KEY("ProjectExplorer.Target.ActiveRunConfiguration"); const char * const RC_KEY_PREFIX("ProjectExplorer.Target.RunConfiguration."); const char * const RC_COUNT_KEY("ProjectExplorer.Target.RunConfigurationCount"); @@ -53,10 +58,10 @@ const char * const RC_COUNT_KEY("ProjectExplorer.Target.RunConfigurationCount"); // ------------------------------------------------------------------------- Target::Target(Project *project, const QString &id) : - ProjectConfiguration(id), - m_project(project), + ProjectConfiguration(project, id), m_isEnabled(true), m_activeBuildConfiguration(0), + m_activeDeployConfiguration(0), m_activeRunConfiguration(0) { } @@ -76,7 +81,7 @@ void Target::changeEnvironment() Project *Target::project() const { - return m_project; + return static_cast<Project *>(parent()); } void Target::addBuildConfiguration(BuildConfiguration *configuration) @@ -148,6 +153,72 @@ void Target::setActiveBuildConfiguration(BuildConfiguration *configuration) } } +void Target::addDeployConfiguration(DeployConfiguration *dc) +{ + QTC_ASSERT(dc && !m_deployConfigurations.contains(dc), return); + Q_ASSERT(dc->target() == this); + + if (!deployConfigurationFactory()) + return; + + // Check that we don't have a configuration with the same displayName + QString configurationDisplayName = dc->displayName(); + QStringList displayNames; + foreach (const DeployConfiguration *bc, m_deployConfigurations) + displayNames << bc->displayName(); + configurationDisplayName = Project::makeUnique(configurationDisplayName, displayNames); + dc->setDisplayName(configurationDisplayName); + + // add it + m_deployConfigurations.push_back(dc); + + emit addedDeployConfiguration(dc); + + if (!m_activeDeployConfiguration) + setActiveDeployConfiguration(dc); + Q_ASSERT(activeDeployConfiguration()); +} + +void Target::removeDeployConfiguration(DeployConfiguration *dc) +{ + //todo: this might be error prone + if (!m_deployConfigurations.contains(dc)) + return; + + m_deployConfigurations.removeOne(dc); + + emit removedDeployConfiguration(dc); + + if (activeDeployConfiguration() == dc) { + if (m_deployConfigurations.isEmpty()) + setActiveDeployConfiguration(0); + else + setActiveDeployConfiguration(m_deployConfigurations.at(0)); + } + + delete dc; +} + +QList<DeployConfiguration *> Target::deployConfigurations() const +{ + return m_deployConfigurations; +} + +DeployConfiguration *Target::activeDeployConfiguration() const +{ + return m_activeDeployConfiguration; +} + +void Target::setActiveDeployConfiguration(DeployConfiguration *dc) +{ + if ((!dc && m_deployConfigurations.isEmpty()) || + (dc && m_deployConfigurations.contains(dc) && + dc != m_activeDeployConfiguration)) { + m_activeDeployConfiguration = dc; + emit activeDeployConfigurationChanged(m_activeDeployConfiguration); + } +} + QList<RunConfiguration *> Target::runConfigurations() const { return m_runConfigurations; @@ -245,6 +316,12 @@ QVariantMap Target::toMap() const for (int i = 0; i < bcs.size(); ++i) map.insert(QString::fromLatin1(BC_KEY_PREFIX) + QString::number(i), bcs.at(i)->toMap()); + const QList<DeployConfiguration *> dcs = deployConfigurations(); + map.insert(QLatin1String(ACTIVE_DC_KEY), dcs.indexOf(m_activeDeployConfiguration)); + map.insert(QLatin1String(DC_COUNT_KEY), dcs.size()); + for (int i = 0; i < dcs.size(); ++i) + map.insert(QString::fromLatin1(DC_KEY_PREFIX) + QString::number(i), dcs.at(i)->toMap()); + const QList<RunConfiguration *> rcs = runConfigurations(); map.insert(QLatin1String(ACTIVE_RC_KEY), rcs.indexOf(m_activeRunConfiguration)); map.insert(QLatin1String(RC_COUNT_KEY), rcs.size()); @@ -292,6 +369,29 @@ bool Target::fromMap(const QVariantMap &map) if (buildConfigurations().isEmpty() && buildConfigurationFactory()) return false; + int dcCount(map.value(QLatin1String(DC_COUNT_KEY), 0).toInt(&ok)); + if (!ok || dcCount < 0) + dcCount = 0; + activeConfiguration = map.value(QLatin1String(ACTIVE_DC_KEY), 0).toInt(&ok); + if (!ok || activeConfiguration < 0) + activeConfiguration = 0; + if (0 > activeConfiguration || dcCount < activeConfiguration) + activeConfiguration = 0; + + for (int i = 0; i < dcCount; ++i) { + const QString key(QString::fromLatin1(DC_KEY_PREFIX) + QString::number(i)); + if (!map.contains(key)) + return false; + DeployConfiguration *dc(deployConfigurationFactory()->restore(this, map.value(key).toMap())); + if (!dc) + continue; + addDeployConfiguration(dc); + if (i == activeConfiguration) + setActiveDeployConfiguration(dc); + } + if (deployConfigurations().isEmpty() && deployConfigurationFactory()) + return false; + int rcCount(map.value(QLatin1String(RC_COUNT_KEY), 0).toInt(&ok)); if (!ok || rcCount < 0) rcCount = 0; @@ -330,9 +430,7 @@ bool Target::fromMap(const QVariantMap &map) ITargetFactory::ITargetFactory(QObject *parent) : QObject(parent) -{ -} +{ } ITargetFactory::~ITargetFactory() -{ -} +{ } diff --git a/src/plugins/projectexplorer/target.h b/src/plugins/projectexplorer/target.h index c6c9e722de..486d80a8b5 100644 --- a/src/plugins/projectexplorer/target.h +++ b/src/plugins/projectexplorer/target.h @@ -40,7 +40,9 @@ namespace ProjectExplorer { class RunConfiguration; class Environment; class BuildConfiguration; +class DeployConfiguration; class IBuildConfigurationFactory; +class DeployConfigurationFactory; class IRunConfigurationFactory; class Project; @@ -63,6 +65,16 @@ public: virtual IBuildConfigurationFactory *buildConfigurationFactory() const = 0; + // DeployConfiguration + void addDeployConfiguration(DeployConfiguration *dc); + void removeDeployConfiguration(DeployConfiguration *dc); + + QList<DeployConfiguration *> deployConfigurations() const; + virtual DeployConfiguration *activeDeployConfiguration() const; + void setActiveDeployConfiguration(DeployConfiguration *configuration); + + virtual DeployConfigurationFactory *deployConfigurationFactory() const = 0; + // Running QList<RunConfiguration *> runConfigurations() const; void addRunConfiguration(RunConfiguration *runConfiguration); @@ -105,6 +117,10 @@ signals: void addedBuildConfiguration(ProjectExplorer::BuildConfiguration *bc); void activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration *); + void removedDeployConfiguration(ProjectExplorer::DeployConfiguration *dc); + void addedDeployConfiguration(ProjectExplorer::DeployConfiguration *dc); + void activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration *dc); + /// convenience signal, emitted if either the active buildconfiguration emits /// environmentChanged() or if the active build configuration changes void environmentChanged(); @@ -120,7 +136,6 @@ private slots: void changeEnvironment(); private: - Project *m_project; bool m_isEnabled; QIcon m_icon; QIcon m_overlayIcon; @@ -128,6 +143,8 @@ private: QList<BuildConfiguration *> m_buildConfigurations; BuildConfiguration *m_activeBuildConfiguration; + QList<DeployConfiguration *> m_deployConfigurations; + DeployConfiguration *m_activeDeployConfiguration; QList<RunConfiguration *> m_runConfigurations; RunConfiguration* m_activeRunConfiguration; }; diff --git a/src/plugins/projectexplorer/userfileaccessor.cpp b/src/plugins/projectexplorer/userfileaccessor.cpp index 2ac2798c6b..8ab124ef96 100644 --- a/src/plugins/projectexplorer/userfileaccessor.cpp +++ b/src/plugins/projectexplorer/userfileaccessor.cpp @@ -184,6 +184,23 @@ public: QVariantMap update(Project *project, const QVariantMap &map); }; +// Version 5 reflects the introduction of new deploy steps for Symbian/Maemo +class Version6Handler : public UserFileVersionHandler +{ +public: + int userFileVersion() const + { + return 6; + } + + QString displayUserFileVersion() const + { + return QLatin1String("2.2pre3"); + } + + QVariantMap update(Project *project, const QVariantMap &map); +}; + // // Helper functions: // @@ -256,6 +273,7 @@ UserFileAccessor::UserFileAccessor() : addVersionHandler(new Version3Handler); addVersionHandler(new Version4Handler); addVersionHandler(new Version5Handler); + addVersionHandler(new Version6Handler); } UserFileAccessor::~UserFileAccessor() @@ -1188,3 +1206,109 @@ QVariantMap Version5Handler::update(Project *, const QVariantMap &map) } return result; } + +// ------------------------------------------------------------------------- +// Version6Handler +// ------------------------------------------------------------------------- + +// Introduce DeployConfiguration and BuildStepLists +QVariantMap Version6Handler::update(Project *, const QVariantMap &map) +{ + QVariantMap result; + QMapIterator<QString, QVariant> it(map); + while (it.hasNext()) { + it.next(); + const QString &globalKey = it.key(); + // check for target info + if (!globalKey.startsWith(QLatin1String("ProjectExplorer.Project.Target."))) { + result.insert(globalKey, it.value()); + continue; + } + + QVariantMap newDc; + const QVariantMap &originalTarget = it.value().toMap(); + QVariantMap newTarget; + QVariantMap deploySteps; + QString deploymentName = QCoreApplication::translate("ProjectExplorer::UserFileHandler", "No deployment"); + + QMapIterator<QString, QVariant> targetIt(originalTarget); + while (targetIt.hasNext()) { + targetIt.next(); + const QString &targetKey = targetIt.key(); + + if (targetKey == QLatin1String("ProjectExplorer.ProjectConfiguration.Id")) { + if (targetIt.value().toString() == QLatin1String("Qt4ProjectManager.Target.MaemoDeviceTarget")) + deploymentName = QCoreApplication::translate("ProjectExplorer::UserFileHandler", "Deploy to Maemo device"); + else if (targetIt.value().toString() == QLatin1String("Qt4ProjectManager.Target.S60DeviceTarget")) + deploymentName = QCoreApplication::translate("ProjectExplorer::UserFileHandler", "Deploy to Symbian device"); + } + + if (!targetKey.startsWith(QLatin1String("ProjectExplorer.Target.BuildConfiguration."))) { + newTarget.insert(targetKey, targetIt.value()); + continue; + } + + QVariantMap buildSteps; + QVariantMap cleanSteps; + QVariantMap &originalBc = targetIt.value().toMap(); + QVariantMap newBc; + + QMapIterator<QString, QVariant> bcIt(originalBc); + while (bcIt.hasNext()) + { + bcIt.next(); + const QString &bcKey = bcIt.key(); + if (bcKey.startsWith(QLatin1String("ProjectExplorer.BuildConfiguration.BuildStep."))) { + QString position = bcKey.mid(45); + buildSteps.insert(QString::fromLatin1("ProjectExplorer.BuildStepList.Step.") + position, bcIt.value()); + continue; + } + if (bcKey.startsWith(QLatin1String("ProjectExplorer.BuildConfiguration.BuildStepsCount"))) { + buildSteps.insert(QLatin1String("ProjectExplorer.BuildStepList.StepsCount"), bcIt.value()); + continue; + } + if (bcKey.startsWith(QLatin1String("ProjectExplorer.BuildConfiguration.CleanStep."))) { + QString position = bcKey.mid(45); + cleanSteps.insert(QString::fromLatin1("ProjectExplorer.BuildStepList.Step.") + position, bcIt.value()); + continue; + } + if (bcKey.startsWith(QLatin1String("ProjectExplorer.BuildConfiguration.CleanStepsCount"))) { + cleanSteps.insert(QLatin1String("ProjectExplorer.BuildStepList.StepsCount"), bcIt.value()); + continue; + } + if (bcKey.startsWith(QLatin1String("ProjectExplorer.BuildConfiguration.DeployStep."))) { + QString position = bcKey.mid(46); + deploySteps.insert(QString::fromLatin1("ProjectExplorer.BuildStepList.Step.") + position, bcIt.value()); + continue; + } + if (bcKey.startsWith(QLatin1String("ProjectExplorer.BuildConfiguration.DeployStepsCount"))) { + deploySteps.insert(QLatin1String("ProjectExplorer.BuildStepList.StepsCount"), bcIt.value()); + continue; + } + newBc.insert(bcKey, bcIt.value()); + } + buildSteps.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.DisplayName"), QLatin1String("Build")); + buildSteps.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"), QLatin1String("ProjectExplorer.BuildSteps.Build")); + cleanSteps.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.DisplayName"), QLatin1String("Clean")); + cleanSteps.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"), QLatin1String("ProjectExplorer.BuildSteps.Clean")); + newBc.insert(QLatin1String("ProjectExplorer.BuildConfiguration.BuildStepList.0"), buildSteps); + newBc.insert(QLatin1String("ProjectExplorer.BuildConfiguration.BuildStepList.1"), cleanSteps); + newBc.insert(QLatin1String("ProjectExplorer.BuildConfiguration.BuildStepListCount"), 2); + newTarget.insert(targetKey, newBc); + } + + // Only insert one deploy configuration: + deploySteps.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.DisplayName"), QLatin1String("Deploy")); + deploySteps.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"), QLatin1String("ProjectExplorer.BuildSteps.Deploy")); + newDc.insert(QLatin1String("ProjectExplorer.BuildConfiguration.BuildStepList.0"), deploySteps); + newDc.insert(QLatin1String("ProjectExplorer.BuildConfiguration.BuildStepListCount"), 1); + newDc.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.DisplayName"), deploymentName); + newDc.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"), QLatin1String("ProjectExplorer.DefaultDeployConfiguration")); + + newTarget.insert(QLatin1String("ProjectExplorer.Target.DeployConfigurationCount"), 1); + newTarget.insert(QLatin1String("ProjectExplorer.Target.ActiveDeployConfiguration"), 0); + newTarget.insert(QLatin1String("ProjectExplorer.Target.DeployConfiguration.0"), newDc); + result.insert(globalKey, newTarget); + } + return result; +} diff --git a/src/plugins/qmlprojectmanager/qmlprojecttarget.cpp b/src/plugins/qmlprojectmanager/qmlprojecttarget.cpp index dded039454..429a65a9d8 100644 --- a/src/plugins/qmlprojectmanager/qmlprojecttarget.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojecttarget.cpp @@ -63,6 +63,11 @@ ProjectExplorer::IBuildConfigurationFactory *QmlProjectTarget::buildConfiguratio return 0; } +ProjectExplorer::DeployConfigurationFactory *QmlProjectTarget::deployConfigurationFactory() const +{ + return 0; +} + bool QmlProjectTarget::fromMap(const QVariantMap &map) { if (!Target::fromMap(map)) diff --git a/src/plugins/qmlprojectmanager/qmlprojecttarget.h b/src/plugins/qmlprojectmanager/qmlprojecttarget.h index 83a0e899fb..1722a1742b 100644 --- a/src/plugins/qmlprojectmanager/qmlprojecttarget.h +++ b/src/plugins/qmlprojectmanager/qmlprojecttarget.h @@ -55,6 +55,7 @@ public: QmlProject *qmlProject() const; ProjectExplorer::IBuildConfigurationFactory *buildConfigurationFactory() const; + ProjectExplorer::DeployConfigurationFactory *deployConfigurationFactory() const; protected: bool fromMap(const QVariantMap &map); diff --git a/src/plugins/qt4projectmanager/makestep.cpp b/src/plugins/qt4projectmanager/makestep.cpp index 94f6500981..26c6128ea5 100644 --- a/src/plugins/qt4projectmanager/makestep.cpp +++ b/src/plugins/qt4projectmanager/makestep.cpp @@ -35,6 +35,7 @@ #include "qt4buildconfiguration.h" #include "qt4projectmanagerconstants.h" +#include <projectexplorer/buildsteplist.h> #include <projectexplorer/gnumakeparser.h> #include <projectexplorer/projectexplorer.h> #include <extensionsystem/pluginmanager.h> @@ -55,15 +56,15 @@ const char * const MAKE_COMMAND_KEY("Qt4ProjectManager.MakeStep.MakeCommand"); const char * const CLEAN_KEY("Qt4ProjectManager.MakeStep.Clean"); } -MakeStep::MakeStep(ProjectExplorer::BuildConfiguration *bc) : - AbstractProcessStep(bc, QLatin1String(MAKESTEP_BS_ID)), +MakeStep::MakeStep(ProjectExplorer::BuildStepList *bsl) : + AbstractProcessStep(bsl, QLatin1String(MAKESTEP_BS_ID)), m_clean(false) { ctor(); } -MakeStep::MakeStep(ProjectExplorer::BuildConfiguration *bc, MakeStep *bs) : - AbstractProcessStep(bc, bs), +MakeStep::MakeStep(ProjectExplorer::BuildStepList *bsl, MakeStep *bs) : + AbstractProcessStep(bsl, bs), m_clean(bs->m_clean), m_userArgs(bs->m_userArgs), m_makeCmd(bs->m_makeCmd) @@ -71,8 +72,8 @@ MakeStep::MakeStep(ProjectExplorer::BuildConfiguration *bc, MakeStep *bs) : ctor(); } -MakeStep::MakeStep(ProjectExplorer::BuildConfiguration *bc, const QString &id) : - AbstractProcessStep(bc, id), +MakeStep::MakeStep(ProjectExplorer::BuildStepList *bsl, const QString &id) : + AbstractProcessStep(bsl, id), m_clean(false) { ctor(); @@ -354,42 +355,41 @@ MakeStepFactory::~MakeStepFactory() { } -bool MakeStepFactory::canCreate(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QString &id) const +bool MakeStepFactory::canCreate(ProjectExplorer::BuildStepList *parent, const QString &id) const { - Q_UNUSED(type) - if (!qobject_cast<Qt4BuildConfiguration *>(parent)) + if (parent->target()->project()->id() != QLatin1String(Constants::QT4PROJECT_ID)) return false; return (id == QLatin1String(MAKESTEP_BS_ID)); } -ProjectExplorer::BuildStep *MakeStepFactory::create(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QString &id) +ProjectExplorer::BuildStep *MakeStepFactory::create(ProjectExplorer::BuildStepList *parent, const QString &id) { - if (!canCreate(parent, type, id)) + if (!canCreate(parent, id)) return 0; return new MakeStep(parent); } -bool MakeStepFactory::canClone(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, ProjectExplorer::BuildStep *source) const +bool MakeStepFactory::canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *source) const { - return canCreate(parent, type, source->id()); + return canCreate(parent, source->id()); } -ProjectExplorer::BuildStep *MakeStepFactory::clone(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, ProjectExplorer::BuildStep *source) +ProjectExplorer::BuildStep *MakeStepFactory::clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *source) { - if (!canClone(parent, type, source)) + if (!canClone(parent, source)) return 0; return new MakeStep(parent, static_cast<MakeStep *>(source)); } -bool MakeStepFactory::canRestore(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QVariantMap &map) const +bool MakeStepFactory::canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const { QString id(ProjectExplorer::idFromMap(map)); - return canCreate(parent, type, id); + return canCreate(parent, id); } -ProjectExplorer::BuildStep *MakeStepFactory::restore(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QVariantMap &map) +ProjectExplorer::BuildStep *MakeStepFactory::restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) { - if (!canRestore(parent, type, map)) + if (!canRestore(parent, map)) return 0; MakeStep *bs(new MakeStep(parent)); if (bs->fromMap(map)) @@ -398,10 +398,9 @@ ProjectExplorer::BuildStep *MakeStepFactory::restore(ProjectExplorer::BuildConfi return 0; } -QStringList MakeStepFactory::availableCreationIds(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type) const +QStringList MakeStepFactory::availableCreationIds(ProjectExplorer::BuildStepList *parent) const { - Q_UNUSED(type) - if (qobject_cast<Qt4BuildConfiguration *>(parent)) + if (parent->target()->project()->id() == QLatin1String(Constants::QT4PROJECT_ID)) return QStringList() << QLatin1String(MAKESTEP_BS_ID); return QStringList(); } diff --git a/src/plugins/qt4projectmanager/makestep.h b/src/plugins/qt4projectmanager/makestep.h index cc6eed8ea2..388125bc5d 100644 --- a/src/plugins/qt4projectmanager/makestep.h +++ b/src/plugins/qt4projectmanager/makestep.h @@ -57,14 +57,14 @@ public: explicit MakeStepFactory(QObject *parent = 0); virtual ~MakeStepFactory(); - bool canCreate(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QString &id) const; - ProjectExplorer::BuildStep *create(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QString &id); - bool canClone(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, ProjectExplorer::BuildStep *source) const; - ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, ProjectExplorer::BuildStep *source); - bool canRestore(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QVariantMap &map) const; - ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QVariantMap &map); - - QStringList availableCreationIds(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type) const; + bool canCreate(ProjectExplorer::BuildStepList *parent, const QString &id) const; + ProjectExplorer::BuildStep *create(ProjectExplorer::BuildStepList *parent, const QString &id); + bool canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *source) const; + ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *source); + bool canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const; + ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map); + + QStringList availableCreationIds(ProjectExplorer::BuildStepList *parent) const; QString displayNameForId(const QString &id) const; }; } //namespace Internal @@ -79,7 +79,7 @@ class MakeStep : public ProjectExplorer::AbstractProcessStep // used to access internal stuff public: - explicit MakeStep(ProjectExplorer::BuildConfiguration *bc); + explicit MakeStep(ProjectExplorer::BuildStepList *bsl); virtual ~MakeStep(); Internal::Qt4BuildConfiguration *qt4BuildConfiguration() const; @@ -100,8 +100,8 @@ signals: void userArgumentsChanged(); protected: - MakeStep(ProjectExplorer::BuildConfiguration *bc, MakeStep *bs); - MakeStep(ProjectExplorer::BuildConfiguration *bc, const QString &id); + MakeStep(ProjectExplorer::BuildStepList *bsl, MakeStep *bs); + MakeStep(ProjectExplorer::BuildStepList *bsl, const QString &id); virtual bool fromMap(const QVariantMap &map); private: diff --git a/src/plugins/qt4projectmanager/qmakestep.cpp b/src/plugins/qt4projectmanager/qmakestep.cpp index ca97410d73..da43b41605 100644 --- a/src/plugins/qt4projectmanager/qmakestep.cpp +++ b/src/plugins/qt4projectmanager/qmakestep.cpp @@ -38,6 +38,8 @@ #include "qt4target.h" #include "qtversionmanager.h" +#include <projectexplorer/buildsteplist.h> + #include <coreplugin/icore.h> #include <utils/qtcassert.h> @@ -54,22 +56,22 @@ const char * const QMAKE_BS_ID("QtProjectManager.QMakeBuildStep"); const char * const QMAKE_ARGUMENTS_KEY("QtProjectManager.QMakeBuildStep.QMakeArguments"); } -QMakeStep::QMakeStep(Qt4BuildConfiguration *bc) : - AbstractProcessStep(bc, QLatin1String(QMAKE_BS_ID)), +QMakeStep::QMakeStep(BuildStepList *bsl) : + AbstractProcessStep(bsl, QLatin1String(QMAKE_BS_ID)), m_forced(false) { ctor(); } -QMakeStep::QMakeStep(Qt4BuildConfiguration *bc, const QString &id) : - AbstractProcessStep(bc, id), +QMakeStep::QMakeStep(BuildStepList *bsl, const QString &id) : + AbstractProcessStep(bsl, id), m_forced(false) { ctor(); } -QMakeStep::QMakeStep(Qt4BuildConfiguration *bc, QMakeStep *bs) : - AbstractProcessStep(bc, bs), +QMakeStep::QMakeStep(BuildStepList *bsl, QMakeStep *bs) : + AbstractProcessStep(bsl, bs), m_forced(false), m_userArgs(bs->m_userArgs) { @@ -423,61 +425,55 @@ QMakeStepFactory::~QMakeStepFactory() { } -bool QMakeStepFactory::canCreate(BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QString &id) const +bool QMakeStepFactory::canCreate(BuildStepList *parent, const QString &id) const { - if (type != ProjectExplorer::BuildStep::Build) + if (parent->id() != QLatin1String(ProjectExplorer::Constants::BUILDSTEPS_BUILD)) return false; - if (!qobject_cast<Qt4BuildConfiguration *>(parent)) + if (!qobject_cast<Qt4BuildConfiguration *>(parent->parent())) return false; return (id == QLatin1String(QMAKE_BS_ID)); } -ProjectExplorer::BuildStep *QMakeStepFactory::create(BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type,const QString &id) +ProjectExplorer::BuildStep *QMakeStepFactory::create(BuildStepList *parent, const QString &id) { - if (!canCreate(parent, type, id)) + if (!canCreate(parent, id)) return 0; - Qt4BuildConfiguration *bc(qobject_cast<Qt4BuildConfiguration *>(parent)); - Q_ASSERT(bc); - return new QMakeStep(bc); + return new QMakeStep(parent); } -bool QMakeStepFactory::canClone(BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, BuildStep *source) const +bool QMakeStepFactory::canClone(BuildStepList *parent, BuildStep *source) const { - return canCreate(parent, type, source->id()); + return canCreate(parent, source->id()); } -ProjectExplorer::BuildStep *QMakeStepFactory::clone(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, ProjectExplorer::BuildStep *source) +ProjectExplorer::BuildStep *QMakeStepFactory::clone(BuildStepList *parent, ProjectExplorer::BuildStep *source) { - if (!canClone(parent, type, source)) + if (!canClone(parent, source)) return 0; - Qt4BuildConfiguration *bc(qobject_cast<Qt4BuildConfiguration *>(parent)); - Q_ASSERT(bc); - return new QMakeStep(bc, qobject_cast<QMakeStep *>(source)); + return new QMakeStep(parent, qobject_cast<QMakeStep *>(source)); } -bool QMakeStepFactory::canRestore(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QVariantMap &map) const +bool QMakeStepFactory::canRestore(BuildStepList *parent, const QVariantMap &map) const { QString id(ProjectExplorer::idFromMap(map)); - return canCreate(parent, type, id); + return canCreate(parent, id); } -ProjectExplorer::BuildStep *QMakeStepFactory::restore(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QVariantMap &map) +ProjectExplorer::BuildStep *QMakeStepFactory::restore(BuildStepList *parent, const QVariantMap &map) { - if (!canRestore(parent, type, map)) + if (!canRestore(parent, map)) return 0; - Qt4BuildConfiguration *bc(qobject_cast<Qt4BuildConfiguration *>(parent)); - Q_ASSERT(bc); - QMakeStep *bs(new QMakeStep(bc)); + QMakeStep *bs = new QMakeStep(parent); if (bs->fromMap(map)) return bs; delete bs; return 0; } -QStringList QMakeStepFactory::availableCreationIds(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type) const +QStringList QMakeStepFactory::availableCreationIds(ProjectExplorer::BuildStepList *parent) const { - if (type == ProjectExplorer::BuildStep::Build) - if (Qt4BuildConfiguration *bc = qobject_cast<Qt4BuildConfiguration *>(parent)) + if (parent->id() == QLatin1String(ProjectExplorer::Constants::BUILDSTEPS_BUILD)) + if (Qt4BuildConfiguration *bc = qobject_cast<Qt4BuildConfiguration *>(parent->parent())) if (!bc->qmakeStep()) return QStringList() << QLatin1String(QMAKE_BS_ID); return QStringList(); diff --git a/src/plugins/qt4projectmanager/qmakestep.h b/src/plugins/qt4projectmanager/qmakestep.h index 2d262dbebc..5c34e5da61 100644 --- a/src/plugins/qt4projectmanager/qmakestep.h +++ b/src/plugins/qt4projectmanager/qmakestep.h @@ -55,13 +55,13 @@ class QMakeStepFactory : public ProjectExplorer::IBuildStepFactory public: explicit QMakeStepFactory(QObject *parent = 0); virtual ~QMakeStepFactory(); - bool canCreate(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type,const QString & id) const; - ProjectExplorer::BuildStep *create(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type,const QString &id); - bool canClone(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type,ProjectExplorer::BuildStep *bs) const; - ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type,ProjectExplorer::BuildStep *bs); - bool canRestore(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type,const QVariantMap &map) const; - ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type,const QVariantMap &map); - QStringList availableCreationIds(ProjectExplorer::BuildConfiguration *bc, ProjectExplorer::BuildStep::Type type) const; + bool canCreate(ProjectExplorer::BuildStepList *parent, const QString & id) const; + ProjectExplorer::BuildStep *create(ProjectExplorer::BuildStepList *parent, const QString &id); + bool canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *bs) const; + ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *bs); + bool canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const; + ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map); + QStringList availableCreationIds(ProjectExplorer::BuildStepList *parent) const; QString displayNameForId(const QString &id) const; }; @@ -74,7 +74,7 @@ class QMakeStep : public ProjectExplorer::AbstractProcessStep friend class Internal::QMakeStepFactory; public: - explicit QMakeStep(Internal::Qt4BuildConfiguration *parent); + explicit QMakeStep(ProjectExplorer::BuildStepList *parent); virtual ~QMakeStep(); Internal::Qt4BuildConfiguration *qt4BuildConfiguration() const; @@ -95,8 +95,8 @@ signals: void userArgumentsChanged(); protected: - QMakeStep(Internal::Qt4BuildConfiguration *parent, QMakeStep *source); - QMakeStep(Internal::Qt4BuildConfiguration *parent, const QString &id); + QMakeStep(ProjectExplorer::BuildStepList *parent, QMakeStep *source); + QMakeStep(ProjectExplorer::BuildStepList *parent, const QString &id); virtual bool fromMap(const QVariantMap &map); virtual void processStartupFailed(); diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.cpp index bfd5895ac4..61bbcc82e2 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.cpp @@ -58,15 +58,15 @@ namespace Internal { const QLatin1String MaemoDeployStep::Id("Qt4ProjectManager.MaemoDeployStep"); -MaemoDeployStep::MaemoDeployStep(ProjectExplorer::BuildConfiguration *bc) - : BuildStep(bc, Id), m_deployables(new MaemoDeployables(this)) +MaemoDeployStep::MaemoDeployStep(ProjectExplorer::BuildStepList *parent) + : BuildStep(parent, Id), m_deployables(new MaemoDeployables(this)) { ctor(); } -MaemoDeployStep::MaemoDeployStep(ProjectExplorer::BuildConfiguration *bc, +MaemoDeployStep::MaemoDeployStep(ProjectExplorer::BuildStepList *parent, MaemoDeployStep *other) - : BuildStep(bc, other), m_deployables(new MaemoDeployables(this)), + : BuildStep(parent, other), m_deployables(new MaemoDeployables(this)), m_lastDeployed(other->m_lastDeployed) { ctor(); diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.h b/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.h index 0307614aec..6b98721b14 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.h @@ -63,7 +63,7 @@ class MaemoDeployStep : public ProjectExplorer::BuildStep Q_OBJECT friend class MaemoDeployStepFactory; public: - MaemoDeployStep(ProjectExplorer::BuildConfiguration *bc); + MaemoDeployStep(ProjectExplorer::BuildStepList *bc); virtual ~MaemoDeployStep(); MaemoDeviceConfig deviceConfig() const; MaemoDeviceConfigListModel *deviceConfigModel() const; @@ -90,7 +90,7 @@ private slots: void handleInstallerErrorOutput(const QByteArray &output); private: - MaemoDeployStep(ProjectExplorer::BuildConfiguration *bc, + MaemoDeployStep(ProjectExplorer::BuildStepList *bc, MaemoDeployStep *other); virtual bool init(); virtual void run(QFutureInterface<bool> &fi); diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeploystepfactory.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemodeploystepfactory.cpp index 2d1e712e1a..ebef6d6288 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodeploystepfactory.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeploystepfactory.cpp @@ -3,6 +3,8 @@ #include "maemodeploystep.h" #include <projectexplorer/buildconfiguration.h> +#include <projectexplorer/buildsteplist.h> +#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/target.h> #include <qt4projectmanager/qt4projectmanagerconstants.h> @@ -16,40 +18,44 @@ MaemoDeployStepFactory::MaemoDeployStepFactory(QObject *parent) { } -QStringList MaemoDeployStepFactory::availableCreationIds(BuildConfiguration *, - BuildStep::Type) const +QStringList MaemoDeployStepFactory::availableCreationIds(BuildStepList *parent) const { + if (parent->id() == QLatin1String(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY) + && parent->target()->id() == QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID) + && !parent->contains(MaemoDeployStep::Id)) + return QStringList() << MaemoDeployStep::Id; return QStringList(); } -QString MaemoDeployStepFactory::displayNameForId(const QString &) const +QString MaemoDeployStepFactory::displayNameForId(const QString &id) const { + if (id == MaemoDeployStep::Id) + return(tr("Deploy to device")); return QString(); } -bool MaemoDeployStepFactory::canCreate(BuildConfiguration *, - BuildStep::Type, const QString &) const +bool MaemoDeployStepFactory::canCreate(BuildStepList *parent, const QString &id) const { - return false; + return parent->id() == QLatin1String(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY) + && id == QLatin1String(MaemoDeployStep::Id) + && parent->target()->id() == QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID) + && !parent->contains(MaemoDeployStep::Id); } -BuildStep *MaemoDeployStepFactory::create(BuildConfiguration *, - BuildStep::Type, const QString &) +BuildStep *MaemoDeployStepFactory::create(BuildStepList *parent, const QString &id) { - Q_ASSERT(false); - return 0; + Q_ASSERT(canCreate(parent, id)); + return new MaemoDeployStep(parent); } -bool MaemoDeployStepFactory::canRestore(BuildConfiguration *parent, - BuildStep::Type type, const QVariantMap &map) const +bool MaemoDeployStepFactory::canRestore(BuildStepList *parent, const QVariantMap &map) const { - return canCreateInternally(parent, type, idFromMap(map)); + return canCreate(parent, idFromMap(map)); } -BuildStep *MaemoDeployStepFactory::restore(BuildConfiguration *parent, - BuildStep::Type type, const QVariantMap &map) +BuildStep *MaemoDeployStepFactory::restore(BuildStepList *parent, const QVariantMap &map) { - Q_ASSERT(canRestore(parent, type, map)); + Q_ASSERT(canRestore(parent, map)); MaemoDeployStep * const step = new MaemoDeployStep(parent); if (!step->fromMap(map)) { delete step; @@ -58,25 +64,16 @@ BuildStep *MaemoDeployStepFactory::restore(BuildConfiguration *parent, return step; } -bool MaemoDeployStepFactory::canClone(BuildConfiguration *parent, - BuildStep::Type type, BuildStep *product) const +bool MaemoDeployStepFactory::canClone(BuildStepList *parent, BuildStep *product) const { - return canCreateInternally(parent, type, product->id()); + return canCreate(parent, product->id()); } -BuildStep *MaemoDeployStepFactory::clone(BuildConfiguration *parent, - BuildStep::Type type, BuildStep *product) +BuildStep *MaemoDeployStepFactory::clone(BuildStepList *parent, BuildStep *product) { - Q_ASSERT(canClone(parent, type, product)); + Q_ASSERT(canClone(parent, product)); return new MaemoDeployStep(parent, static_cast<MaemoDeployStep*>(product)); } -bool MaemoDeployStepFactory::canCreateInternally(BuildConfiguration *parent, - BuildStep::Type type, const QString &id) const -{ - return type == BuildStep::Deploy && id == MaemoDeployStep::Id - && parent->target()->id() == Constants::MAEMO_DEVICE_TARGET_ID; -} - } // namespace Internal } // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeploystepfactory.h b/src/plugins/qt4projectmanager/qt-maemo/maemodeploystepfactory.h index 0516578673..4ea79c430c 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodeploystepfactory.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeploystepfactory.h @@ -11,36 +11,24 @@ class MaemoDeployStepFactory : public ProjectExplorer::IBuildStepFactory public: MaemoDeployStepFactory(QObject *parent); - virtual QStringList availableCreationIds(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type) const; + virtual QStringList availableCreationIds(ProjectExplorer::BuildStepList *parent) const; virtual QString displayNameForId(const QString &id) const; - virtual bool canCreate(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, + virtual bool canCreate(ProjectExplorer::BuildStepList *parent, const QString &id) const; virtual ProjectExplorer::BuildStep * - create(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, const QString &id); + create(ProjectExplorer::BuildStepList *parent, const QString &id); - virtual bool canRestore(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, + virtual bool canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const; virtual ProjectExplorer::BuildStep * - restore(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, const QVariantMap &map); + restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map); - virtual bool canClone(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, + virtual bool canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product) const; virtual ProjectExplorer::BuildStep * - clone(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, + clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product); - -private: - bool canCreateInternally(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, - const QString &id) const; }; } // namespace Internal diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoglobal.h b/src/plugins/qt4projectmanager/qt-maemo/maemoglobal.h index 7d07c0f420..cd98d3bfc3 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoglobal.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoglobal.h @@ -32,6 +32,8 @@ #include <projectexplorer/buildconfiguration.h> #include <projectexplorer/environment.h> +#include <projectexplorer/buildsteplist.h> +#include <projectexplorer/projectexplorerconstants.h> #include <QtCore/QList> @@ -53,8 +55,10 @@ public: template<class T> static T *buildStep(const ProjectExplorer::BuildConfiguration *bc) { - const QList<ProjectExplorer::BuildStep *> &buildSteps - = bc->steps(ProjectExplorer::BuildStep::Deploy); + ProjectExplorer::BuildStepList *bsl = bc->stepList(QLatin1String(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY)); + if (!bsl) + return 0; + const QList<ProjectExplorer::BuildStep *> &buildSteps = bsl->steps(); for (int i = buildSteps.count() - 1; i >= 0; --i) { if (T * const step = qobject_cast<T *>(buildSteps.at(i))) return step; diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationfactory.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationfactory.cpp index 157e92fa86..d6e1873f69 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationfactory.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationfactory.cpp @@ -44,10 +44,13 @@ #include "maemopackagecreationstep.h" #include <projectexplorer/buildconfiguration.h> +#include <projectexplorer/buildsteplist.h> +#include <projectexplorer/deployconfiguration.h> +#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/target.h> #include <qt4projectmanagerconstants.h> -using ProjectExplorer::BuildConfiguration; +using ProjectExplorer::BuildStepList; using ProjectExplorer::BuildStep; namespace Qt4ProjectManager { @@ -56,45 +59,48 @@ namespace Internal { MaemoPackageCreationFactory::MaemoPackageCreationFactory(QObject *parent) : ProjectExplorer::IBuildStepFactory(parent) { - } -QStringList MaemoPackageCreationFactory::availableCreationIds(BuildConfiguration *, - BuildStep::Type) const +QStringList MaemoPackageCreationFactory::availableCreationIds(ProjectExplorer::BuildStepList *parent) const { + if (parent->id() == QLatin1String(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY) + && parent->target()->id() == QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID) + && !parent->contains(MaemoPackageCreationStep::CreatePackageId)) + return QStringList() << MaemoPackageCreationStep::CreatePackageId; return QStringList(); } -QString MaemoPackageCreationFactory::displayNameForId(const QString &) const +QString MaemoPackageCreationFactory::displayNameForId(const QString &id) const { + if (id == MaemoPackageCreationStep::CreatePackageId) + return tr("Create Debian Package"); return QString(); } -bool MaemoPackageCreationFactory::canCreate(BuildConfiguration *, - BuildStep::Type, const QString &) const +bool MaemoPackageCreationFactory::canCreate(ProjectExplorer::BuildStepList *parent, const QString &id) const { - return false; + return parent->id() == QLatin1String(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY) + && id == QLatin1String(MaemoPackageCreationStep::CreatePackageId) + && parent->target()->id() == QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID) + && !parent->contains(MaemoPackageCreationStep::CreatePackageId); } -BuildStep *MaemoPackageCreationFactory::create(BuildConfiguration *, - BuildStep::Type, const QString &) +BuildStep *MaemoPackageCreationFactory::create(ProjectExplorer::BuildStepList *parent, const QString &id) { - Q_ASSERT(false); - return 0; + Q_ASSERT(canCreate(parent, id)); + return new MaemoPackageCreationStep(parent); } -bool MaemoPackageCreationFactory::canRestore(BuildConfiguration *parent, - BuildStep::Type type, +bool MaemoPackageCreationFactory::canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const { - return canCreateInternally(parent, type, ProjectExplorer::idFromMap(map)); + return canCreate(parent, ProjectExplorer::idFromMap(map)); } -BuildStep *MaemoPackageCreationFactory::restore(BuildConfiguration *parent, - BuildStep::Type type, +BuildStep *MaemoPackageCreationFactory::restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) { - Q_ASSERT(canRestore(parent, type, map)); + Q_ASSERT(canRestore(parent, map)); MaemoPackageCreationStep * const step = new MaemoPackageCreationStep(parent); if (!step->fromMap(map)) { @@ -104,29 +110,18 @@ BuildStep *MaemoPackageCreationFactory::restore(BuildConfiguration *parent, return step; } -bool MaemoPackageCreationFactory::canClone(BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, - BuildStep *product) const +bool MaemoPackageCreationFactory::canClone(ProjectExplorer::BuildStepList *parent, + ProjectExplorer::BuildStep *product) const { - return canCreateInternally(parent, type, product->id()); + return canCreate(parent, product->id()); } -BuildStep *MaemoPackageCreationFactory::clone(BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, - BuildStep *product) +BuildStep *MaemoPackageCreationFactory::clone(ProjectExplorer::BuildStepList *parent, + ProjectExplorer::BuildStep *product) { - Q_ASSERT(canClone(parent, type, product)); + Q_ASSERT(canClone(parent, product)); return new MaemoPackageCreationStep(parent, static_cast<MaemoPackageCreationStep *>(product)); } -bool MaemoPackageCreationFactory::canCreateInternally(BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, - const QString &id) const -{ - return type == ProjectExplorer::BuildStep::Deploy - && id == MaemoPackageCreationStep::CreatePackageId - && parent->target()->id() == Constants::MAEMO_DEVICE_TARGET_ID; -} - } // namespace Internal } // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationfactory.h b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationfactory.h index 128c43d5a3..67fd4bbfc0 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationfactory.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationfactory.h @@ -52,36 +52,24 @@ class MaemoPackageCreationFactory : public ProjectExplorer::IBuildStepFactory public: MaemoPackageCreationFactory(QObject *parent); - virtual QStringList availableCreationIds(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type) const; + virtual QStringList availableCreationIds(ProjectExplorer::BuildStepList *parent) const; virtual QString displayNameForId(const QString &id) const; - virtual bool canCreate(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, + virtual bool canCreate(ProjectExplorer::BuildStepList *parent, const QString &id) const; virtual ProjectExplorer::BuildStep * - create(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, const QString &id); + create(ProjectExplorer::BuildStepList *parent, const QString &id); - virtual bool canRestore(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, + virtual bool canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const; virtual ProjectExplorer::BuildStep * - restore(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, const QVariantMap &map); + restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map); - virtual bool canClone(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, + virtual bool canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product) const; virtual ProjectExplorer::BuildStep * - clone(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, + clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product); - -private: - bool canCreateInternally(ProjectExplorer::BuildConfiguration *parent, - ProjectExplorer::BuildStep::Type type, - const QString &id) const; }; } // namespace Internal diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp index 6734d2058b..f3da6f1c11 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp @@ -49,6 +49,7 @@ #include "maemoprofilewrapper.h" #include "maemotoolchain.h" +#include <projectexplorer/buildsteplist.h> #include <projectexplorer/projectexplorerconstants.h> #include <qt4buildconfiguration.h> #include <qt4project.h> @@ -66,24 +67,24 @@ namespace { } using namespace ProjectExplorer::Constants; -using ProjectExplorer::BuildConfiguration; +using ProjectExplorer::BuildStepList; using ProjectExplorer::BuildStepConfigWidget; using ProjectExplorer::Task; namespace Qt4ProjectManager { namespace Internal { -MaemoPackageCreationStep::MaemoPackageCreationStep(BuildConfiguration *buildConfig) - : ProjectExplorer::BuildStep(buildConfig, CreatePackageId), +MaemoPackageCreationStep::MaemoPackageCreationStep(BuildStepList *bsl) + : ProjectExplorer::BuildStep(bsl, CreatePackageId), m_packagingEnabled(true), m_versionString(DefaultVersionNumber) { ctor(); } -MaemoPackageCreationStep::MaemoPackageCreationStep(BuildConfiguration *buildConfig, +MaemoPackageCreationStep::MaemoPackageCreationStep(BuildStepList *bsl, MaemoPackageCreationStep *other) - : BuildStep(buildConfig, other), + : BuildStep(bsl, other), m_packagingEnabled(other->m_packagingEnabled), m_versionString(other->m_versionString) { diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.h b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.h index fe140b88d1..a569136a0f 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.h @@ -64,7 +64,7 @@ class MaemoPackageCreationStep : public ProjectExplorer::BuildStep Q_OBJECT friend class MaemoPackageCreationFactory; public: - MaemoPackageCreationStep(ProjectExplorer::BuildConfiguration *buildConfig); + MaemoPackageCreationStep(ProjectExplorer::BuildStepList *bsl); ~MaemoPackageCreationStep(); QString packageFilePath() const; @@ -82,7 +82,7 @@ private slots: void handleBuildOutput(); private: - MaemoPackageCreationStep(ProjectExplorer::BuildConfiguration *buildConfig, + MaemoPackageCreationStep(ProjectExplorer::BuildStepList *buildConfig, MaemoPackageCreationStep *other); void ctor(); diff --git a/src/plugins/qt4projectmanager/qt-s60/s60createpackagestep.cpp b/src/plugins/qt4projectmanager/qt-s60/s60createpackagestep.cpp index be6f6585ad..7ea037b616 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60createpackagestep.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60createpackagestep.cpp @@ -38,6 +38,8 @@ #include "passphraseforkeydialog.h" #include <projectexplorer/buildconfiguration.h> +#include <projectexplorer/buildsteplist.h> +#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/target.h> #include <projectexplorer/project.h> #include <projectexplorer/gnumakeparser.h> @@ -64,8 +66,8 @@ namespace { const char * const MAKE_CERTIFICATE_ARGUMENT("QT_SIS_CERTIFICATE="); } -S60CreatePackageStep::S60CreatePackageStep(ProjectExplorer::BuildConfiguration *bc) : - BuildStep(bc, QLatin1String(SIGN_BS_ID)), +S60CreatePackageStep::S60CreatePackageStep(ProjectExplorer::BuildStepList *bsl) : + BuildStep(bsl, QLatin1String(SIGN_BS_ID)), m_signingMode(SignSelf), m_createSmartInstaller(false), m_outputParserChain(0), @@ -79,8 +81,8 @@ S60CreatePackageStep::S60CreatePackageStep(ProjectExplorer::BuildConfiguration * ctor_package(); } -S60CreatePackageStep::S60CreatePackageStep(ProjectExplorer::BuildConfiguration *bc, S60CreatePackageStep *bs) : - BuildStep(bc, bs), +S60CreatePackageStep::S60CreatePackageStep(ProjectExplorer::BuildStepList *bsl, S60CreatePackageStep *bs) : + BuildStep(bsl, bs), m_signingMode(bs->m_signingMode), m_customSignaturePath(bs->m_customSignaturePath), m_customKeyPath(bs->m_customKeyPath), @@ -96,8 +98,8 @@ S60CreatePackageStep::S60CreatePackageStep(ProjectExplorer::BuildConfiguration * ctor_package(); } -S60CreatePackageStep::S60CreatePackageStep(ProjectExplorer::BuildConfiguration *bc, const QString &id) : - BuildStep(bc, id), +S60CreatePackageStep::S60CreatePackageStep(ProjectExplorer::BuildStepList *bsl, const QString &id) : + BuildStep(bsl, id), m_signingMode(SignSelf), m_createSmartInstaller(false), m_outputParserChain(0), @@ -564,43 +566,43 @@ S60CreatePackageStepFactory::~S60CreatePackageStepFactory() { } -bool S60CreatePackageStepFactory::canCreate(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QString &id) const +bool S60CreatePackageStepFactory::canCreate(ProjectExplorer::BuildStepList *parent, const QString &id) const { - if (type != ProjectExplorer::BuildStep::Deploy) + if (parent->id() != QLatin1String(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY)) return false; - if (parent->target()->id() != Constants::S60_DEVICE_TARGET_ID) + if (parent->target()->id() != QLatin1String(Constants::S60_DEVICE_TARGET_ID)) return false; return (id == QLatin1String(SIGN_BS_ID)); } -ProjectExplorer::BuildStep *S60CreatePackageStepFactory::create(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QString &id) +ProjectExplorer::BuildStep *S60CreatePackageStepFactory::create(ProjectExplorer::BuildStepList *parent, const QString &id) { - if (!canCreate(parent, type, id)) + if (!canCreate(parent, id)) return 0; return new S60CreatePackageStep(parent); } -bool S60CreatePackageStepFactory::canClone(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, ProjectExplorer::BuildStep *source) const +bool S60CreatePackageStepFactory::canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *source) const { - return canCreate(parent, type, source->id()); + return canCreate(parent, source->id()); } -ProjectExplorer::BuildStep *S60CreatePackageStepFactory::clone(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, ProjectExplorer::BuildStep *source) +ProjectExplorer::BuildStep *S60CreatePackageStepFactory::clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *source) { - if (!canClone(parent, type, source)) + if (!canClone(parent, source)) return 0; return new S60CreatePackageStep(parent, static_cast<S60CreatePackageStep *>(source)); } -bool S60CreatePackageStepFactory::canRestore(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QVariantMap &map) const +bool S60CreatePackageStepFactory::canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const { QString id(ProjectExplorer::idFromMap(map)); - return canCreate(parent, type, id); + return canCreate(parent, id); } -ProjectExplorer::BuildStep *S60CreatePackageStepFactory::restore(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QVariantMap &map) +ProjectExplorer::BuildStep *S60CreatePackageStepFactory::restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) { - if (!canRestore(parent, type, map)) + if (!canRestore(parent, map)) return 0; S60CreatePackageStep *bs(new S60CreatePackageStep(parent)); if (bs->fromMap(map)) @@ -609,11 +611,11 @@ ProjectExplorer::BuildStep *S60CreatePackageStepFactory::restore(ProjectExplorer return 0; } -QStringList S60CreatePackageStepFactory::availableCreationIds(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type) const +QStringList S60CreatePackageStepFactory::availableCreationIds(ProjectExplorer::BuildStepList *parent) const { - if (type != ProjectExplorer::BuildStep::Deploy) + if (parent->id() != QLatin1String(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY)) return QStringList(); - if (parent->target()->id() == Constants::S60_DEVICE_TARGET_ID) + if (parent->target()->id() == QLatin1String(Constants::S60_DEVICE_TARGET_ID)) return QStringList() << QLatin1String(SIGN_BS_ID); return QStringList(); } diff --git a/src/plugins/qt4projectmanager/qt-s60/s60createpackagestep.h b/src/plugins/qt4projectmanager/qt-s60/s60createpackagestep.h index 2cc031861a..e69c8a8044 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60createpackagestep.h +++ b/src/plugins/qt4projectmanager/qt-s60/s60createpackagestep.h @@ -53,17 +53,17 @@ public: ~S60CreatePackageStepFactory(); // used to show the list of possible additons to a target, returns a list of types - QStringList availableCreationIds(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type) const; + QStringList availableCreationIds(ProjectExplorer::BuildStepList *parent) const; // used to translate the types to names to display to the user QString displayNameForId(const QString &id) const; - bool canCreate(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QString &id) const; - ProjectExplorer::BuildStep *create(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QString &id); + bool canCreate(ProjectExplorer::BuildStepList *parent, const QString &id) const; + ProjectExplorer::BuildStep *create(ProjectExplorer::BuildStepList *parent, const QString &id); // used to recreate the runConfigurations when restoring settings - bool canRestore(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QVariantMap &map) const; - ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QVariantMap &map); - bool canClone(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, ProjectExplorer::BuildStep *product) const; - ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, ProjectExplorer::BuildStep *product); + bool canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const; + ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map); + bool canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product) const; + ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product); }; @@ -77,7 +77,7 @@ public: SignCustom = 1 }; - explicit S60CreatePackageStep(ProjectExplorer::BuildConfiguration *bc); + explicit S60CreatePackageStep(ProjectExplorer::BuildStepList *bsl); virtual ~S60CreatePackageStep(); virtual bool init(); @@ -106,8 +106,8 @@ signals: void badPassphrase(); protected: - S60CreatePackageStep(ProjectExplorer::BuildConfiguration *bc, S60CreatePackageStep *bs); - S60CreatePackageStep(ProjectExplorer::BuildConfiguration *bc, const QString &id); + S60CreatePackageStep(ProjectExplorer::BuildStepList *bsl, S60CreatePackageStep *bs); + S60CreatePackageStep(ProjectExplorer::BuildStepList *bsl, const QString &id); bool fromMap(const QVariantMap &map); Qt4BuildConfiguration *qt4BuildConfiguration() const; diff --git a/src/plugins/qt4projectmanager/qt-s60/s60deploystep.cpp b/src/plugins/qt4projectmanager/qt-s60/s60deploystep.cpp index 8a1c47bd95..5a2d947f9d 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60deploystep.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60deploystep.cpp @@ -27,7 +27,6 @@ ** **************************************************************************/ - #include "s60deploystep.h" #include "qt4buildconfiguration.h" @@ -45,9 +44,10 @@ #include <QDir> #include <coreplugin/icore.h> -#include <projectexplorer/buildconfiguration.h> +#include <projectexplorer/buildsteplist.h> #include <projectexplorer/target.h> #include <projectexplorer/ioutputparser.h> +#include <projectexplorer/projectexplorerconstants.h> #include <qt4projectmanagerconstants.h> using namespace ProjectExplorer; @@ -85,14 +85,7 @@ static inline bool renameFile(const QString &sourceName, const QString &targetNa // #pragma mark -- S60DeployStep -S60DeployStep::S60DeployStep(ProjectExplorer::BuildConfiguration *bc, const QString &id) : - BuildStep(bc, id), m_timer(0), - m_releaseDeviceAfterLauncherFinish(true), m_handleDeviceRemoval(true), - m_launcher(0), m_eventLoop(0) -{ -} - -S60DeployStep::S60DeployStep(ProjectExplorer::BuildConfiguration *bc, +S60DeployStep::S60DeployStep(ProjectExplorer::BuildStepList *bc, S60DeployStep *bs): BuildStep(bc, bs), m_timer(0), m_releaseDeviceAfterLauncherFinish(bs->m_releaseDeviceAfterLauncherFinish), @@ -101,7 +94,7 @@ S60DeployStep::S60DeployStep(ProjectExplorer::BuildConfiguration *bc, { } -S60DeployStep::S60DeployStep(ProjectExplorer::BuildConfiguration *bc): +S60DeployStep::S60DeployStep(ProjectExplorer::BuildStepList *bc): BuildStep(bc, QLatin1String(S60_DEPLOY_STEP_ID)), m_timer(0), m_releaseDeviceAfterLauncherFinish(true), m_handleDeviceRemoval(true), m_launcher(0), m_eventLoop(0) @@ -415,12 +408,12 @@ void S60DeployStepWidget::init() QString S60DeployStepWidget::summaryText() const { - return tr("<b>Deploy SIS Package</b>"); + return QString("<b>%1</b>").arg(displayName()); } QString S60DeployStepWidget::displayName() const { - return QString("S60DeployStepWidget::displayName"); + return tr("Deploy SIS Package"); } // #pragma mark -- S60DeployStepFactory @@ -434,43 +427,47 @@ S60DeployStepFactory::~S60DeployStepFactory() { } -bool S60DeployStepFactory::canCreate(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QString &id) const +bool S60DeployStepFactory::canCreate(ProjectExplorer::BuildStepList *parent, const QString &id) const { - if (type != ProjectExplorer::BuildStep::Deploy) + if (parent->id() != QLatin1String(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY)) return false; if (parent->target()->id() != QLatin1String(Constants::S60_DEVICE_TARGET_ID)) return false; return (id == QLatin1String(S60_DEPLOY_STEP_ID)); } -ProjectExplorer::BuildStep *S60DeployStepFactory::create(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QString &id) +ProjectExplorer::BuildStep *S60DeployStepFactory::create(ProjectExplorer::BuildStepList *parent, const QString &id) { - if (!canCreate(parent, type, id)) + if (!canCreate(parent, id)) return 0; - return new S60DeployStep(parent, id); + return new S60DeployStep(parent); } -bool S60DeployStepFactory::canClone(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, ProjectExplorer::BuildStep *source) const +bool S60DeployStepFactory::canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *source) const { - return canCreate(parent, type, source->id()); + if (!canCreate(parent, source->id())) + return false; + if (!qobject_cast<S60DeployStep *>(source)) + return false; + return true; } -ProjectExplorer::BuildStep *S60DeployStepFactory::clone(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, ProjectExplorer::BuildStep *source) +ProjectExplorer::BuildStep *S60DeployStepFactory::clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *source) { - if (!canClone(parent, type, source)) + if (!canClone(parent, source)) return 0; return new S60DeployStep(parent, static_cast<S60DeployStep *>(source)); } -bool S60DeployStepFactory::canRestore(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QVariantMap &map) const +bool S60DeployStepFactory::canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const { QString id(ProjectExplorer::idFromMap(map)); - return canCreate(parent, type, id); + return canCreate(parent, id); } -ProjectExplorer::BuildStep *S60DeployStepFactory::restore(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QVariantMap &map) +ProjectExplorer::BuildStep *S60DeployStepFactory::restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) { - if (!canRestore(parent, type, map)) + if (!canRestore(parent, map)) return 0; S60DeployStep *bs = new S60DeployStep(parent); if (bs->fromMap(map)) @@ -479,11 +476,10 @@ ProjectExplorer::BuildStep *S60DeployStepFactory::restore(ProjectExplorer::Build return 0; } -QStringList S60DeployStepFactory::availableCreationIds(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type) const +QStringList S60DeployStepFactory::availableCreationIds(ProjectExplorer::BuildStepList *parent) const { - if (type != ProjectExplorer::BuildStep::Deploy) - return QStringList(); - if (parent->target()->id() == QLatin1String(Constants::S60_DEVICE_TARGET_ID)) + if (parent->id() == QLatin1String(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY) + && parent->target()->id() == QLatin1String(Constants::S60_DEVICE_TARGET_ID)) return QStringList() << QLatin1String(S60_DEPLOY_STEP_ID); return QStringList(); } diff --git a/src/plugins/qt4projectmanager/qt-s60/s60deploystep.h b/src/plugins/qt4projectmanager/qt-s60/s60deploystep.h index e3c324669d..297a25be09 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60deploystep.h +++ b/src/plugins/qt4projectmanager/qt-s60/s60deploystep.h @@ -60,17 +60,17 @@ public: ~S60DeployStepFactory(); // used to show the list of possible additons to a target, returns a list of types - QStringList availableCreationIds(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type) const; + QStringList availableCreationIds(ProjectExplorer::BuildStepList *parent) const; // used to translate the types to names to display to the user QString displayNameForId(const QString &id) const; - bool canCreate(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QString &id) const; - ProjectExplorer::BuildStep *create(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QString &id); + bool canCreate(ProjectExplorer::BuildStepList *parent, const QString &id) const; + ProjectExplorer::BuildStep *create(ProjectExplorer::BuildStepList *parent, const QString &id); // used to recreate the runConfigurations when restoring settings - bool canRestore(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QVariantMap &map) const; - ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QVariantMap &map); - bool canClone(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, ProjectExplorer::BuildStep *product) const; - ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, ProjectExplorer::BuildStep *product); + bool canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const; + ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map); + bool canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product) const; + ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product); }; class S60DeployStep : public ProjectExplorer::BuildStep @@ -79,10 +79,7 @@ class S60DeployStep : public ProjectExplorer::BuildStep public: friend class S60DeployStepFactory; - S60DeployStep(ProjectExplorer::BuildConfiguration *bc, const QString &id); - S60DeployStep(ProjectExplorer::BuildConfiguration *bc, - S60DeployStep *bs); - explicit S60DeployStep(ProjectExplorer::BuildConfiguration *bc); + explicit S60DeployStep(ProjectExplorer::BuildStepList *parent); virtual ~S60DeployStep(); @@ -97,14 +94,6 @@ public: protected: virtual bool fromMap(const QVariantMap &map); -private: - void start(); - void stop(); - void startDeployment(); - bool processPackageName(QString &errorMessage); - void setupConnections(); - void appendMessage(const QString &error, bool isError); - protected slots: void deviceRemoved(const SymbianUtils::SymbianDevice &); @@ -127,6 +116,16 @@ signals: void finishNow(); private: + S60DeployStep(ProjectExplorer::BuildStepList *parent, + S60DeployStep *bs); + + void start(); + void stop(); + void startDeployment(); + bool processPackageName(QString &errorMessage); + void setupConnections(); + void appendMessage(const QString &error, bool isError); + QString m_serialPortName; QString m_serialPortFriendlyName; QStringList m_packageFileNamesWithTarget; // Support for 4.6.1 diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp index 8bb36a1982..311f2c3203 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp @@ -48,6 +48,7 @@ #include <coreplugin/progressmanager/progressmanager.h> #include <utils/qtcassert.h> #include <utils/pathchooser.h> +#include <projectexplorer/buildsteplist.h> #include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/project.h> #include <projectexplorer/buildconfiguration.h> @@ -413,7 +414,9 @@ bool S60DeviceRunConfiguration::runSmartInstaller() const { BuildConfiguration *bc = target()->activeBuildConfiguration(); QTC_ASSERT(bc, return false); - QList<BuildStep *> steps = bc->steps(ProjectExplorer::BuildStep::Build); + BuildStepList *bsl = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY); + QTC_ASSERT(bsl, return false); + QList<BuildStep *> steps = bsl->steps(); foreach (const BuildStep *step, steps) { if (const S60CreatePackageStep *packageStep = qobject_cast<const S60CreatePackageStep *>(step)) { return packageStep->createsSmartInstaller(); diff --git a/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp b/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp index b8807d8eef..bb5c5d0c4f 100644 --- a/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp @@ -37,6 +37,8 @@ #include "makestep.h" #include <utils/qtcassert.h> +#include <projectexplorer/buildsteplist.h> +#include <projectexplorer/projectexplorerconstants.h> #include <QtCore/QDebug> @@ -398,18 +400,22 @@ void Qt4BuildConfiguration::getConfigCommandLineArguments(QStringList *addedUser QMakeStep *Qt4BuildConfiguration::qmakeStep() const { QMakeStep *qs = 0; - foreach(BuildStep *bs, steps(ProjectExplorer::BuildStep::Build)) - if ((qs = qobject_cast<QMakeStep *>(bs)) != 0) + BuildStepList *bsl = stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); + Q_ASSERT(bsl); + for (int i = 0; i < bsl->count(); ++i) + if ((qs = qobject_cast<QMakeStep *>(bsl->at(i))) != 0) return qs; return 0; } MakeStep *Qt4BuildConfiguration::makeStep() const { - MakeStep *qs = 0; - foreach(BuildStep *bs, steps(ProjectExplorer::BuildStep::Build)) - if ((qs = qobject_cast<MakeStep *>(bs)) != 0) - return qs; + MakeStep *ms = 0; + BuildStepList *bsl = stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); + Q_ASSERT(bsl); + for (int i = 0; i < bsl->count(); ++i) + if ((ms = qobject_cast<MakeStep *>(bsl->at(i))) != 0) + return ms; return 0; } @@ -648,7 +654,7 @@ BuildConfiguration *Qt4BuildConfigurationFactory::create(ProjectExplorer::Target version->displayName(), &ok); if (!ok || buildConfigurationName.isEmpty()) - return false; + return 0; qt4Target->addQt4BuildConfiguration(tr("%1 Debug").arg(buildConfigurationName), version, diff --git a/src/plugins/qt4projectmanager/qt4deployconfiguration.cpp b/src/plugins/qt4projectmanager/qt4deployconfiguration.cpp new file mode 100644 index 0000000000..d3c4e8447a --- /dev/null +++ b/src/plugins/qt4projectmanager/qt4deployconfiguration.cpp @@ -0,0 +1,65 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "qt4deployconfiguration.h" + +#include "qt4projectmanagerconstants.h" +#include "qt4target.h" +#include "qt-maemo/maemodeploystep.h" +#include "qt-maemo/maemopackagecreationstep.h" +#include "qt-s60/s60createpackagestep.h" +#include "qt-s60/s60deploystep.h" + +#include <projectexplorer/buildsteplist.h> + +using namespace Qt4ProjectManager; +using namespace Qt4ProjectManager::Internal; + +Qt4DeployConfigurationFactory::Qt4DeployConfigurationFactory(QObject *parent) : + ProjectExplorer::DeployConfigurationFactory(parent) +{ } + +ProjectExplorer::DeployConfiguration *Qt4DeployConfigurationFactory::create(ProjectExplorer::Target *parent, const QString &id) +{ + ProjectExplorer::DeployConfiguration *dc = ProjectExplorer::DeployConfigurationFactory::create(parent, id); + if (!dc) + return 0; + + if (parent->id() == Constants::S60_DEVICE_TARGET_ID) { + dc->setDisplayName(tr("Deploy to Symbian device")); + dc->stepList()->insertStep(0, new S60CreatePackageStep(dc->stepList())); + dc->stepList()->insertStep(1, new S60DeployStep(dc->stepList())); + } else if (parent->id() == Constants::MAEMO_DEVICE_TARGET_ID) { + dc->setDisplayName(tr("Deploy to Maemo device")); + dc->stepList()->insertStep(0, new MaemoPackageCreationStep(dc->stepList())); + dc->stepList()->insertStep(1, new MaemoDeployStep(dc->stepList())); + } + + return dc; +} diff --git a/src/plugins/qt4projectmanager/qt4deployconfiguration.h b/src/plugins/qt4projectmanager/qt4deployconfiguration.h new file mode 100644 index 0000000000..d0dfdfe62e --- /dev/null +++ b/src/plugins/qt4projectmanager/qt4deployconfiguration.h @@ -0,0 +1,51 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef QT4PROJECTMANAGER_QT4DEPLOYCONFIGURATION_H +#define QT4PROJECTMANAGER_QT4DEPLOYCONFIGURATION_H + +#include <projectexplorer/deployconfiguration.h> + +namespace Qt4ProjectManager { +namespace Internal { + +class Qt4DeployConfigurationFactory : public ProjectExplorer::DeployConfigurationFactory +{ + Q_OBJECT + +public: + explicit Qt4DeployConfigurationFactory(QObject *parent = 0); + + ProjectExplorer::DeployConfiguration *create(ProjectExplorer::Target *parent, const QString &id); +}; + +} // namespace Internal +} // namespace Qt4ProjectManager + +#endif // QT4PROJECTMANAGER_QT4DEPLOYCONFIGURATION_H diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp index 2024315491..8e99d6d91d 100644 --- a/src/plugins/qt4projectmanager/qt4project.cpp +++ b/src/plugins/qt4projectmanager/qt4project.cpp @@ -849,7 +849,7 @@ QString Qt4Project::displayName() const QString Qt4Project::id() const { - return QLatin1String("Qt4ProjectManager.Qt4Project"); + return QLatin1String(Constants::QT4PROJECT_ID); } Core::IFile *Qt4Project::file() const diff --git a/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp b/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp index 3aacc1bde2..dd32f7472e 100644 --- a/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp +++ b/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp @@ -166,7 +166,7 @@ void Qt4ProjectConfigWidget::init(ProjectExplorer::BuildConfiguration *bc) QTC_ASSERT(bc, return); if (debug) - qDebug() << "Qt4ProjectConfigWidget::init() for"<<bc->displayName(); + qDebug() << "Qt4ProjectConfigWidget::init() for" << bc->displayName(); if (m_buildConfiguration) { disconnect(m_buildConfiguration, SIGNAL(buildDirectoryChanged()), diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.cpp b/src/plugins/qt4projectmanager/qt4projectmanager.cpp index 24536e1f60..53c4df3e85 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanager.cpp +++ b/src/plugins/qt4projectmanager/qt4projectmanager.cpp @@ -298,13 +298,15 @@ void Qt4Manager::handleSubDirContexMenu(Qt4Manager::Action action) bc->setSubNodeBuild(profile); if (projectExplorer()->saveModifiedFiles()) { - if (action == BUILD) - projectExplorer()->buildManager()->buildProject(bc); - else if (action == CLEAN) - projectExplorer()->buildManager()->cleanProject(bc); - else if (action == REBUILD) { - projectExplorer()->buildManager()->cleanProject(bc); - projectExplorer()->buildManager()->buildProject(bc); + if (action == BUILD) { + projectExplorer()->buildManager()->buildList(bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD)); + } else if (action == CLEAN) { + projectExplorer()->buildManager()->buildList(bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_CLEAN)); + } else if (action == REBUILD) { + QList<ProjectExplorer::BuildStepList *> stepLists; + stepLists << bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_CLEAN); + stepLists << bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); + projectExplorer()->buildManager()->buildLists(stepLists); } } diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.pro b/src/plugins/qt4projectmanager/qt4projectmanager.pro index 678bd5a9bc..2e2ee5083c 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanager.pro +++ b/src/plugins/qt4projectmanager/qt4projectmanager.pro @@ -3,7 +3,8 @@ TARGET = Qt4ProjectManager QT += network include(../../qtcreatorplugin.pri) include(qt4projectmanager_dependencies.pri) -HEADERS += qt4projectmanagerplugin.h \ +HEADERS += qt4deployconfiguration.h \ + qt4projectmanagerplugin.h \ qt4projectmanager.h \ qt4project.h \ qt4nodes.h \ @@ -46,7 +47,8 @@ HEADERS += qt4projectmanagerplugin.h \ qt4target.h \ qmakeparser.h \ qtoutputformatter.h -SOURCES += qt4projectmanagerplugin.cpp \ +SOURCES += qt4deployconfiguration.cpp \ + qt4projectmanagerplugin.cpp \ qt4projectmanager.cpp \ qt4project.cpp \ qt4nodes.cpp \ diff --git a/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h b/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h index 41ca1944eb..b80c7dac27 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h +++ b/src/plugins/qt4projectmanager/qt4projectmanagerconstants.h @@ -95,6 +95,9 @@ const char * const QT_APP_WIZARD_TR_CATEGORY = QT_TRANSLATE_NOOP("Qt4ProjectMana // Tasks const char * const PROFILE_EVALUATE = "Qt4ProjectManager.ProFileEvaluate"; +// Project +const char * const QT4PROJECT_ID("Qt4ProjectManager.Qt4Project"); + // Targets const char * const DESKTOP_TARGET_ID("Qt4ProjectManager.Target.DesktopTarget"); const char * const S60_EMULATOR_TARGET_ID("Qt4ProjectManager.Target.S60EmulatorTarget"); diff --git a/src/plugins/qt4projectmanager/qt4target.cpp b/src/plugins/qt4projectmanager/qt4target.cpp index a5cbb8ce85..c32c63641c 100644 --- a/src/plugins/qt4projectmanager/qt4target.cpp +++ b/src/plugins/qt4projectmanager/qt4target.cpp @@ -32,6 +32,7 @@ #include "makestep.h" #include "profilereader.h" #include "qmakestep.h" +#include "qt4deployconfiguration.h" #include "qt4project.h" #include "qt4runconfiguration.h" #include "qt4projectmanagerconstants.h" @@ -43,8 +44,10 @@ #include "qt-s60/s60createpackagestep.h" #include "qt-s60/s60deploystep.h" +#include <projectexplorer/buildsteplist.h> #include <projectexplorer/customexecutablerunconfiguration.h> #include <projectexplorer/toolchain.h> +#include <projectexplorer/projectexplorerconstants.h> #include <coreplugin/coreconstants.h> #include <symbianutils/symbiandevicemanager.h> @@ -59,29 +62,29 @@ using namespace Qt4ProjectManager::Internal; namespace { QString displayNameForId(const QString &id) { - if (id == QLatin1String(Constants::DESKTOP_TARGET_ID)) + if (id == QLatin1String(Qt4ProjectManager::Constants::DESKTOP_TARGET_ID)) return QApplication::translate("Qt4ProjectManager::Internal::Qt4Target", "Desktop", "Qt4 Desktop target display name"); - if (id == QLatin1String(Constants::S60_EMULATOR_TARGET_ID)) + if (id == QLatin1String(Qt4ProjectManager::Constants::S60_EMULATOR_TARGET_ID)) return QApplication::translate("Qt4ProjectManager::Internal::Qt4Target", "Symbian Emulator", "Qt4 Symbian Emulator target display name"); - if (id == QLatin1String(Constants::S60_DEVICE_TARGET_ID)) + if (id == QLatin1String(Qt4ProjectManager::Constants::S60_DEVICE_TARGET_ID)) return QApplication::translate("Qt4ProjectManager::Internal::Qt4Target", "Symbian Device", "Qt4 Symbian Device target display name"); - if (id == QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID)) + if (id == QLatin1String(Qt4ProjectManager::Constants::MAEMO_DEVICE_TARGET_ID)) return QApplication::translate("Qt4ProjectManager::Internal::Qt4Target", "Maemo", "Qt4 Maemo target display name"); - if (id == QLatin1String(Constants::QT_SIMULATOR_TARGET_ID)) + if (id == QLatin1String(Qt4ProjectManager::Constants::QT_SIMULATOR_TARGET_ID)) return QApplication::translate("Qt4ProjectManager::Internal::Qt4Target", "Qt Simulator", "Qt4 Simulator target display name"); return QString(); } QIcon iconForId(const QString &id) { - if (id == QLatin1String(Constants::DESKTOP_TARGET_ID)) + if (id == QLatin1String(Qt4ProjectManager::Constants::DESKTOP_TARGET_ID)) return QIcon(qApp->style()->standardIcon(QStyle::SP_ComputerIcon)); - if (id == QLatin1String(Constants::S60_EMULATOR_TARGET_ID)) + if (id == QLatin1String(Qt4ProjectManager::Constants::S60_EMULATOR_TARGET_ID)) return QIcon(QLatin1String(":/projectexplorer/images/SymbianEmulator.png")); - if (id == QLatin1String(Constants::S60_DEVICE_TARGET_ID)) + if (id == QLatin1String(Qt4ProjectManager::Constants::S60_DEVICE_TARGET_ID)) return QIcon(QLatin1String(":/projectexplorer/images/SymbianDevice.png")); - if (id == QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID)) + if (id == QLatin1String(Qt4ProjectManager::Constants::MAEMO_DEVICE_TARGET_ID)) return QIcon(QLatin1String(":/projectexplorer/images/MaemoDevice.png")); - if (id == QLatin1String(Constants::QT_SIMULATOR_TARGET_ID)) + if (id == QLatin1String(Qt4ProjectManager::Constants::QT_SIMULATOR_TARGET_ID)) return QIcon(QLatin1String(":/projectexplorer/images/SymbianEmulator.png")); return QIcon(); } @@ -194,6 +197,8 @@ Qt4Target *Qt4TargetFactory::create(ProjectExplorer::Project *parent, const QStr t->addQt4BuildConfiguration(displayName, info.version, info.buildConfig, info.additionalArguments, info.directory); } + t->addDeployConfiguration(t->deployConfigurationFactory()->create(t, ProjectExplorer::Constants::DEFAULT_DEPLOYCONFIGURATION_ID)); + // create RunConfigurations: QStringList pathes = qt4project->applicationProFilePathes(); foreach (const QString &path, pathes) @@ -231,7 +236,8 @@ Qt4Target::Qt4Target(Qt4Project *parent, const QString &id) : ProjectExplorer::Target(parent, id), m_connectedPixmap(QLatin1String(":/projectexplorer/images/ConnectionOn.png")), m_disconnectedPixmap(QLatin1String(":/projectexplorer/images/ConnectionOff.png")), - m_buildConfigurationFactory(new Qt4BuildConfigurationFactory(this)) + m_buildConfigurationFactory(new Qt4BuildConfigurationFactory(this)), + m_deployConfigurationFactory(new Qt4DeployConfigurationFactory(this)) { connect(project(), SIGNAL(supportedTargetIdsChanged()), this, SLOT(updateQtVersion())); @@ -277,28 +283,21 @@ Qt4BuildConfiguration *Qt4Target::addQt4BuildConfiguration(QString displayName, Qt4BuildConfiguration *bc = new Qt4BuildConfiguration(this); bc->setDisplayName(displayName); - QMakeStep *qmakeStep = new QMakeStep(bc); - bc->insertStep(ProjectExplorer::BuildStep::Build, 0, qmakeStep); - - MakeStep *makeStep = new MakeStep(bc); - bc->insertStep(ProjectExplorer::BuildStep::Build, 1, makeStep); - - if (id() == Constants::S60_DEVICE_TARGET_ID) { - S60CreatePackageStep *packageStep = new S60CreatePackageStep(bc); - bc->insertStep(ProjectExplorer::BuildStep::Deploy, 2, packageStep); - S60DeployStep *deployStep = new S60DeployStep(bc); - bc->insertStep(ProjectExplorer::BuildStep::Deploy, 3, deployStep); - } else if (id() == Constants::MAEMO_DEVICE_TARGET_ID) { - bc->insertStep(ProjectExplorer::BuildStep::Deploy, 2, - new MaemoPackageCreationStep(bc)); - bc->insertStep(ProjectExplorer::BuildStep::Deploy, 3, - new MaemoDeployStep(bc)); - } + BuildStepList *buildSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); + BuildStepList *cleanSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_CLEAN); + Q_ASSERT(buildSteps); + Q_ASSERT(cleanSteps); + + QMakeStep *qmakeStep = new QMakeStep(buildSteps); + buildSteps->insertStep(0, qmakeStep); - MakeStep* cleanStep = new MakeStep(bc); + MakeStep *makeStep = new MakeStep(buildSteps); + buildSteps->insertStep(1, makeStep); + + MakeStep* cleanStep = new MakeStep(cleanSteps); cleanStep->setClean(true); cleanStep->setUserArguments(QStringList() << "clean"); - bc->insertStep(ProjectExplorer::BuildStep::Clean, 0, cleanStep); + cleanSteps->insertStep(0, cleanStep); if (!additionalArguments.isEmpty()) qmakeStep->setUserArguments(additionalArguments); @@ -324,6 +323,11 @@ Qt4BuildConfigurationFactory *Qt4Target::buildConfigurationFactory() const return m_buildConfigurationFactory; } +ProjectExplorer::DeployConfigurationFactory *Qt4Target::deployConfigurationFactory() const +{ + return m_deployConfigurationFactory; +} + void Qt4Target::addRunConfigurationForPath(const QString &proFilePath) { if (id() == QLatin1String(Constants::DESKTOP_TARGET_ID) || diff --git a/src/plugins/qt4projectmanager/qt4target.h b/src/plugins/qt4projectmanager/qt4target.h index ae907d6633..c1ed7f3b60 100644 --- a/src/plugins/qt4projectmanager/qt4target.h +++ b/src/plugins/qt4projectmanager/qt4target.h @@ -43,6 +43,7 @@ namespace Internal { class Qt4ProFileNode; class Qt4TargetFactory; class Qt4BuildConfigurationFactory; +class Qt4DeployConfigurationFactory; struct BuildConfigurationInfo { explicit BuildConfigurationInfo(QtVersion *v = 0, QtVersion::QmakeBuildConfigs bc = QtVersion::QmakeBuildConfig(0), @@ -75,6 +76,7 @@ public: void addRunConfigurationForPath(const QString &proFilePath); Internal::Qt4BuildConfigurationFactory *buildConfigurationFactory() const; + ProjectExplorer::DeployConfigurationFactory *deployConfigurationFactory() const; QList<ProjectExplorer::ToolChain::ToolChainType> filterToolChainTypes(const QList<ProjectExplorer::ToolChain::ToolChainType> &candidates) const; ProjectExplorer::ToolChain::ToolChainType preferredToolChainType(const QList<ProjectExplorer::ToolChain::ToolChainType> &candidates) const; @@ -105,6 +107,7 @@ private: const QPixmap m_disconnectedPixmap; Internal::Qt4BuildConfigurationFactory *m_buildConfigurationFactory; + Internal::Qt4DeployConfigurationFactory *m_deployConfigurationFactory; }; class Qt4TargetFactory : public ProjectExplorer::ITargetFactory |