2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +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
|
|
|
|
2009-09-29 11:39:55 +02:00
|
|
|
#include "persistentsettings.h"
|
|
|
|
|
#include "buildconfiguration.h"
|
|
|
|
|
#include "environment.h"
|
|
|
|
|
#include "projectnodes.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;
|
2009-04-20 16:29:46 +02:00
|
|
|
using namespace ProjectExplorer::Internal;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-22 16:11:45 +02:00
|
|
|
void Project::moveCleanStepUp(int position)
|
|
|
|
|
{
|
|
|
|
|
BuildStep *bs = m_cleanSteps.takeAt(position);
|
|
|
|
|
m_cleanSteps.insert(position - 1, bs);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
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);
|
2009-09-17 13:59:10 +02:00
|
|
|
emit addedBuildConfiguration(this, name);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
2009-09-17 13:59:10 +02:00
|
|
|
emit removedBuildConfiguration(this, name);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
2009-09-17 13:59:10 +02:00
|
|
|
emit addedBuildConfiguration(this, dest);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-06 16:33:43 +02:00
|
|
|
bool Project::hasBuildSettings() const
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-03 16:46:01 +02:00
|
|
|
bool Project::restoreSettings()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
PersistentSettingsReader reader;
|
|
|
|
|
reader.load(file()->fileName() + QLatin1String(".user"));
|
2009-07-03 16:46:01 +02:00
|
|
|
if (!restoreSettingsImpl(reader))
|
|
|
|
|
return false;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
if (m_activeBuildConfiguration.isEmpty() && !m_buildConfigurations.isEmpty())
|
|
|
|
|
setActiveBuildConfiguration(m_buildConfigurations.at(0));
|
|
|
|
|
|
|
|
|
|
if (!m_activeRunConfiguration && !m_runConfigurations.isEmpty())
|
|
|
|
|
setActiveRunConfiguration(m_runConfigurations.at(0));
|
2009-07-03 16:46:01 +02:00
|
|
|
return true;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-08-06 15:31:32 +02:00
|
|
|
QList<BuildConfigWidget*> Project::subConfigWidgets()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-08-06 15:31:32 +02:00
|
|
|
return QList<BuildConfigWidget*>();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 =
|
2009-09-21 17:54:02 +02:00
|
|
|
buildConfiguration(buildConfigurationName)->toMap();
|
2008-12-02 12:01:29 +01:00
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-03 16:46:01 +02:00
|
|
|
bool Project::restoreSettingsImpl(PersistentSettingsReader &reader)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
m_activeBuildConfiguration = reader.restoreValue("activebuildconfiguration").toString();
|
|
|
|
|
|
|
|
|
|
m_values = reader.restoreValue("project").toMap();
|
|
|
|
|
|
2009-04-28 15:40:41 +02:00
|
|
|
// restoring BuldConfigurations from settings
|
2008-12-02 12:01:29 +01:00
|
|
|
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();
|
2009-09-21 17:54:02 +02:00
|
|
|
buildConfiguration(buildConfigurationName)->setValuesFromMap(temp);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-04-28 15:40:41 +02:00
|
|
|
const QList<IBuildStepFactory *> buildStepFactories =
|
|
|
|
|
ExtensionSystem::PluginManager::instance()->getObjects<IBuildStepFactory>();
|
|
|
|
|
//Build Settings
|
2008-12-02 12:01:29 +01:00
|
|
|
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;
|
|
|
|
|
QStringList buildStepNames = buildStepsVariant.toStringList();
|
2009-04-28 15:40:41 +02:00
|
|
|
for (int buildstepnr = 0; buildstepnr < buildStepNames.size(); ++buildstepnr) {
|
|
|
|
|
const QString &buildStepName = buildStepNames.at(buildstepnr);
|
|
|
|
|
BuildStep *buildStep = 0;
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (IBuildStepFactory *factory, buildStepFactories) {
|
|
|
|
|
if (factory->canCreate(buildStepName)) {
|
2009-04-28 15:40:41 +02:00
|
|
|
buildStep = factory->create(this, buildStepName);
|
2008-12-02 12:01:29 +01:00
|
|
|
insertBuildStep(pos, buildStep);
|
|
|
|
|
++pos;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-04-28 15:40:41 +02:00
|
|
|
// Restoring settings
|
|
|
|
|
if (buildStep) {
|
|
|
|
|
QMap<QString, QVariant> buildConfiguration = reader.restoreValue("buildstep" + QString().setNum(buildstepnr)).toMap();
|
|
|
|
|
buildStep->setValuesFromMap(buildConfiguration);
|
|
|
|
|
foreach (const QString &buildConfigurationName, buildConfigurationNames) {
|
|
|
|
|
//get the buildconfiguration for this build step
|
|
|
|
|
QMap<QString, QVariant> buildConfiguration =
|
|
|
|
|
reader.restoreValue("buildconfiguration-" + buildConfigurationName + "-buildstep" + QString().setNum(buildstepnr)).toMap();
|
|
|
|
|
buildStep->setValuesFromMap(buildConfigurationName, buildConfiguration);
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2009-04-28 15:40:41 +02:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-04-28 15:40:41 +02:00
|
|
|
QVariant cleanStepsVariant = reader.restoreValue("cleansteps");
|
|
|
|
|
if (cleanStepsVariant.isValid()) {
|
|
|
|
|
QStringList cleanStepNames = cleanStepsVariant.toStringList();
|
2008-12-02 12:01:29 +01:00
|
|
|
// restoring BuildSteps from settings
|
2009-04-28 15:40:41 +02:00
|
|
|
int pos = 0;
|
|
|
|
|
for (int cleanstepnr = 0; cleanstepnr < cleanStepNames.size(); ++cleanstepnr) {
|
|
|
|
|
const QString &cleanStepName = cleanStepNames.at(cleanstepnr);
|
|
|
|
|
BuildStep *cleanStep = 0;
|
2008-12-09 11:07:24 +01:00
|
|
|
foreach (IBuildStepFactory *factory, buildStepFactories) {
|
|
|
|
|
if (factory->canCreate(cleanStepName)) {
|
2009-04-28 15:40:41 +02:00
|
|
|
cleanStep = factory->create(this, cleanStepName);
|
2008-12-02 12:01:29 +01:00
|
|
|
insertCleanStep(pos, cleanStep);
|
|
|
|
|
++pos;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-04-28 15:40:41 +02:00
|
|
|
// Restoring settings
|
|
|
|
|
if (cleanStep) {
|
|
|
|
|
QMap<QString, QVariant> buildConfiguration = reader.restoreValue("cleanstep" + QString().setNum(cleanstepnr)).toMap();
|
|
|
|
|
cleanStep->setValuesFromMap(buildConfiguration);
|
|
|
|
|
foreach (const QString &buildConfigurationName, buildConfigurationNames) {
|
|
|
|
|
QMap<QString, QVariant> buildConfiguration =
|
|
|
|
|
reader.restoreValue("buildconfiguration-" + buildConfigurationName + "-cleanstep" + QString().setNum(cleanstepnr)).toMap();
|
|
|
|
|
cleanStep->setValuesFromMap(buildConfigurationName, buildConfiguration);
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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) {
|
2009-06-12 17:57:03 +02:00
|
|
|
if (factory->canRestore(type)) {
|
2008-12-02 12:01:29 +01:00
|
|
|
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));
|
2009-07-03 16:46:01 +02:00
|
|
|
return true;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-21 17:54:02 +02:00
|
|
|
BuildConfiguration *Project::buildConfiguration(const QString &name) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
for (int i = 0; i != m_buildConfigurationValues.size(); ++i)
|
|
|
|
|
if (m_buildConfigurationValues.at(i)->name() == name)
|
|
|
|
|
return m_buildConfigurationValues.at(i);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-21 17:54:02 +02:00
|
|
|
void Project::setValue(const QString &buildConfigurationName, const QString &name, const QVariant &value)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-09-21 17:54:02 +02:00
|
|
|
BuildConfiguration *bc = buildConfiguration(buildConfigurationName);
|
2008-12-17 15:51:48 +01:00
|
|
|
Q_ASSERT(bc);
|
2008-12-02 12:01:29 +01:00
|
|
|
bc->setValue(name, value);
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-21 17:54:02 +02:00
|
|
|
QVariant Project::value(const QString &buildConfigurationName, const QString &name) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-09-21 17:54:02 +02:00
|
|
|
BuildConfiguration *bc = buildConfiguration(buildConfigurationName);
|
2008-12-02 12:01:29 +01:00
|
|
|
if (bc)
|
2009-09-21 15:50:27 +02:00
|
|
|
return bc->value(name);
|
2008-12-02 12:01:29 +01:00
|
|
|
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);
|
2009-09-17 13:59:10 +02:00
|
|
|
emit addedRunConfiguration(this, runConfiguration->name());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
2009-04-15 14:52:31 +02:00
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
if (m_activeRunConfiguration == runConfiguration) {
|
2009-04-15 14:52:31 +02:00
|
|
|
if (m_runConfigurations.size() <= 1)
|
2008-12-02 12:01:29 +01:00
|
|
|
setActiveRunConfiguration(QSharedPointer<RunConfiguration>(0));
|
2009-04-15 14:52:31 +02:00
|
|
|
else if (m_runConfigurations.at(0) == m_activeRunConfiguration)
|
|
|
|
|
setActiveRunConfiguration(m_runConfigurations.at(1));
|
2008-12-02 12:01:29 +01:00
|
|
|
else
|
|
|
|
|
setActiveRunConfiguration(m_runConfigurations.at(0));
|
|
|
|
|
}
|
2009-04-15 14:52:31 +02:00
|
|
|
|
|
|
|
|
m_runConfigurations.removeOne(runConfiguration);
|
2009-09-17 13:59:10 +02:00
|
|
|
emit removedRunConfiguration(this, runConfiguration->name());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-21 17:54:02 +02:00
|
|
|
void Project::setDisplayNameFor(const QString &buildConfigurationName, const QString &displayName)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
QStringList displayNames;
|
2009-09-21 17:54:02 +02:00
|
|
|
foreach (BuildConfiguration *bc, m_buildConfigurationValues) {
|
|
|
|
|
if (bc->name() != buildConfigurationName)
|
|
|
|
|
displayNames << bc->displayName();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
if (displayNames.contains(displayName)) {
|
|
|
|
|
int i = 2;
|
|
|
|
|
while (displayNames.contains(displayName + QString::number(i)))
|
|
|
|
|
++i;
|
2009-09-21 17:54:02 +02:00
|
|
|
buildConfiguration(buildConfigurationName)->setDisplayName(displayName + QString::number(i));
|
2008-12-02 12:01:29 +01:00
|
|
|
} else {
|
2009-09-21 17:54:02 +02:00
|
|
|
buildConfiguration(buildConfigurationName)->setDisplayName(displayName);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2009-09-21 17:54:02 +02:00
|
|
|
emit buildConfigurationDisplayNameChanged(buildConfigurationName);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2009-05-04 18:22:40 +02:00
|
|
|
|
2009-05-05 18:21:40 +02:00
|
|
|
QByteArray Project::predefinedMacros(const QString &) const
|
2009-05-04 18:22:40 +02:00
|
|
|
{
|
|
|
|
|
return QByteArray();
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-05 18:21:40 +02:00
|
|
|
QStringList Project::includePaths(const QString &) const
|
2009-05-04 18:22:40 +02:00
|
|
|
{
|
|
|
|
|
return QStringList();
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-05 18:21:40 +02:00
|
|
|
QStringList Project::frameworkPaths(const QString &) const
|
2009-05-04 18:22:40 +02:00
|
|
|
{
|
|
|
|
|
return QStringList();
|
|
|
|
|
}
|