forked from qt-creator/qt-creator
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:
@@ -134,11 +134,11 @@ ProjectPageFactory::ProjectPageFactory()
|
|||||||
|
|
||||||
Utils::WizardPage *ProjectPageFactory::create(JsonWizard *wizard, Core::Id typeId, const QVariant &data)
|
Utils::WizardPage *ProjectPageFactory::create(JsonWizard *wizard, Core::Id typeId, const QVariant &data)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(wizard);
|
||||||
Q_UNUSED(data);
|
Q_UNUSED(data);
|
||||||
QTC_ASSERT(canCreate(typeId), return 0);
|
QTC_ASSERT(canCreate(typeId), return 0);
|
||||||
|
|
||||||
JsonProjectPage *page = new JsonProjectPage;
|
JsonProjectPage *page = new JsonProjectPage;
|
||||||
page->setPath(wizard->value(QStringLiteral("GivenPath")).toString());
|
|
||||||
|
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,13 @@ bool ProjectPageFactory::validateData(Core::Id typeId, const QVariant &data, QSt
|
|||||||
Q_UNUSED(errorMessage);
|
Q_UNUSED(errorMessage);
|
||||||
|
|
||||||
QTC_ASSERT(canCreate(typeId), return false);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user