Commit bbb54cde authored by Tobias Hunger's avatar Tobias Hunger

MiniProjectTargetSelector: Use generic reporting of project configuration changes

Change-Id: I55a852db08ee5700acb7530769166b19fb12a670
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 5021a882
......@@ -972,11 +972,11 @@ void MiniProjectTargetSelector::doLayout(bool keepSize)
void MiniProjectTargetSelector::projectAdded(Project *project)
{
connect(project, &Project::addedTarget,
this, &MiniProjectTargetSelector::slotAddedTarget);
connect(project, &Project::addedProjectConfiguration,
this, &MiniProjectTargetSelector::handleNewProjectConfiguration);
connect(project, &Project::removedTarget,
this, &MiniProjectTargetSelector::slotRemovedTarget);
connect(project, &Project::removedProjectConfiguration,
this, &MiniProjectTargetSelector::handleRemovalOfProjectConfiguration);
foreach (Target *t, project->targets())
addedTarget(t);
......@@ -990,11 +990,11 @@ void MiniProjectTargetSelector::projectAdded(Project *project)
void MiniProjectTargetSelector::projectRemoved(Project *project)
{
disconnect(project, &Project::addedTarget,
this, &MiniProjectTargetSelector::slotAddedTarget);
disconnect(project, &Project::addedProjectConfiguration,
this, &MiniProjectTargetSelector::handleNewProjectConfiguration);
disconnect(project, &Project::removedTarget,
this, &MiniProjectTargetSelector::slotRemovedTarget);
disconnect(project, &Project::removedProjectConfiguration,
this, &MiniProjectTargetSelector::handleRemovalOfProjectConfiguration);
foreach (Target *t, project->targets())
removedTarget(t);
......@@ -1006,23 +1006,63 @@ void MiniProjectTargetSelector::projectRemoved(Project *project)
updateRunListVisible();
}
void MiniProjectTargetSelector::addedTarget(Target *target)
void MiniProjectTargetSelector::handleNewProjectConfiguration(ProjectConfiguration *pc)
{
connect(target, &Target::addedBuildConfiguration,
this, &MiniProjectTargetSelector::slotAddedBuildConfiguration);
connect(target, &Target::removedBuildConfiguration,
this, &MiniProjectTargetSelector::slotRemovedBuildConfiguration);
if (auto t = qobject_cast<Target *>(pc)) {
addedTarget(t);
updateTargetListVisible();
updateBuildListVisible();
updateDeployListVisible();
updateRunListVisible();
return;
}
if (auto bc = qobject_cast<BuildConfiguration *>(pc)) {
addedBuildConfiguration(bc);
updateBuildListVisible();
return;
}
if (auto dc = qobject_cast<DeployConfiguration *>(pc)) {
addedDeployConfiguration(dc);
updateDeployListVisible();
return;
}
if (auto rc = qobject_cast<RunConfiguration *>(pc)) {
addedRunConfiguration(rc);
updateRunListVisible();
return;
}
}
connect(target, &Target::addedDeployConfiguration,
this, &MiniProjectTargetSelector::slotAddedDeployConfiguration);
connect(target, &Target::removedDeployConfiguration,
this, &MiniProjectTargetSelector::slotRemovedDeployConfiguration);
void MiniProjectTargetSelector::handleRemovalOfProjectConfiguration(ProjectConfiguration *pc)
{
if (auto t = qobject_cast<Target *>(pc)) {
removedTarget(t);
connect(target, &Target::addedRunConfiguration,
this, &MiniProjectTargetSelector::slotAddedRunConfiguration);
connect(target, &Target::removedRunConfiguration,
this, &MiniProjectTargetSelector::slotRemovedRunConfiguration);
updateTargetListVisible();
updateBuildListVisible();
updateDeployListVisible();
updateRunListVisible();
return;
}
if (auto bc = qobject_cast<BuildConfiguration *>(pc)) {
removedBuildConfiguration(bc);
updateBuildListVisible();
return;
}
if (auto dc = qobject_cast<DeployConfiguration *>(pc)) {
removedDeployConfiguration(dc);
updateDeployListVisible();
return;
}
if (auto rc = qobject_cast<RunConfiguration *>(pc)) {
removedRunConfiguration(rc);
updateRunListVisible();
return;
}
}
void MiniProjectTargetSelector::addedTarget(Target *target)
{
if (target->project() == m_project)
m_listWidgets[TARGET]->addProjectConfiguration(target);
......@@ -1034,32 +1074,8 @@ void MiniProjectTargetSelector::addedTarget(Target *target)
addedRunConfiguration(rc);
}
void MiniProjectTargetSelector::slotAddedTarget(Target *target)
{
addedTarget(target);
updateTargetListVisible();
updateBuildListVisible();
updateDeployListVisible();
updateRunListVisible();
}
void MiniProjectTargetSelector::removedTarget(Target *target)
{
disconnect(target, &Target::addedBuildConfiguration,
this, &MiniProjectTargetSelector::slotAddedBuildConfiguration);
disconnect(target, &Target::removedBuildConfiguration,
this, &MiniProjectTargetSelector::slotRemovedBuildConfiguration);
disconnect(target, &Target::addedDeployConfiguration,
this, &MiniProjectTargetSelector::slotAddedDeployConfiguration);
disconnect(target, &Target::removedDeployConfiguration,
this, &MiniProjectTargetSelector::slotRemovedDeployConfiguration);
disconnect(target, &Target::addedRunConfiguration,
this, &MiniProjectTargetSelector::slotAddedRunConfiguration);
disconnect(target, &Target::removedRunConfiguration,
this, &MiniProjectTargetSelector::slotRemovedRunConfiguration);
if (target->project() == m_project)
m_listWidgets[TARGET]->removeProjectConfiguration(target);
......@@ -1071,95 +1087,41 @@ void MiniProjectTargetSelector::removedTarget(Target *target)
removedRunConfiguration(rc);
}
void MiniProjectTargetSelector::slotRemovedTarget(Target *target)
{
removedTarget(target);
updateTargetListVisible();
updateBuildListVisible();
updateDeployListVisible();
updateRunListVisible();
}
void MiniProjectTargetSelector::addedBuildConfiguration(BuildConfiguration *bc)
{
if (bc->target() == m_target)
m_listWidgets[BUILD]->addProjectConfiguration(bc);
}
void MiniProjectTargetSelector::slotAddedBuildConfiguration(BuildConfiguration *bc)
{
if (bc->target() == m_target)
m_listWidgets[BUILD]->addProjectConfiguration(bc);
updateBuildListVisible();
}
void MiniProjectTargetSelector::removedBuildConfiguration(BuildConfiguration *bc)
{
if (bc->target() == m_target)
m_listWidgets[BUILD]->removeProjectConfiguration(bc);
}
void MiniProjectTargetSelector::slotRemovedBuildConfiguration(BuildConfiguration *bc)
{
if (bc->target() == m_target)
m_listWidgets[BUILD]->removeProjectConfiguration(bc);
updateBuildListVisible();
}
void MiniProjectTargetSelector::addedDeployConfiguration(DeployConfiguration *dc)
{
if (dc->target() == m_target)
m_listWidgets[DEPLOY]->addProjectConfiguration(dc);
}
void MiniProjectTargetSelector::slotAddedDeployConfiguration(DeployConfiguration *dc)
{
if (dc->target() == m_target)
m_listWidgets[DEPLOY]->addProjectConfiguration(dc);
updateDeployListVisible();
}
void MiniProjectTargetSelector::removedDeployConfiguration(DeployConfiguration *dc)
{
if (dc->target() == m_target)
m_listWidgets[DEPLOY]->removeProjectConfiguration(dc);
}
void MiniProjectTargetSelector::slotRemovedDeployConfiguration(DeployConfiguration *dc)
{
if (dc->target() == m_target)
m_listWidgets[DEPLOY]->removeProjectConfiguration(dc);
updateDeployListVisible();
}
void MiniProjectTargetSelector::addedRunConfiguration(RunConfiguration *rc)
{
if (rc->target() == m_target)
m_listWidgets[RUN]->addProjectConfiguration(rc);
}
void MiniProjectTargetSelector::slotAddedRunConfiguration(RunConfiguration *rc)
{
if (rc->target() == m_target)
m_listWidgets[RUN]->addProjectConfiguration(rc);
updateRunListVisible();
}
void MiniProjectTargetSelector::removedRunConfiguration(RunConfiguration *rc)
{
if (rc->target() == m_target)
m_listWidgets[RUN]->removeProjectConfiguration(rc);
}
void MiniProjectTargetSelector::slotRemovedRunConfiguration(RunConfiguration *rc)
{
if (rc->target() == m_target)
m_listWidgets[RUN]->removeProjectConfiguration(rc);
updateRunListVisible();
}
void MiniProjectTargetSelector::updateProjectListVisible()
{
int count = SessionManager::projects().size();
......
......@@ -148,14 +148,8 @@ public:
private:
void projectAdded(ProjectExplorer::Project *project);
void projectRemoved(ProjectExplorer::Project *project);
void slotAddedTarget(ProjectExplorer::Target *target);
void slotRemovedTarget(ProjectExplorer::Target *target);
void slotAddedBuildConfiguration(ProjectExplorer::BuildConfiguration *bc);
void slotRemovedBuildConfiguration(ProjectExplorer::BuildConfiguration *bc);
void slotAddedDeployConfiguration(ProjectExplorer::DeployConfiguration *dc);
void slotRemovedDeployConfiguration(ProjectExplorer::DeployConfiguration *dc);
void slotAddedRunConfiguration(ProjectExplorer::RunConfiguration *rc);
void slotRemovedRunConfiguration(ProjectExplorer::RunConfiguration *rc);
void handleNewProjectConfiguration(ProjectConfiguration *pc);
void handleRemovalOfProjectConfiguration(ProjectConfiguration *pc);
void changeStartupProject(ProjectExplorer::Project *project);
void activeTargetChanged(ProjectExplorer::Target *target);
......
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