summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@theqtcompany.com>2015-05-08 17:20:18 +0200
committerTobias Hunger <tobias.hunger@theqtcompany.com>2015-05-11 13:33:10 +0000
commit8211e6a0847f3dab892faa82d155c256216fe91a (patch)
tree329d7aba4408a6428bff0c71bf9093d5cbb2394a
parent94dc35694a3374ef785a6765730dfc1d9401075f (diff)
downloadqt-creator-8211e6a0847f3dab892faa82d155c256216fe91a.tar.gz
JsonWizard: Simplify handling of bools via JS
Change-Id: I5381e83f6714886b7bf8cbcb859e1dd3b115a6c3 Reviewed-by: Alessandro Portale <alessandro.portale@theqtcompany.com>
-rw-r--r--share/qtcreator/templates/wizards/classes/cpp/wizard.json14
-rw-r--r--share/qtcreator/templates/wizards/classes/python/wizard.json8
-rw-r--r--share/qtcreator/templates/wizards/projects/qmake/empty/wizard.json4
-rw-r--r--src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp6
4 files changed, 17 insertions, 15 deletions
diff --git a/share/qtcreator/templates/wizards/classes/cpp/wizard.json b/share/qtcreator/templates/wizards/classes/cpp/wizard.json
index dd2915cbfe..eb62b0d44a 100644
--- a/share/qtcreator/templates/wizards/classes/cpp/wizard.json
+++ b/share/qtcreator/templates/wizards/classes/cpp/wizard.json
@@ -16,7 +16,7 @@
{ "key": "SrcPath", "value": "%{Path}/%{SrcFileName}" },
{ "key": "CN", "value": "%{JS: Cpp.className('%{Class}')}" },
{ "key": "Base", "value": "%{JS: ( '%{BaseCB}' === '' ) ? '%{BaseEdit}' : '%{BaseCB}'}" },
- { "key": "isQObject", "value": "%{JS: ('%{Base}' === 'QObject' || '%{Base}' === 'QWidget' || '%{Base}' === 'QMainWindow' || '%{Base}' === 'QDeclarativeItem' || '%{Base}' === 'QQuickItem' ) ? 'yes' : ''}" },
+ { "key": "isQObject", "value": "%{JS: '%{Base}' === 'QObject' || '%{Base}' === 'QWidget' || '%{Base}' === 'QMainWindow' || '%{Base}' === 'QDeclarativeItem' || '%{Base}' === 'QQuickItem' }" },
{ "key": "GUARD", "value": "%{JS: Cpp.classToHeaderGuard('%{Class}', '%{JS: Util.preferredSuffix('text/x-c++hdr')}')}" },
{ "key": "SharedDataInit", "value": "%{JS: ('%{IncludeQSharedData}') ? 'data(new %{CN}Data)' : '' }" }
],
@@ -49,7 +49,7 @@
{
"name": "BaseEdit",
"type": "LineEdit",
- "enabled": "%{JS: ( '%{BaseCB}' === '' ) ? 'yes' : ''}",
+ "enabled": "%{JS: '%{BaseCB}' === ''}",
"mandatory": false,
"data":
{
@@ -71,7 +71,7 @@
{
"checkedValue": "QObject",
"uncheckedValue": "",
- "checked": "%{JS: ('%{BaseCB}' === 'QObject' ) ? 'yes' : ''}"
+ "checked": "%{JS: '%{BaseCB}' === 'QObject'}"
}
},
{
@@ -82,7 +82,7 @@
{
"checkedValue": "QWidget",
"uncheckedValue": "",
- "checked": "%{JS: ('%{BaseCB}' === 'QWidget') ? 'yes' : ''}"
+ "checked": "%{JS: '%{BaseCB}' === 'QWidget'}"
}
},
{
@@ -93,7 +93,7 @@
{
"checkedValue": "QMainWindow",
"uncheckedValue": "",
- "checked": "%{JS: ('%{BaseCB}' === 'QMainWindow') ? 'yes' : ''}"
+ "checked": "%{JS: '%{BaseCB}' === 'QMainWindow'}"
}
},
{
@@ -104,7 +104,7 @@
{
"checkedValue": "QDeclarativeItem",
"uncheckedValue": "",
- "checked": "%{JS: ('%{BaseCB}' === 'QDeclarativeItem') ? 'yes' : ''}"
+ "checked": "%{JS: '%{BaseCB}' === 'QDeclarativeItem'}"
}
},
{
@@ -115,7 +115,7 @@
{
"checkedValue": "QQuickItem",
"uncheckedValue": "",
- "checked": "%{JS: ('%{BaseCB}' === 'QQuickItem') ? 'yes' : ''}"
+ "checked": "%{JS: '%{BaseCB}' === 'QQuickItem'}"
}
},
{
diff --git a/share/qtcreator/templates/wizards/classes/python/wizard.json b/share/qtcreator/templates/wizards/classes/python/wizard.json
index 625bceb530..7df9bccb4b 100644
--- a/share/qtcreator/templates/wizards/classes/python/wizard.json
+++ b/share/qtcreator/templates/wizards/classes/python/wizard.json
@@ -43,7 +43,7 @@
{
"name": "BaseEdit",
"type": "LineEdit",
- "enabled": "%{JS: ( '%{BaseCB}' === '' ) ? 'yes' : ''}",
+ "enabled": "%{JS: '%{BaseCB}' === ''}",
"mandatory": false,
"data": { "trText": "%{BaseCB}" }
},
@@ -63,7 +63,7 @@
{
"checkedValue": "QtCore",
"uncheckedValue": "",
- "checked": "%{JS: ('%{Base}' !== '' ) ? 'yes' : ''}"
+ "checked": "%{JS: '%{Base}' !== ''}"
}
},
{
@@ -74,7 +74,7 @@
{
"checkedValue": "QtWidgets",
"uncheckedValue": "",
- "checked": "%{JS: ('%{Base}' === 'QWidget') ? 'yes' : ''}"
+ "checked": "%{JS: '%{Base}' === 'QWidget'}"
}
},
{
@@ -85,7 +85,7 @@
{
"checkedValue": "QtQuick",
"uncheckedValue": "",
- "checked": "%{JS: ('%{Base}' === 'QQuickItem') ? 'yes' : ''}"
+ "checked": "%{JS: '%{Base}' === 'QQuickItem'}"
}
},
{
diff --git a/share/qtcreator/templates/wizards/projects/qmake/empty/wizard.json b/share/qtcreator/templates/wizards/projects/qmake/empty/wizard.json
index 02aed92f77..d6493f7de3 100644
--- a/share/qtcreator/templates/wizards/projects/qmake/empty/wizard.json
+++ b/share/qtcreator/templates/wizards/projects/qmake/empty/wizard.json
@@ -12,7 +12,7 @@
"options":
[
{ "key": "ProFileName", "value": "%{JS: Util.fileName('%{ProjectDirectory}/%{ProjectName}', 'pro')}" },
- { "key": "IsTopLevelProject", "value": "%{JS: ('%{Exists:ProjectExplorer.Profile.Ids}') ? '' : 'yes'}" }
+ { "key": "IsTopLevelProject", "value": "%{JS: !'%{Exists:ProjectExplorer.Profile.Ids}'}" }
],
"pages":
@@ -50,7 +50,7 @@
{
"source": "../git.ignore",
"target": "%{ProjectDirectory}/.gitignore",
- "condition": "%{JS: ('%{VersionControl}%{IsSubproject}' === 'G.Git') ? 'yes' : ''}"
+ "condition": "%{JS: '%{VersionControl}%{IsSubproject}' === 'G.Git'}"
}
]
}
diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp
index d651ca86ef..b718058de9 100644
--- a/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp
+++ b/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp
@@ -155,8 +155,10 @@ QVariant JsonWizard::value(const QString &n) const
bool JsonWizard::boolFromVariant(const QVariant &v, Utils::MacroExpander *expander)
{
- if (v.type() == QVariant::String)
- return !expander->expand(v.toString()).isEmpty();
+ if (v.type() == QVariant::String) {
+ const QString tmp = expander->expand(v.toString());
+ return !(tmp.isEmpty() || tmp == QLatin1String("false"));
+ }
return v.toBool();
}