summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorTim Jenssen <tim.jenssen@theqtcompany.com>2015-10-22 15:32:42 +0200
committerTim Jenssen <tim.jenssen@theqtcompany.com>2015-10-22 13:53:30 +0000
commite6d038364fe44d96b93fa2f5e40334e7ecad13c2 (patch)
treea6fbeecc7cc30218fbc63abb09af0cb3a6fdb3d9 /src/plugins
parent59ac67c0bb6b2fa999bce830e0ba590ef58fa0ed (diff)
downloadqt-creator-e6d038364fe44d96b93fa2f5e40334e7ecad13c2.tar.gz
add projectNameValidator to JsonProjectPage
Change-Id: Ie9851a8f16d494ef2a6fafdcc83b5b47bcd0e021 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/projectexplorer/jsonwizard/jsonwizardpagefactory_p.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardpagefactory_p.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardpagefactory_p.cpp
index 963ae3c4be..211214c527 100644
--- a/src/plugins/projectexplorer/jsonwizard/jsonwizardpagefactory_p.cpp
+++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardpagefactory_p.cpp
@@ -199,6 +199,8 @@ bool KitsPageFactory::validateData(Core::Id typeId, const QVariant &data, QStrin
// ProjectPageFactory:
// --------------------------------------------------------------------
+static const char KEY_PROJECT_NAME_VALIDATOR[] = "projectNameValidator";
+
ProjectPageFactory::ProjectPageFactory()
{
setTypeIdsSuffix(QLatin1String("Project"));
@@ -216,6 +218,13 @@ Utils::WizardPage *ProjectPageFactory::create(JsonWizard *wizard, Core::Id typeI
QString description
= tmp.value(QLatin1String("trDescription"), QLatin1String("%{trDescription}")).toString();
page->setDescription(wizard->expander()->expand(description));
+ QString projectNameValidator
+ = tmp.value(QLatin1String(KEY_PROJECT_NAME_VALIDATOR)).toString();
+ if (!projectNameValidator.isEmpty()) {
+ QRegularExpression regularExpression(projectNameValidator);
+ if (regularExpression.isValid())
+ page->setProjectNameRegularExpression(regularExpression);
+ }
return page;
}
@@ -230,6 +239,19 @@ bool ProjectPageFactory::validateData(Core::Id typeId, const QVariant &data, QSt
"\"data\" must be empty or a JSON object for \"Project\" pages.");
return false;
}
+ QVariantMap tmp = data.toMap();
+ QString projectNameValidator
+ = tmp.value(QLatin1String(KEY_PROJECT_NAME_VALIDATOR)).toString();
+ if (!projectNameValidator.isNull()) {
+ QRegularExpression regularExpression(projectNameValidator);
+ if (!regularExpression.isValid()) {
+ *errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard",
+ "Invalid regular expression \"%1\" in \"%2\". %3").arg(
+ projectNameValidator, QLatin1String(KEY_PROJECT_NAME_VALIDATOR), regularExpression.errorString());
+ return false;
+ }
+ }
+
return true;
}