2008-12-02 12:01:29 +01:00
|
|
|
/***************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2009-01-13 19:21:51 +01:00
|
|
|
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** Contact: Qt Software Information (qt-info@nokia.com)
|
|
|
|
|
**
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
|
|
|
|
** Non-Open Source Usage
|
|
|
|
|
**
|
2008-12-02 12:01:29 +01:00
|
|
|
** Licensees may use this file in accordance with the Qt Beta Version
|
|
|
|
|
** License Agreement, Agreement version 2.2 provided with the Software or,
|
|
|
|
|
** alternatively, in accordance with the terms contained in a written
|
2008-12-02 14:17:16 +01:00
|
|
|
** agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
** GNU General Public License Usage
|
|
|
|
|
**
|
2008-12-02 12:01:29 +01:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU General
|
|
|
|
|
** Public License versions 2.0 or 3.0 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.GPL included in the packaging
|
|
|
|
|
** of this file. Please review the following information to ensure GNU
|
|
|
|
|
** General Public Licensing requirements will be met:
|
|
|
|
|
**
|
|
|
|
|
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
|
|
|
|
|
** http://www.gnu.org/copyleft/gpl.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2008-12-02 14:17:16 +01:00
|
|
|
** rights. These rights are described in the Nokia Qt GPL Exception
|
2008-12-16 17:20:00 +01:00
|
|
|
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
|
|
|
|
***************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "project.h"
|
2008-12-02 16:19:05 +01:00
|
|
|
|
|
|
|
|
#include "buildstep.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "projectexplorer.h"
|
|
|
|
|
#include "runconfiguration.h"
|
|
|
|
|
#include "editorconfiguration.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/ifile.h>
|
|
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2008-12-09 15:25:01 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include <QtCore/QDebug>
|
2008-12-09 15:25:01 +01:00
|
|
|
#include <QtCore/QTextCodec>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
|
|
|
|
Project::Project()
|
|
|
|
|
: m_activeRunConfiguration(0),
|
|
|
|
|
m_editorConfiguration(new EditorConfiguration())
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-16 16:30:22 +01:00
|
|
|
Project::~Project()
|
|
|
|
|
{
|
|
|
|
|
qDeleteAll(m_buildSteps);
|
|
|
|
|
qDeleteAll(m_cleanSteps);
|
|
|
|
|
qDeleteAll(m_buildConfigurationValues);
|
|
|
|
|
delete m_editorConfiguration;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void Project::insertBuildStep(int position, BuildStep *step)
|
|
|
|
|
{
|
|
|
|
|
m_buildSteps.insert(position, step);
|
|
|
|
|
// check that the step has all the configurations
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (const QString &name, buildConfigurations())
|
2008-12-02 12:01:29 +01:00
|
|
|
if (!step->getBuildConfiguration(name))
|
|
|
|
|
step->addBuildConfiguration(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Project::removeBuildStep(int position)
|
|
|
|
|
{
|
|
|
|
|
delete m_buildSteps.at(position);
|
|
|
|
|
m_buildSteps.removeAt(position);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Project::moveBuildStepUp(int position)
|
|
|
|
|
{
|
|
|
|
|
BuildStep *bs = m_buildSteps.takeAt(position);
|
|
|
|
|
m_buildSteps.insert(position - 1, bs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Project::insertCleanStep(int position, BuildStep *step)
|
|
|
|
|
{
|
|
|
|
|
m_cleanSteps.insert(position, step);
|
|
|
|
|
// check that the step has all the configurations
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (const QString &name, buildConfigurations())
|
2008-12-02 12:01:29 +01:00
|
|
|
if (!step->getBuildConfiguration(name))
|
|
|
|
|
step->addBuildConfiguration(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Project::removeCleanStep(int position)
|
|
|
|
|
{
|
|
|
|
|
delete m_cleanSteps.at(position);
|
|
|
|
|
m_cleanSteps.removeAt(position);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Project::addBuildConfiguration(const QString &name)
|
|
|
|
|
{
|
|
|
|
|
if (buildConfigurations().contains(name) )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_buildConfigurationValues.push_back(new BuildConfiguration(name));
|
|
|
|
|
|
2008-12-09 11:07:24 +01:00
|
|
|
for (int i = 0; i != m_buildSteps.size(); ++i)
|
2008-12-02 12:01:29 +01:00
|
|
|
m_buildSteps.at(i)->addBuildConfiguration(name);
|
|
|
|
|
|
2008-12-09 11:07:24 +01:00
|
|
|
for (int i = 0; i != m_cleanSteps.size(); ++i)
|
2008-12-02 12:01:29 +01:00
|
|
|
m_cleanSteps.at(i)->addBuildConfiguration(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Project::removeBuildConfiguration(const QString &name)
|
|
|
|
|
{
|
|
|
|
|
if (!buildConfigurations().contains(name))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i != m_buildConfigurationValues.size(); ++i)
|
2008-12-09 11:07:24 +01:00
|
|
|
if (m_buildConfigurationValues.at(i)->name() == name) {
|
2008-12-02 12:01:29 +01:00
|
|
|
delete m_buildConfigurationValues.at(i);
|
|
|
|
|
m_buildConfigurationValues.removeAt(i);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-09 11:07:24 +01:00
|
|
|
for (int i = 0; i != m_buildSteps.size(); ++i)
|
2008-12-02 12:01:29 +01:00
|
|
|
m_buildSteps.at(i)->removeBuildConfiguration(name);
|
2008-12-09 11:07:24 +01:00
|
|
|
for (int i = 0; i != m_cleanSteps.size(); ++i)
|
2008-12-02 12:01:29 +01:00
|
|
|
m_cleanSteps.at(i)->removeBuildConfiguration(name);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Project::copyBuildConfiguration(const QString &source, const QString &dest)
|
|
|
|
|
{
|
|
|
|
|
if (!buildConfigurations().contains(source))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i != m_buildConfigurationValues.size(); ++i)
|
2008-12-09 11:07:24 +01:00
|
|
|
if (m_buildConfigurationValues.at(i)->name() == source)
|
2008-12-02 12:01:29 +01:00
|
|
|
m_buildConfigurationValues.push_back(new BuildConfiguration(dest, m_buildConfigurationValues.at(i)));
|
|
|
|
|
|
2008-12-09 11:07:24 +01:00
|
|
|
for (int i = 0; i != m_buildSteps.size(); ++i)
|
2008-12-02 12:01:29 +01:00
|
|
|
m_buildSteps.at(i)->copyBuildConfiguration(source, dest);
|
|
|
|
|
|
2008-12-09 11:07:24 +01:00
|
|
|
for (int i = 0; i != m_cleanSteps.size(); ++i)
|
2008-12-02 12:01:29 +01:00
|
|
|
m_cleanSteps.at(i)->copyBuildConfiguration(source, dest);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList Project::buildConfigurations() const
|
|
|
|
|
{
|
|
|
|
|
QStringList result;
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (BuildConfiguration *bc, m_buildConfigurationValues)
|
2008-12-02 12:01:29 +01:00
|
|
|
result << bc->name();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<BuildStep *> Project::buildSteps() const
|
|
|
|
|
{
|
|
|
|
|
return m_buildSteps;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<BuildStep *> Project::cleanSteps() const
|
|
|
|
|
{
|
|
|
|
|
return m_cleanSteps;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Project::saveSettings()
|
|
|
|
|
{
|
|
|
|
|
PersistentSettingsWriter writer;
|
|
|
|
|
saveSettingsImpl(writer);
|
|
|
|
|
writer.save(file()->fileName() + QLatin1String(".user"), "QtCreatorProject");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Project::restoreSettings()
|
|
|
|
|
{
|
|
|
|
|
PersistentSettingsReader reader;
|
|
|
|
|
reader.load(file()->fileName() + QLatin1String(".user"));
|
|
|
|
|
restoreSettingsImpl(reader);
|
|
|
|
|
|
|
|
|
|
if (m_activeBuildConfiguration.isEmpty() && !m_buildConfigurations.isEmpty())
|
|
|
|
|
setActiveBuildConfiguration(m_buildConfigurations.at(0));
|
|
|
|
|
|
|
|
|
|
if (!m_activeRunConfiguration && !m_runConfigurations.isEmpty())
|
|
|
|
|
setActiveRunConfiguration(m_runConfigurations.at(0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<BuildStepConfigWidget*> Project::subConfigWidgets()
|
|
|
|
|
{
|
|
|
|
|
return QList<BuildStepConfigWidget*>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Project::saveSettingsImpl(PersistentSettingsWriter &writer)
|
|
|
|
|
{
|
|
|
|
|
writer.saveValue("activebuildconfiguration", m_activeBuildConfiguration);
|
|
|
|
|
//save m_values
|
|
|
|
|
writer.saveValue("project", m_values);
|
|
|
|
|
|
|
|
|
|
//save buildsettings
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (const QString &buildConfigurationName, buildConfigurations()) {
|
2008-12-02 12:01:29 +01:00
|
|
|
QMap<QString, QVariant> temp =
|
|
|
|
|
getBuildConfiguration(buildConfigurationName)->toMap();
|
|
|
|
|
writer.saveValue("buildConfiguration-" + buildConfigurationName, temp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList buildStepNames;
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (BuildStep *buildStep, buildSteps())
|
2008-12-02 12:01:29 +01:00
|
|
|
buildStepNames << buildStep->name();
|
|
|
|
|
writer.saveValue("buildsteps", buildStepNames);
|
|
|
|
|
|
|
|
|
|
QStringList cleanStepNames;
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (BuildStep *cleanStep, cleanSteps())
|
2008-12-02 12:01:29 +01:00
|
|
|
cleanStepNames << cleanStep->name();
|
|
|
|
|
writer.saveValue("cleansteps", cleanStepNames);
|
|
|
|
|
QStringList buildConfigurationNames = buildConfigurations();
|
|
|
|
|
writer.saveValue("buildconfigurations", buildConfigurationNames );
|
|
|
|
|
|
|
|
|
|
//save buildstep configuration
|
|
|
|
|
int buildstepnr = 0;
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (BuildStep *buildStep, buildSteps()) {
|
2008-12-02 12:01:29 +01:00
|
|
|
QMap<QString, QVariant> buildConfiguration = buildStep->valuesToMap();
|
|
|
|
|
writer.saveValue("buildstep" + QString().setNum(buildstepnr), buildConfiguration);
|
|
|
|
|
++buildstepnr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// save each buildstep/buildConfiguration combination
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (const QString &buildConfigurationName, buildConfigurationNames) {
|
2008-12-02 12:01:29 +01:00
|
|
|
buildstepnr = 0;
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (BuildStep *buildStep, buildSteps()) {
|
2008-12-02 12:01:29 +01:00
|
|
|
QMap<QString, QVariant> temp =
|
|
|
|
|
buildStep->valuesToMap(buildConfigurationName);
|
|
|
|
|
writer.saveValue("buildconfiguration-" + buildConfigurationName + "-buildstep" + QString().setNum(buildstepnr), temp);
|
|
|
|
|
++buildstepnr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//save cleansteps buildconfiguration
|
|
|
|
|
int cleanstepnr = 0;
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (BuildStep *cleanStep, cleanSteps()) {
|
2008-12-02 12:01:29 +01:00
|
|
|
QMap<QString, QVariant> buildConfiguration = cleanStep->valuesToMap();
|
|
|
|
|
writer.saveValue("cleanstep" + QString().setNum(cleanstepnr), buildConfiguration);
|
|
|
|
|
++cleanstepnr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// save each cleanstep/buildConfiguration combination
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (const QString &buildConfigurationName, buildConfigurationNames) {
|
2008-12-02 12:01:29 +01:00
|
|
|
cleanstepnr = 0;
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (BuildStep *cleanStep, cleanSteps()) {
|
2008-12-02 12:01:29 +01:00
|
|
|
QMap<QString, QVariant> temp = cleanStep->valuesToMap(buildConfigurationName);
|
|
|
|
|
writer.saveValue("buildconfiguration-" + buildConfigurationName + "-cleanstep" + QString().setNum(cleanstepnr), temp);
|
|
|
|
|
++cleanstepnr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Running
|
|
|
|
|
int i = 0;
|
|
|
|
|
int activeId = 0;
|
|
|
|
|
foreach (QSharedPointer<RunConfiguration> rc, m_runConfigurations) {
|
|
|
|
|
writer.setPrefix("RunConfiguration" + QString().setNum(i) + "-");
|
|
|
|
|
writer.saveValue("type", rc->type());
|
|
|
|
|
rc->save(writer);
|
|
|
|
|
if (rc == m_activeRunConfiguration)
|
|
|
|
|
activeId = i;
|
|
|
|
|
++i;
|
|
|
|
|
}
|
|
|
|
|
writer.setPrefix(QString::null);
|
|
|
|
|
writer.saveValue("activeRunConfiguration", activeId);
|
|
|
|
|
|
|
|
|
|
writer.saveValue("defaultFileEncoding", m_editorConfiguration->defaultTextCodec()->name());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Project::restoreSettingsImpl(PersistentSettingsReader &reader)
|
|
|
|
|
{
|
|
|
|
|
m_activeBuildConfiguration = reader.restoreValue("activebuildconfiguration").toString();
|
|
|
|
|
|
|
|
|
|
m_values = reader.restoreValue("project").toMap();
|
|
|
|
|
|
|
|
|
|
//Build Settings
|
|
|
|
|
const QStringList buildConfigurationNames = reader.restoreValue("buildconfigurations").toStringList();
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (const QString &buildConfigurationName, buildConfigurationNames) {
|
2008-12-02 12:01:29 +01:00
|
|
|
addBuildConfiguration(buildConfigurationName);
|
|
|
|
|
QMap<QString, QVariant> temp =
|
|
|
|
|
reader.restoreValue("buildConfiguration-" + buildConfigurationName).toMap();
|
|
|
|
|
getBuildConfiguration(buildConfigurationName)->setValuesFromMap(temp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariant buildStepsVariant = reader.restoreValue("buildsteps");
|
2008-12-09 11:07:24 +01:00
|
|
|
if (buildStepsVariant.isValid()) {
|
2008-12-02 12:01:29 +01:00
|
|
|
// restoring BuildSteps from settings
|
|
|
|
|
int pos = 0;
|
|
|
|
|
const QList<IBuildStepFactory *> buildStepFactories =
|
|
|
|
|
ExtensionSystem::PluginManager::instance()->getObjects<IBuildStepFactory>();
|
|
|
|
|
QStringList buildStepNames = buildStepsVariant.toStringList();
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (const QString &buildStepName, buildStepNames) {
|
|
|
|
|
foreach (IBuildStepFactory *factory, buildStepFactories) {
|
|
|
|
|
if (factory->canCreate(buildStepName)) {
|
|
|
|
|
BuildStep *buildStep = factory->create(this, buildStepName);
|
2008-12-02 12:01:29 +01:00
|
|
|
insertBuildStep(pos, buildStep);
|
|
|
|
|
++pos;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList cleanStepNames = reader.restoreValue("cleansteps").toStringList();
|
|
|
|
|
// restoring BuildSteps from settings
|
|
|
|
|
pos = 0;
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (const QString &cleanStepName, cleanStepNames) {
|
|
|
|
|
foreach (IBuildStepFactory *factory, buildStepFactories) {
|
|
|
|
|
if (factory->canCreate(cleanStepName)) {
|
|
|
|
|
BuildStep *cleanStep = factory->create(this, cleanStepName);
|
2008-12-02 12:01:29 +01:00
|
|
|
insertCleanStep(pos, cleanStep);
|
|
|
|
|
++pos;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// restoring BuldConfigurations from settings
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// restore BuildSteps configuration
|
|
|
|
|
int buildstepnr = 0;
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (BuildStep *buildStep, buildSteps()) {
|
2008-12-02 12:01:29 +01:00
|
|
|
QMap<QString, QVariant> buildConfiguration = reader.restoreValue("buildstep" + QString().setNum(buildstepnr)).toMap();
|
|
|
|
|
buildStep->setValuesFromMap(buildConfiguration);
|
|
|
|
|
++buildstepnr;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (const QString &buildConfigurationName, buildConfigurationNames) {
|
2008-12-02 12:01:29 +01:00
|
|
|
buildstepnr = 0;
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (BuildStep *buildStep, buildSteps()) {
|
2008-12-02 12:01:29 +01:00
|
|
|
//get the buildconfiguration for this build step
|
|
|
|
|
QMap<QString, QVariant> buildConfiguration =
|
|
|
|
|
reader.restoreValue("buildconfiguration-" + buildConfigurationName + "-buildstep" + QString().setNum(buildstepnr)).toMap();
|
|
|
|
|
buildStep->setValuesFromMap(buildConfigurationName, buildConfiguration);
|
|
|
|
|
++buildstepnr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// restore CleanSteps configuration
|
|
|
|
|
int cleanstepnr = 0;
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (BuildStep *cleanStep, cleanSteps()) {
|
2008-12-02 12:01:29 +01:00
|
|
|
QMap<QString, QVariant> buildConfiguration = reader.restoreValue("cleanstep" + QString().setNum(cleanstepnr)).toMap();
|
|
|
|
|
cleanStep->setValuesFromMap(buildConfiguration);
|
|
|
|
|
++cleanstepnr;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (const QString &buildConfigurationName, buildConfigurationNames) {
|
2008-12-02 12:01:29 +01:00
|
|
|
cleanstepnr = 0;
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (BuildStep *cleanStep, cleanSteps()) {
|
2008-12-02 12:01:29 +01:00
|
|
|
//get the buildconfiguration for this clean step
|
|
|
|
|
QMap<QString, QVariant> buildConfiguration =
|
|
|
|
|
reader.restoreValue("buildconfiguration-" + buildConfigurationName + "-cleanstep" + QString().setNum(cleanstepnr)).toMap();
|
|
|
|
|
cleanStep->setValuesFromMap(buildConfigurationName, buildConfiguration);
|
|
|
|
|
++cleanstepnr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Running
|
|
|
|
|
const int activeId = reader.restoreValue("activeRunConfiguration").toInt();
|
|
|
|
|
int i = 0;
|
|
|
|
|
const QList<IRunConfigurationFactory *> factories =
|
|
|
|
|
ExtensionSystem::PluginManager::instance()->getObjects<IRunConfigurationFactory>();
|
|
|
|
|
forever {
|
|
|
|
|
reader.setPrefix("RunConfiguration" + QString().setNum(i) + "-");
|
|
|
|
|
const QVariant &typeVariant = reader.restoreValue("type");
|
|
|
|
|
if (!typeVariant.isValid())
|
|
|
|
|
break;
|
|
|
|
|
const QString &type = typeVariant.toString();
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (IRunConfigurationFactory *factory, factories) {
|
2008-12-02 12:01:29 +01:00
|
|
|
if (factory->canCreate(type)) {
|
|
|
|
|
QSharedPointer<RunConfiguration> rc = factory->create(this, type);
|
|
|
|
|
rc->restore(reader);
|
|
|
|
|
addRunConfiguration(rc);
|
|
|
|
|
if (i == activeId)
|
|
|
|
|
setActiveRunConfiguration(rc);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
++i;
|
|
|
|
|
}
|
|
|
|
|
reader.setPrefix(QString::null);
|
|
|
|
|
|
|
|
|
|
QTextCodec *codec = QTextCodec::codecForName(reader.restoreValue("defaultFileEncoding").toByteArray());
|
|
|
|
|
if (codec)
|
|
|
|
|
m_editorConfiguration->setDefaultTextCodec(codec);
|
|
|
|
|
|
|
|
|
|
if (!m_activeRunConfiguration && !m_runConfigurations.isEmpty())
|
|
|
|
|
setActiveRunConfiguration(m_runConfigurations.at(0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Project::setValue(const QString &name, const QVariant & value)
|
|
|
|
|
{
|
|
|
|
|
m_values.insert(name, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariant Project::value(const QString &name) const
|
|
|
|
|
{
|
|
|
|
|
QMap<QString, QVariant>::const_iterator it =
|
|
|
|
|
m_values.find(name);
|
2008-12-09 11:07:24 +01:00
|
|
|
if (it != m_values.constEnd())
|
2008-12-02 12:01:29 +01:00
|
|
|
return it.value();
|
|
|
|
|
else
|
|
|
|
|
return QVariant();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildConfiguration * Project::getBuildConfiguration(const QString &name) const
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i != m_buildConfigurationValues.size(); ++i)
|
|
|
|
|
if (m_buildConfigurationValues.at(i)->name() == name)
|
|
|
|
|
return m_buildConfigurationValues.at(i);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Project::setValue(const QString &buildConfiguration, const QString &name, const QVariant &value)
|
|
|
|
|
{
|
|
|
|
|
BuildConfiguration *bc = getBuildConfiguration(buildConfiguration);
|
2008-12-17 15:51:48 +01:00
|
|
|
Q_ASSERT(bc);
|
2008-12-02 12:01:29 +01:00
|
|
|
bc->setValue(name, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariant Project::value(const QString &buildConfiguration, const QString &name) const
|
|
|
|
|
{
|
|
|
|
|
BuildConfiguration *bc = getBuildConfiguration(buildConfiguration);
|
|
|
|
|
if (bc)
|
|
|
|
|
return bc->getValue(name);
|
|
|
|
|
else
|
|
|
|
|
return QVariant();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Project::activeBuildConfiguration() const
|
|
|
|
|
{
|
|
|
|
|
return m_activeBuildConfiguration;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Project::setActiveBuildConfiguration(const QString &config)
|
|
|
|
|
{
|
|
|
|
|
if (m_activeBuildConfiguration != config && buildConfigurations().contains(config)) {
|
|
|
|
|
m_activeBuildConfiguration = config;
|
|
|
|
|
emit activeBuildConfigurationChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QList<QSharedPointer<RunConfiguration> > Project::runConfigurations() const
|
|
|
|
|
{
|
|
|
|
|
return m_runConfigurations;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Project::addRunConfiguration(QSharedPointer<RunConfiguration> runConfiguration)
|
|
|
|
|
{
|
2008-12-17 15:51:48 +01:00
|
|
|
if (m_runConfigurations.contains(runConfiguration)) {
|
|
|
|
|
qWarning()<<"Not adding already existing runConfiguration"<<runConfiguration->name();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
m_runConfigurations.push_back(runConfiguration);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Project::removeRunConfiguration(QSharedPointer<RunConfiguration> runConfiguration)
|
|
|
|
|
{
|
2008-12-17 15:51:48 +01:00
|
|
|
if(!m_runConfigurations.contains(runConfiguration)) {
|
|
|
|
|
qWarning()<<"Not removing runConfiguration"<<runConfiguration->name()<<"becasue it doesn't exist";
|
|
|
|
|
return;
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
m_runConfigurations.removeOne(runConfiguration);
|
|
|
|
|
if (m_activeRunConfiguration == runConfiguration) {
|
|
|
|
|
if (m_runConfigurations.isEmpty())
|
|
|
|
|
setActiveRunConfiguration(QSharedPointer<RunConfiguration>(0));
|
|
|
|
|
else
|
|
|
|
|
setActiveRunConfiguration(m_runConfigurations.at(0));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QSharedPointer<RunConfiguration> Project::activeRunConfiguration() const
|
|
|
|
|
{
|
|
|
|
|
return m_activeRunConfiguration;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Project::setActiveRunConfiguration(QSharedPointer<RunConfiguration> runConfiguration)
|
|
|
|
|
{
|
|
|
|
|
if (runConfiguration == m_activeRunConfiguration)
|
|
|
|
|
return;
|
2008-12-17 15:51:48 +01:00
|
|
|
Q_ASSERT(m_runConfigurations.contains(runConfiguration) || runConfiguration == 0);
|
2008-12-02 12:01:29 +01:00
|
|
|
m_activeRunConfiguration = runConfiguration;
|
|
|
|
|
emit activeRunConfigurationChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EditorConfiguration *Project::editorConfiguration() const
|
|
|
|
|
{
|
|
|
|
|
return m_editorConfiguration;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Project::displayNameFor(const QString &buildConfiguration)
|
|
|
|
|
{
|
|
|
|
|
return getBuildConfiguration(buildConfiguration)->displayName();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Project::setDisplayNameFor(const QString &buildConfiguration, const QString &displayName)
|
|
|
|
|
{
|
|
|
|
|
QStringList displayNames;
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (const QString &bc, buildConfigurations()) {
|
2008-12-02 12:01:29 +01:00
|
|
|
if (bc != buildConfiguration)
|
|
|
|
|
displayNames << displayNameFor(bc);
|
|
|
|
|
}
|
|
|
|
|
if (displayNames.contains(displayName)) {
|
|
|
|
|
int i = 2;
|
|
|
|
|
while (displayNames.contains(displayName + QString::number(i)))
|
|
|
|
|
++i;
|
|
|
|
|
getBuildConfiguration(buildConfiguration)->setDisplayName(displayName + QString::number(i));
|
|
|
|
|
} else {
|
|
|
|
|
getBuildConfiguration(buildConfiguration)->setDisplayName(displayName);
|
|
|
|
|
}
|
|
|
|
|
emit buildConfigurationDisplayNameChanged(buildConfiguration);
|
|
|
|
|
}
|