Commit 7904544b authored by dt's avatar dt
Browse files

Remove BuildConfiguration::name()

The pointers can be used to distinguish BuildConfigurations
parent 60a1ee12
......@@ -33,14 +33,14 @@
using namespace CMakeProjectManager;
using namespace Internal;
CMakeBuildConfiguration::CMakeBuildConfiguration(CMakeProject *pro, const QString &name)
: BuildConfiguration(pro, name)
CMakeBuildConfiguration::CMakeBuildConfiguration(CMakeProject *pro)
: BuildConfiguration(pro)
{
}
CMakeBuildConfiguration::CMakeBuildConfiguration(const QString &name, BuildConfiguration *source)
: BuildConfiguration(name, source)
CMakeBuildConfiguration::CMakeBuildConfiguration(BuildConfiguration *source)
: BuildConfiguration(source)
{
}
......
......@@ -40,8 +40,8 @@ class CMakeProject;
class CMakeBuildConfiguration : public ProjectExplorer::BuildConfiguration
{
public:
CMakeBuildConfiguration(CMakeProject *pro, const QString &name);
CMakeBuildConfiguration(const QString &name, BuildConfiguration *source);
CMakeBuildConfiguration(CMakeProject *pro);
CMakeBuildConfiguration(BuildConfiguration *source);
};
......
......@@ -41,7 +41,7 @@ using namespace CMakeProjectManager;
using namespace CMakeProjectManager::Internal;
CMakeBuildEnvironmentWidget::CMakeBuildEnvironmentWidget(CMakeProject *project)
: BuildConfigWidget(), m_pro(project)
: BuildConfigWidget(), m_pro(project), m_buildConfiguration(0)
{
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->setMargin(0);
......@@ -63,29 +63,26 @@ QString CMakeBuildEnvironmentWidget::displayName() const
return tr("Build Environment");
}
void CMakeBuildEnvironmentWidget::init(const QString &buildConfigurationName)
void CMakeBuildEnvironmentWidget::init(ProjectExplorer::BuildConfiguration *bc)
{
if (debug)
qDebug() << "Qt4BuildConfigWidget::init()";
m_buildConfiguration = buildConfigurationName;
m_buildConfiguration = bc;
ProjectExplorer::BuildConfiguration *bc = m_pro->buildConfiguration(buildConfigurationName);
m_clearSystemEnvironmentCheckBox->setChecked(!m_pro->useSystemEnvironment(bc));
m_buildEnvironmentWidget->setBaseEnvironment(m_pro->baseEnvironment(bc));
m_buildEnvironmentWidget->setUserChanges(m_pro->userEnvironmentChanges(bc));
m_clearSystemEnvironmentCheckBox->setChecked(!m_pro->useSystemEnvironment(m_buildConfiguration));
m_buildEnvironmentWidget->setBaseEnvironment(m_pro->baseEnvironment(m_buildConfiguration));
m_buildEnvironmentWidget->setUserChanges(m_pro->userEnvironmentChanges(m_buildConfiguration));
m_buildEnvironmentWidget->updateButtons();
}
void CMakeBuildEnvironmentWidget::environmentModelUserChangesUpdated()
{
m_pro->setUserEnvironmentChanges(
m_pro->buildConfiguration(m_buildConfiguration), m_buildEnvironmentWidget->userChanges());
m_pro->setUserEnvironmentChanges(m_buildConfiguration, m_buildEnvironmentWidget->userChanges());
}
void CMakeBuildEnvironmentWidget::clearSystemEnvironmentCheckBoxClicked(bool checked)
{
ProjectExplorer::BuildConfiguration *bc = m_pro->buildConfiguration(m_buildConfiguration);
m_pro->setUseSystemEnvironment(bc, !checked);
m_buildEnvironmentWidget->setBaseEnvironment(m_pro->baseEnvironment(bc));
m_pro->setUseSystemEnvironment(m_buildConfiguration, !checked);
m_buildEnvironmentWidget->setBaseEnvironment(m_pro->baseEnvironment(m_buildConfiguration));
}
......@@ -51,7 +51,7 @@ public:
CMakeBuildEnvironmentWidget(CMakeProject *project);
QString displayName() const;
void init(const QString &buildConfiguration);
void init(ProjectExplorer::BuildConfiguration *bc);
private slots:
void environmentModelUserChangesUpdated();
......@@ -61,7 +61,7 @@ private:
ProjectExplorer::EnvironmentWidget *m_buildEnvironmentWidget;
QCheckBox *m_clearSystemEnvironmentCheckBox;
CMakeProject *m_pro;
QString m_buildConfiguration;
ProjectExplorer::BuildConfiguration *m_buildConfiguration;
};
} // namespace Internal
......
......@@ -104,7 +104,8 @@ BuildConfiguration *CMakeBuildConfigurationFactory::create(const QString &type)
&ok);
if (!ok || buildConfigurationName.isEmpty())
return false;
BuildConfiguration *bc = new CMakeBuildConfiguration(m_project, buildConfigurationName);
BuildConfiguration *bc = new CMakeBuildConfiguration(m_project);
bc->setDisplayName(buildConfigurationName);
MakeStep *makeStep = new MakeStep(bc);
bc->insertBuildStep(0, makeStep);
......@@ -133,17 +134,17 @@ BuildConfiguration *CMakeBuildConfigurationFactory::create(const QString &type)
return bc;
}
BuildConfiguration *CMakeBuildConfigurationFactory::clone(const QString &name, ProjectExplorer::BuildConfiguration *source) const
BuildConfiguration *CMakeBuildConfigurationFactory::clone(ProjectExplorer::BuildConfiguration *source) const
{
CMakeBuildConfiguration *old = static_cast<CMakeBuildConfiguration *>(source);
CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(name, old);
CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(old);
m_project->addBuildConfiguration(bc);
return bc;
}
BuildConfiguration *CMakeBuildConfigurationFactory::restore(const QString &name) const
BuildConfiguration *CMakeBuildConfigurationFactory::restore() const
{
CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(m_project, name);
CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(m_project);
return bc;
}
......@@ -590,7 +591,7 @@ void CMakeProject::setUseSystemEnvironment(BuildConfiguration *configuration, bo
if (b == useSystemEnvironment(configuration))
return;
configuration->setValue("clearSystemEnvironment", !b);
emit environmentChanged(configuration->name());
emit environmentChanged(configuration);
}
bool CMakeProject::useSystemEnvironment(BuildConfiguration *configuration) const
......@@ -611,7 +612,7 @@ void CMakeProject::setUserEnvironmentChanges(BuildConfiguration *configuration,
if (list == configuration->value("userEnvironmentChanges"))
return;
configuration->setValue("userEnvironmentChanges", list);
emit environmentChanged(configuration->name());
emit environmentChanged(configuration);
}
QString CMakeProject::buildDirectory(BuildConfiguration *configuration) const
......@@ -664,7 +665,8 @@ bool CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader
if (copw.exec() != QDialog::Accepted)
return false;
CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(this, "all");
CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(this);
bc->setDisplayName("all");
addBuildConfiguration(bc);
bc->setValue("msvcVersion", copw.msvcVersion());
if (!copw.buildDirectory().isEmpty())
......@@ -792,7 +794,7 @@ void CMakeFile::modified(ReloadBehavior *behavior)
}
CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeProject *project)
: m_project(project)
: m_project(project), m_buildConfiguration(0)
{
QFormLayout *fl = new QFormLayout(this);
fl->setContentsMargins(20, -1, 0, -1);
......@@ -821,10 +823,9 @@ QString CMakeBuildSettingsWidget::displayName() const
return "CMake";
}
void CMakeBuildSettingsWidget::init(const QString &buildConfigurationName)
void CMakeBuildSettingsWidget::init(BuildConfiguration *bc)
{
m_buildConfiguration = buildConfigurationName;
BuildConfiguration *bc = m_project->buildConfiguration(buildConfigurationName);
m_buildConfiguration = bc;
m_pathLineEdit->setText(m_project->buildDirectory(bc));
if (m_project->buildDirectory(bc) == m_project->sourceDirectory())
m_changeButton->setEnabled(false);
......@@ -834,14 +835,13 @@ void CMakeBuildSettingsWidget::init(const QString &buildConfigurationName)
void CMakeBuildSettingsWidget::openChangeBuildDirectoryDialog()
{
BuildConfiguration *bc = m_project->buildConfiguration(m_buildConfiguration);
CMakeOpenProjectWizard copw(m_project->projectManager(),
m_project->sourceDirectory(),
m_project->buildDirectory(bc),
m_project->environment(bc));
m_project->buildDirectory(m_buildConfiguration),
m_project->environment(m_buildConfiguration));
if (copw.exec() == QDialog::Accepted) {
m_project->changeBuildDirectory(bc, copw.buildDirectory());
m_pathLineEdit->setText(m_project->buildDirectory(bc));
m_project->changeBuildDirectory(m_buildConfiguration, copw.buildDirectory());
m_pathLineEdit->setText(m_project->buildDirectory(m_buildConfiguration));
}
}
......
......@@ -74,8 +74,8 @@ public:
QString displayNameForType(const QString &type) const;
ProjectExplorer::BuildConfiguration *create(const QString &type) const;
ProjectExplorer::BuildConfiguration *clone(const QString &name, ProjectExplorer::BuildConfiguration *source) const;
ProjectExplorer::BuildConfiguration *restore(const QString &name) const;
ProjectExplorer::BuildConfiguration *clone(ProjectExplorer::BuildConfiguration *source) const;
ProjectExplorer::BuildConfiguration *restore() const;
private:
CMakeProject *m_project;
......@@ -232,14 +232,14 @@ public:
// This is called to set up the config widget before showing it
// buildConfiguration is QString::null for the non buildConfiguration specific page
virtual void init(const QString &buildConfiguration);
virtual void init(ProjectExplorer::BuildConfiguration *bc);
private slots:
void openChangeBuildDirectoryDialog();
private:
CMakeProject *m_project;
QLineEdit *m_pathLineEdit;
QPushButton *m_changeButton;
QString m_buildConfiguration;
ProjectExplorer::BuildConfiguration *m_buildConfiguration;
};
} // namespace Internal
......
......@@ -58,7 +58,7 @@ CMakeRunConfiguration::CMakeRunConfiguration(CMakeProject *pro, const QString &t
connect(pro, SIGNAL(activeBuildConfigurationChanged()),
this, SIGNAL(baseEnvironmentChanged()));
connect(pro, SIGNAL(environmentChanged(QString)),
connect(pro, SIGNAL(environmentChanged(ProjectExplorer::BuildConfiguration *)),
this, SIGNAL(baseEnvironmentChanged()));
}
......
......@@ -202,7 +202,8 @@ MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep)
fl->addRow(tr("Targets:"), m_targetsList);
// TODO update this list also on rescans of the CMakeLists.txt
CMakeProject *pro = m_makeStep->project();
// TODO shouldn't be accessing project
CMakeProject *pro = static_cast<CMakeProject *>(m_makeStep->buildConfiguration()->project());
foreach(const QString& target, pro->targets()) {
QListWidgetItem *item = new QListWidgetItem(target, m_targetsList);
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
......@@ -251,11 +252,10 @@ void MakeStepConfigWidget::updateDetails()
{
QStringList arguments = m_makeStep->m_buildTargets;
arguments << m_makeStep->additionalArguments();
m_summaryText = tr("<b>Make:</b> %1 %2")
.arg(m_makeStep->project()->toolChain(
m_makeStep->buildConfiguration())
->makeCommand(),
arguments.join(" "));
BuildConfiguration *bc = m_makeStep->buildConfiguration();
CMakeProject *pro = static_cast<CMakeProject *>(bc->project());
m_summaryText = tr("<b>Make:</b> %1 %2").arg(pro->toolChain(bc)->makeCommand(), arguments.join(" "));
emit updateSummary();
}
......
......@@ -34,14 +34,14 @@ using namespace GenericProjectManager;
using namespace GenericProjectManager::Internal;
using ProjectExplorer::BuildConfiguration;
GenericBuildConfiguration::GenericBuildConfiguration(GenericProject *pro, const QString &name)
: BuildConfiguration(pro, name)
GenericBuildConfiguration::GenericBuildConfiguration(GenericProject *pro)
: BuildConfiguration(pro)
{
}
GenericBuildConfiguration::GenericBuildConfiguration(const QString &name, GenericBuildConfiguration *source)
: BuildConfiguration(name, source)
GenericBuildConfiguration::GenericBuildConfiguration(GenericBuildConfiguration *source)
: BuildConfiguration(source)
{
}
......@@ -41,8 +41,8 @@ class GenericProject;
class GenericBuildConfiguration : public ProjectExplorer::BuildConfiguration
{
public:
GenericBuildConfiguration(GenericProject *pro, const QString &name);
GenericBuildConfiguration(const QString &name, GenericBuildConfiguration *source);
GenericBuildConfiguration(GenericProject *pro);
GenericBuildConfiguration(GenericBuildConfiguration *source);
};
} // namespace GenericProjectManager
......
......@@ -146,7 +146,8 @@ BuildConfiguration *GenericBuildConfigurationFactory::create(const QString &type
&ok);
if (!ok || buildConfigurationName.isEmpty())
return false;
GenericBuildConfiguration *bc = new GenericBuildConfiguration(m_project, buildConfigurationName);
GenericBuildConfiguration *bc = new GenericBuildConfiguration(m_project);
bc->setDisplayName(buildConfigurationName);
m_project->addBuildConfiguration(bc); // also makes the name unique...
GenericMakeStep *makeStep = new GenericMakeStep(bc);
......@@ -155,17 +156,17 @@ BuildConfiguration *GenericBuildConfigurationFactory::create(const QString &type
return bc;
}
BuildConfiguration *GenericBuildConfigurationFactory::clone(const QString &name, BuildConfiguration *source) const
BuildConfiguration *GenericBuildConfigurationFactory::clone(BuildConfiguration *source) const
{
// TODO
GenericBuildConfiguration *bc = new GenericBuildConfiguration(name, static_cast<GenericBuildConfiguration *>(source));
GenericBuildConfiguration *bc = new GenericBuildConfiguration(static_cast<GenericBuildConfiguration *>(source));
m_project->addBuildConfiguration(bc);
return bc;
}
BuildConfiguration *GenericBuildConfigurationFactory::restore(const QString &name) const
BuildConfiguration *GenericBuildConfigurationFactory::restore() const
{
GenericBuildConfiguration *bc = new GenericBuildConfiguration(m_project, name);
GenericBuildConfiguration *bc = new GenericBuildConfiguration(m_project);
return bc;
}
......@@ -533,7 +534,8 @@ bool GenericProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsRead
Project::restoreSettingsImpl(reader);
if (buildConfigurations().isEmpty()) {
GenericBuildConfiguration *bc = new GenericBuildConfiguration(this, "all");
GenericBuildConfiguration *bc = new GenericBuildConfiguration(this);
bc->setDisplayName("all");
addBuildConfiguration(bc);
GenericMakeStep *makeStep = new GenericMakeStep(bc);
......@@ -589,7 +591,7 @@ void GenericProject::saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter
////////////////////////////////////////////////////////////////////////////////////
GenericBuildSettingsWidget::GenericBuildSettingsWidget(GenericProject *project)
: m_project(project)
: m_project(project), m_buildConfiguration(0)
{
QFormLayout *fl = new QFormLayout(this);
fl->setContentsMargins(0, -1, 0, -1);
......@@ -625,15 +627,15 @@ GenericBuildSettingsWidget::~GenericBuildSettingsWidget()
QString GenericBuildSettingsWidget::displayName() const
{ return tr("Generic Manager"); }
void GenericBuildSettingsWidget::init(const QString &buildConfigurationName)
void GenericBuildSettingsWidget::init(BuildConfiguration *bc)
{
m_buildConfiguration = buildConfigurationName;
m_pathChooser->setPath(m_project->buildDirectory(m_project->buildConfiguration(buildConfigurationName)));
m_buildConfiguration = bc;
m_pathChooser->setPath(m_project->buildDirectory(bc));
}
void GenericBuildSettingsWidget::buildDirectoryChanged()
{
m_project->buildConfiguration(m_buildConfiguration)->setValue("buildDirectory", m_pathChooser->path());
m_buildConfiguration->setValue("buildDirectory", m_pathChooser->path());
}
void GenericBuildSettingsWidget::toolChainSelected(int index)
......
......@@ -67,8 +67,8 @@ public:
QString displayNameForType(const QString &type) const;
ProjectExplorer::BuildConfiguration *create(const QString &type) const;
ProjectExplorer::BuildConfiguration *clone(const QString &name, ProjectExplorer::BuildConfiguration *source) const;
ProjectExplorer::BuildConfiguration *restore(const QString &name) const;
ProjectExplorer::BuildConfiguration *clone(ProjectExplorer::BuildConfiguration *source) const;
ProjectExplorer::BuildConfiguration *restore() const;
private:
GenericProject *m_project;
......@@ -195,7 +195,7 @@ public:
virtual QString displayName() const;
virtual void init(const QString &buildConfiguration);
virtual void init(ProjectExplorer::BuildConfiguration *bc);
private Q_SLOTS:
void buildDirectoryChanged();
......@@ -204,7 +204,7 @@ private Q_SLOTS:
private:
GenericProject *m_project;
Utils::PathChooser *m_pathChooser;
QString m_buildConfiguration;
ProjectExplorer::BuildConfiguration *m_buildConfiguration;
};
} // namespace Internal
......
......@@ -44,14 +44,14 @@ IBuildStepFactory *findFactory(const QString &name)
return 0;
}
BuildConfiguration::BuildConfiguration(Project *pro, const QString &name)
: m_name(name), m_project(pro)
BuildConfiguration::BuildConfiguration(Project *pro)
: m_project(pro)
{
setDisplayName(name);
}
BuildConfiguration::BuildConfiguration(const QString &name, BuildConfiguration *source)
: m_values(source->m_values), m_name(name), m_project(source->m_project)
BuildConfiguration::BuildConfiguration(BuildConfiguration *source)
: m_values(source->m_values), m_project(source->m_project)
{
foreach(BuildStep *originalbs, source->buildSteps()) {
IBuildStepFactory *factory = findFactory(originalbs->name());
......@@ -71,16 +71,6 @@ BuildConfiguration::~BuildConfiguration()
qDeleteAll(m_cleanSteps);
}
void BuildConfiguration::setName(const QString &name)
{
m_name = name;
}
QString BuildConfiguration::name() const
{
return m_name;
}
QString BuildConfiguration::displayName() const
{
QVariant v = value("ProjectExplorer.BuildConfiguration.DisplayName");
......
......@@ -53,7 +53,6 @@ public:
// ctors are protected
virtual ~BuildConfiguration();
QString name() const;
QString displayName() const;
void setDisplayName(const QString &name);
......@@ -77,19 +76,15 @@ public:
Project *project() const;
protected:
BuildConfiguration(Project * project, const QString &name);
BuildConfiguration(const QString &name, BuildConfiguration *source);
BuildConfiguration(Project * project);
BuildConfiguration(BuildConfiguration *source);
private:
void setName(const QString &name);
QList<BuildStep *> m_buildSteps;
QList<BuildStep *> m_cleanSteps;
QHash<QString, QVariant> m_values;
QString m_name;
Project *m_project;
friend class Project; // for setName
};
class PROJECTEXPLORER_EXPORT IBuildConfigurationFactory : public QObject
......@@ -110,24 +105,21 @@ public:
virtual BuildConfiguration *create(const QString &type) const = 0;
// clones a given BuildConfiguration and adds it to the project
virtual BuildConfiguration *clone(const QString &name, BuildConfiguration *source) const = 0;
virtual BuildConfiguration *clone(BuildConfiguration *source) const = 0;
// restores a BuildConfiguration with the name and adds it to the project
virtual BuildConfiguration *restore(const QString &name) const = 0;
virtual BuildConfiguration *restore() const = 0;
// TODO All those methods make the internal name (and display name) unique,
// but in different ways
// to come:
// restore
// clone
signals:
void availableCreationTypesChanged();
};
} // namespace ProjectExplorer
Q_DECLARE_METATYPE(ProjectExplorer::BuildConfiguration *);
#endif // BUILDCONFIGURATION_H
......@@ -351,20 +351,12 @@ void BuildManager::buildQueueAppend(BuildStep * bs)
incrementActiveBuildSteps(bs->buildConfiguration()->project());
}
void BuildManager::buildProjects(const QList<Project *> &projects, const QList<QString> &configurations)
void BuildManager::buildProjects(const QList<BuildConfiguration *> &configurations)
{
Q_ASSERT(projects.count() == configurations.count());
QList<QString>::const_iterator cit = configurations.constBegin();
QList<Project *>::const_iterator it, end;
end = projects.constEnd();
for (it = projects.constBegin(); it != end; ++it, ++cit) {
if (*cit != QString::null) {
BuildConfiguration *bc = (*it)->buildConfiguration(*cit);
QList<BuildStep *> buildSteps = bc->buildSteps();
foreach (BuildStep *bs, buildSteps) {
buildQueueAppend(bs);
}
foreach(BuildConfiguration *bc, configurations) {
QList<BuildStep *> buildSteps = bc->buildSteps();
foreach (BuildStep *bs, buildSteps) {
buildQueueAppend(bs);
}
}
if (ProjectExplorerPlugin::instance()->projectExplorerSettings().showCompilerOutput)
......@@ -372,20 +364,12 @@ void BuildManager::buildProjects(const QList<Project *> &projects, const QList<Q
startBuildQueue();
}
void BuildManager::cleanProjects(const QList<Project *> &projects, const QList<QString> &configurations)
void BuildManager::cleanProjects(const QList<BuildConfiguration *> &configurations)
{
Q_ASSERT(projects.count() == configurations.count());
QList<QString>::const_iterator cit = configurations.constBegin();
QList<Project *>::const_iterator it, end;
end = projects.constEnd();
for (it = projects.constBegin(); it != end; ++it, ++cit) {
if (*cit != QString::null) {
BuildConfiguration *bc = (*it)->buildConfiguration(*cit);
QList<BuildStep *> cleanSteps = bc->cleanSteps();
foreach (BuildStep *bs, cleanSteps) {
buildQueueAppend(bs);
}
foreach(BuildConfiguration *bc, configurations) {
QList<BuildStep *> cleanSteps = bc->cleanSteps();
foreach (BuildStep *bs, cleanSteps) {
buildQueueAppend(bs);
}
}
if (ProjectExplorerPlugin::instance()->projectExplorerSettings().showCompilerOutput)
......@@ -393,14 +377,14 @@ void BuildManager::cleanProjects(const QList<Project *> &projects, const QList<Q
startBuildQueue();
}
void BuildManager::buildProject(Project *p, const QString &configuration)
void BuildManager::buildProject(BuildConfiguration *configuration)
{
buildProjects(QList<Project *>() << p, QList<QString>() << configuration);
buildProjects(QList<BuildConfiguration *>() << configuration);
}
void BuildManager::cleanProject(Project *p, const QString &configuration)
void BuildManager::cleanProject(BuildConfiguration *configuration)
{
cleanProjects(QList<Project *>() << p, QList<QString>() << configuration);
cleanProjects(QList<BuildConfiguration *>() << configuration);
}
void BuildManager::appendStep(BuildStep *step)
......
......@@ -49,6 +49,7 @@ namespace Internal {
class BuildStep;
class Project;
class ProjectExplorerPlugin;
class BuildConfiguration;
class PROJECTEXPLORER_EXPORT BuildManager
: public QObject
......@@ -70,10 +71,10 @@ public:
void gotoTaskWindow();
//TODO these should take buildconfiguration object
void buildProject(Project *p, const QString &configuration);
void buildProjects(const QList<Project *> &projects, const QList<QString> &configurations);
void cleanProject(Project *p, const QString &configuration);
void cleanProjects(const QList<Project *> &projects, const QList<QString> &configurations);
void buildProject(BuildConfiguration *bc);
void buildProjects(const QList<BuildConfiguration *> &configurations);
void cleanProject(BuildConfiguration *configuration);
void cleanProjects(const QList<BuildConfiguration *> &configurations);