2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02: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.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02: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
|
|
|
|
2013-07-22 15:53:57 +02:00
|
|
|
#include "buildinfo.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
#include "buildconfiguration.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "editorconfiguration.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "projectexplorer.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>
|
2011-10-24 13:10:38 +00:00
|
|
|
#include <projectexplorer/buildmanager.h>
|
2012-09-03 18:31:44 +02:00
|
|
|
#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
|
|
|
|
|
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The Project class implements a project node in the project explorer.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\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;
|
2012-11-21 16:18:53 +01:00
|
|
|
Core::Context m_projectLanguages;
|
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
|
|
|
}
|
|
|
|
|
|
2013-07-23 12:30:17 +02:00
|
|
|
QString Project::projectFilePath() const
|
|
|
|
|
{
|
|
|
|
|
return document()->filePath();
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
2012-09-25 11:11:02 +02:00
|
|
|
t->setDefaultDisplayName(t->displayName());
|
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;
|
|
|
|
|
|
2013-09-05 14:36:20 +02:00
|
|
|
if (BuildManager::isBuilding(target))
|
2011-10-24 13:10:38 +00:00
|
|
|
return false;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
if (target == activeTarget()) {
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (d->m_targets.size() == 1)
|
2010-02-08 15:50:06 +01:00
|
|
|
setActiveTarget(0);
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
else if (d->m_targets.first() == target)
|
2011-12-06 15:13:50 +01:00
|
|
|
setActiveTarget(d->m_targets.at(1));
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
else
|
2010-09-21 09:17:37 +02:00
|
|
|
setActiveTarget(d->m_targets.at(0));
|
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-20 11:16:47 +02:00
|
|
|
bool Project::supportsKit(Kit *k, QString *errorMessage) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
Q_UNUSED(k);
|
2012-09-20 11:16:47 +02:00
|
|
|
Q_UNUSED(errorMessage);
|
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-10-02 17:46:19 +02:00
|
|
|
if (!setupTarget(t)) {
|
|
|
|
|
delete t;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-02 17:46:19 +02:00
|
|
|
bool Project::setupTarget(Target *t)
|
|
|
|
|
{
|
|
|
|
|
t->updateDefaultBuildConfigurations();
|
|
|
|
|
t->updateDefaultDeployConfigurations();
|
|
|
|
|
t->updateDefaultRunConfigurations();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-21 12:48:46 +02:00
|
|
|
Kit *k = KitManager::find(id);
|
2012-09-03 18:31:44 +02:00
|
|
|
if (!k) {
|
2012-09-27 22:30:29 +02:00
|
|
|
qWarning("Warning: No kit '%s' found. Continuing.", qPrintable(id.toString()));
|
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
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
{
|
2013-07-04 13:30:26 +02:00
|
|
|
return projectDirectory(document()->filePath());
|
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)
|
|
|
|
|
{
|
2013-04-09 15:30:20 +02:00
|
|
|
if (d->m_projectContext == context)
|
|
|
|
|
return;
|
2011-04-12 12:17:19 +02:00
|
|
|
d->m_projectContext = context;
|
2013-04-09 15:30:20 +02:00
|
|
|
emit projectContextUpdated();
|
2011-04-12 12:17:19 +02:00
|
|
|
}
|
|
|
|
|
|
2012-11-21 16:18:53 +01:00
|
|
|
void Project::setProjectLanguages(Core::Context language)
|
2011-04-12 12:17:19 +02:00
|
|
|
{
|
2013-04-09 15:30:20 +02:00
|
|
|
if (d->m_projectLanguages == language)
|
|
|
|
|
return;
|
2012-11-21 16:18:53 +01:00
|
|
|
d->m_projectLanguages = language;
|
2013-04-09 15:30:20 +02:00
|
|
|
emit projectLanguagesUpdated();
|
2011-04-12 12:17:19 +02:00
|
|
|
}
|
|
|
|
|
|
2013-04-10 14:45:47 +02:00
|
|
|
void Project::addProjectLanguage(Core::Id id)
|
|
|
|
|
{
|
|
|
|
|
Core::Context lang = projectLanguages();
|
|
|
|
|
int pos = lang.indexOf(id);
|
|
|
|
|
if (pos < 0)
|
|
|
|
|
lang.add(id);
|
|
|
|
|
setProjectLanguages(lang);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Project::removeProjectLanguage(Core::Id id)
|
|
|
|
|
{
|
|
|
|
|
Core::Context lang = projectLanguages();
|
|
|
|
|
int pos = lang.indexOf(id);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
lang.removeAt(pos);
|
|
|
|
|
setProjectLanguages(lang);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Project::setProjectLanguage(Core::Id id, bool enabled)
|
|
|
|
|
{
|
|
|
|
|
if (enabled)
|
|
|
|
|
addProjectLanguage(id);
|
|
|
|
|
else
|
|
|
|
|
removeProjectLanguage(id);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-12 12:17:19 +02:00
|
|
|
Core::Context Project::projectContext() const
|
|
|
|
|
{
|
|
|
|
|
return d->m_projectContext;
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-21 16:18:53 +01:00
|
|
|
Core::Context Project::projectLanguages() const
|
2011-04-12 12:17:19 +02:00
|
|
|
{
|
2012-11-21 16:18:53 +01:00
|
|
|
return d->m_projectLanguages;
|
2011-04-12 12:17:19 +02:00
|
|
|
}
|
|
|
|
|
|
2011-08-01 13:21:01 +00:00
|
|
|
QVariant Project::namedSettings(const QString &name) const
|
|
|
|
|
{
|
|
|
|
|
return d->m_pluginSettings.value(name);
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-24 16:23:13 +02:00
|
|
|
void Project::setNamedSettings(const QString &name, const QVariant &value)
|
2011-08-01 13:21:01 +00:00
|
|
|
{
|
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-09-06 16:19:14 +02:00
|
|
|
bool Project::supportsNoTargetPanel() const
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-06 11:14:27 +02:00
|
|
|
bool Project::needsSpecialDeployment() const
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-22 15:53:57 +02:00
|
|
|
void Project::setup(QList<const BuildInfo *> infoList)
|
|
|
|
|
{
|
|
|
|
|
QList<Target *> toRegister;
|
|
|
|
|
foreach (const BuildInfo *info, infoList) {
|
|
|
|
|
Kit *k = KitManager::find(info->kitId);
|
|
|
|
|
if (!k)
|
|
|
|
|
continue;
|
|
|
|
|
Target *t = target(k);
|
|
|
|
|
if (!t) {
|
|
|
|
|
foreach (Target *i, toRegister) {
|
|
|
|
|
if (i->kit() == k) {
|
|
|
|
|
t = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!t) {
|
|
|
|
|
t = new Target(this, k);
|
|
|
|
|
toRegister << t;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildConfiguration *bc = info->factory()->create(t, info);
|
|
|
|
|
if (!bc)
|
|
|
|
|
continue;
|
|
|
|
|
t->addBuildConfiguration(bc);
|
|
|
|
|
}
|
|
|
|
|
foreach (Target *t, toRegister)
|
|
|
|
|
addTarget(t);
|
|
|
|
|
}
|
|
|
|
|
|
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
|