From dceda9db70ba01381891b6b8add46d94a7075c89 Mon Sep 17 00:00:00 2001
From: Tobias Hunger <tobias.hunger@nokia.com>
Date: Thu, 11 Mar 2010 13:42:41 +0100
Subject: [PATCH] Refresh ProjectMode when supported targets change

Reviewed-by: con
---
 src/plugins/projectexplorer/projectwindow.cpp | 25 ++++++++++++++++---
 src/plugins/projectexplorer/projectwindow.h   |  6 +++--
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/src/plugins/projectexplorer/projectwindow.cpp b/src/plugins/projectexplorer/projectwindow.cpp
index e5f2bfe47bc..a8e87ee682e 100644
--- a/src/plugins/projectexplorer/projectwindow.cpp
+++ b/src/plugins/projectexplorer/projectwindow.cpp
@@ -277,9 +277,9 @@ ProjectWindow::ProjectWindow(QWidget *parent)
     connect(session, SIGNAL(aboutToSaveSession()), this, SLOT(saveStatus()));
 
     connect(session, SIGNAL(projectAdded(ProjectExplorer::Project*)),
-            this, SLOT(projectAdded(ProjectExplorer::Project*)));
+            this, SLOT(registerProject(ProjectExplorer::Project*)));
     connect(session, SIGNAL(aboutToRemoveProject(ProjectExplorer::Project*)),
-            this, SLOT(aboutToRemoveProject(ProjectExplorer::Project*)));
+            this, SLOT(deregisterProject(ProjectExplorer::Project*)));
 
     // Update properties to empty project for now:
     showProperties(-1, -1);
@@ -296,7 +296,7 @@ void ProjectWindow::shutdown()
     disconnect(ProjectExplorerPlugin::instance()->session(), 0, this, 0);
 }
 
-void ProjectWindow::projectAdded(ProjectExplorer::Project *project)
+void ProjectWindow::registerProject(ProjectExplorer::Project *project)
 {
     if (!project || m_tabIndexToProject.contains(project))
         return;
@@ -320,13 +320,20 @@ void ProjectWindow::projectAdded(ProjectExplorer::Project *project)
 
     m_tabIndexToProject.insert(index, project);
     m_tabWidget->insertTab(index, project->displayName(), subtabs);
+
+    connect(project, SIGNAL(supportedTargetIdsChanged()),
+            this, SLOT(refreshProject()));
 }
 
-void ProjectWindow::aboutToRemoveProject(ProjectExplorer::Project *project)
+void ProjectWindow::deregisterProject(ProjectExplorer::Project *project)
 {
     int index = m_tabIndexToProject.indexOf(project);
     if (index < 0)
         return;
+
+    disconnect(project, SIGNAL(supportedTargetIdsChanged()),
+               this, SLOT(refreshProject()));
+
     m_tabIndexToProject.removeAt(index);
     m_tabWidget->removeTab(index);
 }
@@ -341,6 +348,16 @@ void ProjectWindow::saveStatus()
     // TODO
 }
 
+void ProjectWindow::refreshProject()
+{
+    Project *project = qobject_cast<ProjectExplorer::Project *>(sender());
+    if (!m_tabIndexToProject.contains(project))
+        return;
+
+    deregisterProject(project);
+    registerProject(project);
+}
+
 void ProjectWindow::showProperties(int index, int subIndex)
 {
     if (index < 0 || index >= m_tabIndexToProject.count())
diff --git a/src/plugins/projectexplorer/projectwindow.h b/src/plugins/projectexplorer/projectwindow.h
index fb4fe10a742..8edcb66d59a 100644
--- a/src/plugins/projectexplorer/projectwindow.h
+++ b/src/plugins/projectexplorer/projectwindow.h
@@ -90,8 +90,10 @@ private slots:
     void showProperties(int index, int subIndex);
     void restoreStatus();
     void saveStatus();
-    void projectAdded(ProjectExplorer::Project*);
-    void aboutToRemoveProject(ProjectExplorer::Project*);
+    void registerProject(ProjectExplorer::Project*);
+    void deregisterProject(ProjectExplorer::Project*);
+
+    void refreshProject();
 
 private:
     void removeCurrentWidget();
-- 
GitLab