Commit d5e7262e authored by Tobias Hunger's avatar Tobias Hunger

Wizards: Better selection of project wizards to show

E.g. only show wizards that can create qmake projects when
contining after a SUBDIR-project wizard.

Change-Id: Ib189b1efa479f5b986fdec8658715245e2f2db40
Reviewed-by: default avatarNiels Weber <niels.weber@theqtcompany.com>
Reviewed-by: default avatarTim Jenssen <tim.jenssen@theqtcompany.com>
parent 9e16554e
......@@ -203,19 +203,6 @@ private:
NewItemDialogData s_reopenData;
}
/* A utility to find all wizards supporting a view mode and matching a predicate */
QList<IWizardFactory*> findWizardFactories(const std::function<bool(IWizardFactory*)> &predicate)
{
const QList<IWizardFactory *> allFactories = IWizardFactory::allWizardFactories();
QList<IWizardFactory *> rc;
auto cend = allFactories.constEnd();
for (auto it = allFactories.constBegin(); it != cend; ++it) {
if (predicate(*it))
rc.push_back(*it);
}
return rc;
}
static Id actionId(const IWizardFactory *factory)
{
return factory->id().withPrefix("Wizard.Impl.");
......@@ -263,12 +250,6 @@ QList<IWizardFactory*> IWizardFactory::allWizardFactories()
return s_allFactories;
}
// Utility to find all registered wizards of a certain kind
QList<IWizardFactory*> IWizardFactory::wizardFactoriesOfKind(WizardKind kind)
{
return findWizardFactories([kind](IWizardFactory *f) { return f->kind() == kind; });
}
QString IWizardFactory::runPath(const QString &defaultPath)
{
QString path = defaultPath;
......
......@@ -100,8 +100,6 @@ public:
// Utility to find all registered wizards
static QList<IWizardFactory*> allWizardFactories();
// Utility to find all registered wizards of a certain kind
static QList<IWizardFactory*> wizardFactoriesOfKind(WizardKind kind);
static QSet<Id> allAvailablePlatforms();
static QString displayNameForPlatform(Id i);
......
......@@ -1559,7 +1559,8 @@ void ProjectExplorerPluginPrivate::newProject()
qDebug() << "ProjectExplorerPlugin::newProject";
ICore::showNewItemDialog(tr("New Project", "Title of dialog"),
IWizardFactory::wizardFactoriesOfKind(IWizardFactory::ProjectWizard));
Utils::filtered(IWizardFactory::allWizardFactories(),
[](IWizardFactory *f) { return !f->supportedProjectTypes().isEmpty(); }));
updateActions();
}
......@@ -3098,8 +3099,9 @@ void ProjectExplorerPluginPrivate::addNewFile()
map.insert(QLatin1String(Constants::PROJECT_KIT_IDS), QVariant::fromValue(profileIds));
}
ICore::showNewItemDialog(tr("New File", "Title of dialog"),
IWizardFactory::wizardFactoriesOfKind(IWizardFactory::FileWizard),
location, map);
Utils::filtered(IWizardFactory::allWizardFactories(),
[](IWizardFactory *f) { return f->supportedPlatforms().isEmpty(); }),
location, map);
}
void ProjectExplorerPluginPrivate::addNewSubproject()
......@@ -3113,14 +3115,20 @@ void ProjectExplorerPluginPrivate::addNewSubproject()
currentNode).contains(AddSubProject)) {
QVariantMap map;
map.insert(QLatin1String(Constants::PREFERRED_PROJECT_NODE), QVariant::fromValue(currentNode));
if (ProjectTree::currentProject()) {
Project *project = ProjectTree::currentProject();
Core::Id projectType;
if (project) {
QList<Id> profileIds = Utils::transform(ProjectTree::currentProject()->targets(), &Target::id);
map.insert(QLatin1String(Constants::PROJECT_KIT_IDS), QVariant::fromValue(profileIds));
projectType = project->id();
}
ICore::showNewItemDialog(tr("New Subproject", "Title of dialog"),
IWizardFactory::wizardFactoriesOfKind(IWizardFactory::ProjectWizard),
location, map);
Utils::filtered(IWizardFactory::allWizardFactories(),
[projectType](IWizardFactory *f) {
return projectType.isValid() ? f->supportedPlatforms().contains(projectType)
: !f->supportedPlatforms().isEmpty(); }),
location, map);
}
}
......
......@@ -252,7 +252,8 @@ void ProjectWelcomePage::reloadWelcomeScreenData()
void ProjectWelcomePage::newProject()
{
Core::ICore::showNewItemDialog(tr("New Project"),
Core::IWizardFactory::wizardFactoriesOfKind(Core::IWizardFactory::ProjectWizard));
Utils::filtered(Core::IWizardFactory::allWizardFactories(),
[](Core::IWizardFactory *f) { return !f->supportedProjectTypes().isEmpty(); }));
}
void ProjectWelcomePage::openProject()
......
......@@ -31,11 +31,14 @@
#include "subdirsprojectwizard.h"
#include "subdirsprojectwizarddialog.h"
#include "../qmakeprojectmanagerconstants.h"
#include <projectexplorer/projectexplorerconstants.h>
#include <coreplugin/icore.h>
#include <qtsupport/qtsupportconstants.h>
#include <utils/algorithm.h>
#include <QCoreApplication>
namespace QmakeProjectManager {
......@@ -93,7 +96,10 @@ bool SubdirsProjectWizard::postGenerateFiles(const QWizard *w, const Core::Gener
map.insert(QLatin1String(ProjectExplorer::Constants::PREFERRED_PROJECT_NODE), profileName);
map.insert(QLatin1String(ProjectExplorer::Constants::PROJECT_KIT_IDS), QVariant::fromValue(wizard->selectedKits()));
IWizardFactory::requestNewItemDialog(tr("New Subproject", "Title of dialog"),
Core::IWizardFactory::wizardFactoriesOfKind(Core::IWizardFactory::ProjectWizard),
Utils::filtered(Core::IWizardFactory::allWizardFactories(),
[](Core::IWizardFactory *f) {
return f->supportedPlatforms().contains(Constants::QMAKEPROJECT_ID);
}),
wizard->parameters().projectPath(), map);
} else {
return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment