From 1e46cb424e05a8be9909b13b2031625b691839ec Mon Sep 17 00:00:00 2001
From: dt <qtc-committer@nokia.com>
Date: Thu, 3 Dec 2009 18:37:27 +0100
Subject: [PATCH] Rework connections on the project pane for Qt4Projects.

Should fix a lot of corner cases, might introduce a few bugs.
Also rename functions/slots to be better named.

Generic Project Manager and CMake Project Manager are missing from this
patch.
---
 .../projectexplorer/buildconfiguration.h      |   3 +-
 .../customexecutablerunconfiguration.cpp      |  55 ++++---
 .../customexecutablerunconfiguration.h        |  15 +-
 .../projectexplorer/environmenteditmodel.cpp  |  28 ++--
 .../projectexplorer/environmenteditmodel.h    |   4 +-
 src/plugins/qt4projectmanager/makestep.cpp    |   8 +-
 src/plugins/qt4projectmanager/makestep.h      |   9 +-
 src/plugins/qt4projectmanager/qmakestep.cpp   | 136 ++++++++++--------
 src/plugins/qt4projectmanager/qmakestep.h     |  14 +-
 .../qt-maemo/maemorunconfiguration.cpp        |  19 ++-
 .../qt-maemo/maemorunconfiguration.h          |   2 +
 .../qt-s60/s60devicerunconfiguration.cpp      |  13 +-
 .../qt-s60/s60devicerunconfiguration.h        |   2 +
 .../qt-s60/s60emulatorrunconfiguration.cpp    |  13 +-
 .../qt-s60/s60emulatorrunconfiguration.h      |   2 +
 .../qt4buildconfiguration.cpp                 | 104 ++++++++++----
 .../qt4projectmanager/qt4buildconfiguration.h |  24 +++-
 .../qt4buildenvironmentwidget.cpp             |   2 +-
 src/plugins/qt4projectmanager/qt4nodes.cpp    |   2 -
 src/plugins/qt4projectmanager/qt4project.cpp  | 106 +++++++-------
 src/plugins/qt4projectmanager/qt4project.h    |  23 ++-
 .../qt4projectconfigwidget.cpp                | 130 ++++++++++-------
 .../qt4projectconfigwidget.h                  |  22 +--
 .../qt4projectmanager/qt4runconfiguration.cpp |  50 +++----
 .../qt4projectmanager/qt4runconfiguration.h   |  17 +--
 .../qt4projectmanager/qtversionmanager.cpp    |  93 +++++++++---
 .../qt4projectmanager/qtversionmanager.h      |   4 +-
 27 files changed, 559 insertions(+), 341 deletions(-)

diff --git a/src/plugins/projectexplorer/buildconfiguration.h b/src/plugins/projectexplorer/buildconfiguration.h
index 49a4215493a..79d7cc65223 100644
--- a/src/plugins/projectexplorer/buildconfiguration.h
+++ b/src/plugins/projectexplorer/buildconfiguration.h
@@ -85,13 +85,12 @@ signals:
     void displayNameChanged();
 
 protected:
-    BuildConfiguration(Project * project);
+    BuildConfiguration(Project *project);
     BuildConfiguration(BuildConfiguration *source);
 
 private:
     QList<BuildStep *> m_buildSteps;
     QList<BuildStep *> m_cleanSteps;
-
     QHash<QString, QVariant> m_values;
     Project *m_project;
 };
diff --git a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp
index d48750f6e6e..06bd46658e3 100644
--- a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp
+++ b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp
@@ -124,7 +124,7 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
                                         << tr("Build Environment"));
     m_baseEnvironmentComboBox->setCurrentIndex(rc->baseEnvironmentBase());
     connect(m_baseEnvironmentComboBox, SIGNAL(currentIndexChanged(int)),
-            this, SLOT(baseEnvironmentComboBoxChanged(int)));
+            this, SLOT(baseEnvironmentSelected(int)));
     baseEnvironmentLayout->addWidget(m_baseEnvironmentComboBox);
     baseEnvironmentLayout->addStretch(10);
 
@@ -136,20 +136,20 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
     changed();
 
     connect(m_userName, SIGNAL(textEdited(QString)),
-            this, SLOT(setUserName(QString)));
+            this, SLOT(userNameEdited(QString)));
     connect(m_executableChooser, SIGNAL(changed(QString)),
-            this, SLOT(setExecutable()));
+            this, SLOT(executableEdited()));
     connect(m_commandLineArgumentsLineEdit, SIGNAL(textEdited(const QString&)),
-            this, SLOT(setCommandLineArguments(const QString&)));
+            this, SLOT(argumentsEdited(const QString&)));
     connect(m_workingDirectory, SIGNAL(changed(QString)),
-            this, SLOT(setWorkingDirectory()));
+            this, SLOT(workingDirectoryEdited()));
     connect(m_useTerminalCheck, SIGNAL(toggled(bool)),
             this, SLOT(termToggled(bool)));
 
     connect(m_runConfiguration, SIGNAL(changed()), this, SLOT(changed()));
 
-    connect(m_environmentWidget, SIGNAL(userChangesUpdated()),
-            this, SLOT(userChangesUpdated()));
+    connect(m_environmentWidget, SIGNAL(userChangesChanged()),
+            this, SLOT(userChangesChanged()));
 
     connect(m_runConfiguration, SIGNAL(baseEnvironmentChanged()),
             this, SLOT(baseEnvironmentChanged()));
@@ -157,12 +157,12 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
             this, SLOT(userEnvironmentChangesChanged()));
 }
 
-void CustomExecutableConfigurationWidget::userChangesUpdated()
+void CustomExecutableConfigurationWidget::userChangesChanged()
 {
     m_runConfiguration->setUserEnvironmentChanges(m_environmentWidget->userChanges());
 }
 
-void CustomExecutableConfigurationWidget::baseEnvironmentComboBoxChanged(int index)
+void CustomExecutableConfigurationWidget::baseEnvironmentSelected(int index)
 {
     m_ignoreChange = true;
     m_runConfiguration->setBaseEnvironmentBase(CustomExecutableRunConfiguration::BaseEnvironmentBase(index));
@@ -176,7 +176,9 @@ void CustomExecutableConfigurationWidget::baseEnvironmentChanged()
     if (m_ignoreChange)
         return;
 
-    m_baseEnvironmentComboBox->setCurrentIndex(CustomExecutableRunConfiguration::BaseEnvironmentBase(m_runConfiguration->baseEnvironmentBase()));
+    int index = CustomExecutableRunConfiguration::BaseEnvironmentBase(
+            m_runConfiguration->baseEnvironmentBase());
+    m_baseEnvironmentComboBox->setCurrentIndex(index);
     m_environmentWidget->setBaseEnvironment(m_runConfiguration->baseEnvironment());
 }
 
@@ -186,26 +188,26 @@ void CustomExecutableConfigurationWidget::userEnvironmentChangesChanged()
 }
 
 
-void CustomExecutableConfigurationWidget::setExecutable()
+void CustomExecutableConfigurationWidget::executableEdited()
 {
     m_ignoreChange = true;
     m_runConfiguration->setExecutable(m_executableChooser->path());
     m_ignoreChange = false;
 }
-void CustomExecutableConfigurationWidget::setCommandLineArguments(const QString &commandLineArguments)
+void CustomExecutableConfigurationWidget::argumentsEdited(const QString &arguments)
 {
     m_ignoreChange = true;
-    m_runConfiguration->setCommandLineArguments(commandLineArguments);
+    m_runConfiguration->setCommandLineArguments(arguments);
     m_ignoreChange = false;
 }
-void CustomExecutableConfigurationWidget::setWorkingDirectory()
+void CustomExecutableConfigurationWidget::workingDirectoryEdited()
 {
     m_ignoreChange = true;
     m_runConfiguration->setWorkingDirectory(m_workingDirectory->path());
     m_ignoreChange = false;
 }
 
-void CustomExecutableConfigurationWidget::setUserName(const QString &name)
+void CustomExecutableConfigurationWidget::userNameEdited(const QString &name)
 {
     m_ignoreChange = true;
     m_runConfiguration->setUserName(name);
@@ -250,18 +252,33 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Project *pro)
     setName(tr("Custom Executable"));
 
     connect(pro, SIGNAL(activeBuildConfigurationChanged()),
-            this, SIGNAL(baseEnvironmentChanged()));
+            this, SLOT(activeBuildConfigurationChanged()));
 
-// TODO
-//    connect(pro, SIGNAL(environmentChanged(ProjectExplorer::BuildConfiguration *)),
-//            this, SIGNAL(baseEnvironmentChanged()));
+    m_lastActiveBuildConfiguration = pro->activeBuildConfiguration();
 
+    if (m_lastActiveBuildConfiguration) {
+        connect(m_lastActiveBuildConfiguration, SIGNAL(environmentChanged()),
+                this, SIGNAL(baseEnvironmentChanged()));
+    }
 }
 
 CustomExecutableRunConfiguration::~CustomExecutableRunConfiguration()
 {
 }
 
+void CustomExecutableRunConfiguration::activeBuildConfigurationChanged()
+{
+    if (m_lastActiveBuildConfiguration) {
+        disconnect(m_lastActiveBuildConfiguration, SIGNAL(environmentChanged()),
+                   this, SIGNAL(baseEnvironmentChanged()));
+    }
+    m_lastActiveBuildConfiguration = project()->activeBuildConfiguration();
+    if (m_lastActiveBuildConfiguration) {
+        connect(m_lastActiveBuildConfiguration, SIGNAL(environmentChanged()),
+                this, SIGNAL(baseEnvironmentChanged()));
+    }
+}
+
 QString CustomExecutableRunConfiguration::type() const
 {
     return "ProjectExplorer.CustomExecutableRunConfiguration";
diff --git a/src/plugins/projectexplorer/customexecutablerunconfiguration.h b/src/plugins/projectexplorer/customexecutablerunconfiguration.h
index 35f91fe902d..096a8a98278 100644
--- a/src/plugins/projectexplorer/customexecutablerunconfiguration.h
+++ b/src/plugins/projectexplorer/customexecutablerunconfiguration.h
@@ -102,6 +102,8 @@ signals:
     void baseEnvironmentChanged();
     void userEnvironmentChangesChanged(const QList<ProjectExplorer::EnvironmentItem> &diff);
 
+private slots:
+    void activeBuildConfigurationChanged();
 
 private:
     enum BaseEnvironmentBase { CleanEnvironmentBase = 0,
@@ -126,6 +128,7 @@ private:
     QString m_userName;
     QList<ProjectExplorer::EnvironmentItem> m_userEnvironmentChanges;
     BaseEnvironmentBase m_baseEnvironmentBase;
+    ProjectExplorer::BuildConfiguration *m_lastActiveBuildConfiguration;
 };
 
 class CustomExecutableRunConfigurationFactory : public IRunConfigurationFactory
@@ -154,16 +157,16 @@ public:
 private slots:
     void changed();
 
-    void setExecutable();
-    void setCommandLineArguments(const QString &commandLineArguments);
-    void setUserName(const QString &name);
-    void setWorkingDirectory();
+    void executableEdited();
+    void argumentsEdited(const QString &arguments);
+    void userNameEdited(const QString &name);
+    void workingDirectoryEdited();
     void termToggled(bool);
 
-    void userChangesUpdated();
+    void userChangesChanged();
     void baseEnvironmentChanged();
     void userEnvironmentChangesChanged();
-    void baseEnvironmentComboBoxChanged(int index);
+    void baseEnvironmentSelected(int index);
 private:
     bool m_ignoreChange;
     CustomExecutableRunConfiguration *m_runConfiguration;
diff --git a/src/plugins/projectexplorer/environmenteditmodel.cpp b/src/plugins/projectexplorer/environmenteditmodel.cpp
index b34a7d64b22..0b18f359899 100644
--- a/src/plugins/projectexplorer/environmenteditmodel.cpp
+++ b/src/plugins/projectexplorer/environmenteditmodel.cpp
@@ -277,7 +277,7 @@ bool EnvironmentModel::setData(const QModelIndex &index, const QVariant &value,
                     m_items[pos].unset = false;
                     updateResultEnvironment();
                     emit dataChanged(index, index);
-                    emit userChangesUpdated();
+                    emit userChangesChanged();
                     return true;
                 }
                 // not found in m_items, so add it as a new variable
@@ -287,7 +287,7 @@ bool EnvironmentModel::setData(const QModelIndex &index, const QVariant &value,
                 m_items[index.row()].value = value.toString();
                 m_items[index.row()].unset = false;
                 emit dataChanged(index, index);
-                emit userChangesUpdated();
+                emit userChangesChanged();
                 return true;
             }
         }
