JsonWizard: Add a way to check for existence of a variable

Change-Id: Ia1368334156c33ca270b5cc7d946efcdb7b635a8
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
Tobias Hunger
2014-10-24 17:27:24 +02:00
parent d5b4dd65d3
commit e8d02209e8

View File

@@ -54,6 +54,13 @@ JsonWizard::JsonWizard(QWidget *parent) :
}
return v.isValid();
});
m_expander.registerPrefix("Exists", tr("Check whether a variable exists. Returns \"true\" if it does and an empty string if not."),
[this](const QString &value) -> QString
{
const QString key = QString::fromLatin1("%{") + value + QLatin1Char('}');
return m_expander.expand(key) == key ? QString() : QLatin1String("true");
});
}
JsonWizard::~JsonWizard()