2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-07-19 12:26:56 +02:00
|
|
|
** Contact: http://www.qt-project.org/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
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
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
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
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
#include "buildconfiguration.h"
|
|
|
|
|
#include "deployconfiguration.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "editorconfiguration.h"
|
2009-09-29 11:39:55 +02:00
|
|
|
#include "environment.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "projectexplorer.h"
|
2010-09-09 17:00:26 +02:00
|
|
|
#include "projectexplorerconstants.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "projectnodes.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
#include "runconfiguration.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "target.h"
|
2011-09-16 12:57:37 +02:00
|
|
|
#include "settingsaccessor.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-14 16:43:51 +01:00
|
|
|
#include <coreplugin/idocument.h>
|
2011-04-12 12:17:19 +02:00
|
|
|
#include <coreplugin/icontext.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2011-10-24 13:10:38 +00:00
|
|
|
#include <projectexplorer/buildmanager.h>
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <projectexplorer/kit.h>
|
|
|
|
|
#include <projectexplorer/kitmanager.h>
|
2010-09-09 17:00:26 +02:00
|
|
|
#include <limits>
|
2008-12-09 15:25:01 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::Project
|
|
|
|
|
|
|
|
|
|
\brief A project.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn void ProjectExplorer::Project::environmentChanged()
|
|
|
|
|
|
|
|
|
|
\brief Convenience signal emitted if the activeBuildConfiguration emits environmentChanged
|
|
|
|
|
or if the activeBuildConfiguration changes (including due to the active target changing).
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn void ProjectExplorer::Project::buildConfigurationEnabledChanged()
|
|
|
|
|
|
|
|
|
|
\brief Convenience signal emitted if the activeBuildConfiguration emits isEnabledChanged()
|
|
|
|
|
or if the activeBuildConfiguration changes (including due to the active target changing).
|
|
|
|
|
*/
|
|
|
|
|
|
2010-01-14 19:08:43 +01:00
|
|
|
namespace {
|
2012-06-28 17:17:43 +02:00
|
|
|
const char ACTIVE_TARGET_KEY[] = "ProjectExplorer.Project.ActiveTarget";
|
|
|
|
|
const char TARGET_KEY_PREFIX[] = "ProjectExplorer.Project.Target.";
|
|
|
|
|
const char TARGET_COUNT_KEY[] = "ProjectExplorer.Project.TargetCount";
|
|
|
|
|
const char EDITOR_SETTINGS_KEY[] = "ProjectExplorer.Project.EditorSettings";
|
|
|
|
|
const char PLUGIN_SETTINGS_KEY[] = "ProjectExplorer.Project.PluginSettings";
|
2010-01-14 19:08:43 +01:00
|
|
|
} // namespace
|
|
|
|
|
|
2010-09-21 09:17:37 +02:00
|
|
|
namespace ProjectExplorer {
|
2010-01-14 19:08:43 +01:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
// Project
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
2011-04-12 12:17:19 +02:00
|
|
|
class ProjectPrivate
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
public:
|
|
|
|
|
ProjectPrivate();
|
2012-08-17 13:18:31 +02:00
|
|
|
~ProjectPrivate();
|
|
|
|
|
|
2010-09-21 09:17:37 +02:00
|
|
|
QList<Target *> m_targets;
|
|
|
|
|
Target *m_activeTarget;
|
|
|
|
|
EditorConfiguration *m_editorConfiguration;
|
2011-04-12 12:17:19 +02:00
|
|
|
Core::Context m_projectContext;
|
|
|
|
|
Core::Context m_projectLanguage;
|
2011-08-01 13:21:01 +00:00
|
|
|
QVariantMap m_pluginSettings;
|
2012-08-17 13:18:31 +02:00
|
|
|
SettingsAccessor *m_accessor;
|
2010-09-21 09:17:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ProjectPrivate::ProjectPrivate() :
|
2010-02-08 15:50:06 +01:00
|
|
|
m_activeTarget(0),
|
2012-08-17 13:18:31 +02:00
|
|
|
m_editorConfiguration(new EditorConfiguration()),
|
|
|
|
|
m_accessor(0)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
ProjectPrivate::~ProjectPrivate()
|
|
|
|
|
{ delete m_accessor; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-09-21 09:17:37 +02:00
|
|
|
Project::Project() : d(new ProjectPrivate)
|
2012-08-17 13:18:31 +02:00
|
|
|
{ }
|
2010-09-21 09:17:37 +02:00
|
|
|
|
2009-01-16 16:30:22 +01:00
|
|
|
Project::~Project()
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
qDeleteAll(d->m_targets);
|
|
|
|
|
delete d->m_editorConfiguration;
|
2011-09-16 15:00:41 +02:00
|
|
|
delete d;
|
2009-01-16 16:30:22 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
bool Project::hasActiveBuildSettings() const
|
|
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
return activeTarget() && IBuildConfigurationFactory::find(activeTarget());
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-14 19:08:43 +01:00
|
|
|
QString Project::makeUnique(const QString &preferredName, const QStringList &usedNames)
|
2009-10-07 13:18:26 +02:00
|
|
|
{
|
2010-01-14 19:08:43 +01:00
|
|
|
if (!usedNames.contains(preferredName))
|
|
|
|
|
return preferredName;
|
2009-10-07 13:18:26 +02:00
|
|
|
int i = 2;
|
2010-01-14 19:08:43 +01:00
|
|
|
QString tryName = preferredName + QString::number(i);
|
2009-10-07 13:18:26 +02:00
|
|
|
while (usedNames.contains(tryName))
|
2010-01-14 19:08:43 +01:00
|
|
|
tryName = preferredName + QString::number(++i);
|
2009-10-07 13:18:26 +02:00
|
|
|
return tryName;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
void Project::changeEnvironment()
|
|
|
|
|
{
|
2011-01-19 15:46:01 +01:00
|
|
|
Target *t = qobject_cast<Target *>(sender());
|
2010-02-08 15:50:06 +01:00
|
|
|
if (t == activeTarget())
|
|
|
|
|
emit environmentChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-19 15:46:01 +01:00
|
|
|
void Project::changeBuildConfigurationEnabled()
|
|
|
|
|
{
|
|
|
|
|
Target *t = qobject_cast<Target *>(sender());
|
|
|
|
|
if (t == activeTarget())
|
|
|
|
|
emit buildConfigurationEnabledChanged();
|
|
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
void Project::addTarget(Target *t)
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
QTC_ASSERT(t && !d->m_targets.contains(t), return);
|
2012-09-03 18:31:44 +02:00
|
|
|
QTC_ASSERT(!target(t->kit()), return);
|
2010-02-08 15:50:06 +01:00
|
|
|
Q_ASSERT(t->project() == this);
|
2010-01-15 10:54:29 +01:00
|
|
|
|
2009-09-24 16:02:02 +02:00
|
|
|
// Check that we don't have a configuration with the same displayName
|
2010-02-08 15:50:06 +01:00
|
|
|
QString targetDisplayName = t->displayName();
|
2009-09-24 16:02:02 +02:00
|
|
|
QStringList displayNames;
|
2010-09-21 09:17:37 +02:00
|
|
|
foreach (const Target *target, d->m_targets)
|
2010-02-08 15:50:06 +01:00
|
|
|
displayNames << target->displayName();
|
|
|
|
|
targetDisplayName = makeUnique(targetDisplayName, displayNames);
|
2010-08-19 12:26:21 +02:00
|
|
|
t->setDefaultDisplayName(targetDisplayName);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-09-24 16:02:02 +02:00
|
|
|
// add it
|
2010-09-21 09:17:37 +02:00
|
|
|
d->m_targets.push_back(t);
|
2010-02-08 15:50:06 +01:00
|
|
|
connect(t, SIGNAL(environmentChanged()),
|
|
|
|
|
SLOT(changeEnvironment()));
|
2011-01-19 15:46:01 +01:00
|
|
|
connect(t, SIGNAL(buildConfigurationEnabledChanged()),
|
|
|
|
|
this, SLOT(changeBuildConfigurationEnabled()));
|
2012-04-24 15:49:09 +02:00
|
|
|
connect(t, SIGNAL(buildDirectoryChanged()),
|
|
|
|
|
this, SLOT(onBuildDirectoryChanged()));
|
2010-02-08 15:50:06 +01:00
|
|
|
emit addedTarget(t);
|
|
|
|
|
|
|
|
|
|
// check activeTarget:
|
|
|
|
|
if (activeTarget() == 0)
|
|
|
|
|
setActiveTarget(t);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2011-10-24 13:10:38 +00:00
|
|
|
bool Project::removeTarget(Target *target)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2011-10-24 13:10:38 +00:00
|
|
|
if (!target || !d->m_targets.contains(target))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::BuildManager *bm =
|
|
|
|
|
ProjectExplorer::ProjectExplorerPlugin::instance()->buildManager();
|
|
|
|
|
if (bm->isBuilding(target))
|
|
|
|
|
return false;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
if (target == activeTarget()) {
|
2011-12-06 15:13:50 +01:00
|
|
|
if (d->m_targets.size() == 1) {
|
2010-02-08 15:50:06 +01:00
|
|
|
setActiveTarget(0);
|
2011-12-06 15:13:50 +01:00
|
|
|
} else if (d->m_targets.first() == target) {
|
|
|
|
|
setActiveTarget(d->m_targets.at(1));
|
|
|
|
|
} else {
|
2010-09-21 09:17:37 +02:00
|
|
|
setActiveTarget(d->m_targets.at(0));
|
2011-12-06 15:13:50 +01:00
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
2011-12-06 15:13:50 +01:00
|
|
|
|
|
|
|
|
emit aboutToRemoveTarget(target);
|
|
|
|
|
d->m_targets.removeOne(target);
|
|
|
|
|
emit removedTarget(target);
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
delete target;
|
2011-11-03 14:13:23 +01:00
|
|
|
return true;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
QList<Target *> Project::targets() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
return d->m_targets;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
Target *Project::activeTarget() const
|
2010-01-19 16:33:44 +01:00
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
return d->m_activeTarget;
|
2010-01-19 16:33:44 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
void Project::setActiveTarget(Target *target)
|
2010-01-19 16:33:44 +01:00
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
if ((!target && !d->m_targets.isEmpty()) ||
|
|
|
|
|
(target && d->m_targets.contains(target) && d->m_activeTarget != target)) {
|
|
|
|
|
d->m_activeTarget = target;
|
|
|
|
|
emit activeTargetChanged(d->m_activeTarget);
|
2010-02-08 15:50:06 +01:00
|
|
|
emit environmentChanged();
|
2011-01-19 15:46:01 +01:00
|
|
|
emit buildConfigurationEnabledChanged();
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
2010-01-19 16:33:44 +01:00
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
Target *Project::target(const Core::Id id) const
|
2009-05-06 16:33:43 +02:00
|
|
|
{
|
2012-06-20 16:04:12 +02:00
|
|
|
foreach (Target *target, d->m_targets) {
|
2010-02-08 15:50:06 +01:00
|
|
|
if (target->id() == id)
|
|
|
|
|
return target;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
2009-05-06 16:33:43 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
Target *Project::target(Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
foreach (Target *target, d->m_targets) {
|
2012-09-03 18:31:44 +02:00
|
|
|
if (target->kit() == k)
|
2012-04-24 15:49:09 +02:00
|
|
|
return target;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
bool Project::supportsKit(Kit *k) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
Q_UNUSED(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
Target *Project::createTarget(Kit *k)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
if (!k || target(k))
|
2012-04-24 15:49:09 +02:00
|
|
|
return 0;
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
Target *t = new Target(this, k);
|
2012-04-24 15:49:09 +02:00
|
|
|
t->createDefaultSetup();
|
|
|
|
|
|
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Target *Project::restoreTarget(const QVariantMap &data)
|
|
|
|
|
{
|
|
|
|
|
Core::Id id = idFromMap(data);
|
|
|
|
|
if (target(id)) {
|
|
|
|
|
qWarning("Warning: Duplicated target id found, not restoring second target with id '%s'. Continuing.",
|
|
|
|
|
qPrintable(id.toString()));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
Kit *k = KitManager::instance()->find(id);
|
|
|
|
|
if (!k) {
|
2012-04-24 15:49:09 +02:00
|
|
|
qWarning("Warning: No profile '%s' found. Continuing.", qPrintable(id.toString()));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
Target *t = new Target(this, k);
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!t->fromMap(data)) {
|
|
|
|
|
delete t;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void Project::saveSettings()
|
|
|
|
|
{
|
2011-08-01 13:21:01 +00:00
|
|
|
emit aboutToSaveSettings();
|
2012-08-17 13:18:31 +02:00
|
|
|
if (!d->m_accessor)
|
|
|
|
|
d->m_accessor = new SettingsAccessor(this);
|
|
|
|
|
d->m_accessor->saveSettings(toMap());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-07-03 16:46:01 +02:00
|
|
|
bool Project::restoreSettings()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2012-08-17 13:18:31 +02:00
|
|
|
if (!d->m_accessor)
|
|
|
|
|
d->m_accessor = new SettingsAccessor(this);
|
|
|
|
|
QVariantMap map(d->m_accessor->restoreSettings());
|
2011-08-01 13:21:01 +00:00
|
|
|
bool ok = fromMap(map);
|
|
|
|
|
if (ok)
|
|
|
|
|
emit settingsLoaded();
|
|
|
|
|
return ok;
|
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
|
|
|
}
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\brief Serialize all data into a QVariantMap.
|
|
|
|
|
|
|
|
|
|
This map is then saved in the .user file of the project.
|
|
|
|
|
Just put all your data into the map.
|
|
|
|
|
|
|
|
|
|
\note Do not forget to call your base class' toMap method.
|
|
|
|
|
\note Do not forget to call setActiveBuildConfiguration when
|
|
|
|
|
creating new BuilConfigurations.
|
|
|
|
|
*/
|
|
|
|
|
|
2010-01-19 16:33:44 +01:00
|
|
|
QVariantMap Project::toMap() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
const QList<Target *> ts = targets();
|
2009-11-24 15:36:31 +01:00
|
|
|
|
2010-01-19 16:33:44 +01:00
|
|
|
QVariantMap map;
|
2010-09-21 09:17:37 +02:00
|
|
|
map.insert(QLatin1String(ACTIVE_TARGET_KEY), ts.indexOf(d->m_activeTarget));
|
2010-02-08 15:50:06 +01:00
|
|
|
map.insert(QLatin1String(TARGET_COUNT_KEY), ts.size());
|
|
|
|
|
for (int i = 0; i < ts.size(); ++i)
|
|
|
|
|
map.insert(QString::fromLatin1(TARGET_KEY_PREFIX) + QString::number(i), ts.at(i)->toMap());
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-09-21 09:17:37 +02:00
|
|
|
map.insert(QLatin1String(EDITOR_SETTINGS_KEY), d->m_editorConfiguration->toMap());
|
2011-08-01 13:21:01 +00:00
|
|
|
map.insert(QLatin1String(PLUGIN_SETTINGS_KEY), d->m_pluginSettings);
|
2010-01-19 16:33:44 +01:00
|
|
|
|
|
|
|
|
return map;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-25 13:19:27 +01:00
|
|
|
QString Project::projectDirectory() const
|
|
|
|
|
{
|
2012-02-14 16:43:51 +01:00
|
|
|
return projectDirectory(document()->fileName());
|
2010-06-08 14:19:05 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
QString Project::projectDirectory(const QString &top)
|
2010-06-08 14:19:05 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
if (top.isEmpty())
|
2010-06-30 13:31:09 +02:00
|
|
|
return QString();
|
2012-09-03 18:31:44 +02:00
|
|
|
QFileInfo info(top);
|
2010-03-25 13:19:27 +01:00
|
|
|
return info.absoluteDir().path();
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-08 14:19:05 +02:00
|
|
|
|
2010-01-19 16:33:44 +01:00
|
|
|
bool Project::fromMap(const QVariantMap &map)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-01-19 16:33:44 +01:00
|
|
|
if (map.contains(QLatin1String(EDITOR_SETTINGS_KEY))) {
|
|
|
|
|
QVariantMap values(map.value(QLatin1String(EDITOR_SETTINGS_KEY)).toMap());
|
2010-09-21 09:17:37 +02:00
|
|
|
d->m_editorConfiguration->fromMap(values);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2011-08-01 13:21:01 +00:00
|
|
|
if (map.contains(QLatin1String(PLUGIN_SETTINGS_KEY)))
|
|
|
|
|
d->m_pluginSettings = map.value(QLatin1String(PLUGIN_SETTINGS_KEY)).toMap();
|
|
|
|
|
|
2010-01-19 16:33:44 +01:00
|
|
|
bool ok;
|
2010-02-08 15:50:06 +01:00
|
|
|
int maxI(map.value(QLatin1String(TARGET_COUNT_KEY), 0).toInt(&ok));
|
2010-01-19 16:33:44 +01:00
|
|
|
if (!ok || maxI < 0)
|
|
|
|
|
maxI = 0;
|
2010-02-08 15:50:06 +01:00
|
|
|
int active(map.value(QLatin1String(ACTIVE_TARGET_KEY), 0).toInt(&ok));
|
2012-08-07 14:01:52 +02:00
|
|
|
if (!ok || active < 0 || active >= maxI)
|
2010-02-08 15:50:06 +01:00
|
|
|
active = 0;
|
2010-01-19 16:33:44 +01:00
|
|
|
|
|
|
|
|
for (int i = 0; i < maxI; ++i) {
|
2010-02-08 15:50:06 +01:00
|
|
|
const QString key(QString::fromLatin1(TARGET_KEY_PREFIX) + QString::number(i));
|
2010-02-18 18:37:11 +01:00
|
|
|
if (!map.contains(key)) {
|
|
|
|
|
qWarning() << key << "was not found in data.";
|
2010-01-19 16:33:44 +01:00
|
|
|
return false;
|
2010-02-18 18:37:11 +01:00
|
|
|
}
|
2010-12-10 19:02:19 +01:00
|
|
|
QVariantMap targetMap = map.value(key).toMap();
|
2010-12-06 16:15:41 +01:00
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
Target *t = restoreTarget(targetMap);
|
|
|
|
|
if (!t)
|
|
|
|
|
continue;
|
2010-12-10 19:02:19 +01:00
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
addTarget(t);
|
|
|
|
|
if (i == active)
|
|
|
|
|
setActiveTarget(t);
|
2009-11-30 13:58:06 +01:00
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2010-01-19 16:33:44 +01:00
|
|
|
return true;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EditorConfiguration *Project::editorConfiguration() const
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
return d->m_editorConfiguration;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-12-03 16:23:15 +01:00
|
|
|
QString Project::generatedUiHeader(const QString & /* formFile */) const
|
|
|
|
|
{
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
2010-09-21 09:17:37 +02:00
|
|
|
|
2011-04-12 12:17:19 +02:00
|
|
|
void Project::setProjectContext(Core::Context context)
|
|
|
|
|
{
|
|
|
|
|
d->m_projectContext = context;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Project::setProjectLanguage(Core::Context language)
|
|
|
|
|
{
|
|
|
|
|
d->m_projectLanguage = language;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Core::Context Project::projectContext() const
|
|
|
|
|
{
|
|
|
|
|
return d->m_projectContext;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Core::Context Project::projectLanguage() const
|
|
|
|
|
{
|
|
|
|
|
return d->m_projectLanguage;
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-01 13:21:01 +00:00
|
|
|
QVariant Project::namedSettings(const QString &name) const
|
|
|
|
|
{
|
|
|
|
|
return d->m_pluginSettings.value(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Project::setNamedSettings(const QString &name, QVariant &value)
|
|
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
if (value.isNull())
|
|
|
|
|
d->m_pluginSettings.remove(name);
|
|
|
|
|
else
|
|
|
|
|
d->m_pluginSettings.insert(name, value);
|
2011-08-01 13:21:01 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-28 10:15:04 +00:00
|
|
|
bool Project::needsConfiguration() const
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-06 13:14:42 +01:00
|
|
|
void Project::configureAsExampleProject(const QStringList &platforms)
|
|
|
|
|
{
|
2012-03-12 17:16:16 +01:00
|
|
|
Q_UNUSED(platforms);
|
2012-03-06 13:14:42 +01:00
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
void Project::onBuildDirectoryChanged()
|
|
|
|
|
{
|
|
|
|
|
Target *target = qobject_cast<Target *>(sender());
|
|
|
|
|
if (target && target == activeTarget())
|
|
|
|
|
emit buildDirectoryChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-21 09:17:37 +02:00
|
|
|
} // namespace ProjectExplorer
|