From cf5232b27a13573d061d24ec5ef4b3d6af6c512b Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 29 Apr 2019 15:45:27 +0200 Subject: [PATCH] Fix passing of kit IDs for subproject to JSON wizards The list of preselected kits in case of sub projects was passed in a format not compatible with wizard variables (QList, but only QString and QStringList are supported). This fixes the visibility of the Kit selection page of the "Empty qmake Project" and "Auto Test Project" wizards when triggered from "Add New Subproject" from the project tree's context menu. Change-Id: Ica7305825d6323697c9b0788a9634f3d806b9d50 Reviewed-by: Christian Kandeler --- .../projectexplorer/projectexplorer.cpp | 13 +++++-- .../qmakeprojectmanager/wizards/qtwizard.cpp | 37 ++++++++++++------- .../wizards/subdirsprojectwizard.cpp | 3 +- 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 160b0cb65eb..3d619eab829 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -3327,8 +3327,10 @@ void ProjectExplorerPluginPrivate::addNewFile() map.insert(QLatin1String(Constants::PREFERRED_PROJECT_NODE), QVariant::fromValue(static_cast(currentNode))); map.insert(Constants::PREFERRED_PROJECT_NODE_PATH, currentNode->filePath().toString()); if (Project *p = ProjectTree::currentProject()) { - QList profileIds = Utils::transform(p->targets(), &Target::id); - map.insert(QLatin1String(Constants::PROJECT_KIT_IDS), QVariant::fromValue(profileIds)); + const QStringList profileIds = Utils::transform(p->targets(), [](const Target *t) { + return t->id().toString(); + }); + map.insert(QLatin1String(Constants::PROJECT_KIT_IDS), profileIds); map.insert(Constants::PROJECT_POINTER, QVariant::fromValue(static_cast(p))); } ICore::showNewItemDialog(ProjectExplorerPlugin::tr("New File", "Title of dialog"), @@ -3352,8 +3354,11 @@ void ProjectExplorerPluginPrivate::addNewSubproject() Project *project = ProjectTree::currentProject(); Core::Id projectType; if (project) { - QList profileIds = Utils::transform(ProjectTree::currentProject()->targets(), &Target::id); - map.insert(QLatin1String(Constants::PROJECT_KIT_IDS), QVariant::fromValue(profileIds)); + const QStringList profileIds = Utils::transform(ProjectTree::currentProject()->targets(), + [](const Target *t) { + return t->id().toString(); + }); + map.insert(QLatin1String(Constants::PROJECT_KIT_IDS), profileIds); projectType = project->id(); } diff --git a/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp b/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp index 9ed1939f1ac..9a4b97a0b76 100644 --- a/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp +++ b/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp @@ -140,25 +140,34 @@ bool CustomQmakeProjectWizard::postGenerateFiles(const QWizard *w, const Core::G } // ----------------- BaseQmakeProjectWizardDialog -BaseQmakeProjectWizardDialog::BaseQmakeProjectWizardDialog(const Core::BaseFileWizardFactory *factory, - bool showModulesPage, QWidget *parent, - const Core::WizardDialogParameters ¶meters) : - ProjectExplorer::BaseProjectWizardDialog(factory, parent, parameters), - m_profileIds(parameters.extraValues().value(QLatin1String(ProjectExplorer::Constants::PROJECT_KIT_IDS)) - .value >()) +BaseQmakeProjectWizardDialog::BaseQmakeProjectWizardDialog( + const Core::BaseFileWizardFactory *factory, + bool showModulesPage, + QWidget *parent, + const Core::WizardDialogParameters ¶meters) + : ProjectExplorer::BaseProjectWizardDialog(factory, parent, parameters) { + m_profileIds = Utils::transform(parameters.extraValues() + .value(ProjectExplorer::Constants::PROJECT_KIT_IDS) + .toStringList(), + &Core::Id::fromString); + init(showModulesPage); } -BaseQmakeProjectWizardDialog::BaseQmakeProjectWizardDialog(const Core::BaseFileWizardFactory *factory, - bool showModulesPage, - Utils::ProjectIntroPage *introPage, - int introId, QWidget *parent, - const Core::WizardDialogParameters ¶meters) : - ProjectExplorer::BaseProjectWizardDialog(factory, introPage, introId, parent, parameters), - m_profileIds(parameters.extraValues().value(QLatin1String(ProjectExplorer::Constants::PROJECT_KIT_IDS)) - .value >()) +BaseQmakeProjectWizardDialog::BaseQmakeProjectWizardDialog( + const Core::BaseFileWizardFactory *factory, + bool showModulesPage, + Utils::ProjectIntroPage *introPage, + int introId, + QWidget *parent, + const Core::WizardDialogParameters ¶meters) + : ProjectExplorer::BaseProjectWizardDialog(factory, introPage, introId, parent, parameters) { + m_profileIds = Utils::transform(parameters.extraValues() + .value(ProjectExplorer::Constants::PROJECT_KIT_IDS) + .toStringList(), + &Core::Id::fromString); init(showModulesPage); } diff --git a/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizard.cpp b/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizard.cpp index 306a2438a4b..7c2f57420af 100644 --- a/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizard.cpp +++ b/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizard.cpp @@ -89,7 +89,8 @@ bool SubdirsProjectWizard::postGenerateFiles(const QWizard *w, const Core::Gener const QString profileName = Core::BaseFileWizardFactory::buildFileName(projectPath, params.fileName, profileSuffix()); QVariantMap map; map.insert(QLatin1String(ProjectExplorer::Constants::PREFERRED_PROJECT_NODE), profileName); - map.insert(QLatin1String(ProjectExplorer::Constants::PROJECT_KIT_IDS), QVariant::fromValue(wizard->selectedKits())); + map.insert(QLatin1String(ProjectExplorer::Constants::PROJECT_KIT_IDS), + Utils::transform(wizard->selectedKits(), &Core::Id::toString)); IWizardFactory::requestNewItemDialog(tr("New Subproject", "Title of dialog"), Utils::filtered(Core::IWizardFactory::allWizardFactories(), [](Core::IWizardFactory *f) {