From 87347bb064f81f9f7727bf8800b0964d57d34c22 Mon Sep 17 00:00:00 2001
From: Tobias Hunger <tobias.hunger@digia.com>
Date: Tue, 29 Jan 2013 18:01:16 +0100
Subject: [PATCH] Move settings over from the runconfigurations into the
 environmentaspect

Change-Id: I97ecc00b53d4c6f8f36c1f5f3178712f689747d9
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
---
 .../projectexplorer/settingsaccessor.cpp      | 44 ++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)

diff --git a/src/plugins/projectexplorer/settingsaccessor.cpp b/src/plugins/projectexplorer/settingsaccessor.cpp
index 19549f9ded4..33054f3566f 100644
--- a/src/plugins/projectexplorer/settingsaccessor.cpp
+++ b/src/plugins/projectexplorer/settingsaccessor.cpp
@@ -341,7 +341,7 @@ public:
     QVariantMap update(Project *project, const QVariantMap &map);
 };
 
-// Version 10 introduces disabling buildsteps, and handles upgrading custom process steps
+// Version 11 introduces kits
 class Version11Handler : public UserFileVersionHandler
 {
 public:
@@ -386,6 +386,24 @@ private:
     QHash<Kit *, QVariantMap> m_targets;
 };
 
+// Version 12 reflects the move of environment settings from CMake/Qt4/Custom into
+// LocalApplicationRunConfiguration
+class Version12Handler : public UserFileVersionHandler
+{
+public:
+    int userFileVersion() const
+    {
+         return 12;
+    }
+
+    QString displayUserFileVersion() const
+    {
+        return QLatin1String("2.7pre1");
+    }
+
+    QVariantMap update(Project *project, const QVariantMap &map);
+};
+
 } // namespace
 
 //
@@ -2687,3 +2705,27 @@ void Version11Handler::parseToolChainFile()
         m_toolChainExtras.insert(id, ToolChainExtraData(mkspec, debugger));
     }
 }
+
+QVariantMap Version12Handler::update(Project *project, const QVariantMap &map)
+{
+    QVariantMap result;
+    QMapIterator<QString, QVariant> it(map);
+    while (it.hasNext()) {
+        it.next();
+        if (it.value().type() == QVariant::Map)
+            result.insert(it.key(), update(project, it.value().toMap()));
+        else if (it.key() == QLatin1String("CMakeProjectManager.CMakeRunConfiguration.UserEnvironmentChanges")
+                 || it.key() == QLatin1String("ProjectExplorer.CustomExecutableRunConfiguration.UserEnvironmentChanges")
+                 || it.key() == QLatin1String("Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges")
+                 || it.key() == QLatin1String("Qt4ProjectManager.MaemoRunConfiguration.UserEnvironmentChanges"))
+            result.insert(QLatin1String("PE.UserEnvironmentChanges"), it.value());
+        else if (it.key() == QLatin1String("CMakeProjectManager.BaseEnvironmentBase")
+                 || it.key() == QLatin1String("ProjectExplorer.CustomExecutableRunConfiguration.BaseEnvironmentBase")
+                 || it.key() == QLatin1String("ProjectExplorer.CustomExecutableRunConfiguration.BaseEnvironmentBase")
+                 || it.key() == QLatin1String("Qt4ProjectManager.MaemoRunConfiguration.BaseEnvironmentBase"))
+            result.insert(QLatin1String("PE.BaseEnvironmentBase"), it.value());
+        else
+            result.insert(it.key(), it.value());
+    }
+    return result;
+}
-- 
GitLab