@@ -328,14 +328,14 @@ QModelIndex EnvironmentModel::addVariable(const EnvironmentItem &item)
             m_items.insert(rowInChanges, item);
             updateResultEnvironment();
             emit dataChanged(index(rowInResult, 0, QModelIndex()), index(rowInResult, 1, QModelIndex()));
-            emit userChangesUpdated();
+            emit userChangesChanged();
             return index(rowInResult, 0, QModelIndex());
         } else {
             beginInsertRows(QModelIndex(), rowInResult, rowInResult);
             m_items.insert(rowInChanges, item);
             updateResultEnvironment();
             endInsertRows();
-            emit userChangesUpdated();
+            emit userChangesChanged();
             return index(rowInResult, 0, QModelIndex());
         }
     } else {
@@ -343,7 +343,7 @@ QModelIndex EnvironmentModel::addVariable(const EnvironmentItem &item)
         beginInsertRows(QModelIndex(), newPos, newPos);
         m_items.insert(newPos, item);
         endInsertRows();
-        emit userChangesUpdated();
+        emit userChangesChanged();
         return index(newPos, 0, QModelIndex());
     }
 }
@@ -358,13 +358,13 @@ void EnvironmentModel::removeVariable(const QString &name)
             m_items.removeAt(rowInChanges);
             updateResultEnvironment();
             emit dataChanged(index(rowInResult, 0, QModelIndex()), index(rowInResult, 1, QModelIndex()));
-            emit userChangesUpdated();
+            emit userChangesChanged();
         } else {
             beginRemoveRows(QModelIndex(), rowInResult, rowInResult);
             m_items.removeAt(rowInChanges);
             updateResultEnvironment();
             endRemoveRows();
-            emit userChangesUpdated();
+            emit userChangesChanged();
         }
     } else {
         int removePos = findInChanges(name);
@@ -372,7 +372,7 @@ void EnvironmentModel::removeVariable(const QString &name)
         m_items.removeAt(removePos);
         updateResultEnvironment();
         endRemoveRows();
-        emit userChangesUpdated();
+        emit userChangesChanged();
     }
 }
 
@@ -386,7 +386,7 @@ void EnvironmentModel::unset(const QString &name)
             m_items[pos].unset = true;
             updateResultEnvironment();
             emit dataChanged(index(row, 0, QModelIndex()), index(row, 1, QModelIndex()));
-            emit userChangesUpdated();
+            emit userChangesChanged();
             return;
         }
         pos = findInChangesInsertPosition(name);
@@ -394,13 +394,13 @@ void EnvironmentModel::unset(const QString &name)
         m_items[pos].unset = true;
         updateResultEnvironment();
         emit dataChanged(index(row, 0, QModelIndex()), index(row, 1, QModelIndex()));
-        emit userChangesUpdated();
+        emit userChangesChanged();
         return;
     } else {
         int pos = findInChanges(name);
         m_items[pos].unset = true;
         emit dataChanged(index(pos, 1, QModelIndex()), index(pos, 1, QModelIndex()));
-        emit userChangesUpdated();
+        emit userChangesChanged();
         return;
     }
 }
@@ -440,8 +440,8 @@ EnvironmentWidget::EnvironmentWidget(QWidget *parent, QWidget *additionalDetails
 {
     m_model = new EnvironmentModel();
     m_model->setMergedEnvironments(true);
-    connect(m_model, SIGNAL(userChangesUpdated()),
-            this, SIGNAL(userChangesUpdated()));
+    connect(m_model, SIGNAL(userChangesChanged()),
+            this, SIGNAL(userChangesChanged()));
 
     QVBoxLayout *vbox = new QVBoxLayout(this);
     vbox->setContentsMargins(0, 0, 0, 0);
@@ -509,7 +509,7 @@ EnvironmentWidget::EnvironmentWidget(QWidget *parent, QWidget *additionalDetails
     connect(m_environmentTreeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)),
             this, SLOT(environmentCurrentIndexChanged(QModelIndex, QModelIndex)));
 
-    connect(m_model, SIGNAL(userChangesUpdated()), this, SLOT(updateSummaryText()));
+    connect(m_model, SIGNAL(userChangesChanged()), this, SLOT(updateSummaryText()));
 }
 
 EnvironmentWidget::~EnvironmentWidget()
diff --git a/src/plugins/projectexplorer/environmenteditmodel.h b/src/plugins/projectexplorer/environmenteditmodel.h
index cc681cc8677..c8fefe6349b 100644
--- a/src/plugins/projectexplorer/environmenteditmodel.h
+++ b/src/plugins/projectexplorer/environmenteditmodel.h
@@ -82,7 +82,7 @@ public:
     QList<EnvironmentItem> userChanges() const;
     void setUserChanges(QList<EnvironmentItem> list);
 signals:
-    void userChangesUpdated();
+    void userChangesChanged();
 private:
     void updateResultEnvironment();
     int findInChanges(const QString &name) const;
@@ -115,7 +115,7 @@ public slots:
     void updateButtons();
 
 signals:
-    void userChangesUpdated();
+    void userChangesChanged();
     void detailsVisibleChanged(bool visible);
 
 private slots:
diff --git a/src/plugins/qt4projectmanager/makestep.cpp b/src/plugins/qt4projectmanager/makestep.cpp
index beb2fbc45e7..fb942baa842 100644
--- a/src/plugins/qt4projectmanager/makestep.cpp
+++ b/src/plugins/qt4projectmanager/makestep.cpp
@@ -212,9 +212,9 @@ MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep)
 {
     m_ui.setupUi(this);
     connect(m_ui.makeLineEdit, SIGNAL(textEdited(QString)),
-            this, SLOT(makeLineEditTextEdited()));
+            this, SLOT(makeEdited()));
     connect(m_ui.makeArgumentsLineEdit, SIGNAL(textEdited(QString)),
-            this, SLOT(makeArgumentsLineEditTextEdited()));
+            this, SLOT(makeArgumentsLineEdited()));
 
     connect(makeStep, SIGNAL(userArgumentsChanged()),
             this, SLOT(userArgumentsChanged()));
@@ -300,13 +300,13 @@ void MakeStepConfigWidget::init()
     updateDetails();
 }
 
-void MakeStepConfigWidget::makeLineEditTextEdited()
+void MakeStepConfigWidget::makeEdited()
 {
     m_makeStep->m_makeCmd = m_ui.makeLineEdit->text();
     updateDetails();
 }
 
-void MakeStepConfigWidget::makeArgumentsLineEditTextEdited()
+void MakeStepConfigWidget::makeArgumentsLineEdited()
 {
     m_ignoreChange = true;
     m_makeStep->setUserArguments(
diff --git a/src/plugins/qt4projectmanager/makestep.h b/src/plugins/qt4projectmanager/makestep.h
index db70e16a0e0..5a9390a8cb3 100644
--- a/src/plugins/qt4projectmanager/makestep.h
+++ b/src/plugins/qt4projectmanager/makestep.h
@@ -82,11 +82,10 @@ public:
     virtual bool immutable() const;
     QStringList userArguments();
     void setUserArguments(const QStringList &arguments);
+    void setClean(bool clean);
 
     virtual void restoreFromGlobalMap(const QMap<QString, QVariant> &map);
 
-    void setClean(bool clean);
-
     virtual void restoreFromLocalMap(const QMap<QString, QVariant> &map);
     virtual void storeIntoLocalMap(QMap<QString, QVariant> &map);
 
@@ -107,8 +106,10 @@ public:
     void init();
     QString summaryText() const;
 private slots:
-    void makeLineEditTextEdited();
-    void makeArgumentsLineEditTextEdited();
+    // User changes to our widgets
+    void makeEdited();
+    void makeArgumentsLineEdited();
+
     void updateMakeOverrideLabel();
     void updateDetails();
     void userArgumentsChanged();
diff --git a/src/plugins/qt4projectmanager/qmakestep.cpp b/src/plugins/qt4projectmanager/qmakestep.cpp
index b28ee2e2d3c..f6806428246 100644
--- a/src/plugins/qt4projectmanager/qmakestep.cpp
+++ b/src/plugins/qt4projectmanager/qmakestep.cpp
@@ -99,7 +99,6 @@ QStringList QMakeStep::allArguments()
         foreach (const QString &addedConfig, addedUserConfigArguments)
             arguments.append("CONFIG+=" + addedConfig);
     }
-
     if (!additonalArguments.isEmpty())
         arguments << additonalArguments;
 
@@ -232,17 +231,35 @@ void QMakeStep::storeIntoLocalMap(QMap<QString, QVariant> &map)
     AbstractProcessStep::storeIntoLocalMap(map);
 }
 
+////
+// QMakeStepConfigWidget
+////
+
 QMakeStepConfigWidget::QMakeStepConfigWidget(QMakeStep *step)
     : BuildStepConfigWidget(), m_step(step), m_ignoreChange(false)
 {
     m_ui.setupUi(this);
     connect(m_ui.qmakeAdditonalArgumentsLineEdit, SIGNAL(textEdited(const QString&)),
-            this, SLOT(qmakeArgumentsLineEditTextEdited()));
-    connect(m_ui.buildConfigurationComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(buildConfigurationChanged()));
+            this, SLOT(qmakeArgumentsLineEdited()));
+    connect(m_ui.buildConfigurationComboBox, SIGNAL(currentIndexChanged(int)),
+            this, SLOT(buildConfigurationSelected()));
     connect(step, SIGNAL(userArgumentsChanged()),
             this, SLOT(userArgumentsChanged()));
