summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@nokia.com>2010-01-18 12:11:04 +0100
committerTobias Hunger <tobias.hunger@nokia.com>2010-02-01 12:23:13 +0100
commit16a7d5daa2696425848927f47c40ffbcb48407ca (patch)
tree3709e5bddea895c8d2f68855946d2c069ac1e0f5 /src/plugins
parent1726688434b4f974d0179d4ec979ce00f208c9b2 (diff)
downloadqt-creator-16a7d5daa2696425848927f47c40ffbcb48407ca.tar.gz
Make use of ProjectConfiguration in the BuildConfigurations
* Make use of the ProjectConfiguration base class in the BuildConfigurations and update the factories accordingly. Reviewed-by: dt
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp132
-rw-r--r--src/plugins/cmakeprojectmanager/cmakebuildconfiguration.h29
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeprojectconstants.h1
-rw-r--r--src/plugins/genericprojectmanager/genericbuildconfiguration.cpp100
-rw-r--r--src/plugins/genericprojectmanager/genericbuildconfiguration.h35
-rw-r--r--src/plugins/projectexplorer/buildconfiguration.cpp93
-rw-r--r--src/plugins/projectexplorer/buildconfiguration.h53
-rw-r--r--src/plugins/projectexplorer/buildsettingspropertiespage.cpp8
-rw-r--r--src/plugins/projectexplorer/project.cpp181
-rw-r--r--src/plugins/qt4projectmanager/qt4buildconfiguration.cpp182
-rw-r--r--src/plugins/qt4projectmanager/qt4buildconfiguration.h38
11 files changed, 441 insertions, 411 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp
index 70509b02ff..f4c4ac800f 100644
--- a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp
@@ -40,47 +40,56 @@
using namespace CMakeProjectManager;
using namespace Internal;
-CMakeBuildConfiguration::CMakeBuildConfiguration(CMakeProject *pro)
- : BuildConfiguration(pro),
+namespace {
+const char * const CMAKE_BC_ID("CMakeProjectManager.CMakeBuildConfiguration");
+
+const char * const USER_ENVIRONMENT_CHANGES_KEY("CMakeProjectManager.CMakeBuildConfiguration.UserEnvironmentChanges");
+const char * const MSVC_VERSION_KEY("CMakeProjectManager.CMakeBuildConfiguration.MsvcVersion");
+const char * const BUILD_DIRECTORY_KEY("CMakeProjectManager.CMakeBuildConfiguration.BuildDirectory");
+
+}
+
+CMakeBuildConfiguration::CMakeBuildConfiguration(CMakeProject *project) :
+ BuildConfiguration(project, QLatin1String(CMAKE_BC_ID)),
m_toolChain(0),
m_clearSystemEnvironment(false)
{
-
}
-CMakeBuildConfiguration::CMakeBuildConfiguration(CMakeProject *pro, const QMap<QString, QVariant> &map)
- : BuildConfiguration(pro, map),
- m_toolChain(0)
+CMakeBuildConfiguration::CMakeBuildConfiguration(CMakeProject *project, const QString &id) :
+ BuildConfiguration(project, id),
+ m_toolChain(0),
+ m_clearSystemEnvironment(false)
{
-
- QMap<QString, QVariant>::const_iterator it = map.constFind("clearSystemEnvironment");
- m_clearSystemEnvironment = (it != map.constEnd() && it.value().toBool());
- m_userEnvironmentChanges =
- ProjectExplorer::EnvironmentItem::fromStringList(
- map.value("userEnvironmentChanges").toStringList());
- m_msvcVersion = map.value("msvcVersion").toString();
- m_buildDirectory = map.value("buildDirectory").toString();
-
}
-CMakeBuildConfiguration::CMakeBuildConfiguration(CMakeBuildConfiguration *source)
- : BuildConfiguration(source),
+CMakeBuildConfiguration::CMakeBuildConfiguration(CMakeProject *pro, CMakeBuildConfiguration *source) :
+ BuildConfiguration(pro, source),
m_toolChain(0),
m_clearSystemEnvironment(source->m_clearSystemEnvironment),
m_userEnvironmentChanges(source->m_userEnvironmentChanges),
m_buildDirectory(source->m_buildDirectory),
m_msvcVersion(source->m_msvcVersion)
{
-
}
-void CMakeBuildConfiguration::toMap(QMap<QString, QVariant> &map) const
+QVariantMap CMakeBuildConfiguration::toMap() const
{
- map.insert("userEnvironmentChanges",
+ QVariantMap map(ProjectExplorer::BuildConfiguration::toMap());
+ map.insert(QLatin1String(USER_ENVIRONMENT_CHANGES_KEY),
ProjectExplorer::EnvironmentItem::toStringList(m_userEnvironmentChanges));
- map.insert("msvcVersion", m_msvcVersion);
- map.insert("buildDirectory", m_buildDirectory);
- BuildConfiguration::toMap(map);
+ map.insert(QLatin1String(MSVC_VERSION_KEY), m_msvcVersion);
+ map.insert(QLatin1String(BUILD_DIRECTORY_KEY), m_buildDirectory);
+ return map;
+}
+
+bool CMakeBuildConfiguration::fromMap(const QVariantMap &map)
+{
+ m_userEnvironmentChanges = ProjectExplorer::EnvironmentItem::fromStringList(map.value(QLatin1String(USER_ENVIRONMENT_CHANGES_KEY)).toStringList());
+ m_msvcVersion = map.value(QLatin1String(MSVC_VERSION_KEY)).toString();
+ m_buildDirectory = map.value(QLatin1String(BUILD_DIRECTORY_KEY)).toString();
+
+ return BuildConfiguration::fromMap(map);
}
CMakeBuildConfiguration::~CMakeBuildConfiguration()
@@ -212,9 +221,8 @@ void CMakeBuildConfiguration::setMsvcVersion(const QString &msvcVersion)
\class CMakeBuildConfigurationFactory
*/
-CMakeBuildConfigurationFactory::CMakeBuildConfigurationFactory(CMakeProject *project)
- : IBuildConfigurationFactory(project),
- m_project(project)
+CMakeBuildConfigurationFactory::CMakeBuildConfigurationFactory(QObject *parent) :
+ ProjectExplorer::IBuildConfigurationFactory(parent)
{
}
@@ -222,20 +230,36 @@ CMakeBuildConfigurationFactory::~CMakeBuildConfigurationFactory()
{
}
-QStringList CMakeBuildConfigurationFactory::availableCreationIds() const
+QStringList CMakeBuildConfigurationFactory::availableCreationIds(ProjectExplorer::Project *parent) const
{
- return QStringList() << "Create";
+ if (!qobject_cast<CMakeProject *>(parent))
+ return QStringList();
+ return QStringList() << QLatin1String(CMAKE_BC_ID);
}
QString CMakeBuildConfigurationFactory::displayNameForId(const QString &id) const
{
- QTC_ASSERT(id == "Create", return QString());
- return tr("Create");
+ if (id == QLatin1String(CMAKE_BC_ID))
+ return tr("Build");
+ return QString();
}
-ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::create(const QString &id) const
+bool CMakeBuildConfigurationFactory::canCreate(ProjectExplorer::Project *parent, const QString &id) const
{
- QTC_ASSERT(id == "Create", return 0);
+ if (!qobject_cast<CMakeProject *>(parent))
+ return false;
+ if (id == QLatin1String(CMAKE_BC_ID))
+ return true;
+ return false;
+}
+
+ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::create(ProjectExplorer::Project *parent, const QString &id)
+{
+ if (!canCreate(parent, id))
+ return 0;
+
+ CMakeProject *cmProject = static_cast<CMakeProject *>(parent);
+ Q_ASSERT(cmProject);
//TODO configuration name should be part of the cmakeopenprojectwizard
bool ok;
@@ -247,7 +271,7 @@ ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::create(cons
&ok);
if (!ok || buildConfigurationName.isEmpty())
return false;
- CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(m_project);
+ CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(cmProject);
bc->setDisplayName(buildConfigurationName);
MakeStep *makeStep = new MakeStep(bc);
@@ -258,35 +282,55 @@ ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::create(cons
cleanMakeStep->setAdditionalArguments(QStringList() << "clean");
cleanMakeStep->setClean(true);
- CMakeOpenProjectWizard copw(m_project->projectManager(),
- m_project->sourceDirectory(),
+ CMakeOpenProjectWizard copw(cmProject->projectManager(),
+ cmProject->sourceDirectory(),
bc->buildDirectory(),
bc->environment());
if (copw.exec() != QDialog::Accepted) {
delete bc;
return false;
}
- m_project->addBuildConfiguration(bc); // this also makes the name unique
+ cmProject->addBuildConfiguration(bc); // this also makes the name unique
bc->setBuildDirectory(copw.buildDirectory());
bc->setMsvcVersion(copw.msvcVersion());
- m_project->parseCMakeLists();
+ cmProject->parseCMakeLists();
// Default to all
- if (m_project->hasTarget("all"))
+ if (cmProject->hasTarget("all"))
makeStep->setBuildTarget("all", true);
+
return bc;
}
-ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::clone(ProjectExplorer::BuildConfiguration *source) const
+bool CMakeBuildConfigurationFactory::canClone(ProjectExplorer::Project *parent, ProjectExplorer::BuildConfiguration *source) const
+{
+ return canCreate(parent, source->id());
+}
+
+ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::clone(ProjectExplorer::Project *parent, ProjectExplorer::BuildConfiguration *source)
{
+ if (!canClone(parent, source))
+ return 0;
CMakeBuildConfiguration *old = static_cast<CMakeBuildConfiguration *>(source);
- CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(old);
- return bc;
+ CMakeProject *cmProject(static_cast<CMakeProject *>(parent));
+ return new CMakeBuildConfiguration(cmProject, old);
}
-ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::restore(const QVariantMap &map) const
+bool CMakeBuildConfigurationFactory::canRestore(ProjectExplorer::Project *parent, const QVariantMap &map) const
{
- CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(m_project, map);
- return bc;
+ QString id(ProjectExplorer::idFromMap(map));
+ return canCreate(parent, id);
+}
+
+ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::restore(ProjectExplorer::Project *parent, const QVariantMap &map)
+{
+ if (!canRestore(parent, map))
+ return 0;
+ CMakeProject *cmProject(static_cast<CMakeProject *>(parent));
+ CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(cmProject);
+ if (bc->fromMap(map))
+ return bc;
+ delete bc;
+ return 0;
}
diff --git a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.h b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.h
index 7bf9fe9bd9..7e4f5c4206 100644
--- a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.h
+++ b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.h
@@ -37,14 +37,15 @@ namespace CMakeProjectManager {
namespace Internal {
class CMakeProject;
+class CMakeBuildConfigurationFactory;
class CMakeBuildConfiguration : public ProjectExplorer::BuildConfiguration
{
Q_OBJECT
+ friend class CMakeBuildConfigurationFactory;
+
public:
CMakeBuildConfiguration(CMakeProject *pro);
- CMakeBuildConfiguration(CMakeProject *pro, const QMap<QString, QVariant> &map);
- CMakeBuildConfiguration(CMakeBuildConfiguration *source);
~CMakeBuildConfiguration();
CMakeProject *cmakeProject() const;
@@ -62,17 +63,21 @@ public:
ProjectExplorer::ToolChain::ToolChainType toolChainType() const;
ProjectExplorer::ToolChain *toolChain() const;
-
void setBuildDirectory(const QString &buildDirectory);
QString msvcVersion() const;
void setMsvcVersion(const QString &msvcVersion);
- void toMap(QMap<QString, QVariant> &map) const;
+ QVariantMap toMap() const;
signals:
void msvcVersionChanged();
+protected:
+ CMakeBuildConfiguration(CMakeProject *pro, const QString &id);
+ CMakeBuildConfiguration(CMakeProject *pro, CMakeBuildConfiguration *source);
+ virtual bool fromMap(const QVariantMap &map);
+
private:
void updateToolChain() const;
mutable ProjectExplorer::ToolChain *m_toolChain;
@@ -87,18 +92,18 @@ class CMakeBuildConfigurationFactory : public ProjectExplorer::IBuildConfigurati
Q_OBJECT
public:
- CMakeBuildConfigurationFactory(CMakeProject *project);
+ CMakeBuildConfigurationFactory(QObject *parent = 0);
~CMakeBuildConfigurationFactory();
- QStringList availableCreationIds() const;
+ QStringList availableCreationIds(ProjectExplorer::Project *project) const;
QString displayNameForId(const QString &id) const;
- ProjectExplorer::BuildConfiguration *create(const QString &id) const;
- ProjectExplorer::BuildConfiguration *clone(ProjectExplorer::BuildConfiguration *source) const;
- ProjectExplorer::BuildConfiguration *restore(const QVariantMap &map) const;
-
-private:
- CMakeProject *m_project;
+ bool canCreate(ProjectExplorer::Project *parent, const QString &id) const;
+ ProjectExplorer::BuildConfiguration *create(ProjectExplorer::Project *parent, const QString &id);
+ bool canClone(ProjectExplorer::Project *parent, ProjectExplorer::BuildConfiguration *source) const;
+ ProjectExplorer::BuildConfiguration *clone(ProjectExplorer::Project *parent, ProjectExplorer::BuildConfiguration *source);
+ bool canRestore(ProjectExplorer::Project *parent, const QVariantMap &map) const;
+ ProjectExplorer::BuildConfiguration *restore(ProjectExplorer::Project *parent, const QVariantMap &map);
};
} // namespace Internal
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h b/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h
index 8127ddeafb..4d86ef0741 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h
@@ -35,7 +35,6 @@ namespace Constants {
const char * const PROJECTCONTEXT = "CMakeProject.ProjectContext";
const char * const CMAKEMIMETYPE = "text/x-cmake"; // TOOD check that this is correct
-const char * const MAKESTEP = "CMakeProjectManager.MakeStep";
const char * const CMAKERUNCONFIGURATION = "CMakeProjectManager.CMakeRunConfiguration";
diff --git a/src/plugins/genericprojectmanager/genericbuildconfiguration.cpp b/src/plugins/genericprojectmanager/genericbuildconfiguration.cpp
index 4cfde7339b..32d64b01f1 100644
--- a/src/plugins/genericprojectmanager/genericbuildconfiguration.cpp
+++ b/src/plugins/genericprojectmanager/genericbuildconfiguration.cpp
@@ -40,28 +40,44 @@ using namespace GenericProjectManager;
using namespace GenericProjectManager::Internal;
using ProjectExplorer::BuildConfiguration;
+namespace {
+const char * const GENERIC_BC_ID("GenericProjectManager.GenericBuildConfiguration");
+
+const char * const BUILD_DIRECTORY_KEY("GenericProjectManager.GenericBuildConfiguration.BuildDirectory");
+}
+
GenericBuildConfiguration::GenericBuildConfiguration(GenericProject *pro)
- : BuildConfiguration(pro)
+ : BuildConfiguration(pro, QLatin1String(GENERIC_BC_ID))
{
-
}
-GenericBuildConfiguration::GenericBuildConfiguration(GenericProject *pro, const QVariantMap &map)
- : BuildConfiguration(pro, map)
+GenericBuildConfiguration::GenericBuildConfiguration(GenericProject *pro, const QString &id)
+ : BuildConfiguration(pro, id)
{
- m_buildDirectory = map.value("buildDirectory").toString();
}
-GenericBuildConfiguration::GenericBuildConfiguration(GenericBuildConfiguration *source)
- : BuildConfiguration(source),
+GenericBuildConfiguration::GenericBuildConfiguration(GenericProject *pro, GenericBuildConfiguration *source) :
+ BuildConfiguration(pro, source),
m_buildDirectory(source->m_buildDirectory)
{
+}
+
+GenericBuildConfiguration::~GenericBuildConfiguration()
+{
+}
+QVariantMap GenericBuildConfiguration::toMap() const
+{
+ QVariantMap map(BuildConfiguration::toMap());
+ map.insert(QLatin1String(BUILD_DIRECTORY_KEY), m_buildDirectory);
+ return map;
}
-void GenericBuildConfiguration::toMap(QVariantMap &map) const
+bool GenericBuildConfiguration::fromMap(const QVariantMap &map)
{
- map.insert("buildDirectory", m_buildDirectory);
+ m_buildDirectory = map.value(QLatin1String(BUILD_DIRECTORY_KEY)).toString();
+
+ return BuildConfiguration::fromMap(map);
}
ProjectExplorer::Environment GenericBuildConfiguration::environment() const
@@ -98,9 +114,8 @@ GenericProject *GenericBuildConfiguration::genericProject() const
\class GenericBuildConfigurationFactory
*/
-GenericBuildConfigurationFactory::GenericBuildConfigurationFactory(GenericProject *project)
- : IBuildConfigurationFactory(project),
- m_project(project)
+GenericBuildConfigurationFactory::GenericBuildConfigurationFactory(QObject *parent) :
+ ProjectExplorer::IBuildConfigurationFactory(parent)
{
}
@@ -108,20 +123,34 @@ GenericBuildConfigurationFactory::~GenericBuildConfigurationFactory()
{
}
-QStringList GenericBuildConfigurationFactory::availableCreationIds() const
+QStringList GenericBuildConfigurationFactory::availableCreationIds(ProjectExplorer::Project *parent) const
{
- return QStringList() << "Create";
+ Q_UNUSED(parent);
+ return QStringList() << QLatin1String(GENERIC_BC_ID);
}
QString GenericBuildConfigurationFactory::displayNameForId(const QString &id) const
{
- QTC_ASSERT(id == "Create", return QString());
- return tr("Create");
+ if (id == QLatin1String(GENERIC_BC_ID))
+ return tr("Build");
+ return QString();
}
-BuildConfiguration *GenericBuildConfigurationFactory::create(const QString &id) const
+bool GenericBuildConfigurationFactory::canCreate(ProjectExplorer::Project *parent, const QString &id) const
{
- QTC_ASSERT(id == "Create", return false);
+ if (!qobject_cast<GenericProject *>(parent))
+ return false;
+ if (id == QLatin1String(GENERIC_BC_ID))
+ return true;
+ return false;
+}
+
+BuildConfiguration *GenericBuildConfigurationFactory::create(ProjectExplorer::Project *parent, const QString &id)
+{
+ if (!canCreate(parent, id))
+ return 0;
+ GenericProject *project(static_cast<GenericProject *>(parent));
+
//TODO asking for name is duplicated everywhere, but maybe more
// wizards will show up, that incorporate choosing the name
bool ok;
@@ -133,9 +162,9 @@ BuildConfiguration *GenericBuildConfigurationFactory::create(const QString &id)
&ok);
if (!ok || buildConfigurationName.isEmpty())
return false;
- GenericBuildConfiguration *bc = new GenericBuildConfiguration(m_project);
+ GenericBuildConfiguration *bc = new GenericBuildConfiguration(project);
bc->setDisplayName(buildConfigurationName);
- m_project->addBuildConfiguration(bc); // also makes the name unique...
+ project->addBuildConfiguration(bc); // also makes the name unique...
GenericMakeStep *makeStep = new GenericMakeStep(bc);
bc->insertBuildStep(0, makeStep);
@@ -143,14 +172,33 @@ BuildConfiguration *GenericBuildConfigurationFactory::create(const QString &id)
return bc;
}
-BuildConfiguration *GenericBuildConfigurationFactory::clone(BuildConfiguration *source) const
+bool GenericBuildConfigurationFactory::canClone(ProjectExplorer::Project *parent, ProjectExplorer::BuildConfiguration *source) const
{
- GenericBuildConfiguration *bc = new GenericBuildConfiguration(static_cast<GenericBuildConfiguration *>(source));
- return bc;
+ return canCreate(parent, source->id());
}
-BuildConfiguration *GenericBuildConfigurationFactory::restore(const QVariantMap &map) const
+BuildConfiguration *GenericBuildConfigurationFactory::clone(ProjectExplorer::Project *parent, BuildConfiguration *source)
{
- GenericBuildConfiguration *bc = new GenericBuildConfiguration(m_project, map);
- return bc;
+ if (!canClone(parent, source))
+ return 0;
+ GenericProject *project(static_cast<GenericProject *>(parent));
+ return new GenericBuildConfiguration(project, qobject_cast<GenericBuildConfiguration *>(source));
+}
+
+bool GenericBuildConfigurationFactory::canRestore(ProjectExplorer::Project *parent, const QVariantMap &map) const
+{
+ QString id(ProjectExplorer::idFromMap(map));
+ return canCreate(parent, id);
+}
+
+BuildConfiguration *GenericBuildConfigurationFactory::restore(ProjectExplorer::Project *parent, const QVariantMap &map)
+{
+ if (!canRestore(parent, map))
+ return 0;
+ GenericProject *project(static_cast<GenericProject *>(parent));
+ GenericBuildConfiguration *bc(new GenericBuildConfiguration(project));
+ if (bc->fromMap(map))
+ return bc;
+ delete bc;
+ return 0;
}
diff --git a/src/plugins/genericprojectmanager/genericbuildconfiguration.h b/src/plugins/genericprojectmanager/genericbuildconfiguration.h
index 0ad81ca735..722ca2e217 100644
--- a/src/plugins/genericprojectmanager/genericbuildconfiguration.h
+++ b/src/plugins/genericprojectmanager/genericbuildconfiguration.h
@@ -36,22 +36,29 @@ namespace GenericProjectManager {
namespace Internal {
class GenericProject;
-
+class GenericBuildConfigurationFactory;
class GenericBuildConfiguration : public ProjectExplorer::BuildConfiguration
{
Q_OBJECT
+ friend class GenericBuildConfigurationFactory;
+
public:
- GenericBuildConfiguration(GenericProject *pro);
- GenericBuildConfiguration(GenericProject *pro, const QVariantMap &map);
- GenericBuildConfiguration(GenericBuildConfiguration *source);
+ explicit GenericBuildConfiguration(GenericProject *pro);
+ virtual ~GenericBuildConfiguration();
GenericProject *genericProject() const;
virtual ProjectExplorer::Environment environment() const;
virtual QString buildDirectory() const;
void setBuildDirectory(const QString &buildDirectory);
- void toMap(QVariantMap &map) const;
+ QVariantMap toMap() const;
+
+protected:
+ GenericBuildConfiguration(GenericProject *pro, GenericBuildConfiguration *source);
+ GenericBuildConfiguration(GenericProject *pro, const QString &id);
+ virtual bool fromMap(const QVariantMap &map);
+
private:
QString m_buildDirectory;
};
@@ -61,18 +68,18 @@ class GenericBuildConfigurationFactory : public ProjectExplorer::IBuildConfigura
Q_OBJECT
public:
- GenericBuildConfigurationFactory(GenericProject *project);
- ~GenericBuildConfigurationFactory();
+ explicit GenericBuildConfigurationFactory(QObject *parent = 0);
+ virtual ~GenericBuildConfigurationFactory();
- QStringList availableCreationIds() const;
+ QStringList availableCreationIds(ProjectExplorer::Project *project) const;
QString displayNameForId(const QString &id) const;
- ProjectExplorer::BuildConfiguration *create(const QString &id) const;
- ProjectExplorer::BuildConfiguration *clone(ProjectExplorer::BuildConfiguration *source) const;
- ProjectExplorer::BuildConfiguration *restore(const QVariantMap &map) const;
-
-private:
- GenericProject *m_project;
+ bool canCreate(ProjectExplorer::Project *parent, const QString &id) const;
+ ProjectExplorer::BuildConfiguration *create(ProjectExplorer::Project *parent, const QString &id);
+ bool canClone(ProjectExplorer::Project *parent, ProjectExplorer::BuildConfiguration *source) const;
+ ProjectExplorer::BuildConfiguration *clone(ProjectExplorer::Project *parent, ProjectExplorer::BuildConfiguration *source);
+ bool canRestore(ProjectExplorer::Project *parent, const QVariantMap &map) const;
+ ProjectExplorer::BuildConfiguration *restore(ProjectExplorer::Project *parent, const QVariantMap &map);
};
} // namespace GenericProjectManager
diff --git a/src/plugins/projectexplorer/buildconfiguration.cpp b/src/plugins/projectexplorer/buildconfiguration.cpp
index 847cf4251d..64ca6f1d78 100644
--- a/src/plugins/projectexplorer/buildconfiguration.cpp
+++ b/src/plugins/projectexplorer/buildconfiguration.cpp
@@ -36,6 +36,7 @@
using namespace ProjectExplorer;
namespace {
+
IBuildStepFactory *findCloneFactory(BuildConfiguration *parent, BuildStep *source)
{
QList<IBuildStepFactory *> factories = ExtensionSystem::PluginManager::instance()->getObjects<IBuildStepFactory>();
@@ -44,24 +45,35 @@ IBuildStepFactory *findCloneFactory(BuildConfiguration *parent, BuildStep *sourc
return factory;
return 0;
}
-} // namespace
-BuildConfiguration::BuildConfiguration(Project *pro)
- : m_project(pro)
+IBuildStepFactory *findRestoreFactory(BuildConfiguration *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;
}
-BuildConfiguration::BuildConfiguration(Project *pro, const QVariantMap &map)
- : m_project(pro)
+const char * const BUILD_STEPS_COUNT_KEY("ProjectExplorer.BuildConfiguration.BuildStepsCount");
+const char * const BUILD_STEPS_PREFIX("ProjectExplorer.BuildConfiguration.BuildSteps.");
+const char * const CLEAN_STEPS_COUNT_KEY("ProjectExplorer.BuildConfiguration.CleanStepsCount");
+const char * const CLEAN_STEPS_PREFIX("ProjectExplorer.BuildConfiguration.CleanSteps.");
+
+} // namespace
+
+BuildConfiguration::BuildConfiguration(Project *project, const QString &id) :
+ ProjectConfiguration(id),
+ m_project(project)
{
- m_displayName = map.value("ProjectExplorer.BuildConfiguration.DisplayName").toString();
+ Q_ASSERT(m_project);
}
-BuildConfiguration::BuildConfiguration(BuildConfiguration *source)
- : m_displayName(source->m_displayName),
- m_project(source->m_project)
+BuildConfiguration::BuildConfiguration(Project *project, BuildConfiguration *source) :
+ ProjectConfiguration(source),
+ m_project(project)
{
+ Q_ASSERT(m_project);
foreach(BuildStep *originalbs, source->buildSteps()) {
IBuildStepFactory *factory = findCloneFactory(this, originalbs);
BuildStep *clonebs = factory->clone(this, originalbs);
@@ -82,22 +94,55 @@ BuildConfiguration::~BuildConfiguration()
qDeleteAll(m_cleanSteps);
}
-QString BuildConfiguration::displayName() const
+QVariantMap BuildConfiguration::toMap() const
{
- return m_displayName;
-}
+ QVariantMap map(ProjectConfiguration::toMap());
+ map.insert(QLatin1String(BUILD_STEPS_COUNT_KEY), m_buildSteps.count());
+ for (int i = 0; i < m_buildSteps.count(); ++i)
+ map.insert(QString::fromLatin1(BUILD_STEPS_PREFIX) + QString::number(i), m_buildSteps.at(i)->toMap());
+ map.insert(QLatin1String(CLEAN_STEPS_COUNT_KEY), m_cleanSteps.count());
+ for (int i = 0; i < m_cleanSteps.count(); ++i)
+ map.insert(QString::fromLatin1(CLEAN_STEPS_PREFIX) + QString::number(i), m_cleanSteps.at(i)->toMap());
-void BuildConfiguration::setDisplayName(const QString &name)
-{
- if (m_displayName == name)
- return;
- m_displayName = name;
- emit displayNameChanged();
+ return map;
}
-void BuildConfiguration::toMap(QVariantMap &map) const
+
+bool BuildConfiguration::fromMap(const QVariantMap &map)
{
- map.insert("ProjectExplorer.BuildConfiguration.DisplayName", m_displayName);
+ int maxI(map.value(QLatin1String(BUILD_STEPS_COUNT_KEY), 0).toInt());
+ if (maxI < 0)
+ maxI = 0;
+ for (int i = 0; i < maxI; ++i) {
+ QVariantMap bsData(map.value(QString::fromLatin1(BUILD_STEPS_PREFIX) + QString::number(i)).toMap());
+ if (bsData.isEmpty())
+ continue;
+ IBuildStepFactory *factory(findRestoreFactory(this, bsData));
+ if (!factory)
+ continue;
+ BuildStep *bs(factory->restore(this, bsData));
+ if (!bs)
+ continue;
+ insertBuildStep(m_buildSteps.count(), bs);
+ }
+
+ maxI = map.value(QLatin1String(CLEAN_STEPS_COUNT_KEY), 0).toInt();
+ if (maxI < 0)
+ maxI = 0;
+ for (int i = 0; i < maxI; ++i) {
+ QVariantMap bsData(map.value(QString::fromLatin1(CLEAN_STEPS_PREFIX) + QString::number(i)).toMap());
+ if (bsData.isEmpty())
+ continue;
+ IBuildStepFactory *factory(findRestoreFactory(this, bsData));
+ if (!factory)
+ continue;
+ BuildStep *bs(factory->restore(this, bsData));
+ if (!bs)
+ continue;
+ insertCleanStep(m_cleanSteps.count(), bs);
+ }
+
+ return ProjectConfiguration::fromMap(map);
}
QList<BuildStep *> BuildConfiguration::buildSteps() const
@@ -152,17 +197,15 @@ Project *BuildConfiguration::project() const
return m_project;
}
-
///
// IBuildConfigurationFactory
///
-IBuildConfigurationFactory::IBuildConfigurationFactory(QObject *parent)
- : QObject(parent)
+IBuildConfigurationFactory::IBuildConfigurationFactory(QObject *parent) :
+ QObject(parent)
{
}
IBuildConfigurationFactory::~IBuildConfigurationFactory()
{
-
}
diff --git a/src/plugins/projectexplorer/buildconfiguration.h b/src/plugins/projectexplorer/buildconfiguration.h
index 213934c37e..2c8e881d27 100644
--- a/src/plugins/projectexplorer/buildconfiguration.h
+++ b/src/plugins/projectexplorer/buildconfiguration.h
@@ -33,20 +33,19 @@
#include "projectexplorer_export.h"
#include "environment.h"
-#include <QtCore/QHash>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QList>
#include <QtCore/QObject>
-#include <QtCore/QVariant>
#include "buildstep.h"
+#include "projectconfiguration.h"
namespace ProjectExplorer {
class Project;
-class PROJECTEXPLORER_EXPORT BuildConfiguration : public QObject
+class PROJECTEXPLORER_EXPORT BuildConfiguration : public ProjectConfiguration
{
Q_OBJECT
@@ -54,11 +53,6 @@ public:
// ctors are protected
virtual ~BuildConfiguration();
- QString displayName() const;
- void setDisplayName(const QString &name);
-
- virtual void toMap(QMap<QString, QVariant> &map) const;
-
QList<BuildStep *> buildSteps() const;
void insertBuildStep(int position, BuildStep *step);
void removeBuildStep(int position);
@@ -69,53 +63,50 @@ public:
void removeCleanStep(int position);
void moveCleanStepUp(int position);
- Project *project() const;
-
virtual Environment environment() const = 0;
virtual QString buildDirectory() const = 0;
+ Project *project() const;
+
+ virtual QVariantMap toMap() const;
+
signals:
void environmentChanged();
void buildDirectoryChanged();
- void displayNameChanged();
protected:
- BuildConfiguration(Project *project);
- BuildConfiguration(Project *project, const QMap<QString, QVariant> &map);
- BuildConfiguration(BuildConfiguration *source);
+ BuildConfiguration(Project *project, const QString &id);
+ BuildConfiguration(Project *project, BuildConfiguration *source);
+
+ virtual bool fromMap(const QVariantMap &map);
private:
QList<BuildStep *> m_buildSteps;
QList<BuildStep *> m_cleanSteps;
- QString m_displayName;
Project *m_project;
};
-class PROJECTEXPLORER_EXPORT IBuildConfigurationFactory : public QObject
+class PROJECTEXPLORER_EXPORT IBuildConfigurationFactory :
+ public QObject
{
Q_OBJECT
public:
- IBuildConfigurationFactory(QObject *parent = 0);
+ explicit IBuildConfigurationFactory(QObject *parent = 0);
virtual ~IBuildConfigurationFactory();
- // Used to show the list of possible additons to a project.
- // Returns a list of ids.
- virtual QStringList availableCreationIds() const = 0;
+ // used to show the list of possible additons to a project, returns a list of types
+ virtual QStringList availableCreationIds(Project *parent) const = 0;
// used to translate the types to names to display to the user
virtual QString displayNameForId(const QString &id) const = 0;
- // Creates build configuration(s) for the given id and adds them to
- // the project.
- // If successful it returns the BuildConfiguration that should be shown in
- // project mode.
- virtual BuildConfiguration *create(const QString &id) const = 0;
-
- // Clones a given BuildConfiguration, should not add it to the project
- virtual BuildConfiguration *clone(BuildConfiguration *source) const = 0;
-
- // Restores a BuildConfiguration with the data given and adds it to the project.
- virtual BuildConfiguration *restore(const QVariantMap &values) const = 0;
+ virtual bool canCreate(Project *parent, const QString &id) const = 0;
+ virtual BuildConfiguration *create(Project *parent, const QString &id) = 0;
+ // used to recreate the runConfigurations when restoring settings
+ virtual bool canRestore(Project *parent, const QVariantMap &map) const = 0;
+ virtual BuildConfiguration *restore(Project *parent, const QVariantMap &map) = 0;
+ virtual bool canClone(Project *parent, BuildConfiguration *product) const = 0;
+ virtual BuildConfiguration *clone(Project *parent, BuildConfiguration *product) = 0;
signals:
void availableCreationIdsChanged();
diff --git a/src/plugins/projectexplorer/buildsettingspropertiespage.cpp b/src/plugins/projectexplorer/buildsettingspropertiespage.cpp
index 7010413349..e95e0429b7 100644
--- a/src/plugins/projectexplorer/buildsettingspropertiespage.cpp
+++ b/src/plugins/projectexplorer/buildsettingspropertiespage.cpp
@@ -265,7 +265,7 @@ void BuildSettingsWidget::updateAddButtonMenu()
this, SLOT(cloneConfiguration()));
IBuildConfigurationFactory *factory = m_project->buildConfigurationFactory();
if (factory) {
- foreach (const QString &id, factory->availableCreationIds()) {
+ foreach (const QString &id, factory->availableCreationIds(m_project)) {
QAction *action = m_addButtonMenu->addAction(factory->displayNameForId(id), this, SLOT(createConfiguration()));
action->setData(id);
}
@@ -342,7 +342,7 @@ void BuildSettingsWidget::createConfiguration()
{
QAction *action = qobject_cast<QAction *>(sender());
const QString &type = action->data().toString();
- BuildConfiguration *bc = m_project->buildConfigurationFactory()->create(type);
+ BuildConfiguration *bc = m_project->buildConfigurationFactory()->create(m_project, type);
if (bc) {
m_buildConfiguration = bc;
updateBuildSettings();
@@ -377,7 +377,9 @@ void BuildSettingsWidget::cloneConfiguration(BuildConfiguration *sourceConfigura
buildConfigurationDisplayNames << bc->displayName();
newDisplayName = Project::makeUnique(newDisplayName, buildConfigurationDisplayNames);
- m_buildConfiguration = m_project->buildConfigurationFactory()->clone(sourceConfiguration);
+ m_buildConfiguration = m_project->buildConfigurationFactory()->clone(m_project, sourceConfiguration);
+ if (!m_buildConfiguration)
+ return;
m_buildConfiguration->setDisplayName(newDisplayName);
m_project->addBuildConfiguration(m_buildConfiguration);
diff --git a/src/plugins/projectexplorer/project.cpp b/src/plugins/projectexplorer/project.cpp
index 27ee707efc..9a46598d26 100644
--- a/src/plugins/projectexplorer/project.cpp
+++ b/src/plugins/projectexplorer/project.cpp
@@ -159,43 +159,11 @@ void Project::saveSettingsImpl(PersistentSettingsWriter &writer)
//save buildsettings
QStringList buildConfigurationNames;
for(int i=0; i < bcs.size(); ++i) {
- QMap<QString, QVariant> temp;
- bcs.at(i)->toMap(temp);
- writer.saveValue("buildConfiguration-" + QString::number(i), temp);
+ writer.saveValue("buildConfiguration-" + QString::number(i), bcs.at(i)->toMap());
buildConfigurationNames << QString::number(i);
}
writer.saveValue("buildconfigurations", buildConfigurationNames);
- // save each buildstep/buildConfiguration combination
- for(int i=0; i < bcs.size(); ++i) {
- QStringList buildStepNames;
- foreach (BuildStep *buildStep, bcs.at(i)->buildSteps())
- buildStepNames << buildStep->id();
- writer.saveValue("buildconfiguration-" + QString::number(i) + "-buildsteps", buildStepNames);
-
- int buildstepnr = 0;
- foreach (BuildStep *buildStep, bcs.at(i)->buildSteps()) {
- QVariantMap temp(buildStep->toMap());
- writer.saveValue("buildconfiguration-" + QString::number(i) + "-buildstep" + QString().setNum(buildstepnr), temp);
- ++buildstepnr;
- }
- }
-
- // save each cleanstep/buildConfiguration combination
- for(int i=0; i < bcs.size(); ++i) {
- QStringList cleanStepNames;
- foreach (BuildStep *cleanStep, bcs.at(i)->cleanSteps())
- cleanStepNames << cleanStep->id();
- writer.saveValue("buildconfiguration-" + QString::number(i) + "-cleansteps", cleanStepNames);
-
- int cleanstepnr = 0;
- foreach (BuildStep *cleanStep, bcs.at(i)->cleanSteps()) {
- QVariantMap temp(cleanStep->toMap());
- writer.saveValue("buildconfiguration-" + QString::number(i) + "-cleanstep" + QString().setNum(cleanstepnr), temp);
- ++cleanstepnr;
- }
- }
-
// Running
int i = 0;
int activeId = 0;
@@ -215,83 +183,15 @@ void Project::saveSettingsImpl(PersistentSettingsWriter &writer)
bool Project::restoreSettingsImpl(PersistentSettingsReader &reader)
{
- const QList<IBuildStepFactory *> buildStepFactories =
- ExtensionSystem::PluginManager::instance()->getObjects<IBuildStepFactory>();
-
// restoring BuldConfigurations from settings
const QStringList buildConfigurationNames = reader.restoreValue("buildconfigurations").toStringList();
foreach (const QString &buildConfigurationName, buildConfigurationNames) {
- QMap<QString, QVariant> temp =
- reader.restoreValue("buildConfiguration-" + buildConfigurationName).toMap();
-
- BuildConfiguration *bc = buildConfigurationFactory()->restore(temp);
- // Restore build steps
- QVariant buildStepsValueVariant = reader.restoreValue("buildconfiguration-" + buildConfigurationName + "-buildsteps");
- if(buildStepsValueVariant.isValid()) {
- int pos = 0;
- QStringList buildStepNames = buildStepsValueVariant.toStringList();
- for (int buildstepnr = 0; buildstepnr < buildStepNames.size(); ++buildstepnr) {
- // TODO remove restoreFromGlobalMap after 2.0
- QVariantMap values(reader.restoreValue("buildstep" + QString().setNum(buildstepnr)).toMap());
- QVariantMap localValues(reader.restoreValue("buildconfiguration-" + buildConfigurationName + "-buildstep" + QString().setNum(buildstepnr)).toMap());
-
- // override (global)values with what is found in localValues:
- for (QVariantMap::const_iterator i = localValues.constBegin();
- i != localValues.constEnd(); ++i)
- values.insert(i.key(), i.value());
-
- values.insert("ProjectExplorer.ProjectConfiguration.Id",
- buildStepNames.at(buildstepnr));
- BuildStep *buildStep = 0;
- foreach (IBuildStepFactory *factory, buildStepFactories) {
- if (factory->canRestore(bc, values)) {
- buildStep = factory->restore(bc, values);
- break;
- }
- }
- if (buildStep) {
- bc->insertBuildStep(pos, buildStep);
- ++pos;
- }
- }
- }
- // Restore clean steps
- QVariant cleanStepsValueVariant = reader.restoreValue("buildconfiguration-" + buildConfigurationName + "-cleansteps");
- if(cleanStepsValueVariant.isValid()) {
- int pos = 0;
- QStringList cleanStepNames = cleanStepsValueVariant.toStringList();
- for (int cleanstepnr = 0; cleanstepnr < cleanStepNames.size(); ++cleanstepnr) {
- // TODO remove restoreFromGlobalMap after 2.0
- QVariantMap values(reader.restoreValue("cleanstep" + QString().setNum(cleanstepnr)).toMap());
- QVariantMap localValues(reader.restoreValue("buildconfiguration-" + buildConfigurationName + "-cleanstep" + QString().setNum(cleanstepnr)).toMap());
-
- // override (global)values with what is found in localValues:
- for (QVariantMap::const_iterator i = localValues.constBegin();
- i != localValues.constEnd(); ++i)
- values.insert(i.key(), i.value());
-
- values.insert("ProjectExplorer.ProjectConfiguration.Id",
- cleanStepNames.at(cleanstepnr));
-
- BuildStep *cleanStep = 0;
- foreach (IBuildStepFactory *factory, buildStepFactories) {
- if (factory->canRestore(bc, values)) {
- cleanStep = factory->restore(bc, values);
- break;
- }
- }
- if (cleanStep) {
- // TODO remove restoreFromGlobalMap after 2.0
- bc->insertCleanStep(pos, cleanStep);
- ++pos;
- }
- }
- }
+ QVariantMap temp(reader.restoreValue("buildConfiguration-" + buildConfigurationName).toMap());
+ BuildConfiguration *bc = buildConfigurationFactory()->restore(this, temp);
addBuildConfiguration(bc);
}
- // Set Active Configuration
{ // Try restoring the active configuration
QString activeConfigurationName = reader.restoreValue("activebuildconfiguration").toString();
int index = buildConfigurationNames.indexOf(activeConfigurationName);
@@ -303,81 +203,6 @@ bool Project::restoreSettingsImpl(PersistentSettingsReader &reader)
m_activeBuildConfiguration = 0;
}
- //Build Settings
- QList<BuildConfiguration *> bcs(buildConfigurations());
-
- QVariant buildStepsVariant = reader.restoreValue("buildsteps");
- if (buildStepsVariant.isValid()) {
- // Old code path for 1.3 compatibility
- // restoring BuildSteps from settings
- int pos = 0;
- QStringList buildStepNames = buildStepsVariant.toStringList();
- for (int buildstepnr = 0; buildstepnr < buildStepNames.size(); ++buildstepnr) {
- QVariantMap values(reader.restoreValue("cleanstep" + QString().setNum(buildstepnr)).toMap());
- for (int i = 0; i < bcs.size(); ++i) {
- BuildConfiguration *bc = bcs.at(i);
- BuildStep *buildStep = 0;
-
- QVariantMap localValues(reader.restoreValue("buildconfiguration-" + QString::number(pos) + "-cleanstep" + QString().setNum(buildstepnr)).toMap());
-
- // override (global)values with what is found in localValues:
- for (QVariantMap::const_iterator i = localValues.constBegin();
- i != localValues.constEnd(); ++i)
- values.insert(i.key(), i.value());
-
- values.insert("ProjectExplorer.ProjectConfiguration.Id",
- buildStepNames.at(buildstepnr));
-
- foreach (IBuildStepFactory *factory, buildStepFactories) {
- if (factory->canRestore(bc, values)) {
- buildStep = factory->restore(bc, values);
- break;
- }
- }
- if (buildStep) {
- bc->insertBuildStep(pos, buildStep);
- ++pos;
- }
- }
- }
- }
-
- QVariant cleanStepsVariant = reader.restoreValue("cleansteps");
- if (cleanStepsVariant.isValid()) {
- // Old code path for 1.3 compatibility
- QStringList cleanStepNames = cleanStepsVariant.toStringList();
- // restoring BuildSteps from settings
- int pos = 0;
- for (int cleanstepnr = 0; cleanstepnr < cleanStepNames.size(); ++cleanstepnr) {
- QVariantMap values(reader.restoreValue("cleanstep" + QString().setNum(cleanstepnr)).toMap());
- QVariantMap localValues(reader.restoreValue("buildconfiguration-" + QString::number(pos) + "-cleanstep" + QString().setNum(cleanstepnr)).toMap());
-
- // override (global)values with what is found in localValues:
- for (QVariantMap::const_iterator i = localValues.constBegin();
- i != localValues.constEnd(); ++i)
- values.insert(i.key(), i.value());
-
- values.insert("ProjectExplorer.ProjectConfiguration.Id",
- cleanStepNames.at(cleanstepnr));
-
- for (int i = 0; i < bcs.size(); ++i) {
- BuildConfiguration *bc = bcs.at(i);
- BuildStep *cleanStep = 0;
-
- foreach (IBuildStepFactory *factory, buildStepFactories) {
- if (factory->canRestore(bc, values)) {
- cleanStep = factory->restore(bc, values);
- break;
- }
- }
- if (cleanStep) {
- bc->insertCleanStep(pos, cleanStep);
- ++pos;
- }
- }
- }
- }
-
// Running
const int activeId = reader.restoreValue("activeRunConfiguration").toInt();
int i = 0;
diff --git a/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp b/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp
index df22f9379c..f9987e1f78 100644
--- a/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp
+++ b/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp
@@ -40,15 +40,20 @@ using namespace Qt4ProjectManager::Internal;
using namespace ProjectExplorer;
namespace {
- bool debug = false;
-}
+const char * const QT4_BC_ID_PREFIX("Qt4ProjectManager.Qt4BuildConfiguration.");
+const char * const QT4_BC_ID("Qt4ProjectManager.Qt4BuildConfiguration");
-namespace {
- const char * const KEY_QT_VERSION_ID = "QtVersionId";
+const char * const CLEAR_SYSTEM_ENVIRONMENT_KEY("Qt4ProjectManager.Qt4BuildConfiguration.ClearSystemEnvironment");
+const char * const USER_ENVIRONMENT_CHANGES_KEY("Qt4ProjectManager.Qt4BuildConfiguration.UserEnvironmentChanges");
+const char * const USE_SHADOW_BUILD_KEY("Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild");
+const char * const BUILD_DIRECTORY_KEY("Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory");
+const char * const TOOLCHAIN_KEY("Qt4ProjectManager.Qt4BuildConfiguration.ToolChain");
+const char * const BUILD_CONFIGURATION_KEY("Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration");
+const char * const QT_VERSION_ID_KEY("Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId");
}
-Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4Project *pro)
- : BuildConfiguration(pro),
+Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4Project *pro) :
+ BuildConfiguration(pro, QLatin1String(QT4_BC_ID)),
m_clearSystemEnvironment(false),
m_shadowBuild(false),
m_qtVersion(0),
@@ -56,31 +61,23 @@ Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4Project *pro)
m_qmakeBuildConfiguration(0),
m_subNodeBuild(0)
{
- init();
+ ctor();
}
-Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4Project *pro, const QMap<QString, QVariant> &map)
- : BuildConfiguration(pro, map), m_subNodeBuild(0)
+Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4Project *pro, const QString &id) :
+ BuildConfiguration(pro, id),
+ m_clearSystemEnvironment(false),
+ m_shadowBuild(false),
+ m_qtVersion(0),
+ m_toolChainType(-1), // toolChainType() makes sure to return the default toolchainType
+ m_qmakeBuildConfiguration(0),
+ m_subNodeBuild(0)
{
- init();
- QMap<QString, QVariant>::const_iterator it;
- it = map.constFind("clearSystemEnvironment");
- m_clearSystemEnvironment = (it != map.constEnd() && it.value().toBool());
-
- m_userEnvironmentChanges =
- EnvironmentItem::fromStringList(map.value("userEnvironmentChanges").toStringList());
- m_shadowBuild = map.value("useShadowBuild").toBool();
- m_buildDirectory = map.value("buildDirectory").toString();
- m_qtVersion = map.value(KEY_QT_VERSION_ID).toInt();
- if (!QtVersionManager::instance()->isValidId(m_qtVersion))
- m_qtVersion = 0;
-
- m_toolChainType = map.value("ToolChain").toInt();
- m_qmakeBuildConfiguration = QtVersion::QmakeBuildConfigs(map.value("buildConfiguration").toInt());
+ ctor();
}
-Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4BuildConfiguration *source)
- : BuildConfiguration(source),
+Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4Project *pro, Qt4BuildConfiguration *source) :
+ BuildConfiguration(pro, source),
m_clearSystemEnvironment(source->m_clearSystemEnvironment),
m_userEnvironmentChanges(source->m_userEnvironmentChanges),
m_shadowBuild(source->m_shadowBuild),
@@ -90,27 +87,41 @@ Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4BuildConfiguration *source)
m_qmakeBuildConfiguration(source->m_qmakeBuildConfiguration),
m_subNodeBuild(0) // temporary value, so not copied
{
- init();
+ ctor();
}
Qt4BuildConfiguration::~Qt4BuildConfiguration()
{
+}
+QVariantMap Qt4BuildConfiguration::toMap() const
+{
+ QVariantMap map(BuildConfiguration::toMap());
+ map.insert(QLatin1String(CLEAR_SYSTEM_ENVIRONMENT_KEY), m_clearSystemEnvironment);
+ map.insert(QLatin1String(USER_ENVIRONMENT_CHANGES_KEY), EnvironmentItem::toStringList(m_userEnvironmentChanges));
+ map.insert(QLatin1String(USE_SHADOW_BUILD_KEY), m_shadowBuild);
+ map.insert(QLatin1String(BUILD_DIRECTORY_KEY), m_buildDirectory);
+ map.insert(QLatin1String(QT_VERSION_ID_KEY), m_qtVersion);
+ map.insert(QLatin1String(TOOLCHAIN_KEY), m_toolChainType);
+ map.insert(QLatin1String(BUILD_CONFIGURATION_KEY), int(m_qmakeBuildConfiguration));
+ return map;
}
-void Qt4BuildConfiguration::toMap(QMap<QString, QVariant> &map) const
+
+bool Qt4BuildConfiguration::fromMap(const QVariantMap &map)
{
- map.insert("clearSystemEnvironment", m_clearSystemEnvironment);
- map.insert("userEnvironmentChanges", EnvironmentItem::toStringList(m_userEnvironmentChanges));
- map.insert("useShadowBuild", m_shadowBuild);
- map.insert("buildDirectory", m_buildDirectory);
- map.insert(KEY_QT_VERSION_ID, m_qtVersion);
- map.insert("ToolChain", m_toolChainType);
- map.insert("buildConfiguration", int(m_qmakeBuildConfiguration));
- BuildConfiguration::toMap(map);
+ m_clearSystemEnvironment = map.value(QLatin1String(CLEAR_SYSTEM_ENVIRONMENT_KEY)).toBool();
+ m_userEnvironmentChanges = EnvironmentItem::fromStringList(map.value(QLatin1String(USER_ENVIRONMENT_CHANGES_KEY)).toStringList());
+ m_shadowBuild = map.value(QLatin1String(USE_SHADOW_BUILD_KEY)).toBool();
+ m_buildDirectory = map.value(QLatin1String(BUILD_DIRECTORY_KEY)).toString();
+ m_qtVersion = map.value(QLatin1String(QT_VERSION_ID_KEY)).toInt();
+ m_toolChainType = map.value(QLatin1String(TOOLCHAIN_KEY)).toInt();
+ m_qmakeBuildConfiguration = QtVersion::QmakeBuildConfigs(map.value(QLatin1String(BUILD_CONFIGURATION_KEY)).toInt());
+
+ return BuildConfiguration::fromMap(map);
}
-void Qt4BuildConfiguration::init()
+void Qt4BuildConfiguration::ctor()
{
QtVersionManager *vm = QtVersionManager::instance();
connect(vm, SIGNAL(defaultQtVersionChanged()),
@@ -282,9 +293,14 @@ QtVersion *Qt4BuildConfiguration::qtVersion() const
int Qt4BuildConfiguration::qtVersionId() const
{
+ QtVersionManager *vm = QtVersionManager::instance();
+ if (!vm->version(m_qtVersion)->isValid())
+ m_qtVersion = 0;
+
return m_qtVersion;
}
+// TODO: This assumes there is always at least one Qt version... Is that valid?
void Qt4BuildConfiguration::setQtVersion(int id)
{
if (m_qtVersion == id)
@@ -293,6 +309,10 @@ void Qt4BuildConfiguration::setQtVersion(int id)
if (!QtVersionManager::instance()->isValidId(id))
return;
+ QtVersionManager *vm = QtVersionManager::instance();
+ if (!vm->version(id)->isValid())
+ return;
+
m_qtVersion = id;
emit qtVersionChanged();
emit targetInformationChanged();
@@ -535,9 +555,8 @@ QString Qt4BuildConfiguration::extractSpecFromArgumentList(const QStringList &li
\class Qt4BuildConfigurationFactory
*/
-Qt4BuildConfigurationFactory::Qt4BuildConfigurationFactory(Qt4Project *project)
- : IBuildConfigurationFactory(project),
- m_project(project)
+Qt4BuildConfigurationFactory::Qt4BuildConfigurationFactory(QObject *parent) :
+ ProjectExplorer::IBuildConfigurationFactory(parent)
{
update();
@@ -554,36 +573,54 @@ Qt4BuildConfigurationFactory::~Qt4BuildConfigurationFactory()
void Qt4BuildConfigurationFactory::update()
{
-
m_versions.clear();
- m_versions.insert(QLatin1String("DefaultQt"), VersionInfo(tr("Using Default Qt Version"), 0));
+ m_versions.insert(QString::fromLatin1(QT4_BC_ID_PREFIX) + QLatin1String("DefaultQt"), VersionInfo(tr("Using Default Qt Version"), 0));
QtVersionManager *vm = QtVersionManager::instance();
foreach (const QtVersion *version, vm->versions()) {
- m_versions.insert(QString::fromLatin1("Qt%1").arg(version->uniqueId()),
+ m_versions.insert(QString::fromLatin1(QT4_BC_ID_PREFIX) + QString::fromLatin1("Qt%1").arg(version->uniqueId()),
VersionInfo(tr("Using Qt Version \"%1\"").arg(version->displayName()), version->uniqueId()));
}
emit availableCreationIdsChanged();
}
-QStringList Qt4BuildConfigurationFactory::availableCreationIds() const
+QStringList Qt4BuildConfigurationFactory::availableCreationIds(ProjectExplorer::Project *parent) const
{
+ if (!qobject_cast<Qt4Project *>(parent))
+ return QStringList();
return m_versions.keys();
}
QString Qt4BuildConfigurationFactory::displayNameForId(const QString &id) const
{
- if (m_versions.contains(id))
- return m_versions.value(id).displayName;
- return QString();
+ if (!m_versions.contains(id))
+ return QString();
+ return m_versions.value(id).displayName;
}
-BuildConfiguration *Qt4BuildConfigurationFactory::create(const QString &id) const
+bool Qt4BuildConfigurationFactory::canCreate(ProjectExplorer::Project *parent, const QString &id) const
{
- QTC_ASSERT(m_versions.contains(id), return false);
+ if (!qobject_cast<Qt4Project *>(parent))
+ return false;
+ if (!m_versions.contains(id))
+ return false;
const VersionInfo &info = m_versions.value(id);
QtVersion *version = QtVersionManager::instance()->version(info.versionId);
if (!version)
return false;
+ return true;
+}
+
+BuildConfiguration *Qt4BuildConfigurationFactory::create(ProjectExplorer::Project *parent, const QString &id)
+{
+ if (!canCreate(parent, id))
+ return 0;
+
+ const VersionInfo &info = m_versions.value(id);
+ QtVersion *version = QtVersionManager::instance()->version(info.versionId);
+ Q_ASSERT(version);
+
+ Qt4Project *qt4project(static_cast<Qt4Project *>(parent));
+
bool ok;
QString buildConfigurationName = QInputDialog::getText(0,
tr("New configuration"),
@@ -594,26 +631,47 @@ BuildConfiguration *Qt4BuildConfigurationFactory::create(const QString &id) cons
if (!ok || buildConfigurationName.isEmpty())
return false;
- m_project->addQt4BuildConfiguration(tr("%1 Debug").arg(buildConfigurationName),
- version,
- (version->defaultBuildConfig() | QtVersion::DebugBuild));
+ qt4project->addQt4BuildConfiguration(tr("%1 Debug").arg(buildConfigurationName),
+ version,
+ (version->defaultBuildConfig() | QtVersion::DebugBuild));
BuildConfiguration *bc =
- m_project->addQt4BuildConfiguration(tr("%1 Release").arg(buildConfigurationName),
- version,
- (version->defaultBuildConfig() & ~QtVersion::DebugBuild));
+ qt4project->addQt4BuildConfiguration(tr("%1 Release").arg(buildConfigurationName),
+ version,
+ (version->defaultBuildConfig() & ~QtVersion::DebugBuild));
return bc;
}
-BuildConfiguration *Qt4BuildConfigurationFactory::clone(BuildConfiguration *source) const
+bool Qt4BuildConfigurationFactory::canClone(ProjectExplorer::Project *parent, ProjectExplorer::BuildConfiguration *source) const
{
- Qt4BuildConfiguration *oldbc = static_cast<Qt4BuildConfiguration *>(source);
- Qt4BuildConfiguration *newbc = new Qt4BuildConfiguration(oldbc);
- return newbc;
+ return canCreate(parent, source->id());
}
-BuildConfiguration *Qt4BuildConfigurationFactory::restore(const QMap<QString, QVariant> &values) const
+BuildConfiguration *Qt4BuildConfigurationFactory::clone(ProjectExplorer::Project *parent, BuildConfiguration *source)
{
- Qt4BuildConfiguration *bc = new Qt4BuildConfiguration(m_project, values);
- return bc;
+ if (!canClone(parent, source))
+ return 0;
+ Qt4Project *project(static_cast<Qt4Project *>(parent));
+ Qt4BuildConfiguration *oldbc(static_cast<Qt4BuildConfiguration *>(source));
+ return new Qt4BuildConfiguration(project, oldbc);
+}
+
+bool Qt4BuildConfigurationFactory::canRestore(ProjectExplorer::Project *parent, const QVariantMap &map) const
+{
+ QString id(ProjectExplorer::idFromMap(map));
+ if (!qobject_cast<Qt4Project *>(parent))
+ return false;
+ return id.startsWith(QLatin1String(QT4_BC_ID_PREFIX)) ||
+ id == QLatin1String(QT4_BC_ID);
}
+BuildConfiguration *Qt4BuildConfigurationFactory::restore(ProjectExplorer::Project *parent, const QVariantMap &map)
+{
+ if (!canRestore(parent, map))
+ return 0;
+ Qt4Project *project(static_cast<Qt4Project *>(parent));
+ Qt4BuildConfiguration *bc(new Qt4BuildConfiguration(project));
+ if (bc->fromMap(map))
+ return bc;
+ delete bc;
+ return 0;
+}
diff --git a/src/plugins/qt4projectmanager/qt4buildconfiguration.h b/src/plugins/qt4projectmanager/qt4buildconfiguration.h
index 3593d917f4..a62f1e9b61 100644
--- a/src/plugins/qt4projectmanager/qt4buildconfiguration.h
+++ b/src/plugins/qt4projectmanager/qt4buildconfiguration.h
@@ -44,17 +44,16 @@ class MakeStep;
namespace Internal {
+class Qt4BuildConfigurationFactory;
+
class Qt4BuildConfiguration : public ProjectExplorer::BuildConfiguration
{
Q_OBJECT
+ friend class Qt4BuildConfigurationFactory;
+
public:
- // new buildconfiguration
- Qt4BuildConfiguration(Qt4Project *pro);
- // restore ctor
- Qt4BuildConfiguration(Qt4Project *pro, const QMap<QString, QVariant> &values);
- // copy ctor
- Qt4BuildConfiguration(Qt4BuildConfiguration *source);
- ~Qt4BuildConfiguration();
+ explicit Qt4BuildConfiguration(Qt4Project *pro);
+ virtual ~Qt4BuildConfiguration();
Qt4Project *qt4Project() const;
@@ -114,7 +113,7 @@ public:
static QStringList removeSpecFromArgumentList(const QStringList &old);
static QString extractSpecFromArgumentList(const QStringList &list, QString directory, QtVersion *version);
- void toMap(QMap<QString, QVariant> &map) const;
+ QVariantMap toMap() const;
signals:
/// emitted if the qt version changes (either directly, or because the default qt version changed
@@ -130,11 +129,18 @@ signals:
/// a covenience signal, emitted if either the qtversion, the toolchainType or the qmake build
/// configuration changed
void targetInformationChanged();
+
private slots:
void defaultQtVersionChanged();
void qtVersionsChanged(const QList<int> &changedVersions);
+
+protected:
+ Qt4BuildConfiguration(Qt4Project *pro, Qt4BuildConfiguration *source);
+ Qt4BuildConfiguration(Qt4Project *pro, const QString &id);
+ virtual bool fromMap(const QVariantMap &map);
+
private:
- void init();
+ void ctor();
bool m_clearSystemEnvironment;
QList<ProjectExplorer::EnvironmentItem> m_userEnvironmentChanges;
bool m_shadowBuild;
@@ -150,15 +156,18 @@ class Qt4BuildConfigurationFactory : public ProjectExplorer::IBuildConfiguration
Q_OBJECT
public:
- Qt4BuildConfigurationFactory(Qt4Project *project);
+ explicit Qt4BuildConfigurationFactory(QObject *parent = 0);
~Qt4BuildConfigurationFactory();
- QStringList availableCreationIds() const;
+ QStringList availableCreationIds(ProjectExplorer::Project *parent) const;
QString displayNameForId(const QString &id) const;
- ProjectExplorer::BuildConfiguration *create(const QString &id) const;
- ProjectExplorer::BuildConfiguration *clone(ProjectExplorer::BuildConfiguration *source) const;
- ProjectExplorer::BuildConfiguration *restore(const QVariantMap &values) const;
+ bool canCreate(ProjectExplorer::Project *parent, const QString &id) const;
+ ProjectExplorer::BuildConfiguration *create(ProjectExplorer::Project *parent, const QString &id);
+ bool canClone(ProjectExplorer::Project *parent, ProjectExplorer::BuildConfiguration *source) const;
+ ProjectExplorer::BuildConfiguration *clone(ProjectExplorer::Project *parent, ProjectExplorer::BuildConfiguration *source);
+ bool canRestore(ProjectExplorer::Project *parent, const QVariantMap &map) const;
+ ProjectExplorer::BuildConfiguration *restore(ProjectExplorer::Project *parent, const QVariantMap &map);
private slots:
void update();
@@ -172,7 +181,6 @@ private:
int versionId;
};
- Qt4Project *m_project;
QMap<QString, VersionInfo> m_versions;
};