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_buildConfigurationValues);
|
2009-10-09 18:46:44 +02:00
|
|
|
qDeleteAll(m_runConfigurations);
|
2009-01-16 16:30:22 +01:00
|
|
|
delete m_editorConfiguration;
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-07 13:18:26 +02:00
|
|
|
QString Project::makeUnique(const QString &preferedName, const QStringList &usedNames)
|
|
|
|
|
{
|
|
|
|
|
if (!usedNames.contains(preferedName))
|
|
|
|
|
return preferedName;
|
|
|
|
|
int i = 2;
|
|
|
|
|
QString tryName = preferedName + QString::number(i);
|
|
|
|
|
while (usedNames.contains(tryName))
|
|
|
|
|
tryName = preferedName + QString::number(++i);
|
|
|
|
|
return tryName;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-24 16:02:02 +02:00
|
|
|
void Project::addBuildConfiguration(BuildConfiguration *configuration)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-09-24 16:02:02 +02:00
|
|
|
QStringList buildConfigurationNames;
|
|
|
|
|
foreach (const BuildConfiguration *bc, buildConfigurations())
|
|
|
|
|
buildConfigurationNames << bc->name();
|
|
|
|
|
|
|
|
|
|
// Check that the internal name is not taken and use a different one otherwise
|
|
|
|
|
QString configurationName = configuration->name();
|
2009-10-07 13:18:26 +02:00
|
|
|
configurationName = makeUnique(configurationName, buildConfigurationNames);
|
2009-09-24 16:02:02 +02:00
|
|
|
configuration->setName(configurationName);
|
|
|
|
|
|
|
|
|
|
// Check that we don't have a configuration with the same displayName
|
|
|
|
|
QString configurationDisplayName = configuration->displayName();
|
|
|
|
|
QStringList displayNames;
|
|
|
|
|
foreach (const BuildConfiguration *bc, m_buildConfigurationValues)
|
|
|
|
|
displayNames << bc->displayName();
|
2009-10-07 13:18:26 +02:00
|
|
|
configurationDisplayName = makeUnique(configurationDisplayName, displayNames);
|
2009-09-24 16:02:02 +02:00
|
|
|
configuration->setDisplayName(configurationDisplayName);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-09-24 16:02:02 +02:00
|
|
|
// add it
|
|
|
|
|
m_buildConfigurationValues.push_back(configuration);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-09-24 16:02:02 +02:00
|
|
|
emit addedBuildConfiguration(this, configuration->name());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-09-24 16:02:02 +02:00
|
|
|
void Project::removeBuildConfiguration(BuildConfiguration *configuration)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-09-24 16:02:02 +02:00
|
|
|
//todo: this might be error prone
|
2009-10-08 20:01:07 +02:00
|
|
|
if (!m_buildConfigurationValues.contains(configuration))
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
|
|
|
|
|
2009-10-08 20:01:07 +02:00
|
|
|
m_buildConfigurationValues.removeOne(configuration);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-09-24 16:02:02 +02:00
|
|
|
emit removedBuildConfiguration(this, configuration->name());
|
2009-10-08 20:01:07 +02:00
|
|
|
delete configuration;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-09-24 16:02:02 +02:00
|
|
|
QList<BuildConfiguration *> Project::buildConfigurations() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-09-24 16:02:02 +02:00
|
|
|
return m_buildConfigurationValues;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-05-06 16:33:43 +02:00
|
|
|
bool Project::hasBuildSettings() const
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
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
|
|
|
|
2009-09-30 18:36:31 +02:00
|
|
|
if (m_activeBuildConfiguration.isEmpty() && !m_buildConfigurationValues.isEmpty())
|
2009-09-24 16:02:02 +02:00
|
|
|
setActiveBuildConfiguration(m_buildConfigurationValues.at(0));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
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
|
2009-09-24 16:02:02 +02:00
|
|
|
QStringList buildConfigurationNames;
|
|
|
|
|
foreach (const BuildConfiguration *bc, buildConfigurations()) {
|
|
|
|
|
QMap<QString, QVariant> temp = bc->toMap();
|
|
|
|
|
writer.saveValue("buildConfiguration-" + bc->name(), temp);
|
|
|
|
|
buildConfigurationNames << bc->name();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2009-10-27 14:16:28 +01:00
|
|
|
writer.saveValue("buildconfigurations", buildConfigurationNames);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// save each buildstep/buildConfiguration combination
|
2009-10-27 14:16:28 +01:00
|
|
|
foreach (const BuildConfiguration *bc, buildConfigurations()) {
|
|
|
|
|
QStringList buildStepNames;
|
|
|
|
|
foreach (BuildStep *buildStep, bc->buildSteps())
|
|
|
|
|
buildStepNames << buildStep->name();
|
|
|
|
|
writer.saveValue("buildconfiguration-" + bc->name() + "-buildsteps", buildStepNames);
|
|
|
|
|
|
|
|
|
|
int buildstepnr = 0;
|
|
|
|
|
foreach (BuildStep *buildStep, bc->buildSteps()) {
|
2009-10-15 19:06:51 +02:00
|
|
|
QMap<QString, QVariant> temp;
|
2009-10-27 14:16:28 +01:00
|
|
|
buildStep->storeIntoLocalMap(temp);
|
|
|
|
|
writer.saveValue("buildconfiguration-" + bc->name() + "-buildstep" + QString().setNum(buildstepnr), temp);
|
2008-12-02 12:01:29 +01:00
|
|
|
++buildstepnr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// save each cleanstep/buildConfiguration combination
|
2009-10-27 14:16:28 +01:00
|
|
|
foreach (const BuildConfiguration *bc, buildConfigurations()) {
|
|
|
|
|
QStringList cleanStepNames;
|
|
|
|
|
foreach (BuildStep *cleanStep, bc->cleanSteps())
|
|
|
|
|
cleanStepNames << cleanStep->name();
|
|
|
|
|
writer.saveValue("buildconfiguration-" + bc->name() + "-cleansteps", cleanStepNames);
|
|
|
|
|
|
|
|
|
|
int cleanstepnr = 0;
|
|
|
|
|
foreach (BuildStep *cleanStep, bc->cleanSteps()) {
|
2009-10-15 19:06:51 +02:00
|
|
|
QMap<QString, QVariant> temp;
|
2009-10-27 14:16:28 +01:00
|
|
|
cleanStep->storeIntoLocalMap(temp);
|
|
|
|
|
writer.saveValue("buildconfiguration-" + bc->name() + "-cleanstep" + QString().setNum(cleanstepnr), temp);
|
2008-12-02 12:01:29 +01:00
|
|
|
++cleanstepnr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Running
|
|
|
|
|
int i = 0;
|
|
|
|
|
int activeId = 0;
|
2009-10-08 18:37:18 +02:00
|
|
|
foreach (RunConfiguration* rc, m_runConfigurations) {
|
2008-12-02 12:01:29 +01:00
|
|
|
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-10-27 14:16:28 +01:00
|
|
|
const QList<IBuildStepFactory *> buildStepFactories =
|
|
|
|
|
ExtensionSystem::PluginManager::instance()->getObjects<IBuildStepFactory>();
|
|
|
|
|
|
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) {
|
2009-11-23 13:29:45 +01:00
|
|
|
BuildConfiguration *bc = buildConfigurationFactory()->restore(buildConfigurationName);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QMap<QString, QVariant> temp =
|
|
|
|
|
reader.restoreValue("buildConfiguration-" + buildConfigurationName).toMap();
|
2009-09-24 16:02:02 +02:00
|
|
|
bc->setValuesFromMap(temp);
|
2009-10-27 14:16:28 +01:00
|
|
|
|
|
|
|
|
// Restore build steps
|
|
|
|
|
QVariant buildStepsValueVariant = reader.restoreValue("buildconfiguration-" + bc->name() + "-buildsteps");
|
|
|
|
|
if(buildStepsValueVariant.isValid()) {
|
|
|
|
|
int pos = 0;
|
|
|
|
|
QStringList buildStepNames = buildStepsValueVariant.toStringList();
|
|
|
|
|
for (int buildstepnr = 0; buildstepnr < buildStepNames.size(); ++buildstepnr) {
|
|
|
|
|
const QString &buildStepName = buildStepNames.at(buildstepnr);
|
|
|
|
|
BuildStep *buildStep = 0;
|
|
|
|
|
foreach (IBuildStepFactory *factory, buildStepFactories) {
|
|
|
|
|
if (factory->canCreate(buildStepName)) {
|
2009-11-23 15:47:26 +01:00
|
|
|
buildStep = factory->create(bc, buildStepName);
|
2009-10-27 14:16:28 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Restoring settings
|
|
|
|
|
if (buildStep) {
|
|
|
|
|
// TODO remove restoreFromGlobalMap after 2.0
|
|
|
|
|
QMap<QString, QVariant> buildStepValues = reader.restoreValue("buildstep" + QString().setNum(buildstepnr)).toMap();
|
|
|
|
|
buildStep->restoreFromGlobalMap(buildStepValues);
|
|
|
|
|
buildStepValues =
|
|
|
|
|
reader.restoreValue("buildconfiguration-" + bc->name() + "-buildstep" + QString().setNum(buildstepnr)).toMap();
|
|
|
|
|
buildStep->restoreFromLocalMap(buildStepValues);
|
|
|
|
|
bc->insertBuildStep(pos, buildStep);
|
|
|
|
|
++pos;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Restore clean steps
|
|
|
|
|
QVariant cleanStepsValueVariant = reader.restoreValue("buildconfiguration-" + bc->name() + "-cleansteps");
|
|
|
|
|
if(cleanStepsValueVariant.isValid()) {
|
|
|
|
|
int pos = 0;
|
|
|
|
|
QStringList cleanStepNames = cleanStepsValueVariant.toStringList();
|
|
|
|
|
for (int cleanstepnr = 0; cleanstepnr < cleanStepNames.size(); ++cleanstepnr) {
|
|
|
|
|
const QString &cleanStepName = cleanStepNames.at(cleanstepnr);
|
|
|
|
|
BuildStep *cleanStep = 0;
|
|
|
|
|
foreach (IBuildStepFactory *factory, buildStepFactories) {
|
|
|
|
|
if (factory->canCreate(cleanStepName)) {
|
2009-11-23 15:47:26 +01:00
|
|
|
cleanStep = factory->create(bc, cleanStepName);
|
2009-10-27 14:16:28 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Restoring settings
|
|
|
|
|
if (cleanStep) {
|
|
|
|
|
// TODO remove restoreFromGlobalMap after 2.0
|
|
|
|
|
QMap<QString, QVariant> buildStepValues = reader.restoreValue("cleanstep" + QString().setNum(cleanstepnr)).toMap();
|
|
|
|
|
cleanStep->restoreFromGlobalMap(buildStepValues);
|
|
|
|
|
buildStepValues =
|
|
|
|
|
reader.restoreValue("buildconfiguration-" + bc->name() + "-cleanstep" + QString().setNum(cleanstepnr)).toMap();
|
|
|
|
|
cleanStep->restoreFromLocalMap(buildStepValues);
|
|
|
|
|
bc->insertCleanStep(pos, cleanStep);
|
|
|
|
|
++pos;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-04-28 15:40:41 +02:00
|
|
|
//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()) {
|
2009-10-27 14:16:28 +01:00
|
|
|
// Old code path for 1.3 compability
|
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;
|
2009-10-27 14:16:28 +01:00
|
|
|
IBuildStepFactory *factory = 0;
|
|
|
|
|
foreach (IBuildStepFactory *fac, buildStepFactories) {
|
|
|
|
|
if (fac->canCreate(buildStepName)) {
|
|
|
|
|
factory = fac;
|
2008-12-02 12:01:29 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-10-27 14:16:28 +01:00
|
|
|
if (factory) {
|
|
|
|
|
foreach(BuildConfiguration *bc, buildConfigurations()) {
|
2009-11-23 15:47:26 +01:00
|
|
|
buildStep = factory->create(bc, buildStepName);
|
2009-10-27 14:16:28 +01:00
|
|
|
bc->insertBuildStep(pos, buildStep);
|
|
|
|
|
QMap<QString, QVariant> buildStepValues = reader.restoreValue("buildstep" + QString().setNum(buildstepnr)).toMap();
|
|
|
|
|
buildStep->restoreFromGlobalMap(buildStepValues);
|
|
|
|
|
buildStepValues =
|
|
|
|
|
reader.restoreValue("buildconfiguration-" + bc->name() + "-buildstep" + QString().setNum(buildstepnr)).toMap();
|
|
|
|
|
buildStep->restoreFromLocalMap(buildStepValues);
|
2009-04-28 15:40:41 +02:00
|
|
|
}
|
2009-10-27 14:16:28 +01:00
|
|
|
++pos;
|
2009-04-28 15:40:41 +02:00
|
|
|
}
|
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()) {
|
2009-10-27 14:16:28 +01:00
|
|
|
// Old code path for 1.3 compability
|
2009-04-28 15:40:41 +02:00
|
|
|
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;
|
2009-10-27 14:16:28 +01:00
|
|
|
IBuildStepFactory *factory = 0;
|
|
|
|
|
foreach (IBuildStepFactory *fac, buildStepFactories) {
|
|
|
|
|
if (fac->canCreate(cleanStepName)) {
|
|
|
|
|
factory = fac;
|
2008-12-02 12:01:29 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-10-27 14:16:28 +01:00
|
|
|
|
|
|
|
|
if (factory) {
|
|
|
|
|
foreach(BuildConfiguration *bc, buildConfigurations()) {
|
2009-11-23 15:47:26 +01:00
|
|
|
cleanStep = factory->create(bc, cleanStepName);
|
2009-10-27 14:16:28 +01:00
|
|
|
bc->insertCleanStep(pos, cleanStep);
|
|
|
|
|
QMap<QString, QVariant> cleanStepValues = reader.restoreValue("cleanstep" + QString().setNum(cleanstepnr)).toMap();
|
|
|
|
|
cleanStep->restoreFromGlobalMap(cleanStepValues);
|
2009-10-15 19:06:51 +02:00
|
|
|
QMap<QString, QVariant> buildStepValues =
|
2009-10-27 14:16:28 +01:00
|
|
|
reader.restoreValue("buildconfiguration-" + bc->name() + "-cleanstep" + QString().setNum(cleanstepnr)).toMap();
|
|
|
|
|
cleanStep->restoreFromLocalMap(buildStepValues);
|
2009-04-28 15:40:41 +02:00
|
|
|
}
|
2009-10-27 14:16:28 +01:00
|
|
|
++pos;
|
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)) {
|
2009-10-08 18:37:18 +02:00
|
|
|
RunConfiguration* rc = factory->create(this, type);
|
2008-12-02 12:01:29 +01:00
|
|
|
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-24 16:02:02 +02:00
|
|
|
BuildConfiguration *Project::activeBuildConfiguration() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-09-24 16:02:02 +02:00
|
|
|
return buildConfiguration(m_activeBuildConfiguration); //TODO
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-09-24 16:02:02 +02:00
|
|
|
void Project::setActiveBuildConfiguration(BuildConfiguration *configuration)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-09-24 16:02:02 +02:00
|
|
|
if (m_activeBuildConfiguration != configuration->name() && m_buildConfigurationValues.contains(configuration)) {
|
|
|
|
|
m_activeBuildConfiguration = configuration->name();
|
2008-12-02 12:01:29 +01:00
|
|
|
emit activeBuildConfigurationChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-08 18:37:18 +02:00
|
|
|
QList<RunConfiguration *> Project::runConfigurations() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
return m_runConfigurations;
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-08 18:37:18 +02:00
|
|
|
void Project::addRunConfiguration(RunConfiguration* runConfiguration)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
2009-10-08 18:37:18 +02:00
|
|
|
void Project::removeRunConfiguration(RunConfiguration* runConfiguration)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
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-09-24 16:02:02 +02:00
|
|
|
}
|
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)
|
2009-10-08 18:37:18 +02:00
|
|
|
setActiveRunConfiguration(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());
|
2009-10-09 18:46:44 +02:00
|
|
|
delete runConfiguration;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-10-08 18:37:18 +02:00
|
|
|
RunConfiguration* Project::activeRunConfiguration() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
return m_activeRunConfiguration;
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-08 18:37:18 +02:00
|
|
|
void Project::setActiveRunConfiguration(RunConfiguration* runConfiguration)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
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-25 15:19:45 +02:00
|
|
|
void Project::setDisplayNameFor(BuildConfiguration *configuration, const QString &displayName)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-10-07 13:18:26 +02:00
|
|
|
if (configuration->displayName() == displayName)
|
|
|
|
|
return;
|
|
|
|
|
QString dn = displayName;
|
2008-12-02 12:01:29 +01:00
|
|
|
QStringList displayNames;
|
2009-09-21 17:54:02 +02:00
|
|
|
foreach (BuildConfiguration *bc, m_buildConfigurationValues) {
|
2009-09-25 15:19:45 +02:00
|
|
|
if (bc != configuration)
|
2009-09-21 17:54:02 +02:00
|
|
|
displayNames << bc->displayName();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2009-10-07 13:18:26 +02:00
|
|
|
dn = makeUnique(displayName, displayNames);
|
|
|
|
|
|
|
|
|
|
configuration->setDisplayName(displayName);
|
|
|
|
|
|
2009-09-25 15:19:45 +02:00
|
|
|
emit buildConfigurationDisplayNameChanged(configuration->name());
|
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();
|
|
|
|
|
}
|