2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-02-08 15:50:06 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2010-02-08 15:50:06 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-02-08 15:50:06 +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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2010-02-08 15:50:06 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
#include "target.h"
|
|
|
|
|
|
2013-07-22 15:53:57 +02:00
|
|
|
#include "buildinfo.h"
|
2012-08-20 12:41:52 +02:00
|
|
|
#include "buildtargetinfo.h"
|
|
|
|
|
#include "deploymentdata.h"
|
2012-09-03 18:31:44 +02:00
|
|
|
#include "kit.h"
|
|
|
|
|
#include "kitinformation.h"
|
|
|
|
|
#include "kitmanager.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "buildconfiguration.h"
|
2010-07-16 14:00:41 +02:00
|
|
|
#include "deployconfiguration.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "project.h"
|
|
|
|
|
#include "runconfiguration.h"
|
2015-07-28 18:29:52 +02:00
|
|
|
#include "session.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-09-09 17:00:26 +02:00
|
|
|
#include <limits>
|
2012-03-26 11:15:11 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2011-10-24 13:10:38 +00:00
|
|
|
#include <projectexplorer/buildmanager.h>
|
2012-03-26 11:15:11 +02:00
|
|
|
#include <projectexplorer/devicesupport/devicemanager.h>
|
2016-09-27 17:45:42 +02:00
|
|
|
#include <projectexplorer/projectexplorericons.h>
|
2012-03-26 11:15:11 +02:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2011-10-24 13:10:38 +00:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
2010-02-08 15:50:06 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2014-07-07 19:02:26 +02:00
|
|
|
#include <utils/algorithm.h>
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <QDebug>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QIcon>
|
2012-03-26 11:15:11 +02:00
|
|
|
#include <QPainter>
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
namespace {
|
2011-11-02 16:45:13 +01:00
|
|
|
const char ACTIVE_BC_KEY[] = "ProjectExplorer.Target.ActiveBuildConfiguration";
|
|
|
|
|
const char BC_KEY_PREFIX[] = "ProjectExplorer.Target.BuildConfiguration.";
|
|
|
|
|
const char BC_COUNT_KEY[] = "ProjectExplorer.Target.BuildConfigurationCount";
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2011-11-02 16:45:13 +01:00
|
|
|
const char ACTIVE_DC_KEY[] = "ProjectExplorer.Target.ActiveDeployConfiguration";
|
|
|
|
|
const char DC_KEY_PREFIX[] = "ProjectExplorer.Target.DeployConfiguration.";
|
|
|
|
|
const char DC_COUNT_KEY[] = "ProjectExplorer.Target.DeployConfigurationCount";
|
2010-07-16 14:00:41 +02:00
|
|
|
|
2011-11-02 16:45:13 +01:00
|
|
|
const char ACTIVE_RC_KEY[] = "ProjectExplorer.Target.ActiveRunConfiguration";
|
|
|
|
|
const char RC_KEY_PREFIX[] = "ProjectExplorer.Target.RunConfiguration.";
|
|
|
|
|
const char RC_COUNT_KEY[] = "ProjectExplorer.Target.RunConfigurationCount";
|
2013-04-19 16:27:31 +02:00
|
|
|
const char PLUGIN_SETTINGS_KEY[] = "ProjectExplorer.Target.PluginSettings";
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
// Target
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
2010-09-21 09:17:37 +02:00
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
|
2011-04-21 15:01:48 +02:00
|
|
|
class TargetPrivate
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
public:
|
2015-11-16 17:08:04 +01:00
|
|
|
TargetPrivate(Kit *k);
|
2011-03-09 12:07:35 +01:00
|
|
|
|
|
|
|
|
QList<DeployConfigurationFactory *> deployFactories() const;
|
|
|
|
|
|
2015-11-16 17:08:04 +01:00
|
|
|
bool m_isEnabled = true;
|
2010-09-21 09:17:37 +02:00
|
|
|
QIcon m_icon;
|
|
|
|
|
QIcon m_overlayIcon;
|
|
|
|
|
QString m_toolTip;
|
|
|
|
|
|
|
|
|
|
QList<BuildConfiguration *> m_buildConfigurations;
|
2015-11-16 17:08:04 +01:00
|
|
|
BuildConfiguration *m_activeBuildConfiguration = 0;
|
2010-09-21 09:17:37 +02:00
|
|
|
QList<DeployConfiguration *> m_deployConfigurations;
|
2015-11-16 17:08:04 +01:00
|
|
|
DeployConfiguration *m_activeDeployConfiguration = 0;
|
2010-09-21 09:17:37 +02:00
|
|
|
QList<RunConfiguration *> m_runConfigurations;
|
2015-11-16 17:08:04 +01:00
|
|
|
RunConfiguration* m_activeRunConfiguration = 0;
|
2012-08-20 12:41:52 +02:00
|
|
|
DeploymentData m_deploymentData;
|
|
|
|
|
BuildTargetInfoList m_appTargets;
|
2013-04-19 16:27:31 +02:00
|
|
|
QVariantMap m_pluginSettings;
|
2012-03-26 11:15:11 +02:00
|
|
|
|
2015-11-16 17:08:04 +01:00
|
|
|
Kit *const m_kit;
|
2010-09-21 09:17:37 +02:00
|
|
|
};
|
|
|
|
|
|
2015-11-16 17:08:04 +01:00
|
|
|
TargetPrivate::TargetPrivate(Kit *k) :
|
|
|
|
|
m_kit(k)
|
|
|
|
|
{ }
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2011-03-09 12:07:35 +01:00
|
|
|
QList<DeployConfigurationFactory *> TargetPrivate::deployFactories() const
|
|
|
|
|
{
|
2012-06-18 11:34:15 +02:00
|
|
|
return ExtensionSystem::PluginManager::getObjects<DeployConfigurationFactory>();
|
2011-03-09 12:07:35 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-09 20:41:30 +03:00
|
|
|
Target::Target(Project *project, Kit *k) :
|
|
|
|
|
ProjectConfiguration(project, k->id()),
|
2015-11-16 17:08:04 +01:00
|
|
|
d(new TargetPrivate(k))
|
2010-09-21 09:17:37 +02:00
|
|
|
{
|
2015-11-16 17:08:04 +01:00
|
|
|
QTC_CHECK(d->m_kit);
|
2015-11-16 16:57:54 +01:00
|
|
|
connect(DeviceManager::instance(), &DeviceManager::updated, this, &Target::updateDeviceState);
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2012-09-04 15:27:10 +02:00
|
|
|
setDisplayName(d->m_kit->displayName());
|
|
|
|
|
setIcon(d->m_kit->icon());
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2015-11-16 16:57:54 +01:00
|
|
|
KitManager *km = KitManager::instance();
|
|
|
|
|
connect(km, &KitManager::kitUpdated, this, &Target::handleKitUpdates);
|
|
|
|
|
connect(km, &KitManager::kitRemoved, this, &Target::handleKitRemoval);
|
2014-11-05 14:01:26 +01:00
|
|
|
|
|
|
|
|
Utils::MacroExpander *expander = macroExpander();
|
2014-11-05 15:45:56 +01:00
|
|
|
expander->setDisplayName(tr("Target Settings"));
|
|
|
|
|
expander->setAccumulating(true);
|
2014-11-05 14:01:26 +01:00
|
|
|
|
|
|
|
|
expander->registerSubProvider([this] { return kit()->macroExpander(); });
|
|
|
|
|
|
2014-11-05 15:45:56 +01:00
|
|
|
expander->registerVariable("sourceDir", tr("Source directory"),
|
|
|
|
|
[project] { return project->projectDirectory().toUserOutput(); });
|
|
|
|
|
|
2014-11-05 14:01:26 +01:00
|
|
|
// Legacy support.
|
|
|
|
|
expander->registerVariable(Constants::VAR_CURRENTPROJECT_NAME,
|
|
|
|
|
QCoreApplication::translate("ProjectExplorer", "Name of current project"),
|
|
|
|
|
[project] { return project->displayName(); },
|
|
|
|
|
false);
|
|
|
|
|
|
2010-09-21 09:17:37 +02:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
Target::~Target()
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
qDeleteAll(d->m_buildConfigurations);
|
2012-04-24 15:49:09 +02:00
|
|
|
qDeleteAll(d->m_deployConfigurations);
|
2010-09-21 09:17:37 +02:00
|
|
|
qDeleteAll(d->m_runConfigurations);
|
2011-09-16 15:00:41 +02:00
|
|
|
delete d;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::changeEnvironment()
|
|
|
|
|
{
|
2016-04-13 15:52:14 +02:00
|
|
|
auto bc = qobject_cast<BuildConfiguration *>(sender());
|
2010-02-08 15:50:06 +01:00
|
|
|
if (bc == activeBuildConfiguration())
|
|
|
|
|
emit environmentChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-19 15:46:01 +01:00
|
|
|
void Target::changeBuildConfigurationEnabled()
|
|
|
|
|
{
|
2016-04-13 15:52:14 +02:00
|
|
|
auto bc = qobject_cast<BuildConfiguration *>(sender());
|
2011-01-19 15:46:01 +01:00
|
|
|
if (bc == activeBuildConfiguration())
|
|
|
|
|
emit buildConfigurationEnabledChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-29 13:16:25 +02:00
|
|
|
void Target::changeDeployConfigurationEnabled()
|
|
|
|
|
{
|
2016-04-13 15:52:14 +02:00
|
|
|
auto dc = qobject_cast<DeployConfiguration *>(sender());
|
2012-03-29 13:16:25 +02:00
|
|
|
if (dc == activeDeployConfiguration())
|
|
|
|
|
emit deployConfigurationEnabledChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::changeRunConfigurationEnabled()
|
|
|
|
|
{
|
2016-04-13 15:52:14 +02:00
|
|
|
auto rc = qobject_cast<RunConfiguration *>(sender());
|
2012-03-29 13:16:25 +02:00
|
|
|
if (rc == activeRunConfiguration())
|
|
|
|
|
emit runConfigurationEnabledChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
void Target::onBuildDirectoryChanged()
|
|
|
|
|
{
|
2016-04-13 15:52:14 +02:00
|
|
|
auto bc = qobject_cast<BuildConfiguration *>(sender());
|
2013-12-16 13:30:52 +01:00
|
|
|
if (bc && activeBuildConfiguration() == bc)
|
2012-04-24 15:49:09 +02:00
|
|
|
emit buildDirectoryChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-09 20:41:30 +03:00
|
|
|
void Target::handleKitUpdates(Kit *k)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-09 20:41:30 +03:00
|
|
|
if (k != d->m_kit)
|
2012-04-24 15:49:09 +02:00
|
|
|
return;
|
|
|
|
|
|
2012-09-09 20:41:30 +03:00
|
|
|
setDisplayName(k->displayName());
|
|
|
|
|
setIcon(k->icon());
|
2012-04-24 15:49:09 +02:00
|
|
|
updateDefaultDeployConfigurations();
|
2012-09-28 14:33:26 +02:00
|
|
|
updateDeviceState(); // in case the device changed...
|
2012-09-03 18:31:44 +02:00
|
|
|
emit kitChanged();
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-09 20:41:30 +03:00
|
|
|
void Target::handleKitRemoval(Kit *k)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-09 20:41:30 +03:00
|
|
|
if (k != d->m_kit)
|
2012-04-24 15:49:09 +02:00
|
|
|
return;
|
|
|
|
|
project()->removeTarget(this);
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
Project *Target::project() const
|
|
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
return static_cast<Project *>(parent());
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
Kit *Target::kit() const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-04 15:27:10 +02:00
|
|
|
return d->m_kit;
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2016-05-02 15:47:06 +02:00
|
|
|
void Target::addBuildConfiguration(BuildConfiguration *bc)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2016-05-02 15:47:06 +02:00
|
|
|
QTC_ASSERT(bc && !d->m_buildConfigurations.contains(bc), return);
|
|
|
|
|
Q_ASSERT(bc->target() == this);
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
// Check that we don't have a configuration with the same displayName
|
2016-05-02 15:47:06 +02:00
|
|
|
QString configurationDisplayName = bc->displayName();
|
2014-07-07 19:02:26 +02:00
|
|
|
QStringList displayNames = Utils::transform(d->m_buildConfigurations, &BuildConfiguration::displayName);
|
2010-02-08 15:50:06 +01:00
|
|
|
configurationDisplayName = Project::makeUnique(configurationDisplayName, displayNames);
|
2016-05-02 15:47:06 +02:00
|
|
|
if (configurationDisplayName != bc->displayName()) {
|
|
|
|
|
if (bc->usesDefaultDisplayName())
|
|
|
|
|
bc->setDefaultDisplayName(configurationDisplayName);
|
2012-04-24 15:49:09 +02:00
|
|
|
else
|
2016-05-02 15:47:06 +02:00
|
|
|
bc->setDisplayName(configurationDisplayName);
|
2011-05-20 12:52:59 +02:00
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
// add it
|
2016-05-02 15:47:06 +02:00
|
|
|
d->m_buildConfigurations.push_back(bc);
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2016-05-02 15:47:06 +02:00
|
|
|
emit addedBuildConfiguration(bc);
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2016-05-02 15:47:06 +02:00
|
|
|
connect(bc, &BuildConfiguration::environmentChanged,
|
2015-11-16 16:57:54 +01:00
|
|
|
this, &Target::changeEnvironment);
|
2016-05-02 15:47:06 +02:00
|
|
|
connect(bc, &BuildConfiguration::enabledChanged,
|
2015-11-16 16:57:54 +01:00
|
|
|
this, &Target::changeBuildConfigurationEnabled);
|
2016-05-02 15:47:06 +02:00
|
|
|
connect(bc, &BuildConfiguration::buildDirectoryChanged,
|
2015-11-16 16:57:54 +01:00
|
|
|
this, &Target::onBuildDirectoryChanged);
|
2011-01-19 15:46:01 +01:00
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!activeBuildConfiguration())
|
2016-05-02 15:47:06 +02:00
|
|
|
setActiveBuildConfiguration(bc);
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2016-05-02 15:47:06 +02:00
|
|
|
bool Target::removeBuildConfiguration(BuildConfiguration *bc)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
//todo: this might be error prone
|
2016-05-02 15:47:06 +02:00
|
|
|
if (!d->m_buildConfigurations.contains(bc))
|
2011-10-24 13:10:38 +00:00
|
|
|
return false;
|
|
|
|
|
|
2016-05-02 15:47:06 +02:00
|
|
|
if (BuildManager::isBuilding(bc))
|
2011-10-24 13:10:38 +00:00
|
|
|
return false;
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2016-05-02 15:47:06 +02:00
|
|
|
d->m_buildConfigurations.removeOne(bc);
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2016-05-02 15:47:06 +02:00
|
|
|
emit removedBuildConfiguration(bc);
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2016-05-02 15:47:06 +02:00
|
|
|
if (activeBuildConfiguration() == bc) {
|
2010-09-21 09:17:37 +02:00
|
|
|
if (d->m_buildConfigurations.isEmpty())
|
2016-04-13 15:52:14 +02:00
|
|
|
SessionManager::setActiveBuildConfiguration(this, nullptr, SetActive::Cascade);
|
2010-02-08 15:50:06 +01:00
|
|
|
else
|
2015-07-28 18:29:52 +02:00
|
|
|
SessionManager::setActiveBuildConfiguration(this, d->m_buildConfigurations.at(0), SetActive::Cascade);
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2016-05-02 15:47:06 +02:00
|
|
|
delete bc;
|
2011-10-24 13:10:38 +00:00
|
|
|
return true;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<BuildConfiguration *> Target::buildConfigurations() const
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
return d->m_buildConfigurations;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildConfiguration *Target::activeBuildConfiguration() const
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
return d->m_activeBuildConfiguration;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::setActiveBuildConfiguration(BuildConfiguration *configuration)
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
if ((!configuration && d->m_buildConfigurations.isEmpty()) ||
|
|
|
|
|
(configuration && d->m_buildConfigurations.contains(configuration) &&
|
|
|
|
|
configuration != d->m_activeBuildConfiguration)) {
|
|
|
|
|
d->m_activeBuildConfiguration = configuration;
|
|
|
|
|
emit activeBuildConfigurationChanged(d->m_activeBuildConfiguration);
|
2010-02-08 15:50:06 +01:00
|
|
|
emit environmentChanged();
|
2011-01-19 15:46:01 +01:00
|
|
|
emit buildConfigurationEnabledChanged();
|
2012-04-24 15:49:09 +02:00
|
|
|
emit buildDirectoryChanged();
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
void Target::addDeployConfiguration(DeployConfiguration *dc)
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
QTC_ASSERT(dc && !d->m_deployConfigurations.contains(dc), return);
|
2010-07-16 14:00:41 +02:00
|
|
|
Q_ASSERT(dc->target() == this);
|
|
|
|
|
|
2011-03-09 12:07:35 +01:00
|
|
|
if (d->deployFactories().isEmpty())
|
2010-07-16 14:00:41 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Check that we don't have a configuration with the same displayName
|
|
|
|
|
QString configurationDisplayName = dc->displayName();
|
2014-07-07 19:02:26 +02:00
|
|
|
QStringList displayNames = Utils::transform(d->m_deployConfigurations, &DeployConfiguration::displayName);
|
2010-07-16 14:00:41 +02:00
|
|
|
configurationDisplayName = Project::makeUnique(configurationDisplayName, displayNames);
|
|
|
|
|
dc->setDisplayName(configurationDisplayName);
|
|
|
|
|
|
|
|
|
|
// add it
|
2010-09-21 09:17:37 +02:00
|
|
|
d->m_deployConfigurations.push_back(dc);
|
2010-07-16 14:00:41 +02:00
|
|
|
|
2015-11-16 16:57:54 +01:00
|
|
|
connect(dc, &DeployConfiguration::enabledChanged,
|
|
|
|
|
this, &Target::changeDeployConfigurationEnabled);
|
2012-03-29 13:16:25 +02:00
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
emit addedDeployConfiguration(dc);
|
|
|
|
|
|
2010-09-21 09:17:37 +02:00
|
|
|
if (!d->m_activeDeployConfiguration)
|
2010-07-16 14:00:41 +02:00
|
|
|
setActiveDeployConfiguration(dc);
|
|
|
|
|
Q_ASSERT(activeDeployConfiguration());
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-24 13:10:38 +00:00
|
|
|
bool Target::removeDeployConfiguration(DeployConfiguration *dc)
|
2010-07-16 14:00:41 +02:00
|
|
|
{
|
|
|
|
|
//todo: this might be error prone
|
2010-09-21 09:17:37 +02:00
|
|
|
if (!d->m_deployConfigurations.contains(dc))
|
2011-10-24 13:10:38 +00:00
|
|
|
return false;
|
|
|
|
|
|
2013-09-05 14:36:20 +02:00
|
|
|
if (BuildManager::isBuilding(dc))
|
2011-10-24 13:10:38 +00:00
|
|
|
return false;
|
2010-07-16 14:00:41 +02:00
|
|
|
|
2010-09-21 09:17:37 +02:00
|
|
|
d->m_deployConfigurations.removeOne(dc);
|
2010-07-16 14:00:41 +02:00
|
|
|
|
|
|
|
|
emit removedDeployConfiguration(dc);
|
|
|
|
|
|
|
|
|
|
if (activeDeployConfiguration() == dc) {
|
2010-09-21 09:17:37 +02:00
|
|
|
if (d->m_deployConfigurations.isEmpty())
|
2016-04-13 15:52:14 +02:00
|
|
|
SessionManager::setActiveDeployConfiguration(this, nullptr, SetActive::Cascade);
|
2010-07-16 14:00:41 +02:00
|
|
|
else
|
2015-07-28 18:29:52 +02:00
|
|
|
SessionManager::setActiveDeployConfiguration(this, d->m_deployConfigurations.at(0),
|
|
|
|
|
SetActive::Cascade);
|
2010-07-16 14:00:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete dc;
|
2011-10-24 13:10:38 +00:00
|
|
|
return true;
|
2010-07-16 14:00:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<DeployConfiguration *> Target::deployConfigurations() const
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
return d->m_deployConfigurations;
|
2010-07-16 14:00:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DeployConfiguration *Target::activeDeployConfiguration() const
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
return d->m_activeDeployConfiguration;
|
2010-07-16 14:00:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::setActiveDeployConfiguration(DeployConfiguration *dc)
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
if ((!dc && d->m_deployConfigurations.isEmpty()) ||
|
|
|
|
|
(dc && d->m_deployConfigurations.contains(dc) &&
|
|
|
|
|
dc != d->m_activeDeployConfiguration)) {
|
|
|
|
|
d->m_activeDeployConfiguration = dc;
|
|
|
|
|
emit activeDeployConfigurationChanged(d->m_activeDeployConfiguration);
|
2012-03-29 13:16:25 +02:00
|
|
|
emit deployConfigurationEnabledChanged();
|
2010-07-16 14:00:41 +02:00
|
|
|
}
|
2012-03-26 11:15:11 +02:00
|
|
|
updateDeviceState();
|
2010-07-16 14:00:41 +02:00
|
|
|
}
|
|
|
|
|
|
2012-08-20 12:41:52 +02:00
|
|
|
void Target::setDeploymentData(const DeploymentData &deploymentData)
|
|
|
|
|
{
|
2012-08-29 15:52:47 +02:00
|
|
|
if (d->m_deploymentData != deploymentData) {
|
|
|
|
|
d->m_deploymentData = deploymentData;
|
|
|
|
|
emit deploymentDataChanged();
|
|
|
|
|
}
|
2012-08-20 12:41:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DeploymentData Target::deploymentData() const
|
|
|
|
|
{
|
|
|
|
|
return d->m_deploymentData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::setApplicationTargets(const BuildTargetInfoList &appTargets)
|
|
|
|
|
{
|
2012-08-29 15:52:47 +02:00
|
|
|
if (d->m_appTargets != appTargets) {
|
|
|
|
|
d->m_appTargets = appTargets;
|
|
|
|
|
emit applicationTargetsChanged();
|
|
|
|
|
}
|
2012-08-20 12:41:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildTargetInfoList Target::applicationTargets() const
|
|
|
|
|
{
|
|
|
|
|
return d->m_appTargets;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
QList<RunConfiguration *> Target::runConfigurations() const
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
return d->m_runConfigurations;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2016-05-02 15:47:06 +02:00
|
|
|
void Target::addRunConfiguration(RunConfiguration *rc)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2016-05-02 15:47:06 +02:00
|
|
|
QTC_ASSERT(rc && !d->m_runConfigurations.contains(rc), return);
|
|
|
|
|
Q_ASSERT(rc->target() == this);
|
|
|
|
|
rc->addExtraAspects();
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-08-18 15:38:42 +02:00
|
|
|
// Check that we don't have a configuration with the same displayName
|
2016-05-02 15:47:06 +02:00
|
|
|
QString configurationDisplayName = rc->displayName();
|
2014-07-07 19:02:26 +02:00
|
|
|
QStringList displayNames = Utils::transform(d->m_runConfigurations, &RunConfiguration::displayName);
|
2010-08-18 15:38:42 +02:00
|
|
|
configurationDisplayName = Project::makeUnique(configurationDisplayName, displayNames);
|
2016-05-02 15:47:06 +02:00
|
|
|
rc->setDisplayName(configurationDisplayName);
|
2010-08-18 15:38:42 +02:00
|
|
|
|
2016-05-02 15:47:06 +02:00
|
|
|
d->m_runConfigurations.push_back(rc);
|
2012-03-29 13:16:25 +02:00
|
|
|
|
2016-05-02 15:47:06 +02:00
|
|
|
connect(rc, &RunConfiguration::enabledChanged,
|
2015-11-16 16:57:54 +01:00
|
|
|
this, &Target::changeRunConfigurationEnabled);
|
2012-03-29 13:16:25 +02:00
|
|
|
|
2016-05-02 15:47:06 +02:00
|
|
|
emit addedRunConfiguration(rc);
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
if (!activeRunConfiguration())
|
2016-05-02 15:47:06 +02:00
|
|
|
setActiveRunConfiguration(rc);
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2016-05-02 15:47:06 +02:00
|
|
|
void Target::removeRunConfiguration(RunConfiguration *rc)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2016-05-02 15:47:06 +02:00
|
|
|
QTC_ASSERT(rc && d->m_runConfigurations.contains(rc), return);
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2016-05-02 15:47:06 +02:00
|
|
|
d->m_runConfigurations.removeOne(rc);
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2016-05-02 15:47:06 +02:00
|
|
|
if (activeRunConfiguration() == rc) {
|
2010-09-21 09:17:37 +02:00
|
|
|
if (d->m_runConfigurations.isEmpty())
|
2016-04-13 15:52:14 +02:00
|
|
|
setActiveRunConfiguration(nullptr);
|
2010-02-08 15:50:06 +01:00
|
|
|
else
|
2010-09-21 09:17:37 +02:00
|
|
|
setActiveRunConfiguration(d->m_runConfigurations.at(0));
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2016-05-02 15:47:06 +02:00
|
|
|
emit removedRunConfiguration(rc);
|
|
|
|
|
delete rc;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2016-05-02 15:47:06 +02:00
|
|
|
RunConfiguration *Target::activeRunConfiguration() const
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
return d->m_activeRunConfiguration;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2016-05-02 15:47:06 +02:00
|
|
|
void Target::setActiveRunConfiguration(RunConfiguration *rc)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2016-05-02 15:47:06 +02:00
|
|
|
if ((!rc && d->m_runConfigurations.isEmpty()) ||
|
|
|
|
|
(rc && d->m_runConfigurations.contains(rc) &&
|
|
|
|
|
rc != d->m_activeRunConfiguration)) {
|
|
|
|
|
d->m_activeRunConfiguration = rc;
|
2010-09-21 09:17:37 +02:00
|
|
|
emit activeRunConfigurationChanged(d->m_activeRunConfiguration);
|
2012-03-29 13:16:25 +02:00
|
|
|
emit runConfigurationEnabledChanged();
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
2012-03-26 11:15:11 +02:00
|
|
|
updateDeviceState();
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Target::isEnabled() const
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
return d->m_isEnabled;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QIcon Target::icon() const
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
return d->m_icon;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::setIcon(QIcon icon)
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
d->m_icon = icon;
|
2010-02-08 15:50:06 +01:00
|
|
|
emit iconChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-23 16:52:03 +01:00
|
|
|
QIcon Target::overlayIcon() const
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
return d->m_overlayIcon;
|
2010-02-23 16:52:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::setOverlayIcon(QIcon icon)
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
d->m_overlayIcon = icon;
|
2010-02-23 16:52:03 +01:00
|
|
|
emit overlayIconChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-09 19:05:15 +01:00
|
|
|
QString Target::toolTip() const
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
return d->m_toolTip;
|
2010-02-09 19:05:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::setToolTip(const QString &text)
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
d->m_toolTip = text;
|
2010-02-09 19:05:15 +01:00
|
|
|
emit toolTipChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
QVariantMap Target::toMap() const
|
|
|
|
|
{
|
2012-09-04 15:27:10 +02:00
|
|
|
if (!d->m_kit) // Kit was deleted, target is only around to be copied.
|
2012-04-24 15:49:09 +02:00
|
|
|
return QVariantMap();
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
QVariantMap map(ProjectConfiguration::toMap());
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
const QList<BuildConfiguration *> bcs = buildConfigurations();
|
2010-09-21 09:17:37 +02:00
|
|
|
map.insert(QLatin1String(ACTIVE_BC_KEY), bcs.indexOf(d->m_activeBuildConfiguration));
|
2010-02-08 15:50:06 +01:00
|
|
|
map.insert(QLatin1String(BC_COUNT_KEY), bcs.size());
|
|
|
|
|
for (int i = 0; i < bcs.size(); ++i)
|
|
|
|
|
map.insert(QString::fromLatin1(BC_KEY_PREFIX) + QString::number(i), bcs.at(i)->toMap());
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
const QList<DeployConfiguration *> dcs = deployConfigurations();
|
2010-09-21 09:17:37 +02:00
|
|
|
map.insert(QLatin1String(ACTIVE_DC_KEY), dcs.indexOf(d->m_activeDeployConfiguration));
|
2010-07-16 14:00:41 +02:00
|
|
|
map.insert(QLatin1String(DC_COUNT_KEY), dcs.size());
|
|
|
|
|
for (int i = 0; i < dcs.size(); ++i)
|
|
|
|
|
map.insert(QString::fromLatin1(DC_KEY_PREFIX) + QString::number(i), dcs.at(i)->toMap());
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
const QList<RunConfiguration *> rcs = runConfigurations();
|
2010-09-21 09:17:37 +02:00
|
|
|
map.insert(QLatin1String(ACTIVE_RC_KEY), rcs.indexOf(d->m_activeRunConfiguration));
|
2010-02-08 15:50:06 +01:00
|
|
|
map.insert(QLatin1String(RC_COUNT_KEY), rcs.size());
|
|
|
|
|
for (int i = 0; i < rcs.size(); ++i)
|
|
|
|
|
map.insert(QString::fromLatin1(RC_KEY_PREFIX) + QString::number(i), rcs.at(i)->toMap());
|
|
|
|
|
|
2013-04-19 16:27:31 +02:00
|
|
|
map.insert(QLatin1String(PLUGIN_SETTINGS_KEY), d->m_pluginSettings);
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
void Target::updateDefaultBuildConfigurations()
|
|
|
|
|
{
|
|
|
|
|
IBuildConfigurationFactory *bcFactory = IBuildConfigurationFactory::find(this);
|
|
|
|
|
if (!bcFactory) {
|
|
|
|
|
qWarning("No build configuration factory found for target id '%s'.", qPrintable(id().toString()));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-05-02 12:22:58 +02:00
|
|
|
QList<BuildInfo *> infoList = bcFactory->availableSetups(this->kit(), project()->projectFilePath().toString());
|
2013-07-22 15:53:57 +02:00
|
|
|
foreach (BuildInfo *info, infoList) {
|
|
|
|
|
BuildConfiguration *bc = bcFactory->create(this, info);
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!bc)
|
|
|
|
|
continue;
|
|
|
|
|
addBuildConfiguration(bc);
|
|
|
|
|
}
|
2013-07-22 15:53:57 +02:00
|
|
|
qDeleteAll(infoList);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::updateDefaultDeployConfigurations()
|
|
|
|
|
{
|
2013-03-04 14:48:24 +01:00
|
|
|
QList<DeployConfigurationFactory *> dcFactories = DeployConfigurationFactory::find(this);
|
|
|
|
|
if (dcFactories.isEmpty()) {
|
2012-04-24 15:49:09 +02:00
|
|
|
qWarning("No deployment configuration factory found for target id '%s'.", qPrintable(id().toString()));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2013-03-04 14:48:24 +01:00
|
|
|
|
|
|
|
|
QList<Core::Id> dcIds;
|
|
|
|
|
foreach (DeployConfigurationFactory *dcFactory, dcFactories)
|
|
|
|
|
dcIds.append(dcFactory->availableCreationIds(this));
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
QList<DeployConfiguration *> dcList = deployConfigurations();
|
2013-12-02 11:53:59 +01:00
|
|
|
QList<Core::Id> toCreate = dcIds;
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
foreach (DeployConfiguration *dc, dcList) {
|
|
|
|
|
if (dcIds.contains(dc->id()))
|
2013-12-02 11:53:59 +01:00
|
|
|
toCreate.removeOne(dc->id());
|
2012-04-24 15:49:09 +02:00
|
|
|
else
|
|
|
|
|
removeDeployConfiguration(dc);
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-02 11:53:59 +01:00
|
|
|
foreach (Core::Id id, toCreate) {
|
2013-03-04 14:48:24 +01:00
|
|
|
foreach (DeployConfigurationFactory *dcFactory, dcFactories) {
|
|
|
|
|
if (dcFactory->canCreate(this, id)) {
|
|
|
|
|
DeployConfiguration *dc = dcFactory->create(this, id);
|
|
|
|
|
if (dc) {
|
|
|
|
|
QTC_CHECK(dc->id() == id);
|
|
|
|
|
addDeployConfiguration(dc);
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::updateDefaultRunConfigurations()
|
|
|
|
|
{
|
|
|
|
|
QList<IRunConfigurationFactory *> rcFactories = IRunConfigurationFactory::find(this);
|
|
|
|
|
if (rcFactories.isEmpty()) {
|
|
|
|
|
qWarning("No run configuration factory found for target id '%s'.", qPrintable(id().toString()));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<RunConfiguration *> existingConfigured; // Existing configured RCs
|
|
|
|
|
QList<RunConfiguration *> existingUnconfigured; // Existing unconfigured RCs
|
|
|
|
|
QList<RunConfiguration *> newConfigured; // NEW configured Rcs
|
|
|
|
|
QList<RunConfiguration *> newUnconfigured; // NEW unconfigured RCs
|
|
|
|
|
|
|
|
|
|
// sort existing RCs into configured/unconfigured.
|
2016-04-01 16:19:55 +02:00
|
|
|
std::tie(existingConfigured, existingUnconfigured)
|
|
|
|
|
= Utils::partition(runConfigurations(),
|
|
|
|
|
[](const RunConfiguration *rc) { return rc->isConfigured(); });
|
2012-04-24 15:49:09 +02:00
|
|
|
int configuredCount = existingConfigured.count();
|
|
|
|
|
|
|
|
|
|
// find all RC ids that can get created:
|
2014-06-12 16:24:52 +02:00
|
|
|
QList<Core::Id> availableFactoryIds;
|
2012-04-24 15:49:09 +02:00
|
|
|
foreach (IRunConfigurationFactory *rcFactory, rcFactories)
|
2014-06-12 16:24:52 +02:00
|
|
|
availableFactoryIds.append(rcFactory->availableCreationIds(this));
|
|
|
|
|
|
|
|
|
|
QList<Core::Id> autoCreateFactoryIds;
|
|
|
|
|
foreach (IRunConfigurationFactory *rcFactory, rcFactories)
|
|
|
|
|
autoCreateFactoryIds.append(rcFactory->availableCreationIds(this,
|
|
|
|
|
IRunConfigurationFactory::AutoCreate));
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
// Put outdated RCs into toRemove, do not bother with factories
|
|
|
|
|
// that produce already existing RCs
|
|
|
|
|
QList<RunConfiguration *> toRemove;
|
2012-07-03 14:01:11 +02:00
|
|
|
QList<Core::Id> toIgnore;
|
2012-04-24 15:49:09 +02:00
|
|
|
foreach (RunConfiguration *rc, existingConfigured) {
|
2014-06-12 16:24:52 +02:00
|
|
|
if (availableFactoryIds.contains(rc->id()))
|
2012-07-03 14:01:11 +02:00
|
|
|
toIgnore.append(rc->id()); // Already there
|
2016-04-01 16:19:55 +02:00
|
|
|
else if (project()->knowsAllBuildExecutables())
|
2012-04-24 15:49:09 +02:00
|
|
|
toRemove << rc;
|
|
|
|
|
}
|
2012-07-03 14:01:11 +02:00
|
|
|
foreach (Core::Id i, toIgnore)
|
2014-06-12 16:24:52 +02:00
|
|
|
autoCreateFactoryIds.removeAll(i);
|
2012-04-24 15:49:09 +02:00
|
|
|
configuredCount -= toRemove.count();
|
|
|
|
|
|
|
|
|
|
// Create new RCs and put them into newConfigured/newUnconfigured
|
2014-06-12 16:24:52 +02:00
|
|
|
foreach (Core::Id id, autoCreateFactoryIds) {
|
2014-07-07 19:02:26 +02:00
|
|
|
IRunConfigurationFactory *factory = Utils::findOrDefault(rcFactories,
|
|
|
|
|
[this, id] (IRunConfigurationFactory *i) {
|
|
|
|
|
return i->canCreate(this, id);
|
|
|
|
|
});
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!factory)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
RunConfiguration *rc = factory->create(this, id);
|
|
|
|
|
if (!rc)
|
|
|
|
|
continue;
|
|
|
|
|
QTC_CHECK(rc->id() == id);
|
|
|
|
|
if (!rc->isConfigured())
|
|
|
|
|
newUnconfigured << rc;
|
|
|
|
|
else
|
|
|
|
|
newConfigured << rc;
|
|
|
|
|
}
|
|
|
|
|
configuredCount += newConfigured.count();
|
|
|
|
|
|
|
|
|
|
// Decide what to do with the different categories:
|
|
|
|
|
bool removeExistingUnconfigured = false;
|
|
|
|
|
if (configuredCount > 0) {
|
|
|
|
|
// new non-Custom Executable RCs were added
|
|
|
|
|
removeExistingUnconfigured = true;
|
|
|
|
|
qDeleteAll(newUnconfigured);
|
|
|
|
|
newUnconfigured.clear();
|
|
|
|
|
} else {
|
|
|
|
|
// no new RCs, use old or new CERCs?
|
|
|
|
|
if (!existingUnconfigured.isEmpty()) {
|
|
|
|
|
qDeleteAll(newUnconfigured);
|
|
|
|
|
newUnconfigured.clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Do actual changes:
|
2013-10-18 17:46:40 +02:00
|
|
|
foreach (RunConfiguration *rc, newConfigured)
|
|
|
|
|
addRunConfiguration(rc);
|
|
|
|
|
foreach (RunConfiguration *rc, newUnconfigured)
|
|
|
|
|
addRunConfiguration(rc);
|
|
|
|
|
|
|
|
|
|
// Generate complete list of RCs to remove later:
|
|
|
|
|
QList<RunConfiguration *> removalList;
|
2013-05-29 15:27:05 +02:00
|
|
|
foreach (RunConfiguration *rc, toRemove) {
|
2013-10-18 17:46:40 +02:00
|
|
|
removalList << rc;
|
2013-05-29 15:27:05 +02:00
|
|
|
existingConfigured.removeOne(rc); // make sure to also remove them from existingConfigured!
|
|
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
if (removeExistingUnconfigured) {
|
2013-10-18 17:46:40 +02:00
|
|
|
removalList.append(existingUnconfigured);
|
2012-04-24 15:49:09 +02:00
|
|
|
existingUnconfigured.clear();
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-18 17:46:40 +02:00
|
|
|
// Make sure a configured RC will be active after we delete the RCs:
|
|
|
|
|
RunConfiguration *active = activeRunConfiguration();
|
2016-04-01 16:19:55 +02:00
|
|
|
if (removalList.contains(active) || !active->isEnabled()) {
|
|
|
|
|
RunConfiguration *newConfiguredDefault = newConfigured.isEmpty() ? nullptr : newConfigured.at(0);
|
|
|
|
|
|
|
|
|
|
RunConfiguration *rc
|
|
|
|
|
= Utils::findOrDefault(existingConfigured,
|
|
|
|
|
[](RunConfiguration *rc) { return rc->isEnabled(); });
|
|
|
|
|
if (!rc) {
|
|
|
|
|
rc = Utils::findOr(newConfigured, newConfiguredDefault,
|
|
|
|
|
Utils::equal(&RunConfiguration::displayName, project()->displayName()));
|
|
|
|
|
}
|
|
|
|
|
if (!rc)
|
|
|
|
|
rc = newUnconfigured.isEmpty() ? nullptr : newUnconfigured.at(0);
|
|
|
|
|
if (!rc) {
|
|
|
|
|
// No RCs will be deleted, so use the one that will emit the minimum number of signals.
|
|
|
|
|
// One signal will be emitted from the next setActiveRunConfiguration, another one
|
|
|
|
|
// when the RC gets removed (and the activeRunConfiguration turns into a nullptr).
|
|
|
|
|
rc = removalList.isEmpty() ? nullptr : removalList.last();
|
2013-05-15 13:36:11 +02:00
|
|
|
}
|
2016-04-01 16:19:55 +02:00
|
|
|
|
|
|
|
|
if (rc)
|
|
|
|
|
setActiveRunConfiguration(rc);
|
2013-05-15 13:36:11 +02:00
|
|
|
}
|
2013-10-18 17:46:40 +02:00
|
|
|
|
|
|
|
|
// Remove the RCs that are no longer needed:
|
|
|
|
|
foreach (RunConfiguration *rc, removalList)
|
|
|
|
|
removeRunConfiguration(rc);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2013-04-19 16:27:31 +02:00
|
|
|
QVariant Target::namedSettings(const QString &name) const
|
|
|
|
|
{
|
|
|
|
|
return d->m_pluginSettings.value(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::setNamedSettings(const QString &name, const QVariant &value)
|
|
|
|
|
{
|
|
|
|
|
if (value.isNull())
|
|
|
|
|
d->m_pluginSettings.remove(name);
|
|
|
|
|
else
|
|
|
|
|
d->m_pluginSettings.insert(name, value);
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-26 11:15:11 +02:00
|
|
|
static QString formatToolTip(const IDevice::DeviceInfo &input)
|
|
|
|
|
{
|
|
|
|
|
QStringList lines;
|
|
|
|
|
foreach (const IDevice::DeviceInfoItem &item, input)
|
|
|
|
|
lines << QString::fromLatin1("<b>%1:</b> %2").arg(item.key, item.value);
|
|
|
|
|
return lines.join(QLatin1String("<br>"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Target::updateDeviceState()
|
|
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
IDevice::ConstPtr current = DeviceKitInformation::device(kit());
|
2012-03-26 11:15:11 +02:00
|
|
|
|
2016-09-27 17:45:42 +02:00
|
|
|
QIcon overlay;
|
|
|
|
|
static const QIcon disconnected = Icons::DEVICE_DISCONNECTED_INDICATOR.icon();
|
2012-04-27 15:58:59 +02:00
|
|
|
if (current.isNull()) {
|
2016-09-27 17:45:42 +02:00
|
|
|
overlay = disconnected;
|
2012-04-27 15:58:59 +02:00
|
|
|
} else {
|
2012-05-29 13:49:34 +02:00
|
|
|
switch (current->deviceState()) {
|
|
|
|
|
case IDevice::DeviceStateUnknown:
|
2016-09-27 17:45:42 +02:00
|
|
|
overlay = QIcon();
|
2012-04-27 15:58:59 +02:00
|
|
|
setToolTip(QString());
|
|
|
|
|
return;
|
2016-09-27 17:45:42 +02:00
|
|
|
case IDevice::DeviceReadyToUse: {
|
|
|
|
|
static const QIcon ready = Icons::DEVICE_READY_INDICATOR.icon();
|
|
|
|
|
overlay = ready;
|
2012-05-29 13:49:34 +02:00
|
|
|
break;
|
2016-09-27 17:45:42 +02:00
|
|
|
}
|
|
|
|
|
case IDevice::DeviceConnected: {
|
|
|
|
|
static const QIcon connected = Icons::DEVICE_CONNECTED_INDICATOR.icon();
|
|
|
|
|
overlay = connected;
|
2012-04-27 15:58:59 +02:00
|
|
|
break;
|
2016-09-27 17:45:42 +02:00
|
|
|
}
|
2012-05-29 13:49:34 +02:00
|
|
|
case IDevice::DeviceDisconnected:
|
2016-09-27 17:45:42 +02:00
|
|
|
overlay = disconnected;
|
2012-04-27 15:58:59 +02:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-27 17:45:42 +02:00
|
|
|
setOverlayIcon(overlay);
|
2012-04-27 15:58:59 +02:00
|
|
|
setToolTip(current.isNull() ? QString() : formatToolTip(current->deviceInformation()));
|
2012-03-26 11:15:11 +02:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
void Target::setEnabled(bool enabled)
|
|
|
|
|
{
|
2010-09-21 09:17:37 +02:00
|
|
|
if (enabled == d->m_isEnabled)
|
2010-02-08 15:50:06 +01:00
|
|
|
return;
|
|
|
|
|
|
2010-09-21 09:17:37 +02:00
|
|
|
d->m_isEnabled = enabled;
|
|
|
|
|
emit targetEnabled(d->m_isEnabled);
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Target::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
if (!ProjectConfiguration::fromMap(map))
|
|
|
|
|
return false;
|
|
|
|
|
|
2015-11-16 17:08:04 +01:00
|
|
|
QTC_ASSERT(d->m_kit == KitManager::find(id()), return false);
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2013-10-18 11:31:45 +02:00
|
|
|
setDisplayName(d->m_kit->displayName()); // Overwrite displayname read from file
|
|
|
|
|
setDefaultDisplayName(d->m_kit->displayName());
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
bool ok;
|
2011-04-21 15:01:48 +02:00
|
|
|
int bcCount = map.value(QLatin1String(BC_COUNT_KEY), 0).toInt(&ok);
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!ok || bcCount < 0)
|
|
|
|
|
bcCount = 0;
|
2011-04-21 15:01:48 +02:00
|
|
|
int activeConfiguration = map.value(QLatin1String(ACTIVE_BC_KEY), 0).toInt(&ok);
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!ok || activeConfiguration < 0)
|
|
|
|
|
activeConfiguration = 0;
|
|
|
|
|
if (0 > activeConfiguration || bcCount < activeConfiguration)
|
|
|
|
|
activeConfiguration = 0;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < bcCount; ++i) {
|
2011-04-21 15:01:48 +02:00
|
|
|
const QString key = QString::fromLatin1(BC_KEY_PREFIX) + QString::number(i);
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!map.contains(key))
|
|
|
|
|
return false;
|
2012-04-24 15:49:09 +02:00
|
|
|
const QVariantMap valueMap = map.value(key).toMap();
|
|
|
|
|
IBuildConfigurationFactory *factory = IBuildConfigurationFactory::find(this, valueMap);
|
|
|
|
|
if (!factory) {
|
|
|
|
|
qWarning("No factory found to restore build configuration!");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
BuildConfiguration *bc = factory->restore(this, valueMap);
|
|
|
|
|
if (!bc) {
|
|
|
|
|
qWarning("Failed '%s' to restore build configuration!", qPrintable(factory->objectName()));
|
2010-02-08 15:50:06 +01:00
|
|
|
continue;
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
QTC_CHECK(bc->id() == ProjectExplorer::idFromMap(valueMap));
|
2010-02-08 15:50:06 +01:00
|
|
|
addBuildConfiguration(bc);
|
|
|
|
|
if (i == activeConfiguration)
|
|
|
|
|
setActiveBuildConfiguration(bc);
|
|
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
if (buildConfigurations().isEmpty() && IBuildConfigurationFactory::find(this))
|
2010-02-08 15:50:06 +01:00
|
|
|
return false;
|
|
|
|
|
|
2011-04-21 15:01:48 +02:00
|
|
|
int dcCount = map.value(QLatin1String(DC_COUNT_KEY), 0).toInt(&ok);
|
2010-07-16 14:00:41 +02:00
|
|
|
if (!ok || dcCount < 0)
|
|
|
|
|
dcCount = 0;
|
|
|
|
|
activeConfiguration = map.value(QLatin1String(ACTIVE_DC_KEY), 0).toInt(&ok);
|
|
|
|
|
if (!ok || activeConfiguration < 0)
|
|
|
|
|
activeConfiguration = 0;
|
|
|
|
|
if (0 > activeConfiguration || dcCount < activeConfiguration)
|
|
|
|
|
activeConfiguration = 0;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < dcCount; ++i) {
|
2011-04-21 15:01:48 +02:00
|
|
|
const QString key = QString::fromLatin1(DC_KEY_PREFIX) + QString::number(i);
|
2010-07-16 14:00:41 +02:00
|
|
|
if (!map.contains(key))
|
|
|
|
|
return false;
|
2012-04-24 15:49:09 +02:00
|
|
|
QVariantMap valueMap = map.value(key).toMap();
|
|
|
|
|
DeployConfigurationFactory *factory = DeployConfigurationFactory::find(this, valueMap);
|
|
|
|
|
if (!factory) {
|
2012-06-20 15:44:44 +02:00
|
|
|
Core::Id id = idFromMap(valueMap);
|
|
|
|
|
qWarning("No factory found to restore deployment configuration of id '%s'!",
|
2012-11-21 22:40:31 +02:00
|
|
|
id.isValid() ? qPrintable(id.toString()) : "UNKNOWN");
|
2012-04-24 15:49:09 +02:00
|
|
|
continue;
|
2011-03-09 12:07:35 +01:00
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
DeployConfiguration *dc = factory->restore(this, valueMap);
|
|
|
|
|
if (!dc) {
|
|
|
|
|
qWarning("Factory '%s' failed to restore deployment configuration!", qPrintable(factory->objectName()));
|
2010-07-16 14:00:41 +02:00
|
|
|
continue;
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
QTC_CHECK(dc->id() == ProjectExplorer::idFromMap(valueMap));
|
2010-07-16 14:00:41 +02:00
|
|
|
addDeployConfiguration(dc);
|
|
|
|
|
if (i == activeConfiguration)
|
|
|
|
|
setActiveDeployConfiguration(dc);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-21 15:01:48 +02:00
|
|
|
int rcCount = map.value(QLatin1String(RC_COUNT_KEY), 0).toInt(&ok);
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!ok || rcCount < 0)
|
|
|
|
|
rcCount = 0;
|
|
|
|
|
activeConfiguration = map.value(QLatin1String(ACTIVE_RC_KEY), 0).toInt(&ok);
|
|
|
|
|
if (!ok || activeConfiguration < 0)
|
|
|
|
|
activeConfiguration = 0;
|
|
|
|
|
if (0 > activeConfiguration || rcCount < activeConfiguration)
|
|
|
|
|
activeConfiguration = 0;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < rcCount; ++i) {
|
2011-04-21 15:01:48 +02:00
|
|
|
const QString key = QString::fromLatin1(RC_KEY_PREFIX) + QString::number(i);
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!map.contains(key))
|
|
|
|
|
return false;
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
// Ignore missing RCs: We will just populate them using the default ones.
|
2011-04-21 15:01:48 +02:00
|
|
|
QVariantMap valueMap = map.value(key).toMap();
|
2012-04-24 15:49:09 +02:00
|
|
|
IRunConfigurationFactory *factory = IRunConfigurationFactory::find(this, valueMap);
|
2012-06-20 15:44:44 +02:00
|
|
|
if (!factory)
|
2012-04-24 15:49:09 +02:00
|
|
|
continue;
|
2011-04-21 15:01:48 +02:00
|
|
|
RunConfiguration *rc = factory->restore(this, valueMap);
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!rc)
|
|
|
|
|
continue;
|
2012-04-24 15:49:09 +02:00
|
|
|
QTC_CHECK(rc->id() == ProjectExplorer::idFromMap(valueMap));
|
2010-02-08 15:50:06 +01:00
|
|
|
addRunConfiguration(rc);
|
|
|
|
|
if (i == activeConfiguration)
|
|
|
|
|
setActiveRunConfiguration(rc);
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-19 16:27:31 +02:00
|
|
|
if (map.contains(QLatin1String(PLUGIN_SETTINGS_KEY)))
|
|
|
|
|
d->m_pluginSettings = map.value(QLatin1String(PLUGIN_SETTINGS_KEY)).toMap();
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-21 09:17:37 +02:00
|
|
|
} // namespace ProjectExplorer
|