-    connect(step->buildConfiguration(), SIGNAL(qtVersionChanged()),
+    connect(step->qt4BuildConfiguration(), SIGNAL(qtVersionChanged()),
             this, SLOT(qtVersionChanged()));
+    connect(step->qt4BuildConfiguration(), SIGNAL(qmakeBuildConfigurationChanged()),
+            this, SLOT(qmakeBuildConfigChanged()));
+}
+
+void QMakeStepConfigWidget::init()
+{
+    QString qmakeArgs = ProjectExplorer::Environment::joinArgumentList(m_step->userArguments());
+    m_ui.qmakeAdditonalArgumentsLineEdit->setText(qmakeArgs);
+
+    qmakeBuildConfigChanged();
+
+    updateSummaryLabel();
+    updateEffectiveQMakeCall();
 }
 
 QString QMakeStepConfigWidget::summaryText() const
@@ -250,91 +267,90 @@ QString QMakeStepConfigWidget::summaryText() const
     return m_summaryText;
 }
 
+QString QMakeStepConfigWidget::displayName() const
+{
+    return m_step->displayName();
+}
+
 void QMakeStepConfigWidget::qtVersionChanged()
 {
-    updateTitleLabel();
+    updateSummaryLabel();
     updateEffectiveQMakeCall();
 }
 
-void QMakeStepConfigWidget::updateTitleLabel()
+void QMakeStepConfigWidget::qmakeBuildConfigChanged()
 {
-    Qt4BuildConfiguration *qt4bc = m_step->qt4BuildConfiguration();
-    const QtVersion *qtVersion = qt4bc->qtVersion();
-    if (!qtVersion) {
-        m_summaryText = tr("<b>QMake:</b> No Qt version set. QMake can not be run.");
-        emit updateSummary();
-        return;
-    }
-
-    QStringList args = m_step->allArguments();
-    // We don't want the full path to the .pro file
-    const QString projectFileName = m_step->buildConfiguration()->project()->file()->fileName();
-    int index = args.indexOf(projectFileName);
-    if (index != -1)
-        args[index] = QFileInfo(projectFileName).fileName();
-
-    // And we only use the .pro filename not the full path
-    QString program = QFileInfo(qtVersion->qmakeCommand()).fileName();
-    m_summaryText = tr("<b>QMake:</b> %1 %2").arg(program, args.join(QString(QLatin1Char(' '))));
-    emit updateSummary();
+    Qt4BuildConfiguration *bc = m_step->qt4BuildConfiguration();
+    bool debug = bc->qmakeBuildConfiguration() & QtVersion::DebugBuild;
+    m_ignoreChange = true;
+    m_ui.buildConfigurationComboBox->setCurrentIndex(debug? 0 : 1);
+    m_ignoreChange = false;
+    updateSummaryLabel();
+    updateEffectiveQMakeCall();
+}
 
+void QMakeStepConfigWidget::userArgumentsChanged()
+{
+    if (m_ignoreChange)
+        return;
+    QString qmakeArgs = ProjectExplorer::Environment::joinArgumentList(m_step->userArguments());
+    m_ui.qmakeAdditonalArgumentsLineEdit->setText(qmakeArgs);
+    updateSummaryLabel();
+    updateEffectiveQMakeCall();
 }
 
-void QMakeStepConfigWidget::qmakeArgumentsLineEditTextEdited()
+void QMakeStepConfigWidget::qmakeArgumentsLineEdited()
 {
     m_ignoreChange = true;
     m_step->setUserArguments(
             ProjectExplorer::Environment::parseCombinedArgString(m_ui.qmakeAdditonalArgumentsLineEdit->text()));
     m_ignoreChange = false;
 
-    m_step->qt4BuildConfiguration()->qt4Project()->invalidateCachedTargetInformation();
-    updateTitleLabel();
+    updateSummaryLabel();
     updateEffectiveQMakeCall();
 }
 
-void QMakeStepConfigWidget::buildConfigurationChanged()
+void QMakeStepConfigWidget::buildConfigurationSelected()
 {
-    ProjectExplorer::BuildConfiguration *bc = m_step->buildConfiguration();
-    QtVersion::QmakeBuildConfigs buildConfiguration = QtVersion::QmakeBuildConfig(bc->value("buildConfiguration").toInt());
-    if (m_ui.buildConfigurationComboBox->currentIndex() == 0) {
-        // debug
+    if (m_ignoreChange)
+        return;
+    Qt4BuildConfiguration *bc = m_step->qt4BuildConfiguration();
+    QtVersion::QmakeBuildConfigs buildConfiguration = bc->qmakeBuildConfiguration();
+    if (m_ui.buildConfigurationComboBox->currentIndex() == 0) { // debug
         buildConfiguration = buildConfiguration | QtVersion::DebugBuild;
     } else {
         buildConfiguration = buildConfiguration & ~QtVersion::DebugBuild;
     }
-    bc->setValue("buildConfiguration", int(buildConfiguration));
-    m_step->qt4BuildConfiguration()->qt4Project()->invalidateCachedTargetInformation();
-    updateTitleLabel();
-    updateEffectiveQMakeCall();
-    // TODO if exact parsing is the default, we need to update the code model
-    // and all the Qt4ProFileNodes
-    // m_step->qt4Project()->update();
-}
+    m_ignoreChange = true;
+    bc->setQMakeBuildConfiguration(buildConfiguration);
+    m_ignoreChange = false;
 
-QString QMakeStepConfigWidget::displayName() const
-{
-    return m_step->displayName();
+    updateSummaryLabel();
+    updateEffectiveQMakeCall();
 }
 
-void QMakeStepConfigWidget::userArgumentsChanged()
+void QMakeStepConfigWidget::updateSummaryLabel()
 {
-    if (m_ignoreChange)
+    Qt4BuildConfiguration *qt4bc = m_step->qt4BuildConfiguration();
+    const QtVersion *qtVersion = qt4bc->qtVersion();
+    if (!qtVersion) {
+        m_summaryText = tr("<b>QMake:</b> No Qt version set. QMake can not be run.");
+        emit updateSummary();
         return;
-    QString qmakeArgs = ProjectExplorer::Environment::joinArgumentList(m_step->userArguments());
-    m_ui.qmakeAdditonalArgumentsLineEdit->setText(qmakeArgs);
-    updateTitleLabel();
-    updateEffectiveQMakeCall();
-}
+    }
+
+    QStringList args = m_step->allArguments();
+    // We don't want the full path to the .pro file
+    const QString projectFileName = m_step->buildConfiguration()->project()->file()->fileName();
+    int index = args.indexOf(projectFileName);
+    if (index != -1)
+        args[index] = QFileInfo(projectFileName).fileName();
+
+    // And we only use the .pro filename not the full path
+    QString program = QFileInfo(qtVersion->qmakeCommand()).fileName();
+    m_summaryText = tr("<b>QMake:</b> %1 %2").arg(program, args.join(QString(QLatin1Char(' '))));
+    emit updateSummary();
 
-void QMakeStepConfigWidget::init()
-{
-    QString qmakeArgs = ProjectExplorer::Environment::joinArgumentList(m_step->userArguments());
-    m_ui.qmakeAdditonalArgumentsLineEdit->setText(qmakeArgs);
-    ProjectExplorer::BuildConfiguration *bc = m_step->buildConfiguration();
-    bool debug = QtVersion::QmakeBuildConfig(bc->value("buildConfiguration").toInt()) & QtVersion::DebugBuild;
-    m_ui.buildConfigurationComboBox->setCurrentIndex(debug? 0 : 1);
-    updateTitleLabel();
-    updateEffectiveQMakeCall();
 }
 
 void QMakeStepConfigWidget::updateEffectiveQMakeCall()
diff --git a/src/plugins/qt4projectmanager/qmakestep.h b/src/plugins/qt4projectmanager/qmakestep.h
index c6a4a37b95d..f620c9b8681 100644
--- a/src/plugins/qt4projectmanager/qmakestep.h
+++ b/src/plugins/qt4projectmanager/qmakestep.h
@@ -109,16 +109,20 @@ class QMakeStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget
     Q_OBJECT
 public:
     QMakeStepConfigWidget(QMakeStep *step);
-    QString displayName() const;
     void init();
     QString summaryText() const;
+    QString displayName() const;
 private slots:
-    void qmakeArgumentsLineEditTextEdited();
-    void buildConfigurationChanged();
-    void userArgumentsChanged();
+    // slots for handling buildconfiguration/step signals
     void qtVersionChanged();
+    void qmakeBuildConfigChanged();
+    void userArgumentsChanged();
+
+    // slots for dealing with user changes in our UI
+    void qmakeArgumentsLineEdited();
+    void buildConfigurationSelected();
 private:
-    void updateTitleLabel();
+    void updateSummaryLabel();
     void updateEffectiveQMakeCall();
     Ui::QMakeStep m_ui;
     QMakeStep *m_step;
diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.cpp
index 63c2da4bd2a..ccf023bef79 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.cpp
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.cpp
@@ -268,10 +268,14 @@ MaemoRunConfiguration::MaemoRunConfiguration(Project *project,
     connect(&MaemoDeviceConfigurations::instance(), SIGNAL(updated()),
             this, SLOT(updateDeviceConfigurations()));
 
-    connect(project, SIGNAL(targetInformationChanged()), this,
-        SLOT(invalidateCachedTargetInformation()));
-    connect(project, SIGNAL(activeBuildConfigurationChanged()), this,
-        SLOT(invalidateCachedTargetInformation()));
+    connect(project, SIGNAL(targetInformationChanged()),
+            this, SLOT(invalidateCachedTargetInformation()));
+
+    connect(project, SIGNAL(targetInformationChanged()),
+            this, SLOT(enabledStateChanged()));
+
+    connect(project, SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode*)),
+            this, SLOT(proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode*)));
 
     qemu = new QProcess(this);
     connect(qemu, SIGNAL(error(QProcess::ProcessError)), &dumper,
@@ -315,6 +319,13 @@ QWidget *MaemoRunConfiguration::configurationWidget()
     return new MaemoRunConfigurationWidget(this);
 }
 
+void MaemoRunConfiguration::proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode *pro)
+{
+    if (m_proFilePath == pro->path())
+        invalidateCachedTargetInformation();
+}
+
+
 void MaemoRunConfiguration::save(PersistentSettingsWriter &writer) const
 {
     writer.saveValue(DeviceIdKey, m_devConfig.internalId);
diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.h b/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.h
index 5286b5bf500..f617c85da08 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.h
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemorunconfiguration.h
@@ -46,6 +46,7 @@ namespace Internal {
 
 class MaemoManager;
 class MaemoToolChain;
+class Qt4ProFileNode;
 using namespace ProjectExplorer;
 
 #define USE_SSL_PASSWORD 0
@@ -120,6 +121,7 @@ signals:
     void qemuProcessStatus(bool running);
 
 private slots:
+    void proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode *pro);
     void updateDeviceConfigurations();
     void invalidateCachedTargetInformation();
 
diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp
index 07203248d37..432deed02b4 100644
--- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp
@@ -97,13 +97,20 @@ S60DeviceRunConfiguration::S60DeviceRunConfiguration(Project *project, const QSt
     else
         setName(tr("QtS60DeviceRunConfiguration"));
 
-    connect(project, SIGNAL(activeBuildConfigurationChanged()),
-            this, SLOT(invalidateCachedTargetInformation()));
-
     connect(project, SIGNAL(targetInformationChanged()),
             this, SLOT(invalidateCachedTargetInformation()));
+
+    connect(project, SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode*)),
+            this, SLOT(proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode*)));
 }
 
