ProjectExplorer: Use ids in RunConfigFactory:: setSupportedProjectType

More similar to what build/deploy uses.

Change-Id: Icf8bd7031d00a6e2831f8c1f3b1bdcaa8bf259b4
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
hjk
2017-12-08 14:50:57 +01:00
parent 7f7aa6034d
commit 4a66cae854
13 changed files with 39 additions and 31 deletions
@@ -238,7 +238,7 @@ CMakeRunConfigurationFactory::CMakeRunConfigurationFactory(QObject *parent) :
{
setObjectName("CMakeRunConfigurationFactory");
registerRunConfiguration<CMakeRunConfiguration>(CMAKE_RC_PREFIX);
setSupportedProjectType<CMakeProject>();
addSupportedProjectType(CMakeProjectManager::Constants::CMAKEPROJECT_ID);
}
QList<QString> CMakeRunConfigurationFactory::availableBuildTargets(Target *parent, CreationMode) const
+2 -2
View File
@@ -30,11 +30,11 @@
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/target.h>
#include <qmakeprojectmanager/qmakenodes.h>
#include <qmakeprojectmanager/qmakeproject.h>
#include <qmakeprojectmanager/qmakeprojectmanagerconstants.h>
using namespace ProjectExplorer;
using namespace QmakeProjectManager;
@@ -48,7 +48,7 @@ IosRunConfigurationFactory::IosRunConfigurationFactory(QObject *parent)
setObjectName("IosRunConfigurationFactory");
registerRunConfiguration<IosRunConfiguration>(Constants::IOS_RC_ID_PREFIX);
setSupportedTargetDeviceTypes({Constants::IOS_DEVICE_TYPE, Constants::IOS_SIMULATOR_TYPE});
setSupportedProjectType<QmakeProject>();
addSupportedProjectType(QmakeProjectManager::Constants::QMAKEPROJECT_ID);
}
bool IosRunConfigurationFactory::canCreateHelper(Target *parent, const QString &buildTarget) const
@@ -39,7 +39,7 @@ namespace Nim {
NimRunConfigurationFactory::NimRunConfigurationFactory()
{
registerRunConfiguration<NimRunConfiguration>(Constants::C_NIMRUNCONFIGURATION_ID);
setSupportedProjectType<NimProject>();
addSupportedProjectType(Constants::C_NIMPROJECT_ID);
}
QList<QString> NimRunConfigurationFactory::availableBuildTargets(Target *, CreationMode) const
@@ -475,17 +475,26 @@ void IRunConfigurationFactory::setSupportedTargetDeviceTypes(const QList<Core::I
m_supportedTargetDeviceTypes = ids;
}
void IRunConfigurationFactory::addSupportedProjectType(Core::Id id)
{
m_supportedProjectTypes.append(id);
}
bool IRunConfigurationFactory::canHandle(Target *target) const
{
if (m_projectTypeChecker && !m_projectTypeChecker(target->project()))
const Project *project = target->project();
Kit *kit = target->kit();
if (!project->supportsKit(kit))
return false;
if (!target->project()->supportsKit(target->kit()))
if (!m_supportedProjectTypes.isEmpty())
if (!m_supportedProjectTypes.contains(project->id()))
return false;
if (!m_supportedTargetDeviceTypes.isEmpty())
if (!m_supportedTargetDeviceTypes.contains(
DeviceTypeKitInformation::deviceTypeId(target->kit())))
DeviceTypeKitInformation::deviceTypeId(kit)))
return false;
return true;
@@ -334,20 +334,13 @@ protected:
m_runConfigBaseId = runConfigBaseId;
}
using ProjectTypeChecker = std::function<bool(Project *)>;
template <class ProjectType>
void setSupportedProjectType()
{
m_projectTypeChecker = [](Project *p) { return qobject_cast<ProjectType *>(p) != nullptr; };
}
void addSupportedProjectType(Core::Id id);
void setSupportedTargetDeviceTypes(const QList<Core::Id> &ids);
private:
RunConfigurationCreator m_creator;
Core::Id m_runConfigBaseId;
ProjectTypeChecker m_projectTypeChecker;
QList<Core::Id> m_supportedProjectTypes;
QList<Core::Id> m_supportedTargetDeviceTypes;
};
@@ -262,7 +262,7 @@ public:
{
setObjectName("PythonRunConfigurationFactory");
registerRunConfiguration<PythonRunConfiguration>(PythonRunConfigurationPrefix);
setSupportedProjectType<PythonProject>();
addSupportedProjectType(PythonProjectId);
}
QList<QString> availableBuildTargets(Target *parent, CreationMode mode) const override
@@ -25,6 +25,7 @@
#include "qbsrunconfiguration.h"
#include "qbsprojectmanagerconstants.h"
#include "qbsdeployconfigurationfactory.h"
#include "qbsinstallstep.h"
#include "qbsproject.h"
@@ -352,8 +353,8 @@ QbsRunConfigurationFactory::QbsRunConfigurationFactory(QObject *parent) :
{
setObjectName("QbsRunConfigurationFactory");
registerRunConfiguration<QbsRunConfiguration>(QBS_RC_PREFIX);
setSupportedProjectType<QbsProject>();
setSupportedTargetDeviceTypes({Constants::DESKTOP_DEVICE_TYPE});
addSupportedProjectType(Constants::PROJECT_ID);
setSupportedTargetDeviceTypes({ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE});
}
bool QbsRunConfigurationFactory::canCreateHelper(Target *parent, const QString &buildTarget) const
@@ -31,9 +31,11 @@
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h>
#include <debugger/debuggerconstants.h>
#include <qmakeprojectmanager/qmakeproject.h>
#include <qmakeprojectmanager/qmakenodes.h>
#include <qmakeprojectmanager/qmakeproject.h>
#include <qmakeprojectmanager/qmakeprojectmanagerconstants.h>
#include <qtsupport/qtkitinformation.h>
#include <qtsupport/qtsupportconstants.h>
@@ -50,7 +52,7 @@ QmakeAndroidRunConfigurationFactory::QmakeAndroidRunConfigurationFactory(QObject
: IRunConfigurationFactory(parent)
{
registerRunConfiguration<QmakeAndroidRunConfiguration>(ANDROID_RC_ID_PREFIX);
setSupportedProjectType<QmakeProject>();
addSupportedProjectType(QmakeProjectManager::Constants::QMAKEPROJECT_ID);
}
QString QmakeAndroidRunConfigurationFactory::displayNameForBuildTarget(const QString &buildTarget) const
@@ -25,9 +25,10 @@
#include "desktopqmakerunconfiguration.h"
#include "qmakebuildconfiguration.h"
#include "qmakenodes.h"
#include "qmakeproject.h"
#include "qmakebuildconfiguration.h"
#include "qmakeprojectmanagerconstants.h"
#include <coreplugin/variablechooser.h>
#include <projectexplorer/localenvironmentaspect.h>
@@ -441,8 +442,8 @@ DesktopQmakeRunConfigurationFactory::DesktopQmakeRunConfigurationFactory(QObject
{
setObjectName("DesktopQmakeRunConfigurationFactory");
registerRunConfiguration<DesktopQmakeRunConfiguration>(QMAKE_RC_PREFIX);
setSupportedProjectType<QmakeProject>();
setSupportedTargetDeviceTypes({Constants::DESKTOP_DEVICE_TYPE});
addSupportedProjectType(QmakeProjectManager::Constants::PROJECT_ID);
setSupportedTargetDeviceTypes({ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE});
}
bool DesktopQmakeRunConfigurationFactory::canCreateHelper(Target *parent, const QString &buildTarget) const
+2 -1
View File
@@ -28,6 +28,7 @@
#include "fileformat/qmlprojectitem.h"
#include "qmlprojectrunconfiguration.h"
#include "qmlprojectconstants.h"
#include "qmlprojectmanagerconstants.h"
#include "qmlprojectnodes.h"
#include <coreplugin/icontext.h>
@@ -57,7 +58,7 @@ QmlProject::QmlProject(const Utils::FileName &fileName) :
Project(QString::fromLatin1(Constants::QMLPROJECT_MIMETYPE), fileName,
[this]() { refreshProjectFile(); })
{
setId("QmlProjectManager.QmlProject");
setId(QmlProjectManager::Constants::QML_PROJECT_ID);
setProjectContext(Context(QmlProjectManager::Constants::PROJECTCONTEXT));
setProjectLanguages(Context(ProjectExplorer::Constants::QMLJS_LANGUAGE_ID));
setDisplayName(fileName.toFileInfo().completeBaseName());
@@ -30,6 +30,7 @@
namespace QmlProjectManager {
namespace Constants {
const char QML_PROJECT_ID[] = "QmlProjectManager.QmlProject";
const char QML_SCENE_RC_ID[] = "QmlProjectManager.QmlRunConfiguration.QmlScene";
const char QML_VIEWER_ARGUMENTS_KEY[] = "QmlProjectManager.QmlRunConfiguration.QDeclarativeViewerArguments";
const char QML_VIEWER_TARGET_DISPLAY_NAME[] = "QML Viewer";
@@ -36,7 +36,7 @@ QmlProjectRunConfigurationFactory::QmlProjectRunConfigurationFactory(QObject *pa
{
setObjectName("QmlProjectRunConfigurationFactory");
registerRunConfiguration<QmlProjectRunConfiguration>(Constants::QML_SCENE_RC_ID);
setSupportedProjectType<QmlProject>();
addSupportedProjectType(QmlProjectManager::Constants::QML_PROJECT_ID);
setSupportedTargetDeviceTypes({ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE});
}
+3 -3
View File
@@ -28,11 +28,11 @@
#include "winrtruncontrol.h"
#include "winrtconstants.h"
#include <projectexplorer/kit.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/project.h>
#include <projectexplorer/target.h>
#include <qmakeprojectmanager/qmakeproject.h>
#include <qmakeprojectmanager/qmakeprojectmanagerconstants.h>
using namespace ProjectExplorer;
using QmakeProjectManager::QmakeProject;
@@ -44,7 +44,7 @@ namespace Internal {
WinRtRunConfigurationFactory::WinRtRunConfigurationFactory()
{
registerRunConfiguration<WinRtRunConfiguration>(Constants::WINRT_RC_PREFIX);
setSupportedProjectType<QmakeProject>();
addSupportedProjectType(QmakeProjectManager::Constants::QMAKEPROJECT_ID);
setSupportedTargetDeviceTypes({Constants::WINRT_DEVICE_TYPE_LOCAL,
Constants::WINRT_DEVICE_TYPE_PHONE,
Constants::WINRT_DEVICE_TYPE_EMULATOR});