forked from qt-creator/qt-creator
JsonWizard: Allow object or list of objects for "options"
This is compatible with the existing wizards and makes writing a wizard a tiny bit simpler and more consistent. Change-Id: I72c6f858f337552fe2495a16beff17cdf0cce66d Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -625,9 +625,12 @@ bool JsonWizardFactory::initialize(const QVariantMap &data, const QDir &baseDir,
|
||||
setFlags(flags);
|
||||
|
||||
// Options:
|
||||
QVariant optionValue = data.value(QLatin1String(OPTIONS_KEY));
|
||||
if (optionValue.type() == QVariant::List) {
|
||||
foreach (const QVariant &v, optionValue.toList()) {
|
||||
const QVariant optionValue = data.value(QLatin1String(OPTIONS_KEY));
|
||||
const QVariantList optionList = objectOrList(optionValue, errorMessage);
|
||||
if (optionList.isEmpty())
|
||||
return false;
|
||||
|
||||
foreach (const QVariant &v, optionList) {
|
||||
if (v.type() != QVariant::Map) {
|
||||
*errorMessage = tr("List element of \"options\" is not an object.");
|
||||
return false;
|
||||
@@ -645,10 +648,6 @@ bool JsonWizardFactory::initialize(const QVariantMap &data, const QDir &baseDir,
|
||||
}
|
||||
m_options.insert(key, value);
|
||||
}
|
||||
} else if (optionValue.isValid()) {
|
||||
*errorMessage = tr("Value for \"options\" is not a list.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user