+void S60DeviceRunConfiguration::proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode *pro)
+{
+    if (m_proFilePath == pro->path())
+        invalidateCachedTargetInformation();
+}
+
+
 S60DeviceRunConfiguration::~S60DeviceRunConfiguration()
 {
 }
diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h
index 8eac205640f..8bfe992aa33 100644
--- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h
+++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.h
@@ -51,6 +51,7 @@ namespace Qt4ProjectManager {
 class Qt4Project;
 
 namespace Internal {
+class Qt4ProFileNode;
 
 class S60DeviceRunConfiguration : public ProjectExplorer::RunConfiguration
 {
@@ -100,6 +101,7 @@ signals:
 
 private slots:
     void invalidateCachedTargetInformation();
+    void proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode *pro);
 
 private:
     ProjectExplorer::ToolChain::ToolChainType toolChainType(ProjectExplorer::BuildConfiguration *configuration) const;
diff --git a/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.cpp
index 54922b5e4d3..8f5244e0323 100644
--- a/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.cpp
@@ -62,17 +62,24 @@ S60EmulatorRunConfiguration::S60EmulatorRunConfiguration(Project *project, const
     else
         setName(tr("QtSymbianEmulatorRunConfiguration"));
 
-    connect(project, SIGNAL(activeBuildConfigurationChanged()),
-            this, SLOT(invalidateCachedTargetInformation()));
-
     connect(project, SIGNAL(targetInformationChanged()),
             this, SLOT(invalidateCachedTargetInformation()));
+
+    connect(project, SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode*)),
+            this, SLOT(proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode*)));
 }
 
 S60EmulatorRunConfiguration::~S60EmulatorRunConfiguration()
 {
 }
 
+void S60EmulatorRunConfiguration::proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode *pro)
+{
+    if (m_proFilePath == pro->path())
+        invalidateCachedTargetInformation();
+}
+
+
 Qt4Project *S60EmulatorRunConfiguration::qt4Project() const
 {
     return static_cast<Qt4Project *>(project());
diff --git a/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.h b/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.h
index 64c8cdfce93..b5db9a313b1 100644
--- a/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.h
+++ b/src/plugins/qt4projectmanager/qt-s60/s60emulatorrunconfiguration.h
@@ -48,6 +48,7 @@ namespace Qt4ProjectManager {
 class Qt4Project;
 
 namespace Internal {
+class Qt4ProFileNode;
 
 class S60EmulatorRunConfiguration : public ProjectExplorer::RunConfiguration
 {
@@ -71,6 +72,7 @@ signals:
 
 private slots:
     void invalidateCachedTargetInformation();
+    void proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode *pro);
 
 private:
     void updateTarget();
diff --git a/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp b/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp
index 486c995d18e..c3cbc89f0b9 100644
--- a/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp
+++ b/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp
@@ -45,13 +45,13 @@ namespace {
 Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4Project *pro)
     : BuildConfiguration(pro)
 {
-
+    init();
 }
 
 Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4BuildConfiguration *source)
     : BuildConfiguration(source)
 {
-
+    init();
 }
 
 Qt4BuildConfiguration::~Qt4BuildConfiguration()
@@ -59,6 +59,15 @@ Qt4BuildConfiguration::~Qt4BuildConfiguration()
 
 }
 
+void Qt4BuildConfiguration::init()
+{
+    QtVersionManager *vm = QtVersionManager::instance();
+    connect(vm, SIGNAL(defaultQtVersionChanged()),
+            this, SLOT(defaultQtVersionChanged()));
+    connect(vm, SIGNAL(qtVersionsChanged(QList<int>)),
+            this, SLOT(qtVersionsChanged(QList<int>)));
+}
+
 Qt4Project *Qt4BuildConfiguration::qt4Project() const
 {
     return static_cast<Qt4Project *>(project());
@@ -120,6 +129,14 @@ QString Qt4BuildConfiguration::buildDirectory() const
     return workingDirectory;
 }
 
+void Qt4BuildConfiguration::setShadowBuildAndDirectory(bool shadowBuild, const QString &buildDirectory)
+{
+    setValue("useShadowBuild", shadowBuild);
+    setValue("buildDirectory", buildDirectory);
+    emit buildDirectoryChanged();
+    emit targetInformationChanged();
+}
+
 ProjectExplorer::ToolChain *Qt4BuildConfiguration::toolChain() const
 {
     ToolChain::ToolChainType tct = toolChainType();
@@ -199,15 +216,21 @@ int Qt4BuildConfiguration::qtVersionId() const
 
 void Qt4BuildConfiguration::setQtVersion(int id)
 {
+    if (qtVersionId() == id)
+        return;
+
     setValue(KEY_QT_VERSION_ID, id);
     emit qtVersionChanged();
-    qt4Project()->updateActiveRunConfiguration();
+    emit targetInformationChanged();
 }
 
 void Qt4BuildConfiguration::setToolChainType(ProjectExplorer::ToolChain::ToolChainType type)
 {
+    if (value("ToolChain").toInt() == type)
+        return;
     setValue("ToolChain", (int)type);
-    qt4Project()->updateActiveRunConfiguration();
+    emit toolChainTypeChanged();
+    emit targetInformationChanged();
 }
 
 ProjectExplorer::ToolChain::ToolChainType Qt4BuildConfiguration::toolChainType() const
@@ -224,6 +247,37 @@ ProjectExplorer::ToolChain::ToolChainType Qt4BuildConfiguration::toolChainType()
     return type;
 }
 
+QtVersion::QmakeBuildConfigs Qt4BuildConfiguration::qmakeBuildConfiguration() const
+{
+    return QtVersion::QmakeBuildConfigs(value("buildConfiguration").toInt());
+}
+
+void Qt4BuildConfiguration::setQMakeBuildConfiguration(QtVersion::QmakeBuildConfigs config)
+{
+    if (value("buildConfiguration").toInt() == int(config))
+        return;
+    setValue("buildConfiguration", int(config));
+    emit qmakeBuildConfigurationChanged();
+    emit targetInformationChanged();
+}
+
+void Qt4BuildConfiguration::getConfigCommandLineArguments(QStringList *addedUserConfigs, QStringList *removedUserConfigs) const
+{
+    QtVersion::QmakeBuildConfigs defaultBuildConfiguration = qtVersion()->defaultBuildConfig();
+    QtVersion::QmakeBuildConfigs userBuildConfiguration = qmakeBuildConfiguration();
+    if (removedUserConfigs) {
+        if ((defaultBuildConfiguration & QtVersion::BuildAll) && !(userBuildConfiguration & QtVersion::BuildAll))
+            (*removedUserConfigs) << "debug_and_release";
+    }
+    if (addedUserConfigs) {
+        if (!(defaultBuildConfiguration & QtVersion::BuildAll) && (userBuildConfiguration & QtVersion::BuildAll))
+            (*addedUserConfigs) << "debug_and_release";
+        if ((defaultBuildConfiguration & QtVersion::DebugBuild) && !(userBuildConfiguration & QtVersion::DebugBuild))
+            (*addedUserConfigs) << "release";
+        if (!(defaultBuildConfiguration & QtVersion::DebugBuild) && (userBuildConfiguration & QtVersion::DebugBuild))
+            (*addedUserConfigs) << "debug";
+    }
+}
 
 QMakeStep *Qt4BuildConfiguration::qmakeStep() const
 {
@@ -243,6 +297,24 @@ MakeStep *Qt4BuildConfiguration::makeStep() const
     return 0;
 }
 
+void Qt4BuildConfiguration::defaultQtVersionChanged()
+{
+    if (qtVersionId() == 0) {
+        emit qtVersionChanged();
+        emit targetInformationChanged();
+    }
+}
+
+void Qt4BuildConfiguration::qtVersionsChanged(const QList<int> &changedVersions)
+{
+    if (changedVersions.contains(qtVersionId())) {
+        if (!qtVersion()->isValid())
+            setQtVersion(0);
+        emit qtVersionChanged();
+        emit targetInformationChanged();
+    }
+}
+
 // returns true if both are equal
 bool Qt4BuildConfiguration::compareToImportFrom(const QString &workingDirectory)
 {
@@ -375,28 +447,4 @@ QString Qt4BuildConfiguration::extractSpecFromArgumentList(const QStringList &li
     parsedSpec = parsedSpec.toLower();
 #endif
     return parsedSpec;
-
-}
-
-QtVersion::QmakeBuildConfigs Qt4BuildConfiguration::qmakeBuildConfiguration() const
-{
-    return QtVersion::QmakeBuildConfigs(value("buildConfiguration").toInt());
-}
-
-void Qt4BuildConfiguration::getConfigCommandLineArguments(QStringList *addedUserConfigs, QStringList *removedUserConfigs) const
-{
-    QtVersion::QmakeBuildConfigs defaultBuildConfiguration = qtVersion()->defaultBuildConfig();
-    QtVersion::QmakeBuildConfigs userBuildConfiguration = qmakeBuildConfiguration();
-    if (removedUserConfigs) {
-        if ((defaultBuildConfiguration & QtVersion::BuildAll) && !(userBuildConfiguration & QtVersion::BuildAll))
-            (*removedUserConfigs) << "debug_and_release";
-    }
-    if (addedUserConfigs) {
-        if (!(defaultBuildConfiguration & QtVersion::BuildAll) && (userBuildConfiguration & QtVersion::BuildAll))
-            (*addedUserConfigs) << "debug_and_release";
-        if ((defaultBuildConfiguration & QtVersion::DebugBuild) && !(userBuildConfiguration & QtVersion::DebugBuild))
-            (*addedUserConfigs) << "release";
-        if (!(defaultBuildConfiguration & QtVersion::DebugBuild) && (userBuildConfiguration & QtVersion::DebugBuild))
-            (*addedUserConfigs) << "debug";
-    }
 }
diff --git a/src/plugins/qt4projectmanager/qt4buildconfiguration.h b/src/plugins/qt4projectmanager/qt4buildconfiguration.h
index 8769731d87e..262e1cf2198 100644
--- a/src/plugins/qt4projectmanager/qt4buildconfiguration.h
+++ b/src/plugins/qt4projectmanager/qt4buildconfiguration.h
@@ -34,6 +34,7 @@
 
 #include <projectexplorer/buildconfiguration.h>
 #include <projectexplorer/toolchain.h>
+#include "qtversionmanager.h"
 
 namespace Qt4ProjectManager {
 
@@ -62,6 +63,7 @@ public:
     void setUseSystemEnvironment(bool b);
 
     virtual QString buildDirectory() const;
+    void setShadowBuildAndDirectory(bool shadowBuild, const QString &buildDirectory);
 
     //returns the qtVersion, if the project is set to use the default qt version, then
     // that is returned
@@ -81,6 +83,9 @@ public:
     void setToolChainType(ProjectExplorer::ToolChain::ToolChainType type);
     ProjectExplorer::ToolChain::ToolChainType toolChainType() const;
 
+    QtVersion::QmakeBuildConfigs qmakeBuildConfiguration() const;
+    void setQMakeBuildConfiguration(QtVersion::QmakeBuildConfigs config);
+    void getConfigCommandLineArguments(QStringList *addedUserConfigs, QStringList *removedUserConfigs) const;
 
     // Those functions are used in a few places.
     // The drawback is that we shouldn't actually depend on them beeing always there
@@ -97,11 +102,26 @@ public:
     static QStringList removeSpecFromArgumentList(const QStringList &old);
     static QString extractSpecFromArgumentList(const QStringList &list, QString directory, QtVersion *version);
 
-    QtVersion::QmakeBuildConfigs qmakeBuildConfiguration() const;
-    void getConfigCommandLineArguments(QStringList *addedUserConfigs, QStringList *removedUserConfigs) const;
 
 signals:
+    /// emitted if the qt version changes (either directly, or because the default qt version changed
+    /// or because the user changed the settings for the qt version
     void qtVersionChanged();
+    /// emitted iff the setToolChainType() funciton is called, not emitted for qtversion changes
+    /// even if those result in a toolchain change
+    void toolChainTypeChanged();
+    /// emitted for setQMakeBuildConfig, not emitted for qt version changes, even
+    /// if those change the qmakebuildconfig
+    void qmakeBuildConfigurationChanged();
+
+    /// a covenience signal, emitted if either the qtversion, the toolchainType or the qmake build
+    /// configuration changed
+    void targetInformationChanged();
+private slots:
+    void defaultQtVersionChanged();
+    void qtVersionsChanged(const QList<int> &changedVersions);
+private:
+    void init();
 };
 
 } // namespace Qt4ProjectManager
diff --git a/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.cpp b/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.cpp
index 998ae3591bf..4887dd21af8 100644
--- a/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.cpp
+++ b/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.cpp
@@ -54,7 +54,7 @@ Qt4BuildEnvironmentWidget::Qt4BuildEnvironmentWidget(Qt4Project *project)
     m_buildEnvironmentWidget = new ProjectExplorer::EnvironmentWidget(this, m_clearSystemEnvironmentCheckBox);
     vbox->addWidget(m_buildEnvironmentWidget);
 
-    connect(m_buildEnvironmentWidget, SIGNAL(userChangesUpdated()),
+    connect(m_buildEnvironmentWidget, SIGNAL(userChangesChanged()),
             this, SLOT(environmentModelUserChangesUpdated()));
 
     connect(m_clearSystemEnvironmentCheckBox, SIGNAL(toggled(bool)),
diff --git a/src/plugins/qt4projectmanager/qt4nodes.cpp b/src/plugins/qt4projectmanager/qt4nodes.cpp
index a359ed2e3c0..34b68973de9 100644
--- a/src/plugins/qt4projectmanager/qt4nodes.cpp
+++ b/src/plugins/qt4projectmanager/qt4nodes.cpp
@@ -768,8 +768,6 @@ Qt4ProFileNode::Qt4ProFileNode(Qt4Project *project,
     m_updateTimer.setInterval(100);
     m_updateTimer.setSingleShot(true);
 
-    connect(m_project, SIGNAL(activeBuildConfigurationChanged()),
-            this, SLOT(update()));
     connect(&m_updateTimer, SIGNAL(timeout()),
             this, SLOT(update()));
 
diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp
index d4057a9b036..3c5475efdbd 100644
--- a/src/plugins/qt4projectmanager/qt4project.cpp
+++ b/src/plugins/qt4projectmanager/qt4project.cpp
@@ -40,14 +40,7 @@
 #include "qt4buildenvironmentwidget.h"
 #include "qt4projectmanagerconstants.h"
 #include "projectloadwizard.h"
-#include "qtversionmanager.h"
 #include "qt4buildconfiguration.h"
-#include "qt4buildconfiguration.h"
-
-#ifdef QTCREATOR_WITH_S60
-#include "qt-s60/gccetoolchain.h"
-#include "qt-s60/rvcttoolchain.h"
-#endif
 
 #include <coreplugin/icore.h>
 #include <coreplugin/messagemanager.h>
@@ -236,6 +229,12 @@ Qt4BuildConfigurationFactory::Qt4BuildConfigurationFactory(Qt4Project *project)
     m_project(project)
 {
     update();
+
+    QtVersionManager *vm = QtVersionManager::instance();
+    connect(vm, SIGNAL(defaultQtVersionChanged()),
+            this, SLOT(update()));
+    connect(vm, SIGNAL(qtVersionsChanged(QList<int>)),
+            this, SLOT(update()));
 }
 
 Qt4BuildConfigurationFactory::~Qt4BuildConfigurationFactory()
@@ -320,7 +319,8 @@ Qt4Project::Qt4Project(Qt4Manager *manager, const QString& fileName) :
     m_buildConfigurationFactory(new Qt4BuildConfigurationFactory(this)),
     m_fileInfo(new Qt4ProjectFile(this, fileName, this)),
     m_isApplication(true),
-    m_projectFiles(new Qt4ProjectFiles)
+    m_projectFiles(new Qt4ProjectFiles),
+    m_lastActiveQt4BuildConfiguration(0)
 {
     m_manager->registerProject(this);
 
@@ -340,24 +340,9 @@ Qt4BuildConfiguration *Qt4Project::activeQt4BuildConfiguration() const
     return static_cast<Qt4BuildConfiguration *>(activeBuildConfiguration());
 }
 
-void Qt4Project::defaultQtVersionChanged()
+void Qt4Project::qtVersionChanged()
 {
-    if (activeQt4BuildConfiguration()->qtVersionId() == 0)
-        m_rootProjectNode->update();
-}
-
-void Qt4Project::qtVersionsChanged()
-{
-    QtVersionManager *vm = QtVersionManager::instance();
-    foreach (BuildConfiguration *bc, buildConfigurations()) {
-        Qt4BuildConfiguration *qt4bc = static_cast<Qt4BuildConfiguration *>(bc);
-        if (!vm->version(qt4bc->qtVersionId())->isValid()) {
-            qt4bc->setQtVersion(0);
-            if (qt4bc == activeBuildConfiguration())
-                m_rootProjectNode->update();
-        }
-    }
-    m_buildConfigurationFactory->update();
+    m_rootProjectNode->update();
 }
 
 void Qt4Project::updateFileList()
@@ -420,13 +405,6 @@ bool Qt4Project::restoreSettingsImpl(PersistentSettingsReader &settingsReader)
     }
 
     // Now connect
-    QtVersionManager *vm = QtVersionManager::instance();
-    connect(vm, SIGNAL(defaultQtVersionChanged()),
-            this, SLOT(defaultQtVersionChanged()));
-    connect(vm, SIGNAL(qtVersionsChanged()),
-            this, SLOT(qtVersionsChanged()));
-
-
     connect(m_nodesWatcher, SIGNAL(foldersAboutToBeAdded(FolderNode *, const QList<FolderNode*> &)),
             this, SLOT(foldersAboutToBeAdded(FolderNode *, const QList<FolderNode*> &)));
     connect(m_nodesWatcher, SIGNAL(foldersAdded()), this, SLOT(checkForNewApplicationProjects()));
@@ -441,10 +419,47 @@ bool Qt4Project::restoreSettingsImpl(PersistentSettingsReader &settingsReader)
                                           const Qt4ProjectManager::Internal::Qt4ProjectType)));
 
     connect(m_nodesWatcher, SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode *)),
-            this, SLOT(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode *)));
+            this, SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode *)));
+
+    connect(this, SIGNAL(activeBuildConfigurationChanged()),
+            this, SLOT(slotActiveBuildConfigurationChanged()));
+
+    m_lastActiveQt4BuildConfiguration = activeQt4BuildConfiguration();
+    if (m_lastActiveQt4BuildConfiguration) {
+        connect(m_lastActiveQt4BuildConfiguration, SIGNAL(qtVersionChanged()),
+                this, SLOT(update()));
+        connect(m_lastActiveQt4BuildConfiguration, SIGNAL(targetInformationChanged()),
+                this, SIGNAL(targetInformationChanged()));
+        connect(m_lastActiveQt4BuildConfiguration, SIGNAL(environmentChanged()),
+                this, SIGNAL(environmentChanged()));
+    }
+
     return true;
 }
 
+void Qt4Project::slotActiveBuildConfigurationChanged()
+{
+    if (m_lastActiveQt4BuildConfiguration) {
+        disconnect(m_lastActiveQt4BuildConfiguration, SIGNAL(qtVersionChanged()),
+                   this, SLOT(update()));
+        disconnect(m_lastActiveQt4BuildConfiguration, SIGNAL(targetInformationChanged()),
+                   this, SIGNAL(targetInformationChanged()));
+        disconnect(m_lastActiveQt4BuildConfiguration, SIGNAL(environmentChanged()),
+                   this, SIGNAL(environmentChanged()));
+    }
+    m_lastActiveQt4BuildConfiguration = activeQt4BuildConfiguration();
+    if (m_lastActiveQt4BuildConfiguration) {
+        connect(m_lastActiveQt4BuildConfiguration, SIGNAL(qtVersionChanged()),
+                this, SLOT(update()));
+        connect(m_lastActiveQt4BuildConfiguration, SIGNAL(targetInformationChanged()),
+                this, SIGNAL(targetInformationChanged()));
+        connect(m_lastActiveQt4BuildConfiguration, SIGNAL(environmentChanged()),
+                this, SIGNAL(environmentChanged()));
+    }
+    emit environmentChanged();
+    emit targetInformationChanged();
+}
+
 void Qt4Project::saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer)
 {
     Project::saveSettingsImpl(writer);
@@ -482,7 +497,7 @@ Qt4BuildConfiguration *Qt4Project::addQt4BuildConfiguration(QString displayName,
     if (qmakeBuildConfiguration & QtVersion::BuildAll) // debug_and_release => explicit targets
         makeStep->setUserArguments(QStringList() << (debug ? "debug" : "release"));
 
-    bc->setValue("buildConfiguration", int(qmakeBuildConfiguration));
+    bc->setQMakeBuildConfiguration(qmakeBuildConfiguration);
 
     // Finally set the qt version
     bool defaultQtVersion = (qtversion == 0);
@@ -845,13 +860,6 @@ Qt4ProFileNode *Qt4Project::rootProjectNode() const
     return m_rootProjectNode;
 }
 
-
-void Qt4Project::updateActiveRunConfiguration()
-{
-    emit runConfigurationsEnabledStateChanged();
-    emit targetInformationChanged();
-}
-
 BuildConfigWidget *Qt4Project::createConfigWidget()
 {
     return new Qt4ProjectConfigWidget(this);
@@ -969,17 +977,6 @@ void Qt4Project::projectTypeChanged(Qt4ProFileNode *node, const Qt4ProjectType o
     }
 }
 
-void Qt4Project::proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode *node)
-{
-    foreach (RunConfiguration *rc, runConfigurations()) {
-        if (Qt4RunConfiguration *qt4rc = qobject_cast<Qt4RunConfiguration *>(rc)) {
-            if (qt4rc->proFilePath() == node->path()) {
-                qt4rc->invalidateCachedTargetInformation();
-            }
-        }
-    }
-}
-
 bool Qt4Project::hasSubNode(Qt4PriFileNode *root, const QString &path)
 {
     if (root->path() == path)
@@ -1015,11 +1012,6 @@ void Qt4Project::notifyChanged(const QString &name)
     }
 }
 
