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) ...@@ -251,6 +251,11 @@ void Project::addTarget(Target *t)
connect(t, &Target::buildConfigurationEnabledChanged, connect(t, &Target::buildConfigurationEnabledChanged,
this, &Project::changeBuildConfigurationEnabled); this, &Project::changeBuildConfigurationEnabled);
connect(t, &Target::buildDirectoryChanged, this, &Project::onBuildDirectoryChanged); 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); emit addedTarget(t);
// check activeTarget: // check activeTarget:
...@@ -274,9 +279,11 @@ bool Project::removeTarget(Target *target) ...@@ -274,9 +279,11 @@ bool Project::removeTarget(Target *target)
SessionManager::setActiveTarget(this, d->m_targets.at(0), SetActive::Cascade); SessionManager::setActiveTarget(this, d->m_targets.at(0), SetActive::Cascade);
} }
emit aboutToRemoveProjectConfiguration(target);
emit aboutToRemoveTarget(target); emit aboutToRemoveTarget(target);
d->m_targets.removeOne(target); d->m_targets.removeOne(target);
emit removedTarget(target); emit removedTarget(target);
emit removedProjectConfiguration(target);
delete target; delete target;
return true; return true;
...@@ -297,6 +304,7 @@ void Project::setActiveTarget(Target *target) ...@@ -297,6 +304,7 @@ void Project::setActiveTarget(Target *target)
if ((!target && !d->m_targets.isEmpty()) || if ((!target && !d->m_targets.isEmpty()) ||
(target && d->m_targets.contains(target) && d->m_activeTarget != target)) { (target && d->m_targets.contains(target) && d->m_activeTarget != target)) {
d->m_activeTarget = target; d->m_activeTarget = target;
emit activeProjectConfigurationChanged();
emit activeTargetChanged(d->m_activeTarget); emit activeTargetChanged(d->m_activeTarget);
emit environmentChanged(); emit environmentChanged();
emit buildConfigurationEnabledChanged(); emit buildConfigurationEnabledChanged();
......
...@@ -49,6 +49,7 @@ class ContainerNode; ...@@ -49,6 +49,7 @@ class ContainerNode;
class EditorConfiguration; class EditorConfiguration;
class NamedWidget; class NamedWidget;
class Node; class Node;
class ProjectConfiguration;
class ProjectImporter; class ProjectImporter;
class ProjectNode; class ProjectNode;
class ProjectPrivate; class ProjectPrivate;
...@@ -174,6 +175,15 @@ signals: ...@@ -174,6 +175,15 @@ signals:
// Note: activeTarget can be 0 (if no targets are defined). // Note: activeTarget can be 0 (if no targets are defined).
void activeTargetChanged(ProjectExplorer::Target *target); 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 aboutToRemoveTarget(ProjectExplorer::Target *target);
void removedTarget(ProjectExplorer::Target *target); void removedTarget(ProjectExplorer::Target *target);
void addedTarget(ProjectExplorer::Target *target); void addedTarget(ProjectExplorer::Target *target);
......
...@@ -238,6 +238,7 @@ void Target::addBuildConfiguration(BuildConfiguration *bc) ...@@ -238,6 +238,7 @@ void Target::addBuildConfiguration(BuildConfiguration *bc)
// add it // add it
d->m_buildConfigurations.push_back(bc); d->m_buildConfigurations.push_back(bc);
emit addedProjectConfiguration(bc);
emit addedBuildConfiguration(bc); emit addedBuildConfiguration(bc);
connect(bc, &BuildConfiguration::environmentChanged, connect(bc, &BuildConfiguration::environmentChanged,
...@@ -261,8 +262,9 @@ bool Target::removeBuildConfiguration(BuildConfiguration *bc) ...@@ -261,8 +262,9 @@ bool Target::removeBuildConfiguration(BuildConfiguration *bc)
return false; return false;
d->m_buildConfigurations.removeOne(bc); d->m_buildConfigurations.removeOne(bc);
emit aboutToRemoveProjectConfiguration(bc);
d->m_buildConfigurations.removeOne(bc);
emit removedBuildConfiguration(bc);
if (activeBuildConfiguration() == bc) { if (activeBuildConfiguration() == bc) {
if (d->m_buildConfigurations.isEmpty()) if (d->m_buildConfigurations.isEmpty())
...@@ -271,6 +273,9 @@ bool Target::removeBuildConfiguration(BuildConfiguration *bc) ...@@ -271,6 +273,9 @@ bool Target::removeBuildConfiguration(BuildConfiguration *bc)
SessionManager::setActiveBuildConfiguration(this, d->m_buildConfigurations.at(0), SetActive::Cascade); SessionManager::setActiveBuildConfiguration(this, d->m_buildConfigurations.at(0), SetActive::Cascade);
} }
emit removedBuildConfiguration(bc);
emit removedProjectConfiguration(bc);
delete bc; delete bc;
return true; return true;
} }
...@@ -285,12 +290,13 @@ BuildConfiguration *Target::activeBuildConfiguration() const ...@@ -285,12 +290,13 @@ BuildConfiguration *Target::activeBuildConfiguration() const
return d->m_activeBuildConfiguration; return d->m_activeBuildConfiguration;
} }
void Target::setActiveBuildConfiguration(BuildConfiguration *configuration) void Target::setActiveBuildConfiguration(BuildConfiguration *bc)
{ {
if ((!configuration && d->m_buildConfigurations.isEmpty()) || if ((!bc && d->m_buildConfigurations.isEmpty()) ||
(configuration && d->m_buildConfigurations.contains(configuration) && (bc && d->m_buildConfigurations.contains(bc) &&
configuration != d->m_activeBuildConfiguration)) { bc != d->m_activeBuildConfiguration)) {
d->m_activeBuildConfiguration = configuration; d->m_activeBuildConfiguration = bc;
emit activeProjectConfigurationChanged();
emit activeBuildConfigurationChanged(d->m_activeBuildConfiguration); emit activeBuildConfigurationChanged(d->m_activeBuildConfiguration);
emit environmentChanged(); emit environmentChanged();
emit buildConfigurationEnabledChanged(); emit buildConfigurationEnabledChanged();
...@@ -318,6 +324,7 @@ void Target::addDeployConfiguration(DeployConfiguration *dc) ...@@ -318,6 +324,7 @@ void Target::addDeployConfiguration(DeployConfiguration *dc)
connect(dc, &DeployConfiguration::enabledChanged, connect(dc, &DeployConfiguration::enabledChanged,
this, &Target::changeDeployConfigurationEnabled); this, &Target::changeDeployConfigurationEnabled);
emit addedProjectConfiguration(dc);
emit addedDeployConfiguration(dc); emit addedDeployConfiguration(dc);
if (!d->m_activeDeployConfiguration) if (!d->m_activeDeployConfiguration)
...@@ -334,10 +341,9 @@ bool Target::removeDeployConfiguration(DeployConfiguration *dc) ...@@ -334,10 +341,9 @@ bool Target::removeDeployConfiguration(DeployConfiguration *dc)
if (BuildManager::isBuilding(dc)) if (BuildManager::isBuilding(dc))
return false; return false;
emit aboutToRemoveProjectConfiguration(dc);
d->m_deployConfigurations.removeOne(dc); d->m_deployConfigurations.removeOne(dc);
emit removedDeployConfiguration(dc);
if (activeDeployConfiguration() == dc) { if (activeDeployConfiguration() == dc) {
if (d->m_deployConfigurations.isEmpty()) if (d->m_deployConfigurations.isEmpty())
SessionManager::setActiveDeployConfiguration(this, nullptr, SetActive::Cascade); SessionManager::setActiveDeployConfiguration(this, nullptr, SetActive::Cascade);
...@@ -346,6 +352,9 @@ bool Target::removeDeployConfiguration(DeployConfiguration *dc) ...@@ -346,6 +352,9 @@ bool Target::removeDeployConfiguration(DeployConfiguration *dc)
SetActive::Cascade); SetActive::Cascade);
} }
emit removedProjectConfiguration(dc);
emit removedDeployConfiguration(dc);
delete dc; delete dc;
return true; return true;
} }
...@@ -366,6 +375,7 @@ void Target::setActiveDeployConfiguration(DeployConfiguration *dc) ...@@ -366,6 +375,7 @@ void Target::setActiveDeployConfiguration(DeployConfiguration *dc)
(dc && d->m_deployConfigurations.contains(dc) && (dc && d->m_deployConfigurations.contains(dc) &&
dc != d->m_activeDeployConfiguration)) { dc != d->m_activeDeployConfiguration)) {
d->m_activeDeployConfiguration = dc; d->m_activeDeployConfiguration = dc;
emit activeProjectConfigurationChanged();
emit activeDeployConfigurationChanged(d->m_activeDeployConfiguration); emit activeDeployConfigurationChanged(d->m_activeDeployConfiguration);
emit deployConfigurationEnabledChanged(); emit deployConfigurationEnabledChanged();
} }
...@@ -419,6 +429,7 @@ void Target::addRunConfiguration(RunConfiguration *rc) ...@@ -419,6 +429,7 @@ void Target::addRunConfiguration(RunConfiguration *rc)
connect(rc, &RunConfiguration::enabledChanged, connect(rc, &RunConfiguration::enabledChanged,
this, &Target::changeRunConfigurationEnabled); this, &Target::changeRunConfigurationEnabled);
emit addedProjectConfiguration(rc);
emit addedRunConfiguration(rc); emit addedRunConfiguration(rc);
if (!activeRunConfiguration()) if (!activeRunConfiguration())
...@@ -429,6 +440,7 @@ void Target::removeRunConfiguration(RunConfiguration *rc) ...@@ -429,6 +440,7 @@ void Target::removeRunConfiguration(RunConfiguration *rc)
{ {
QTC_ASSERT(rc && d->m_runConfigurations.contains(rc), return); QTC_ASSERT(rc && d->m_runConfigurations.contains(rc), return);
emit aboutToRemoveProjectConfiguration(rc);
d->m_runConfigurations.removeOne(rc); d->m_runConfigurations.removeOne(rc);
if (activeRunConfiguration() == rc) { if (activeRunConfiguration() == rc) {
...@@ -439,6 +451,8 @@ void Target::removeRunConfiguration(RunConfiguration *rc) ...@@ -439,6 +451,8 @@ void Target::removeRunConfiguration(RunConfiguration *rc)
} }
emit removedRunConfiguration(rc); emit removedRunConfiguration(rc);
emit removedProjectConfiguration(rc);
delete rc; delete rc;
} }
...@@ -453,6 +467,7 @@ void Target::setActiveRunConfiguration(RunConfiguration *rc) ...@@ -453,6 +467,7 @@ void Target::setActiveRunConfiguration(RunConfiguration *rc)
(rc && d->m_runConfigurations.contains(rc) && (rc && d->m_runConfigurations.contains(rc) &&
rc != d->m_activeRunConfiguration)) { rc != d->m_activeRunConfiguration)) {
d->m_activeRunConfiguration = rc; d->m_activeRunConfiguration = rc;
emit activeProjectConfigurationChanged();
emit activeRunConfigurationChanged(d->m_activeRunConfiguration); emit activeRunConfigurationChanged(d->m_activeRunConfiguration);
emit runConfigurationEnabledChanged(); emit runConfigurationEnabledChanged();
} }
......
...@@ -61,8 +61,8 @@ public: ...@@ -61,8 +61,8 @@ public:
Kit *kit() const; Kit *kit() const;
// Build configuration // Build configuration
void addBuildConfiguration(BuildConfiguration *configuration); void addBuildConfiguration(BuildConfiguration *bc);
bool removeBuildConfiguration(BuildConfiguration *configuration); bool removeBuildConfiguration(BuildConfiguration *bc);
QList<BuildConfiguration *> buildConfigurations() const; QList<BuildConfiguration *> buildConfigurations() const;
BuildConfiguration *activeBuildConfiguration() const; BuildConfiguration *activeBuildConfiguration() const;
...@@ -82,11 +82,11 @@ public: ...@@ -82,11 +82,11 @@ public:
// Running // Running
QList<RunConfiguration *> runConfigurations() const; QList<RunConfiguration *> runConfigurations() const;
void addRunConfiguration(RunConfiguration *runConfiguration); void addRunConfiguration(RunConfiguration *rc);
void removeRunConfiguration(RunConfiguration *runConfiguration); void removeRunConfiguration(RunConfiguration *rc);
RunConfiguration *activeRunConfiguration() const; RunConfiguration *activeRunConfiguration() const;
void setActiveRunConfiguration(RunConfiguration *runConfiguration); void setActiveRunConfiguration(RunConfiguration *rc);
// Returns whether this target is actually available at he time // Returns whether this target is actually available at he time
// of the call. A target may become unavailable e.g. when a Qt version // of the call. A target may become unavailable e.g. when a Qt version
...@@ -115,6 +115,12 @@ signals: ...@@ -115,6 +115,12 @@ signals:
void kitChanged(); void kitChanged();
void aboutToRemoveProjectConfiguration(ProjectExplorer::ProjectConfiguration *pc);
void removedProjectConfiguration(ProjectExplorer::ProjectConfiguration *pc);
void addedProjectConfiguration(ProjectExplorer::ProjectConfiguration *pc);
void activeProjectConfigurationChanged();
// TODO clean up signal names // TODO clean up signal names
// might be better to also have aboutToRemove signals // might be better to also have aboutToRemove signals
void removedRunConfiguration(ProjectExplorer::RunConfiguration *rc); 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