From b9d2fd8eac11ddf1f41762be73453e765ae945f0 Mon Sep 17 00:00:00 2001
From: Tobias Hunger <tobias.hunger@theqtcompany.com>
Date: Fri, 24 Oct 2014 17:28:30 +0200
Subject: [PATCH] JsonWizard: Allow enableing/disableing of pages from the Json
 file

Change-Id: Ic21f0f176f2a82577eaf4a72fbb01c011e1ada2b
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
---
 .../jsonwizard/jsonwizardfactory.cpp               | 14 +++++++++++---
 .../projectexplorer/jsonwizard/jsonwizardfactory.h |  1 +
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp
index f730819b1a4..419ec171cb6 100644
--- a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp
+++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp
@@ -82,6 +82,7 @@ static const char DATA_KEY[] = "data";
 static const char PAGE_SUB_TITLE_KEY[] = "trSubTitle";
 static const char PAGE_SHORT_TITLE_KEY[] = "trShortTitle";
 static const char PAGE_INDEX_KEY[] = "index";
+static const char PAGE_ENABLED_EXPRESSION_KEY[] = "enabled";
 static const char OPTIONS_KEY[] = "options";
 static const char PLATFORM_INDEPENDENT_KEY[] = "platformIndependent";
 
@@ -185,8 +186,10 @@ static JsonWizardFactory::Page parsePage(const QVariant &value, QString *errorMe
         return p;
     }
 
-    QVariant varVal = data.value(QLatin1String(DATA_KEY));
-    if (!factory->validateData(typeId, varVal, errorMessage))
+    QVariant enabled = data.value(QLatin1String(PAGE_ENABLED_EXPRESSION_KEY), true);
+
+    QVariant subData = data.value(QLatin1String(DATA_KEY));
+    if (!factory->validateData(typeId, subData, errorMessage))
         return p;
 
     p.typeId = typeId;
@@ -194,7 +197,8 @@ static JsonWizardFactory::Page parsePage(const QVariant &value, QString *errorMe
     p.subTitle = subTitle;
     p.shortTitle = shortTitle;
     p.index = index;
-    p.data = varVal;
+    p.data = subData;
+    p.enabled = enabled;
 
     return p;
 }
@@ -392,6 +396,10 @@ void JsonWizardFactory::runWizard(const QString &path, QWidget *parent, const QS
 
     foreach (const Page &data, m_pages) {
         QTC_ASSERT(data.isValid(), continue);
+
+        if (!JsonWizard::boolFromVariant(data.enabled, wizard.expander()))
+            continue;
+
         JsonWizardPageFactory *factory = Utils::findOr(s_pageFactories, 0,
                                                        [&data](JsonWizardPageFactory *f) {
                                                             return f->canCreate(data.typeId);
diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.h b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.h
index d708ada1c41..e4da75e2545 100644
--- a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.h
+++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.h
@@ -76,6 +76,7 @@ public:
         QString shortTitle;
         int index; // page index in the wizard
         Core::Id typeId;
+        QVariant enabled;
         QVariant data;
     };
 
-- 
GitLab