-void Qt4Project::invalidateCachedTargetInformation()
-{
-    emit targetInformationChanged();
-}
-
 /*!
   Handle special case were a subproject of the qt directory is opened, and
   qt was configured to be built as a shadow build -> also build in the sub-
diff --git a/src/plugins/qt4projectmanager/qt4project.h b/src/plugins/qt4projectmanager/qt4project.h
index 94a6b4c3263..7b9b2249c3f 100644
--- a/src/plugins/qt4projectmanager/qt4project.h
+++ b/src/plugins/qt4projectmanager/qt4project.h
@@ -135,6 +135,7 @@ public:
     ProjectExplorer::BuildConfiguration *clone(ProjectExplorer::BuildConfiguration *source) const;
     ProjectExplorer::BuildConfiguration *restore() const;
 
+private slots:
     void update();
 
 private:
@@ -191,21 +192,18 @@ public:
 
     void notifyChanged(const QString &name);
 
-    // Is called by qmakestep qt4configurationwidget if the settings change
-    // Informs all Qt4RunConfigurations that their cached values are now invalid
-    // the Qt4RunConfigurations will update as soon as asked
-
-    // TODO remove
-    void invalidateCachedTargetInformation();
-
     virtual QByteArray predefinedMacros(const QString &fileName) const;
     virtual QStringList includePaths(const QString &fileName) const;
     virtual QStringList frameworkPaths(const QString &fileName) const;
 
-    // TODO can i remove this?
-    void updateActiveRunConfiguration();
 signals:
+    /// convenience signal, emitted if either the active buildconfiguration emits
+    /// targetInformationChanged() or if the active build configuration changes
     void targetInformationChanged();
+    void proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode *node);
+    /// convenience signal, emitted if either the active buildconfiguration emits
+    /// environmentChanged() or if the active build configuration changes
+    void environmentChanged();
 
 public slots:
     void update();
@@ -214,8 +212,8 @@ public slots:
 
 private slots:
     void updateCodeModel();
-    void defaultQtVersionChanged();
-    void qtVersionsChanged();
+    void qtVersionChanged();
+    void slotActiveBuildConfigurationChanged();
     void updateFileList();
 
     void foldersAboutToBeAdded(FolderNode *, const QList<FolderNode*> &);
@@ -224,7 +222,6 @@ private slots:
     void projectTypeChanged(Qt4ProjectManager::Internal::Qt4ProFileNode *node,
                             const Qt4ProjectManager::Internal::Qt4ProjectType oldType,
                             const Qt4ProjectManager::Internal::Qt4ProjectType newType);
-    void proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode *node);
 
 protected:
     virtual bool restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &settingsReader);
@@ -261,6 +258,8 @@ private:
     QList<Qt4ProjectManager::Internal::Qt4ProFileNode *> m_proFilesForCodeModelUpdate;
 
     QMap<QString, Internal::CodeModelInfo> m_codeModelInfo;
+    Internal::Qt4BuildConfiguration *m_lastActiveQt4BuildConfiguration;
+
     friend class Qt4ProjectFile;
     friend class Internal::Qt4ProjectConfigWidget;
 };
diff --git a/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp b/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp
index 13ac7cb6d6c..ac42bec16c7 100644
--- a/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp
+++ b/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp
@@ -51,10 +51,12 @@ bool debug = false;
 
 using namespace Qt4ProjectManager;
 using namespace Qt4ProjectManager::Internal;
+using ProjectExplorer::ToolChain;
 
 Qt4ProjectConfigWidget::Qt4ProjectConfigWidget(Qt4Project *project)
     : BuildConfigWidget(),
-      m_buildConfiguration(0)
+      m_buildConfiguration(0),
+      m_ignoreChange(false)
 {
     Q_UNUSED(project);
     QVBoxLayout *vbox = new QVBoxLayout(this);
@@ -75,22 +77,22 @@ Qt4ProjectConfigWidget::Qt4ProjectConfigWidget(Qt4Project *project)
     m_ui->invalidQtWarningLabel->setVisible(false);
 
     connect(m_ui->nameLineEdit, SIGNAL(textEdited(QString)),
-            this, SLOT(changeConfigName(QString)));
+            this, SLOT(configNameEdited(QString)));
 
     connect(m_ui->shadowBuildCheckBox, SIGNAL(clicked(bool)),
-            this, SLOT(shadowBuildCheckBoxClicked(bool)));
+            this, SLOT(shadowBuildClicked(bool)));
 
     connect(m_ui->shadowBuildDirEdit, SIGNAL(beforeBrowsing()),
             this, SLOT(onBeforeBeforeShadowBuildDirBrowsed()));
 
     connect(m_ui->shadowBuildDirEdit, SIGNAL(changed(QString)),
-            this, SLOT(shadowBuildLineEditTextChanged()));
+            this, SLOT(shadowBuildEdited()));
 
     connect(m_ui->qtVersionComboBox, SIGNAL(currentIndexChanged(QString)),
-            this, SLOT(qtVersionComboBoxCurrentIndexChanged(QString)));
+            this, SLOT(qtVersionSelected(QString)));
 
     connect(m_ui->toolChainComboBox, SIGNAL(activated(int)),
-            this, SLOT(selectToolChain(int)));
+            this, SLOT(toolChainSelected(int)));
 
     connect(m_ui->importLabel, SIGNAL(linkActivated(QString)),
             this, SLOT(importLabelClicked()));
@@ -98,12 +100,10 @@ Qt4ProjectConfigWidget::Qt4ProjectConfigWidget(Qt4Project *project)
     connect(m_ui->manageQtVersionPushButtons, SIGNAL(clicked()),
             this, SLOT(manageQtVersions()));
 
-    QtVersionManager *vm = QtVersionManager::instance();
 
-    connect(vm, SIGNAL(qtVersionsChanged()),
-            this, SLOT(setupQtVersionsComboBox()));
-    connect(vm, SIGNAL(qtVersionsChanged()),
-            this, SLOT(updateDetails()));
+    QtVersionManager *vm = QtVersionManager::instance();
+    connect(vm, SIGNAL(qtVersionsChanged(QList<int>)),
+            this, SLOT(qtVersionsChanged()));
 }
 
 Qt4ProjectConfigWidget::~Qt4ProjectConfigWidget()
@@ -148,10 +148,23 @@ void Qt4ProjectConfigWidget::init(ProjectExplorer::BuildConfiguration *bc)
     if (debug)
         qDebug() << "Qt4ProjectConfigWidget::init() for"<<bc->displayName();
 
+    if (m_buildConfiguration) {
+        disconnect(m_buildConfiguration, SIGNAL(buildDirectoryChanged()),
+                   this, SLOT(buildDirectoryChanged()));
+        disconnect(m_buildConfiguration, SIGNAL(qtVersionChanged()),
+                   this, SLOT(qtVersionChanged()));
+    }
+
     m_buildConfiguration = static_cast<Qt4BuildConfiguration *>(bc);
+
+    connect(m_buildConfiguration, SIGNAL(buildDirectoryChanged()),
+            this, SLOT(buildDirectoryChanged()));
+    connect(m_buildConfiguration, SIGNAL(qtVersionChanged()),
+            this, SLOT(qtVersionChanged()));
+
     m_ui->nameLineEdit->setText(m_buildConfiguration->displayName());
 
-    setupQtVersionsComboBox();
+    qtVersionsChanged();
 
     bool shadowBuild = m_buildConfiguration->value("useShadowBuild").toBool();
     m_ui->shadowBuildCheckBox->setChecked(shadowBuild);
@@ -163,18 +176,25 @@ void Qt4ProjectConfigWidget::init(ProjectExplorer::BuildConfiguration *bc)
     updateDetails();
 }
 
-void Qt4ProjectConfigWidget::changeConfigName(const QString &newName)
+void Qt4ProjectConfigWidget::qtVersionChanged()
+{
+    updateImportLabel();
+    updateToolChainCombo();
+    updateDetails();
+}
+
+void Qt4ProjectConfigWidget::configNameEdited(const QString &newName)
 {
     m_buildConfiguration->setDisplayName(newName);
 }
 
-void Qt4ProjectConfigWidget::setupQtVersionsComboBox()
+void Qt4ProjectConfigWidget::qtVersionsChanged()
 {
     if (!m_buildConfiguration) // not yet initialized
         return;
 
     disconnect(m_ui->qtVersionComboBox, SIGNAL(currentIndexChanged(QString)),
-        this, SLOT(qtVersionComboBoxCurrentIndexChanged(QString)));
+        this, SLOT(qtVersionSelected(QString)));
 
     QtVersionManager *vm = QtVersionManager::instance();
 
@@ -200,7 +220,14 @@ void Qt4ProjectConfigWidget::setupQtVersionsComboBox()
 
     // And connect again
     connect(m_ui->qtVersionComboBox, SIGNAL(currentIndexChanged(QString)),
-        this, SLOT(qtVersionComboBoxCurrentIndexChanged(QString)));
+        this, SLOT(qtVersionSelected(QString)));
+}
+
+void Qt4ProjectConfigWidget::buildDirectoryChanged()
+{
+    m_ui->shadowBuildDirEdit->setPath(m_buildConfiguration->value("buildDirectory").toString());
+    updateDetails();
+    updateImportLabel();
 }
 
 void Qt4ProjectConfigWidget::onBeforeBeforeShadowBuildDirBrowsed()
@@ -210,21 +237,35 @@ void Qt4ProjectConfigWidget::onBeforeBeforeShadowBuildDirBrowsed()
         m_ui->shadowBuildDirEdit->setInitialBrowsePathBackup(initialDirectory);
 }
 
-void Qt4ProjectConfigWidget::shadowBuildCheckBoxClicked(bool checked)
+void Qt4ProjectConfigWidget::shadowBuildClicked(bool checked)
 {
     m_ui->shadowBuildDirEdit->setEnabled(checked);
     m_browseButton->setEnabled(checked);
     bool b = m_ui->shadowBuildCheckBox->isChecked();
-    m_buildConfiguration->setValue("useShadowBuild", b);
-    if (b)
-        m_buildConfiguration->setValue("buildDirectory", m_ui->shadowBuildDirEdit->path());
-    else
-        m_buildConfiguration->setValue("buildDirectory", QVariant(QString::null));
+
+    m_ignoreChange = true;
+    m_buildConfiguration->setShadowBuildAndDirectory(b, b ? m_ui->shadowBuildDirEdit->path() : QString::null);
+    m_ignoreChange = false;
+
     updateDetails();
-    m_buildConfiguration->qt4Project()->invalidateCachedTargetInformation();
     updateImportLabel();
 }
 
+void Qt4ProjectConfigWidget::shadowBuildEdited()
+{
+    if (m_buildConfiguration->value("buildDirectory").toString() == m_ui->shadowBuildDirEdit->path())
+        return;
+    m_ignoreChange = true;
+    m_buildConfiguration->setShadowBuildAndDirectory(true, m_ui->shadowBuildDirEdit->path());
+    m_ignoreChange = false;
+
+    // if the directory already exists
+    // check if we have a build in there and
+    // offer to import it
+    updateImportLabel();
+    updateDetails();
+}
+
 void Qt4ProjectConfigWidget::updateImportLabel()
 {
     bool visible = false;
@@ -251,20 +292,6 @@ void Qt4ProjectConfigWidget::updateImportLabel()
     m_ui->importLabel->setVisible(visible);
 }
 
-void Qt4ProjectConfigWidget::shadowBuildLineEditTextChanged()
-{
-    if (m_buildConfiguration->value("buildDirectory").toString() == m_ui->shadowBuildDirEdit->path())
-        return;
-    m_buildConfiguration->setValue("buildDirectory", m_ui->shadowBuildDirEdit->path());
-    // if the directory already exists
-    // check if we have a build in there and
-    // offer to import it
-    updateImportLabel();
-
-    m_buildConfiguration->qt4Project()->invalidateCachedTargetInformation();
-    updateDetails();
-}
-
 void Qt4ProjectConfigWidget::importLabelClicked()
 {
     if (!m_buildConfiguration->qmakeStep() || !m_buildConfiguration->makeStep())
@@ -301,7 +328,7 @@ void Qt4ProjectConfigWidget::importLabelClicked()
             qmakeStep->setUserArguments(additionalArguments);
             MakeStep *makeStep = m_buildConfiguration->makeStep();
 
-            m_buildConfiguration->setValue("buildConfiguration", int(qmakeBuildConfig));
+            m_buildConfiguration->setQMakeBuildConfiguration(qmakeBuildConfig);
             // Adjust command line arguments, this is ugly as hell
             // If we are switching to BuildAll we want "release" in there and no "debug"
             // or "debug" in there and no "release"
@@ -319,12 +346,12 @@ void Qt4ProjectConfigWidget::importLabelClicked()
             makeStep->setUserArguments(makeCmdArguments);
         }
     }
-    setupQtVersionsComboBox();
-    updateDetails();
-    updateImportLabel();
+    // All our widgets are updated by signals from the buildconfiguration
+    // if not, there's either a signal missing
+    // or we don't respond to it correctly
 }
 
-void Qt4ProjectConfigWidget::qtVersionComboBoxCurrentIndexChanged(const QString &)
+void Qt4ProjectConfigWidget::qtVersionSelected(const QString &)
 {
     //Qt Version
     int newQtVersion;
@@ -337,9 +364,10 @@ void Qt4ProjectConfigWidget::qtVersionComboBoxCurrentIndexChanged(const QString
     bool isValid = vm->version(newQtVersion)->isValid();
     m_ui->invalidQtWarningLabel->setVisible(!isValid);
     if (newQtVersion != m_buildConfiguration->qtVersionId()) {
+        m_ignoreChange = true;
         m_buildConfiguration->setQtVersion(newQtVersion);
+        m_ignoreChange = false;
         updateToolChainCombo();
-        m_buildConfiguration->qt4Project()->update();
     }
     updateDetails();
 }
@@ -348,27 +376,21 @@ void Qt4ProjectConfigWidget::updateToolChainCombo()
 {
     m_ui->toolChainComboBox->clear();
     QList<ProjectExplorer::ToolChain::ToolChainType> toolchains = m_buildConfiguration->qtVersion()->possibleToolChainTypes();
-    using namespace ProjectExplorer;
     foreach (ToolChain::ToolChainType toolchain, toolchains) {
         m_ui->toolChainComboBox->addItem(ToolChain::toolChainName(toolchain), qVariantFromValue(toolchain));
     }
     m_ui->toolChainComboBox->setEnabled(toolchains.size() > 1);
-    setToolChain(toolchains.indexOf(m_buildConfiguration->toolChainType()));
-}
-
-void Qt4ProjectConfigWidget::selectToolChain(int index)
-{
-    setToolChain(index);
-    m_buildConfiguration->qt4Project()->update();
+    m_ui->toolChainComboBox->setCurrentIndex(toolchains.indexOf(m_buildConfiguration->toolChainType()));
+    updateDetails();
 }
 
-void Qt4ProjectConfigWidget::setToolChain(int index)
+void Qt4ProjectConfigWidget::toolChainSelected(int index)
 {
     ProjectExplorer::ToolChain::ToolChainType selectedToolChainType =
         m_ui->toolChainComboBox->itemData(index,
             Qt::UserRole).value<ProjectExplorer::ToolChain::ToolChainType>();
+    m_ignoreChange = true;
     m_buildConfiguration->setToolChainType(selectedToolChainType);
-    if (m_ui->toolChainComboBox->currentIndex() != index)
-        m_ui->toolChainComboBox->setCurrentIndex(index);
+    m_ignoreChange = false;
     updateDetails();
 }
diff --git a/src/plugins/qt4projectmanager/qt4projectconfigwidget.h b/src/plugins/qt4projectmanager/qt4projectconfigwidget.h
index 2f6171a9ad7..ea6832f1a8f 100644
--- a/src/plugins/qt4projectmanager/qt4projectconfigwidget.h
+++ b/src/plugins/qt4projectmanager/qt4projectconfigwidget.h
@@ -56,25 +56,29 @@ public:
     void init(ProjectExplorer::BuildConfiguration *bc);
 
 private slots:
-    void changeConfigName(const QString &newName);
-    void setupQtVersionsComboBox();
-    void shadowBuildCheckBoxClicked(bool checked);
+    // User changes in our widgets
+    void configNameEdited(const QString &newName);
+    void shadowBuildClicked(bool checked);
     void onBeforeBeforeShadowBuildDirBrowsed();
-    void shadowBuildLineEditTextChanged();
-    void importLabelClicked();
-    void qtVersionComboBoxCurrentIndexChanged(const QString &);
+    void shadowBuildEdited();
+    void qtVersionSelected(const QString &);
+    void toolChainSelected(int index);
     void manageQtVersions();
-    void selectToolChain(int index);
-    void updateDetails();
+    void importLabelClicked();
 
+    // Changes triggered from creator
+    void qtVersionsChanged();
+    void qtVersionChanged();
+    void buildDirectoryChanged();
 private:
+    void updateDetails();
     void updateToolChainCombo();
     void updateImportLabel();
-    void setToolChain(int index);
     Ui::Qt4ProjectConfigWidget *m_ui;
     QAbstractButton *m_browseButton;
     Qt4BuildConfiguration *m_buildConfiguration;
     Utils::DetailsWidget *m_detailsContainer;
+    bool m_ignoreChange;
 };
 
 } // namespace Internal
diff --git a/src/plugins/qt4projectmanager/qt4runconfiguration.cpp b/src/plugins/qt4projectmanager/qt4runconfiguration.cpp
index 07ce7ceafdd..1f912efb278 100644
--- a/src/plugins/qt4projectmanager/qt4runconfiguration.cpp
+++ b/src/plugins/qt4projectmanager/qt4runconfiguration.cpp
@@ -72,18 +72,14 @@ Qt4RunConfiguration::Qt4RunConfiguration(Qt4Project *pro, const QString &proFile
     else
         setName(tr("Qt4RunConfiguration"));
 
-    connect(pro, SIGNAL(activeBuildConfigurationChanged()),
-            this, SLOT(invalidateCachedTargetInformation()));
-
     connect(pro, SIGNAL(targetInformationChanged()),
             this, SLOT(invalidateCachedTargetInformation()));
 
-    connect(pro, SIGNAL(activeBuildConfigurationChanged()),
+    connect(pro, SIGNAL(environmentChanged()),
             this, SIGNAL(baseEnvironmentChanged()));
 
-//    TODO
-//    connect(pro, SIGNAL(environmentChanged(ProjectExplorer::BuildConfiguration *)),
-//            this, SIGNAL(baseEnvironmentChanged()));
+    connect(pro, SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode*)),
+            this, SLOT(proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode*)));
 }
 
 Qt4RunConfiguration::~Qt4RunConfiguration()
@@ -123,6 +119,12 @@ bool Qt4RunConfiguration::isEnabled(ProjectExplorer::BuildConfiguration *configu
     return true;
 }
 
+void Qt4RunConfiguration::proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode *pro)
+{
+    if  (m_proFilePath == pro->path())
+        invalidateCachedTargetInformation();
+}
+
 //////
 /// Qt4RunConfigurationWidget
 /////
@@ -205,7 +207,7 @@ Qt4RunConfigurationWidget::Qt4RunConfigurationWidget(Qt4RunConfiguration *qt4Run
                                         << tr("Build Environment"));
     m_baseEnvironmentComboBox->setCurrentIndex(qt4RunConfiguration->baseEnvironmentBase());
     connect(m_baseEnvironmentComboBox, SIGNAL(currentIndexChanged(int)),
-            this, SLOT(baseEnvironmentComboBoxChanged(int)));
+            this, SLOT(baseEnvironmentSelected(int)));
     baseEnvironmentLayout->addWidget(m_baseEnvironmentComboBox);
     baseEnvironmentLayout->addStretch(10);
 
@@ -216,20 +218,20 @@ Qt4RunConfigurationWidget::Qt4RunConfigurationWidget(Qt4RunConfiguration *qt4Run
     vboxTopLayout->addWidget(m_environmentWidget);
 
     connect(m_workingDirectoryEdit, SIGNAL(changed(QString)),
-            this, SLOT(setWorkingDirectory()));
+            this, SLOT(workDirectoryEdited()));
 
     connect(resetButton, SIGNAL(clicked()),
-            this, SLOT(resetWorkingDirectory()));
+            this, SLOT(workingDirectoryReseted()));
 
     connect(m_argumentsLineEdit, SIGNAL(textEdited(QString)),
-            this, SLOT(setCommandLineArguments(QString)));
+            this, SLOT(argumentsEdited(QString)));
     connect(m_nameLineEdit, SIGNAL(textEdited(QString)),
             this, SLOT(nameEdited(QString)));
     connect(m_useTerminalCheck, SIGNAL(toggled(bool)),
             this, SLOT(termToggled(bool)));
 
-    connect(m_environmentWidget, SIGNAL(userChangesUpdated()),
-            this, SLOT(userChangesUpdated()));
+    connect(m_environmentWidget, SIGNAL(userChangesChanged()),
+            this, SLOT(userChangesEdited()));
 
     connect(qt4RunConfiguration, SIGNAL(workingDirectoryChanged(QString)),
             this, SLOT(workingDirectoryChanged(QString)));
@@ -263,7 +265,7 @@ void Qt4RunConfigurationWidget::updateSummary()
     m_detailsContainer->setSummaryText(text);
 }
 
-void Qt4RunConfigurationWidget::baseEnvironmentComboBoxChanged(int index)
+void Qt4RunConfigurationWidget::baseEnvironmentSelected(int index)
 {
     m_ignoreChange = true;
     m_qt4RunConfiguration->setBaseEnvironmentBase(Qt4RunConfiguration::BaseEnvironmentBase(index));
@@ -288,14 +290,14 @@ void Qt4RunConfigurationWidget::userEnvironmentChangesChanged(const QList<Projec
     m_environmentWidget->setUserChanges(userChanges);
 }
 
-void Qt4RunConfigurationWidget::userChangesUpdated()
+void Qt4RunConfigurationWidget::userChangesEdited()
 {
     m_ignoreChange = true;
     m_qt4RunConfiguration->setUserEnvironmentChanges(m_environmentWidget->userChanges());
     m_ignoreChange = false;
 }
 
-void Qt4RunConfigurationWidget::setWorkingDirectory()
+void Qt4RunConfigurationWidget::workDirectoryEdited()
 {
     if (m_ignoreChange)
         return;
@@ -304,24 +306,24 @@ void Qt4RunConfigurationWidget::setWorkingDirectory()
     m_ignoreChange = false;
 }
 
-void Qt4RunConfigurationWidget::resetWorkingDirectory()
+void Qt4RunConfigurationWidget::workingDirectoryReseted()
 {
     // This emits a signal connected to workingDirectoryChanged()
     // that sets the m_workingDirectoryEdit
     m_qt4RunConfiguration->setWorkingDirectory("");
 }
 
-void Qt4RunConfigurationWidget::setCommandLineArguments(const QString &args)
+void Qt4RunConfigurationWidget::argumentsEdited(const QString &args)
 {
     m_ignoreChange = true;
-    m_qt4RunConfiguration->setCommandLineArguments(args);
+    m_qt4RunConfiguration->setArguments(args);
     m_ignoreChange = false;
 }
 
 void Qt4RunConfigurationWidget::nameEdited(const QString &name)
 {
     m_ignoreChange = true;
-    m_qt4RunConfiguration->nameEdited(name);
+    m_qt4RunConfiguration->setUserName(name);
     m_ignoreChange = false;
 }
 
@@ -527,7 +529,7 @@ void Qt4RunConfiguration::setWorkingDirectory(const QString &wd)
     }
 }
 
-void Qt4RunConfiguration::setCommandLineArguments(const QString &argumentsString)
+void Qt4RunConfiguration::setArguments(const QString &argumentsString)
 {
     m_commandLineArguments = ProjectExplorer::Environment::parseCombinedArgString(argumentsString);
     emit commandLineArgumentsChanged(argumentsString);
@@ -539,14 +541,14 @@ void Qt4RunConfiguration::setRunMode(RunMode runMode)
     emit runModeChanged(runMode);
 }
 
-void Qt4RunConfiguration::nameEdited(const QString &name)
+void Qt4RunConfiguration::setUserName(const QString &name)
 {
     if (name == "") {
-        setName(tr("Qt4RunConfiguration"));
         m_userSetName = false;
+        setName(tr("Qt4RunConfiguration"));
     } else {
-        setName(name);
         m_userSetName = true;
+        setName(name);
     }
     emit nameChanged(name);
 }
diff --git a/src/plugins/qt4projectmanager/qt4runconfiguration.h b/src/plugins/qt4projectmanager/qt4runconfiguration.h
index ce16df7c16a..f0622e4b77f 100644
--- a/src/plugins/qt4projectmanager/qt4runconfiguration.h
+++ b/src/plugins/qt4projectmanager/qt4runconfiguration.h
@@ -53,8 +53,8 @@ namespace Qt4ProjectManager {
 class Qt4Project;
 
 namespace Internal {
-
 class Qt4PriFileNode;
+class Qt4ProFileNode;
 
 class Qt4RunConfiguration : public ProjectExplorer::LocalApplicationRunConfiguration
 {
@@ -109,9 +109,10 @@ signals:
     void effectiveTargetInformationChanged();
 
 private slots:
-    void setCommandLineArguments(const QString &argumentsString);
+    void proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode *pro);
+    void setArguments(const QString &argumentsString);
     void setWorkingDirectory(const QString &workingDirectory);
-    void nameEdited(const QString&);
+    void setUserName(const QString&);
     void setRunMode(RunMode runMode);
 
 private:
@@ -152,11 +153,11 @@ protected:
     void showEvent(QShowEvent *event);
     void hideEvent(QHideEvent *event);
 private slots:
-    void setWorkingDirectory();
-    void resetWorkingDirectory();
-    void setCommandLineArguments(const QString &arguments);
+    void workDirectoryEdited();
+    void workingDirectoryReseted();
+    void argumentsEdited(const QString &arguments);
     void nameEdited(const QString &name);
-    void userChangesUpdated();
+    void userChangesEdited();
 
     void workingDirectoryChanged(const QString &workingDirectory);
     void commandLineArgumentsChanged(const QString &args);
@@ -169,7 +170,7 @@ private slots:
     void termToggled(bool);
     void usingDyldImageSuffixToggled(bool);
     void usingDyldImageSuffixChanged(bool);
-    void baseEnvironmentComboBoxChanged(int index);
+    void baseEnvironmentSelected(int index);
 
 private:
     void updateSummary();
diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp
index 633f1ee0699..2893b1fe102 100644
--- a/src/plugins/qt4projectmanager/qtversionmanager.cpp
+++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp
@@ -181,8 +181,9 @@ void QtVersionManager::addVersion(QtVersion *version)
 {
     QTC_ASSERT(version != 0, return);
     m_versions.append(version);
-    m_uniqueIdToIndex.insert(version->uniqueId(), m_versions.count() - 1);
-    emit qtVersionsChanged();
+    int uniqueId = version->uniqueId();
+    m_uniqueIdToIndex.insert(uniqueId, m_versions.count() - 1);
+    emit qtVersionsChanged(QList<int>() << uniqueId);
     writeVersionsIntoSettings();
 }
 
@@ -190,8 +191,9 @@ void QtVersionManager::removeVersion(QtVersion *version)
 {
     QTC_ASSERT(version != 0, return);
     m_versions.removeAll(version);
-    m_uniqueIdToIndex.remove(version->uniqueId());
-    emit qtVersionsChanged();
+    int uniqueId = version->uniqueId();
+    m_uniqueIdToIndex.remove(uniqueId);
+    emit qtVersionsChanged(QList<int>() << uniqueId);
     writeVersionsIntoSettings();
     delete version;
 }
@@ -378,21 +380,78 @@ QtVersion *QtVersionManager::defaultVersion() const
         return m_emptyVersion;
 }
 
+class SortByUniqueId
+{
+public:
+    bool operator()(QtVersion *a, QtVersion *b)
+    {
+        return a->uniqueId() < b->uniqueId();
+    }
+};
+
+bool QtVersionManager::equals(QtVersion *a, QtVersion *b)
+{
+    if (a->m_qmakeCommand != b->m_qmakeCommand)
+        return false;
+    if (a->m_id != b->m_id)
+        return false;
+    if (a->m_mingwDirectory != b->m_mingwDirectory
+        || a->m_msvcVersion != b->m_msvcVersion
+        || a->m_mwcDirectory != b->m_mwcDirectory)
+        return false;
+    return true;
+}
+
 void QtVersionManager::setNewQtVersions(QList<QtVersion *> newVersions, int newDefaultVersion)
 {
-    bool versionPathsChanged = m_versions.size() != newVersions.size();
-    if (!versionPathsChanged) {
-        for (int i = 0; i < m_versions.size(); ++i) {
-            if (m_versions.at(i)->qmakeCommand() != newVersions.at(i)->qmakeCommand()) {
-                versionPathsChanged = true;
-                break;
-            }
+    // We want to preserve the same order as in the settings dialog
+    // so we sort a copy
+    QList<QtVersion *> sortedNewVersions = newVersions;
+    SortByUniqueId sortByUniqueId;
+    qSort(sortedNewVersions.begin(), sortedNewVersions.end(), sortByUniqueId);
+    qSort(m_versions.begin(), m_versions.end(), sortByUniqueId);
+
+    QList<int> changedVersions;
+    // So we trying to find the minimal set of changed versions,
+    // iterate over both sorted list
+
+    // newVersions and oldVersions iterator
+    QList<QtVersion *>::const_iterator nit, nend, oit, oend;
+    nit = sortedNewVersions.constBegin();
+    nend = sortedNewVersions.constEnd();
+    oit = m_versions.constBegin();
+    oend = m_versions.constEnd();
+
+    while (nit != nend && oit != oend) {
+        int nid = (*nit)->uniqueId();
+        int oid = (*oit)->uniqueId();
+        if (nid < oid) {
+            changedVersions.push_back(nid);
+            ++nit;
+        } else if (oid < nid) {
+            changedVersions.push_back(oid);
+            ++oit;
+        } else {
+            if (!equals(*oit, *nit))
+                changedVersions.push_back(oid);
+            ++oit;
+            ++nit;
         }
     }
+
+    while (nit != nend) {
+        changedVersions.push_back((*nit)->uniqueId());
+    }
+
+    while (oit != oend) {
+        changedVersions.push_back((*oit)->uniqueId());
+    }
+
     qDeleteAll(m_versions);
     m_versions.clear();
     m_versions = newVersions;
-    if (versionPathsChanged)
+
+    if (!changedVersions.isEmpty())
         updateDocumentation();
     updateUniqueIdToIndexMap();
 
@@ -402,13 +461,13 @@ void QtVersionManager::setNewQtVersions(QList<QtVersion *> newVersions, int newD
         emitDefaultChanged = true;
     }
 
-    emit qtVersionsChanged();
-    if (emitDefaultChanged) {
-        emit defaultQtVersionChanged();
-    }
-
     updateExamples();
     writeVersionsIntoSettings();
+
+    if (!changedVersions.isEmpty())
+        emit qtVersionsChanged(changedVersions);
+    if (emitDefaultChanged)
+        emit defaultQtVersionChanged();
 }
 
 ///
diff --git a/src/plugins/qt4projectmanager/qtversionmanager.h b/src/plugins/qt4projectmanager/qtversionmanager.h
index 46268303168..5300ad9e0ac 100644
--- a/src/plugins/qt4projectmanager/qtversionmanager.h
+++ b/src/plugins/qt4projectmanager/qtversionmanager.h
@@ -214,12 +214,14 @@ public:
     static QString findQMakeBinaryFromMakefile(const QString &directory);
 signals:
     void defaultQtVersionChanged();
-    void qtVersionsChanged();
+    void qtVersionsChanged(const QList<int> &uniqueIds);
     void updateExamples(QString, QString, QString);
 
 private slots:
     void updateExamples();
 private:
+    // This function is really simplistic...
+    static bool equals(QtVersion *a, QtVersion *b);
     static QString findQMakeLine(const QString &directory);
     static QString trimLine(const QString line);
     static QStringList splitLine(const QString &line);
-- 
GitLab