Commit f1d735b7 authored by Tobias Hunger's avatar Tobias Hunger

Target/Project: Add generic signals for changes in the project configuration tree

Change-Id: Iae0589620a8caf8e3748589b12329608ef3a39da
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent d7aa0956
......@@ -251,6 +251,11 @@ void Project::addTarget(Target *t)
connect(t, &Target::buildConfigurationEnabledChanged,
this, &Project::changeBuildConfigurationEnabled);
connect(t, &Target::buildDirectoryChanged, this, &Project::onBuildDirectoryChanged);
connect(t, &Target::addedProjectConfiguration, this, &Project::addedProjectConfiguration);
connect(t, &Target::aboutToRemoveProjectConfiguration, this, &Project::aboutToRemoveProjectConfiguration);
connect(t, &Target::removedProjectConfiguration, this, &Project::removedProjectConfiguration);
connect(t, &Target::activeProjectConfigurationChanged, this, &Project::activeProjectConfigurationChanged);
emit addedProjectConfiguration(t);
emit addedTarget(t);
// check activeTarget:
......@@ -274,9 +279,11 @@ bool Project::removeTarget(Target *target)
SessionManager::setActiveTarget(this, d->m_targets.at(0), SetActive::Cascade);
}
emit aboutToRemoveProjectConfiguration(target);
emit aboutToRemoveTarget(target);
d->m_targets.removeOne(target);
emit removedTarget(target);
emit removedProjectConfiguration(target);
delete target;
return true;
......@@ -297,6 +304,7 @@ void Project::setActiveTarget(Target *target)
if ((!target && !d->m_targets.isEmpty()) ||
(target && d->m_targets.contains(target) && d->m_activeTarget != target)) {
d->m_activeTarget = target;
emit activeProjectConfigurationChanged();
emit activeTargetChanged(d->m_activeTarget);
emit environmentChanged();
emit buildConfigurationEnabledChanged();
......
......@@ -49,6 +49,7 @@ class ContainerNode;
class EditorConfiguration;
class NamedWidget;
class Node;
class ProjectConfiguration;
class ProjectImporter;
class ProjectNode;
class ProjectPrivate;
......@@ -174,6 +175,15 @@ signals:
// Note: activeTarget can be 0 (if no targets are defined).
void activeTargetChanged(ProjectExplorer::Target *target);
void aboutToRemoveProjectConfiguration(ProjectExplorer::ProjectConfiguration *pc);
void removedProjectConfiguration(ProjectExplorer::ProjectConfiguration *pc);
void addedProjectConfiguration(ProjectExplorer::ProjectConfiguration *pc);
// *ANY* active project configuration changed somewhere in the tree. This might not be
// the one that would get started right now, since some part of the tree in between might
// not be active.
void activeProjectConfigurationChanged();
void aboutToRemoveTarget(ProjectExplorer::Target *target);
void removedTarget(ProjectExplorer::Target *target);
void addedTarget(ProjectExplorer::Target *target);
......
......@@ -238,6 +238,7 @@ void Target::addBuildConfiguration(BuildConfiguration *bc)
// add it
d->m_buildConfigurations.push_back(bc);
emit addedProjectConfiguration(bc);
emit addedBuildConfiguration(bc);
connect(bc, &BuildConfiguration::environmentChanged,
......@@ -261,8 +262,9 @@ bool Target::removeBuildConfiguration(BuildConfiguration *bc)
return false;
d->m_buildConfigurations.removeOne(bc);
emit aboutToRemoveProjectConfiguration(bc);
d->m_buildConfigurations.removeOne(bc);
emit removedBuildConfiguration(bc);
if (activeBuildConfiguration() == bc) {
if (d->m_buildConfigurations.isEmpty())
......@@ -271,6 +273,9 @@ bool Target::removeBuildConfiguration(BuildConfiguration *bc)
SessionManager::setActiveBuildConfiguration(this, d->m_buildConfigurations.at(0), SetActive::Cascade);
}
emit removedBuildConfiguration(bc);
emit removedProjectConfiguration(bc);
delete bc;
return true;
}
......@@ -285,12 +290,13 @@ BuildConfiguration *Target::activeBuildConfiguration() const
return d->m_activeBuildConfiguration;
}
void Target::setActiveBuildConfiguration(BuildConfiguration *configuration)
void Target::setActiveBuildConfiguration(BuildConfiguration *bc)
{
if ((!configuration && d->m_buildConfigurations.isEmpty()) ||
(configuration && d->m_buildConfigurations.contains(configuration) &&
configuration != d->m_activeBuildConfiguration)) {
d->m_activeBuildConfiguration = configuration;
if ((!bc && d->m_buildConfigurations.isEmpty()) ||
(bc && d->m_buildConfigurations.contains(bc) &&
bc != d->m_activeBuildConfiguration)) {
d->m_activeBuildConfiguration = bc;
emit activeProjectConfigurationChanged();
emit activeBuildConfigurationChanged(d->m_activeBuildConfiguration);
emit environmentChanged();
emit buildConfigurationEnabledChanged();
......@@ -318,6 +324,7 @@ void Target::addDeployConfiguration(DeployConfiguration *dc)
connect(dc, &DeployConfiguration::enabledChanged,
this, &Target::changeDeployConfigurationEnabled);
emit addedProjectConfiguration(dc);
emit addedDeployConfiguration(dc);
if (!d->m_activeDeployConfiguration)
......@@ -334,10 +341,9 @@ bool Target::removeDeployConfiguration(DeployConfiguration *dc)
if (BuildManager::isBuilding(dc))
return false;
emit aboutToRemoveProjectConfiguration(dc);
d->m_deployConfigurations.removeOne(dc);
emit removedDeployConfiguration(dc);
if (activeDeployConfiguration() == dc) {
if (d->m_deployConfigurations.isEmpty())
SessionManager::setActiveDeployConfiguration(this, nullptr, SetActive::Cascade);
......@@ -346,6 +352,9 @@ bool Target::removeDeployConfiguration(DeployConfiguration *dc)
SetActive::Cascade);
}
emit removedProjectConfiguration(dc);
emit removedDeployConfiguration(dc);
delete dc;
return true;
}
......@@ -366,6 +375,7 @@ void Target::setActiveDeployConfiguration(DeployConfiguration *dc)
(dc && d->m_deployConfigurations.contains(dc) &&
dc != d->m_activeDeployConfiguration)) {
d->m_activeDeployConfiguration = dc;
emit activeProjectConfigurationChanged();
emit activeDeployConfigurationChanged(d->m_activeDeployConfiguration);
emit deployConfigurationEnabledChanged();
}
......@@ -419,6 +429,7 @@ void Target::addRunConfiguration(RunConfiguration *rc)
connect(rc, &RunConfiguration::enabledChanged,
this, &Target::changeRunConfigurationEnabled);
emit addedProjectConfiguration(rc);
emit addedRunConfiguration(rc);
if (!activeRunConfiguration())
......@@ -429,6 +440,7 @@ void Target::removeRunConfiguration(RunConfiguration *rc)
{
QTC_ASSERT(rc && d->m_runConfigurations.contains(rc), return);
emit aboutToRemoveProjectConfiguration(rc);
d->m_runConfigurations.removeOne(rc);
if (activeRunConfiguration() == rc) {
......@@ -439,6 +451,8 @@ void Target::removeRunConfiguration(RunConfiguration *rc)
}
emit removedRunConfiguration(rc);
emit removedProjectConfiguration(rc);
delete rc;
}
......@@ -453,6 +467,7 @@ void Target::setActiveRunConfiguration(RunConfiguration *rc)
(rc && d->m_runConfigurations.contains(rc) &&
rc != d->m_activeRunConfiguration)) {
d->m_activeRunConfiguration = rc;
emit activeProjectConfigurationChanged();
emit activeRunConfigurationChanged(d->m_activeRunConfiguration);
emit runConfigurationEnabledChanged();
}
......
......@@ -61,8 +61,8 @@ public:
Kit *kit() const;
// Build configuration
void addBuildConfiguration(BuildConfiguration *configuration);
bool removeBuildConfiguration(BuildConfiguration *configuration);
void addBuildConfiguration(BuildConfiguration *bc);
bool removeBuildConfiguration(BuildConfiguration *bc);
QList<BuildConfiguration *> buildConfigurations() const;
BuildConfiguration *activeBuildConfiguration() const;
......@@ -82,11 +82,11 @@ public:
// Running
QList<RunConfiguration *> runConfigurations() const;
void addRunConfiguration(RunConfiguration *runConfiguration);
void removeRunConfiguration(RunConfiguration *runConfiguration);
void addRunConfiguration(RunConfiguration *rc);
void removeRunConfiguration(RunConfiguration *rc);
RunConfiguration *activeRunConfiguration() const;
void setActiveRunConfiguration(RunConfiguration *runConfiguration);
void setActiveRunConfiguration(RunConfiguration *rc);
// Returns whether this target is actually available at he time
// of the call. A target may become unavailable e.g. when a Qt version
......@@ -115,6 +115,12 @@ signals:
void kitChanged();
void aboutToRemoveProjectConfiguration(ProjectExplorer::ProjectConfiguration *pc);
void removedProjectConfiguration(ProjectExplorer::ProjectConfiguration *pc);
void addedProjectConfiguration(ProjectExplorer::ProjectConfiguration *pc);
void activeProjectConfigurationChanged();
// TODO clean up signal names
// might be better to also have aboutToRemove signals
void removedRunConfiguration(ProjectExplorer::RunConfiguration *rc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment