JsonWizard: Clean up page factories

Improve error reporting and remove useless setup code.

Change-Id: I97e9fba0aa1cf6bb2cba26f70d46d1ba87bbd192
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
Tobias Hunger
2014-10-15 15:08:15 +02:00
parent 72f0b52555
commit 06d7d58c88

View File

@@ -134,11 +134,11 @@ ProjectPageFactory::ProjectPageFactory()
Utils::WizardPage *ProjectPageFactory::create(JsonWizard *wizard, Core::Id typeId, const QVariant &data)
{
Q_UNUSED(wizard);
Q_UNUSED(data);
QTC_ASSERT(canCreate(typeId), return 0);
JsonProjectPage *page = new JsonProjectPage;
page->setPath(wizard->value(QStringLiteral("GivenPath")).toString());
return page;
}
@@ -148,7 +148,13 @@ bool ProjectPageFactory::validateData(Core::Id typeId, const QVariant &data, QSt
Q_UNUSED(errorMessage);
QTC_ASSERT(canCreate(typeId), return false);
return data.isNull();
if (!data.isNull() && (data.type() != QVariant::Map || !data.toMap().isEmpty())) {
*errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard",
"\"data\" for a \"Project\" page needs to be unset or an empty object.");
return false;
}
return true;
}
// --------------------------------------------------------------------