Commit 8211e6a0 authored by Tobias Hunger's avatar Tobias Hunger

JsonWizard: Simplify handling of bools via JS

Change-Id: I5381e83f6714886b7bf8cbcb859e1dd3b115a6c3
Reviewed-by: default avatarAlessandro Portale <alessandro.portale@theqtcompany.com>
parent 94dc3569
......@@ -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'}"
}
},
{
......
......@@ -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'}"
}
},
{
......
......@@ -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'}"
}
]
}
......
......@@ -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();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment