forked from qt-creator/qt-creator
ProjectExplorer: Register createes' base id in RunConfigurationFactory
This shifts the resposibility of creation/splitting of RunConfiguration ids into what are essentially "type ids" and "build targets" to the base implementation, possibly opening the path of abandoning the mangled ids in favor of explicitly storing their constituent parts. Take advantage of base id split in RunConfigurations for availableIds /displayNameForId and for canCreate/canRestore/canClone. Change-Id: I19fefb32757407ab5053a2ae0e5a79438659f6ec Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io> Reviewed-by: Filippo Cucchetto <filippocucchetto@gmail.com>
This commit is contained in:
@@ -45,48 +45,26 @@ BareMetalRunConfigurationFactory::BareMetalRunConfigurationFactory(QObject *pare
|
|||||||
IRunConfigurationFactory(parent)
|
IRunConfigurationFactory(parent)
|
||||||
{
|
{
|
||||||
setObjectName("BareMetalRunConfigurationFactory");
|
setObjectName("BareMetalRunConfigurationFactory");
|
||||||
registerRunConfiguration<BareMetalRunConfiguration>();
|
registerRunConfiguration<BareMetalRunConfiguration>(BareMetalRunConfiguration::IdPrefix);
|
||||||
setSupportedTargetDeviceTypes({BareMetal::Constants::BareMetalOsType});
|
setSupportedTargetDeviceTypes({BareMetal::Constants::BareMetalOsType});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BareMetalRunConfigurationFactory::canCreate(Target *parent, Core::Id id) const
|
bool BareMetalRunConfigurationFactory::canCreateHelper(Target *parent, const QString &buildTarget) const
|
||||||
{
|
{
|
||||||
if (!canHandle(parent))
|
const QString targetName = QFileInfo(buildTarget).fileName();
|
||||||
return false;
|
return parent->applicationTargets().hasTarget(targetName);
|
||||||
const QString targetName = BareMetalRunConfiguration::targetNameFromId(id);
|
|
||||||
return !parent->applicationTargets().targetFilePath(targetName).isEmpty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BareMetalRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
|
QList<QString> BareMetalRunConfigurationFactory::availableBuildTargets(Target *parent, CreationMode) const
|
||||||
{
|
{
|
||||||
if (!canHandle(parent))
|
return Utils::transform(parent->applicationTargets().list, [](const BuildTargetInfo &bti) {
|
||||||
return false;
|
return QString(bti.projectFilePath.toString() + '/' + bti.targetName);
|
||||||
return idFromMap(map).name().startsWith(BareMetalRunConfiguration::IdPrefix);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BareMetalRunConfigurationFactory::canClone(Target *parent, RunConfiguration *source) const
|
QString BareMetalRunConfigurationFactory::displayNameForBuildTarget(const QString &buildTarget) const
|
||||||
{
|
{
|
||||||
auto bmrc = qobject_cast<BareMetalRunConfiguration *>(source);
|
return tr("%1 (on GDB server or hardware debugger)").arg(QFileInfo(buildTarget).fileName());
|
||||||
return bmrc && canCreate(parent, source->id());
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<Core::Id> BareMetalRunConfigurationFactory::availableCreationIds(Target *parent, CreationMode mode) const
|
|
||||||
{
|
|
||||||
Q_UNUSED(mode)
|
|
||||||
QList<Core::Id> result;
|
|
||||||
if (!canHandle(parent))
|
|
||||||
return result;
|
|
||||||
|
|
||||||
const Core::Id base = Core::Id(BareMetalRunConfiguration::IdPrefix);
|
|
||||||
foreach (const BuildTargetInfo &bti, parent->applicationTargets().list)
|
|
||||||
result << base.withSuffix(bti.projectFilePath.toString() + QLatin1Char('/') + bti.targetName);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString BareMetalRunConfigurationFactory::displayNameForId(Core::Id id) const
|
|
||||||
{
|
|
||||||
return tr("%1 (on GDB server or hardware debugger)")
|
|
||||||
.arg(BareMetalRunConfiguration::targetNameFromId(id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -96,43 +74,17 @@ BareMetalCustomRunConfigurationFactory::BareMetalCustomRunConfigurationFactory(Q
|
|||||||
IRunConfigurationFactory(parent)
|
IRunConfigurationFactory(parent)
|
||||||
{
|
{
|
||||||
setObjectName("BareMetalCustomRunConfigurationFactory");
|
setObjectName("BareMetalCustomRunConfigurationFactory");
|
||||||
registerRunConfiguration<BareMetalCustomRunConfiguration>();
|
registerRunConfiguration<BareMetalCustomRunConfiguration>
|
||||||
|
(BareMetalCustomRunConfiguration::runConfigId());
|
||||||
setSupportedTargetDeviceTypes({BareMetal::Constants::BareMetalOsType});
|
setSupportedTargetDeviceTypes({BareMetal::Constants::BareMetalOsType});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BareMetalCustomRunConfigurationFactory::canCreate(Target *parent, Core::Id id) const
|
QList<QString> BareMetalCustomRunConfigurationFactory::availableBuildTargets(Target *, CreationMode) const
|
||||||
{
|
{
|
||||||
if (!canHandle(parent))
|
return {QString()};
|
||||||
return false;
|
|
||||||
return id == BareMetalCustomRunConfiguration::runConfigId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BareMetalCustomRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
|
QString BareMetalCustomRunConfigurationFactory::displayNameForBuildTarget(const QString &) const
|
||||||
{
|
|
||||||
if (!canHandle(parent))
|
|
||||||
return false;
|
|
||||||
const Core::Id id = idFromMap(map);
|
|
||||||
return id == BareMetalCustomRunConfiguration::runConfigId();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BareMetalCustomRunConfigurationFactory::canClone(Target *parent, RunConfiguration *source) const
|
|
||||||
{
|
|
||||||
auto bmrc = qobject_cast<BareMetalCustomRunConfiguration *>(source);
|
|
||||||
return bmrc && canCreate(parent, source->id());
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<Core::Id> BareMetalCustomRunConfigurationFactory::availableCreationIds(Target *parent, CreationMode mode) const
|
|
||||||
{
|
|
||||||
Q_UNUSED(mode)
|
|
||||||
QList<Core::Id> result;
|
|
||||||
if (!canHandle(parent))
|
|
||||||
return result;
|
|
||||||
|
|
||||||
result << BareMetalCustomRunConfiguration::runConfigId();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString BareMetalCustomRunConfigurationFactory::displayNameForId(Core::Id) const
|
|
||||||
{
|
{
|
||||||
return BareMetalCustomRunConfiguration::runConfigDefaultDisplayName();
|
return BareMetalCustomRunConfiguration::runConfigDefaultDisplayName();
|
||||||
}
|
}
|
||||||
|
@@ -37,12 +37,10 @@ class BareMetalRunConfigurationFactory : public ProjectExplorer::IRunConfigurati
|
|||||||
public:
|
public:
|
||||||
explicit BareMetalRunConfigurationFactory(QObject *parent = 0);
|
explicit BareMetalRunConfigurationFactory(QObject *parent = 0);
|
||||||
|
|
||||||
QString displayNameForId(Core::Id id) const override;
|
QList<QString> availableBuildTargets(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
||||||
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
QString displayNameForBuildTarget(const QString &buildTarget) const override;
|
||||||
|
|
||||||
bool canCreate(ProjectExplorer::Target *parent, Core::Id id) const override;
|
bool canCreateHelper(ProjectExplorer::Target *parent, const QString &suffix) const override;
|
||||||
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const override;
|
|
||||||
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class BareMetalCustomRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory
|
class BareMetalCustomRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory
|
||||||
@@ -52,12 +50,8 @@ class BareMetalCustomRunConfigurationFactory : public ProjectExplorer::IRunConfi
|
|||||||
public:
|
public:
|
||||||
explicit BareMetalCustomRunConfigurationFactory(QObject *parent = 0);
|
explicit BareMetalCustomRunConfigurationFactory(QObject *parent = 0);
|
||||||
|
|
||||||
QString displayNameForId(Core::Id id) const override;
|
QList<QString> availableBuildTargets(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
||||||
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
QString displayNameForBuildTarget(const QString &buildTarget) const override;
|
||||||
|
|
||||||
bool canCreate(ProjectExplorer::Target *parent, Core::Id id) const override;
|
|
||||||
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const override;
|
|
||||||
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -232,57 +232,18 @@ CMakeRunConfigurationFactory::CMakeRunConfigurationFactory(QObject *parent) :
|
|||||||
IRunConfigurationFactory(parent)
|
IRunConfigurationFactory(parent)
|
||||||
{
|
{
|
||||||
setObjectName("CMakeRunConfigurationFactory");
|
setObjectName("CMakeRunConfigurationFactory");
|
||||||
registerRunConfiguration<CMakeRunConfiguration>();
|
registerRunConfiguration<CMakeRunConfiguration>(CMAKE_RC_PREFIX);
|
||||||
setSupportedProjectType<CMakeProject>();
|
setSupportedProjectType<CMakeProject>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// used to show the list of possible additons to a project, returns a list of ids
|
QList<QString> CMakeRunConfigurationFactory::availableBuildTargets(Target *parent, CreationMode) const
|
||||||
QList<Core::Id> CMakeRunConfigurationFactory::availableCreationIds(Target *parent, CreationMode mode) const
|
|
||||||
{
|
{
|
||||||
Q_UNUSED(mode)
|
|
||||||
if (!canHandle(parent))
|
|
||||||
return QList<Core::Id>();
|
|
||||||
CMakeProject *project = static_cast<CMakeProject *>(parent->project());
|
CMakeProject *project = static_cast<CMakeProject *>(parent->project());
|
||||||
QList<Core::Id> allIds;
|
return project->buildTargetTitles(true);
|
||||||
foreach (const QString &buildTarget, project->buildTargetTitles(true))
|
|
||||||
allIds << idFromBuildTarget(buildTarget);
|
|
||||||
return allIds;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// used to translate the ids to names to display to the user
|
bool CMakeRunConfigurationFactory::canCreateHelper(Target *parent, const QString &buildTarget) const
|
||||||
QString CMakeRunConfigurationFactory::displayNameForId(Core::Id id) const
|
|
||||||
{
|
{
|
||||||
return buildTargetFromId(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CMakeRunConfigurationFactory::canCreate(Target *parent, Core::Id id) const
|
|
||||||
{
|
|
||||||
if (!canHandle(parent))
|
|
||||||
return false;
|
|
||||||
CMakeProject *project = static_cast<CMakeProject *>(parent->project());
|
CMakeProject *project = static_cast<CMakeProject *>(parent->project());
|
||||||
return project->hasBuildTarget(buildTargetFromId(id));
|
return project->hasBuildTarget(buildTarget);
|
||||||
}
|
|
||||||
|
|
||||||
bool CMakeRunConfigurationFactory::canClone(Target *parent, RunConfiguration *source) const
|
|
||||||
{
|
|
||||||
if (!canHandle(parent))
|
|
||||||
return false;
|
|
||||||
return source->id().name().startsWith(CMAKE_RC_PREFIX);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CMakeRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
|
|
||||||
{
|
|
||||||
if (!qobject_cast<CMakeProject *>(parent->project()))
|
|
||||||
return false;
|
|
||||||
return idFromMap(map).name().startsWith(CMAKE_RC_PREFIX);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CMakeRunConfigurationFactory::buildTargetFromId(Core::Id id)
|
|
||||||
{
|
|
||||||
return id.suffixAfter(CMAKE_RC_PREFIX);
|
|
||||||
}
|
|
||||||
|
|
||||||
Core::Id CMakeRunConfigurationFactory::idFromBuildTarget(const QString &target)
|
|
||||||
{
|
|
||||||
return Core::Id(CMAKE_RC_PREFIX).withSuffix(target);
|
|
||||||
}
|
}
|
||||||
|
@@ -85,15 +85,8 @@ class CMakeRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFa
|
|||||||
public:
|
public:
|
||||||
explicit CMakeRunConfigurationFactory(QObject *parent = 0);
|
explicit CMakeRunConfigurationFactory(QObject *parent = 0);
|
||||||
|
|
||||||
bool canCreate(ProjectExplorer::Target *parent, Core::Id id) const override;
|
QList<QString> availableBuildTargets(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
||||||
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const override;
|
bool canCreateHelper(ProjectExplorer::Target *parent, const QString &suffix) const override;
|
||||||
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *product) const override;
|
|
||||||
|
|
||||||
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
|
||||||
QString displayNameForId(Core::Id id) const override;
|
|
||||||
|
|
||||||
static Core::Id idFromBuildTarget(const QString &target);
|
|
||||||
static QString buildTargetFromId(Core::Id id);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -47,44 +47,26 @@ IosRunConfigurationFactory::IosRunConfigurationFactory(QObject *parent)
|
|||||||
: QmakeRunConfigurationFactory(parent)
|
: QmakeRunConfigurationFactory(parent)
|
||||||
{
|
{
|
||||||
setObjectName("IosRunConfigurationFactory");
|
setObjectName("IosRunConfigurationFactory");
|
||||||
registerRunConfiguration<IosRunConfiguration>();
|
registerRunConfiguration<IosRunConfiguration>(Constants::IOS_RC_ID_PREFIX);
|
||||||
setSupportedProjectType<QmakeProject>();
|
setSupportedProjectType<QmakeProject>();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IosRunConfigurationFactory::canCreate(Target *parent, Core::Id id) const
|
bool IosRunConfigurationFactory::canCreateHelper(Target *parent, const QString &buildTarget) const
|
||||||
{
|
{
|
||||||
if (!canHandle(parent))
|
return availableBuildTargets(parent, UserCreate).contains(buildTarget);
|
||||||
return false;
|
|
||||||
return availableCreationIds(parent).contains(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IosRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
|
QList<QString> IosRunConfigurationFactory::availableBuildTargets(Target *parent, CreationMode mode) const
|
||||||
{
|
{
|
||||||
if (!canHandle(parent))
|
|
||||||
return false;
|
|
||||||
QString id = ProjectExplorer::idFromMap(map).toString();
|
|
||||||
return id.startsWith(Ios::Constants::IOS_RC_ID_PREFIX);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IosRunConfigurationFactory::canClone(Target *parent, RunConfiguration *source) const
|
|
||||||
{
|
|
||||||
return canCreate(parent, source->id());
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<Core::Id> IosRunConfigurationFactory::availableCreationIds(Target *parent, CreationMode mode) const
|
|
||||||
{
|
|
||||||
if (!IosManager::supportsIos(parent))
|
|
||||||
return QList<Core::Id>();
|
|
||||||
|
|
||||||
auto project = static_cast<QmakeProject *>(parent->project());
|
auto project = static_cast<QmakeProject *>(parent->project());
|
||||||
return project->creationIds(Constants::IOS_RC_ID_PREFIX, mode, {ProjectType::ApplicationTemplate,
|
return project->buildTargets(mode, {ProjectType::ApplicationTemplate,
|
||||||
ProjectType::SharedLibraryTemplate,
|
ProjectType::SharedLibraryTemplate,
|
||||||
ProjectType::AuxTemplate});
|
ProjectType::AuxTemplate});
|
||||||
}
|
}
|
||||||
|
|
||||||
QString IosRunConfigurationFactory::displayNameForId(Core::Id id) const
|
QString IosRunConfigurationFactory::displayNameForBuildTarget(const QString &buildTarget) const
|
||||||
{
|
{
|
||||||
return IosRunConfiguration::pathFromId(id).toFileInfo().completeBaseName();
|
return QFileInfo(buildTarget).completeBaseName();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IosRunConfigurationFactory::canHandle(Target *t) const
|
bool IosRunConfigurationFactory::canHandle(Target *t) const
|
||||||
|
@@ -43,17 +43,12 @@ class IosRunConfigurationFactory : public QmakeProjectManager::QmakeRunConfigura
|
|||||||
public:
|
public:
|
||||||
explicit IosRunConfigurationFactory(QObject *parent = 0);
|
explicit IosRunConfigurationFactory(QObject *parent = 0);
|
||||||
|
|
||||||
QString displayNameForId(Core::Id id) const override;
|
QList<QString> availableBuildTargets(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
||||||
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode = UserCreate) const override;
|
QString displayNameForBuildTarget(const QString &buildTarget) const override;
|
||||||
|
|
||||||
bool canCreate(ProjectExplorer::Target *parent, Core::Id id) const override;
|
|
||||||
|
|
||||||
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const override;
|
|
||||||
|
|
||||||
bool canClone(ProjectExplorer::Target *parent,
|
|
||||||
ProjectExplorer::RunConfiguration *source) const override;
|
|
||||||
|
|
||||||
bool canHandle(ProjectExplorer::Target *t) const override;
|
bool canHandle(ProjectExplorer::Target *t) const override;
|
||||||
|
bool canCreateHelper(ProjectExplorer::Target *parent, const QString &suffix) const override;
|
||||||
|
|
||||||
QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Target *t,
|
QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Target *t,
|
||||||
const ProjectExplorer::Node *n
|
const ProjectExplorer::Node *n
|
||||||
) override;
|
) override;
|
||||||
|
@@ -38,43 +38,18 @@ namespace Nim {
|
|||||||
|
|
||||||
NimRunConfigurationFactory::NimRunConfigurationFactory()
|
NimRunConfigurationFactory::NimRunConfigurationFactory()
|
||||||
{
|
{
|
||||||
registerRunConfiguration<NimRunConfiguration>();
|
registerRunConfiguration<NimRunConfiguration>(Constants::C_NIMRUNCONFIGURATION_ID);
|
||||||
setSupportedProjectType<NimProject>();
|
setSupportedProjectType<NimProject>();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Core::Id> NimRunConfigurationFactory::availableCreationIds(Target *parent,
|
QList<QString> NimRunConfigurationFactory::availableBuildTargets(Target *, CreationMode) const
|
||||||
IRunConfigurationFactory::CreationMode mode) const
|
|
||||||
{
|
{
|
||||||
Q_UNUSED(mode);
|
return {QString()};
|
||||||
QList<Core::Id> result;
|
|
||||||
if (canHandle(parent))
|
|
||||||
result.append(Constants::C_NIMRUNCONFIGURATION_ID);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString NimRunConfigurationFactory::displayNameForId(Core::Id id) const
|
QString NimRunConfigurationFactory::displayNameForBuildTarget(const QString &buildTarget) const
|
||||||
{
|
{
|
||||||
return id.toString() + QStringLiteral("-TempRunConf");
|
return buildTarget + "-TempRunConf";
|
||||||
}
|
|
||||||
|
|
||||||
bool NimRunConfigurationFactory::canCreate(Target *parent, Core::Id id) const
|
|
||||||
{
|
|
||||||
Q_UNUSED(id);
|
|
||||||
return canHandle(parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NimRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
|
|
||||||
{
|
|
||||||
Q_UNUSED(parent);
|
|
||||||
Q_UNUSED(map);
|
|
||||||
return canHandle(parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NimRunConfigurationFactory::canClone(Target *parent, RunConfiguration *product) const
|
|
||||||
{
|
|
||||||
QTC_ASSERT(parent, return false);
|
|
||||||
QTC_ASSERT(product, return false);
|
|
||||||
return canHandle(parent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -34,13 +34,8 @@ class NimRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFact
|
|||||||
public:
|
public:
|
||||||
NimRunConfigurationFactory();
|
NimRunConfigurationFactory();
|
||||||
|
|
||||||
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
QList<QString> availableBuildTargets(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
||||||
|
QString displayNameForBuildTarget(const QString &) const override;
|
||||||
QString displayNameForId(Core::Id id) const override;
|
|
||||||
|
|
||||||
bool canCreate(ProjectExplorer::Target *parent, Core::Id id) const override;
|
|
||||||
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const override;
|
|
||||||
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *product) const override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -316,44 +316,17 @@ CustomExecutableRunConfigurationFactory::CustomExecutableRunConfigurationFactory
|
|||||||
IRunConfigurationFactory(parent)
|
IRunConfigurationFactory(parent)
|
||||||
{
|
{
|
||||||
setObjectName("CustomExecutableRunConfigurationFactory");
|
setObjectName("CustomExecutableRunConfigurationFactory");
|
||||||
registerRunConfiguration<CustomExecutableRunConfiguration>();
|
registerRunConfiguration<CustomExecutableRunConfiguration>(CUSTOM_EXECUTABLE_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CustomExecutableRunConfigurationFactory::canCreate(Target *parent, Core::Id id) const
|
QList<QString> CustomExecutableRunConfigurationFactory::availableBuildTargets(Target *, CreationMode) const
|
||||||
{
|
{
|
||||||
if (!canHandle(parent))
|
return {QString()};
|
||||||
return false;
|
|
||||||
return id == CUSTOM_EXECUTABLE_ID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CustomExecutableRunConfigurationFactory::canRestore(Target *parent,
|
QString CustomExecutableRunConfigurationFactory::displayNameForBuildTarget(const QString &) const
|
||||||
const QVariantMap &map) const
|
|
||||||
{
|
{
|
||||||
if (!canHandle(parent))
|
return tr("Custom Executable");
|
||||||
return false;
|
|
||||||
Core::Id id(idFromMap(map));
|
|
||||||
return canCreate(parent, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CustomExecutableRunConfigurationFactory::canClone(Target *parent,
|
|
||||||
RunConfiguration *source) const
|
|
||||||
{
|
|
||||||
return canCreate(parent, source->id());
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<Core::Id> CustomExecutableRunConfigurationFactory::availableCreationIds(Target *parent, CreationMode mode) const
|
|
||||||
{
|
|
||||||
Q_UNUSED(mode)
|
|
||||||
if (!canHandle(parent))
|
|
||||||
return QList<Core::Id>();
|
|
||||||
return QList<Core::Id>() << Core::Id(CUSTOM_EXECUTABLE_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CustomExecutableRunConfigurationFactory::displayNameForId(Core::Id id) const
|
|
||||||
{
|
|
||||||
if (id == CUSTOM_EXECUTABLE_ID)
|
|
||||||
return tr("Custom Executable");
|
|
||||||
return QString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
@@ -95,12 +95,8 @@ class CustomExecutableRunConfigurationFactory : public IRunConfigurationFactory
|
|||||||
public:
|
public:
|
||||||
explicit CustomExecutableRunConfigurationFactory(QObject *parent = 0);
|
explicit CustomExecutableRunConfigurationFactory(QObject *parent = 0);
|
||||||
|
|
||||||
QList<Core::Id> availableCreationIds(Target *parent, CreationMode mode) const override;
|
QList<QString> availableBuildTargets(Target *parent, CreationMode mode) const override;
|
||||||
QString displayNameForId(Core::Id id) const override;
|
QString displayNameForBuildTarget(const QString &) const override;
|
||||||
|
|
||||||
bool canCreate(Target *parent, Core::Id id) const override;
|
|
||||||
bool canRestore(Target *parent, const QVariantMap &map) const override;
|
|
||||||
bool canClone(Target *parent, RunConfiguration *product) const override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
@@ -450,6 +450,25 @@ IRunConfigurationFactory::IRunConfigurationFactory(QObject *parent) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<Core::Id> IRunConfigurationFactory::availableCreationIds(Target *parent, CreationMode mode) const
|
||||||
|
{
|
||||||
|
if (!canHandle(parent))
|
||||||
|
return {};
|
||||||
|
return Utils::transform(availableBuildTargets(parent, mode), [this](const QString &suffix) {
|
||||||
|
return m_runConfigBaseId.withSuffix(suffix);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
QString IRunConfigurationFactory::displayNameForId(Core::Id id) const
|
||||||
|
{
|
||||||
|
return displayNameForBuildTarget(id.suffixAfter(m_runConfigBaseId));
|
||||||
|
}
|
||||||
|
|
||||||
|
QString IRunConfigurationFactory::displayNameForBuildTarget(const QString &buildTarget) const
|
||||||
|
{
|
||||||
|
return buildTarget;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Specifies a list of device types for which this RunConfigurationFactory
|
Specifies a list of device types for which this RunConfigurationFactory
|
||||||
can create RunConfiguration.
|
can create RunConfiguration.
|
||||||
@@ -477,6 +496,20 @@ bool IRunConfigurationFactory::canHandle(Target *target) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IRunConfigurationFactory::canCreateHelper(Target *, const QString &) const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IRunConfigurationFactory::canCreate(Target *parent, Core::Id id) const
|
||||||
|
{
|
||||||
|
if (!canHandle(parent))
|
||||||
|
return false;
|
||||||
|
if (!id.name().startsWith(m_runConfigBaseId.name()))
|
||||||
|
return false;
|
||||||
|
return canCreateHelper(parent, id.suffixAfter(m_runConfigBaseId));
|
||||||
|
}
|
||||||
|
|
||||||
RunConfiguration *IRunConfigurationFactory::create(Target *parent, Core::Id id)
|
RunConfiguration *IRunConfigurationFactory::create(Target *parent, Core::Id id)
|
||||||
{
|
{
|
||||||
if (!canCreate(parent, id))
|
if (!canCreate(parent, id))
|
||||||
@@ -489,6 +522,21 @@ RunConfiguration *IRunConfigurationFactory::create(Target *parent, Core::Id id)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IRunConfigurationFactory::canCloneHelper(Target *, RunConfiguration *) const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IRunConfigurationFactory::canClone(Target *parent, RunConfiguration *product) const
|
||||||
|
{
|
||||||
|
if (!canHandle(parent))
|
||||||
|
return false;
|
||||||
|
const Core::Id id = product->id();
|
||||||
|
if (!id.name().startsWith(m_runConfigBaseId.name()))
|
||||||
|
return false;
|
||||||
|
return canCloneHelper(parent, product);
|
||||||
|
}
|
||||||
|
|
||||||
RunConfiguration *IRunConfigurationFactory::restore(Target *parent, const QVariantMap &map)
|
RunConfiguration *IRunConfigurationFactory::restore(Target *parent, const QVariantMap &map)
|
||||||
{
|
{
|
||||||
if (!canRestore(parent, map))
|
if (!canRestore(parent, map))
|
||||||
@@ -504,6 +552,14 @@ RunConfiguration *IRunConfigurationFactory::restore(Target *parent, const QVaria
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
|
||||||
|
{
|
||||||
|
if (!canHandle(parent))
|
||||||
|
return false;
|
||||||
|
const Core::Id id = idFromMap(map);
|
||||||
|
return id.name().startsWith(m_runConfigBaseId.name());
|
||||||
|
}
|
||||||
|
|
||||||
RunConfiguration *IRunConfigurationFactory::clone(Target *parent, RunConfiguration *product)
|
RunConfiguration *IRunConfigurationFactory::clone(Target *parent, RunConfiguration *product)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_creator, return nullptr);
|
QTC_ASSERT(m_creator, return nullptr);
|
||||||
|
@@ -285,15 +285,16 @@ public:
|
|||||||
explicit IRunConfigurationFactory(QObject *parent = nullptr);
|
explicit IRunConfigurationFactory(QObject *parent = nullptr);
|
||||||
|
|
||||||
enum CreationMode {UserCreate, AutoCreate};
|
enum CreationMode {UserCreate, AutoCreate};
|
||||||
virtual QList<Core::Id> availableCreationIds(Target *parent, CreationMode mode = UserCreate) const = 0;
|
QList<Core::Id> availableCreationIds(Target *parent, CreationMode mode = UserCreate) const;
|
||||||
virtual QString displayNameForId(Core::Id id) const = 0;
|
QString displayNameForId(Core::Id id) const;
|
||||||
|
|
||||||
virtual bool canHandle(Target *target) const;
|
virtual bool canHandle(Target *target) const;
|
||||||
virtual bool canCreate(Target *parent, Core::Id id) const = 0;
|
|
||||||
|
bool canCreate(Target *parent, Core::Id id) const;
|
||||||
RunConfiguration *create(Target *parent, Core::Id id);
|
RunConfiguration *create(Target *parent, Core::Id id);
|
||||||
virtual bool canRestore(Target *parent, const QVariantMap &map) const = 0;
|
bool canRestore(Target *parent, const QVariantMap &map) const;
|
||||||
RunConfiguration *restore(Target *parent, const QVariantMap &map);
|
RunConfiguration *restore(Target *parent, const QVariantMap &map);
|
||||||
virtual bool canClone(Target *parent, RunConfiguration *product) const = 0;
|
bool canClone(Target *parent, RunConfiguration *product) const;
|
||||||
RunConfiguration *clone(Target *parent, RunConfiguration *product);
|
RunConfiguration *clone(Target *parent, RunConfiguration *product);
|
||||||
|
|
||||||
static IRunConfigurationFactory *find(Target *parent, const QVariantMap &map);
|
static IRunConfigurationFactory *find(Target *parent, const QVariantMap &map);
|
||||||
@@ -304,12 +305,19 @@ signals:
|
|||||||
void availableCreationIdsChanged();
|
void availableCreationIdsChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual QList<QString> availableBuildTargets(Target *parent, CreationMode mode = UserCreate) const = 0;
|
||||||
|
virtual QString displayNameForBuildTarget(const QString &buildTarget) const;
|
||||||
|
|
||||||
|
virtual bool canCreateHelper(Target *parent, const QString &buildTarget) const;
|
||||||
|
virtual bool canCloneHelper(Target *parent, RunConfiguration *product) const;
|
||||||
|
|
||||||
using RunConfigurationCreator = std::function<RunConfiguration *(Target *)>;
|
using RunConfigurationCreator = std::function<RunConfiguration *(Target *)>;
|
||||||
|
|
||||||
template <class RunConfig>
|
template <class RunConfig>
|
||||||
void registerRunConfiguration()
|
void registerRunConfiguration(Core::Id runConfigBaseId)
|
||||||
{
|
{
|
||||||
m_creator = [](Target *t) -> RunConfiguration * { return new RunConfig(t); };
|
m_creator = [](Target *t) -> RunConfiguration * { return new RunConfig(t); };
|
||||||
|
m_runConfigBaseId = runConfigBaseId;
|
||||||
}
|
}
|
||||||
|
|
||||||
using ProjectTypeChecker = std::function<bool(Project *)>;
|
using ProjectTypeChecker = std::function<bool(Project *)>;
|
||||||
@@ -324,6 +332,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
RunConfigurationCreator m_creator;
|
RunConfigurationCreator m_creator;
|
||||||
|
Core::Id m_runConfigBaseId;
|
||||||
ProjectTypeChecker m_projectTypeChecker;
|
ProjectTypeChecker m_projectTypeChecker;
|
||||||
QList<Core::Id> m_supportedTargetDeviceTypes;
|
QList<Core::Id> m_supportedTargetDeviceTypes;
|
||||||
};
|
};
|
||||||
|
@@ -84,11 +84,6 @@ static QString scriptFromId(Core::Id id)
|
|||||||
return id.suffixAfter(PythonRunConfigurationPrefix);
|
return id.suffixAfter(PythonRunConfigurationPrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Core::Id idFromScript(const QString &target)
|
|
||||||
{
|
|
||||||
return Core::Id(PythonRunConfigurationPrefix).withSuffix(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
class PythonProject : public Project
|
class PythonProject : public Project
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -279,52 +274,26 @@ public:
|
|||||||
PythonRunConfigurationFactory()
|
PythonRunConfigurationFactory()
|
||||||
{
|
{
|
||||||
setObjectName("PythonRunConfigurationFactory");
|
setObjectName("PythonRunConfigurationFactory");
|
||||||
registerRunConfiguration<PythonRunConfiguration>();
|
registerRunConfiguration<PythonRunConfiguration>(PythonRunConfigurationPrefix);
|
||||||
setSupportedProjectType<PythonProject>();
|
setSupportedProjectType<PythonProject>();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Core::Id> availableCreationIds(Target *parent, CreationMode mode) const override
|
QList<QString> availableBuildTargets(Target *parent, CreationMode mode) const override
|
||||||
{
|
{
|
||||||
Q_UNUSED(mode);
|
Q_UNUSED(mode);
|
||||||
if (!canHandle(parent))
|
|
||||||
return {};
|
|
||||||
//return { Core::Id(PythonExecutableId) };
|
//return { Core::Id(PythonExecutableId) };
|
||||||
|
|
||||||
PythonProject *project = static_cast<PythonProject *>(parent->project());
|
PythonProject *project = static_cast<PythonProject *>(parent->project());
|
||||||
QList<Core::Id> allIds;
|
return project->files(ProjectExplorer::Project::AllFiles);
|
||||||
foreach (const QString &file, project->files(ProjectExplorer::Project::AllFiles))
|
|
||||||
allIds.append(idFromScript(file));
|
|
||||||
return allIds;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString displayNameForId(Core::Id id) const override
|
bool canCreateHelper(Target *parent, const QString &buildTarget) const override
|
||||||
{
|
{
|
||||||
return scriptFromId(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool canCreate(Target *parent, Core::Id id) const override
|
|
||||||
{
|
|
||||||
if (!canHandle(parent))
|
|
||||||
return false;
|
|
||||||
PythonProject *project = static_cast<PythonProject *>(parent->project());
|
PythonProject *project = static_cast<PythonProject *>(parent->project());
|
||||||
const QString script = scriptFromId(id);
|
const QString script = buildTarget;
|
||||||
if (script.endsWith(".pyqtc"))
|
if (script.endsWith(".pyqtc"))
|
||||||
return false;
|
return false;
|
||||||
return project->files(ProjectExplorer::Project::AllFiles).contains(script);
|
return project->files(ProjectExplorer::Project::AllFiles).contains(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool canRestore(Target *parent, const QVariantMap &map) const override
|
|
||||||
{
|
|
||||||
Q_UNUSED(parent);
|
|
||||||
return idFromMap(map).name().startsWith(PythonRunConfigurationPrefix);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool canClone(Target *parent, RunConfiguration *source) const override
|
|
||||||
{
|
|
||||||
if (!canHandle(parent))
|
|
||||||
return false;
|
|
||||||
return source->id().name().startsWith(PythonRunConfigurationPrefix);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
PythonProject::PythonProject(const FileName &fileName) :
|
PythonProject::PythonProject(const FileName &fileName) :
|
||||||
|
@@ -72,14 +72,6 @@ const char QBS_RC_PREFIX[] = "Qbs.RunConfiguration:";
|
|||||||
|
|
||||||
static QString rcNameSeparator() { return QLatin1String("---Qbs.RC.NameSeparator---"); }
|
static QString rcNameSeparator() { return QLatin1String("---Qbs.RC.NameSeparator---"); }
|
||||||
|
|
||||||
static Core::Id idFromProduct(const QbsProject *project, const qbs::ProductData &product)
|
|
||||||
{
|
|
||||||
QString id = QLatin1String(QBS_RC_PREFIX);
|
|
||||||
id.append(QbsProject::uniqueProductName(product)).append(rcNameSeparator())
|
|
||||||
.append(QbsProject::productDisplayName(project->qbsProject(), product));
|
|
||||||
return Core::Id::fromString(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
static QString uniqueProductNameFromId(Core::Id id)
|
static QString uniqueProductNameFromId(Core::Id id)
|
||||||
{
|
{
|
||||||
const QString suffix = id.suffixAfter(QBS_RC_PREFIX);
|
const QString suffix = id.suffixAfter(QBS_RC_PREFIX);
|
||||||
@@ -353,42 +345,25 @@ QbsRunConfigurationFactory::QbsRunConfigurationFactory(QObject *parent) :
|
|||||||
IRunConfigurationFactory(parent)
|
IRunConfigurationFactory(parent)
|
||||||
{
|
{
|
||||||
setObjectName("QbsRunConfigurationFactory");
|
setObjectName("QbsRunConfigurationFactory");
|
||||||
registerRunConfiguration<QbsRunConfiguration>();
|
registerRunConfiguration<QbsRunConfiguration>(QBS_RC_PREFIX);
|
||||||
setSupportedProjectType<QbsProject>();
|
setSupportedProjectType<QbsProject>();
|
||||||
setSupportedTargetDeviceTypes({Constants::DESKTOP_DEVICE_TYPE});
|
setSupportedTargetDeviceTypes({Constants::DESKTOP_DEVICE_TYPE});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QbsRunConfigurationFactory::canCreate(Target *parent, Core::Id id) const
|
bool QbsRunConfigurationFactory::canCreateHelper(Target *parent, const QString &buildTarget) const
|
||||||
{
|
{
|
||||||
if (!canHandle(parent))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
QbsProject *project = static_cast<QbsProject *>(parent->project());
|
QbsProject *project = static_cast<QbsProject *>(parent->project());
|
||||||
return findProduct(project->qbsProjectData(), uniqueProductNameFromId(id)).isValid();
|
QString product = buildTarget.left(buildTarget.indexOf(rcNameSeparator()));
|
||||||
|
return findProduct(project->qbsProjectData(), product).isValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QbsRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
|
QList<QString> QbsRunConfigurationFactory::availableBuildTargets(Target *parent, CreationMode mode) const
|
||||||
{
|
|
||||||
if (!canHandle(parent))
|
|
||||||
return false;
|
|
||||||
return idFromMap(map).toString().startsWith(QLatin1String(QBS_RC_PREFIX));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QbsRunConfigurationFactory::canClone(Target *parent, RunConfiguration *source) const
|
|
||||||
{
|
|
||||||
return canCreate(parent, source->id());
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<Core::Id> QbsRunConfigurationFactory::availableCreationIds(Target *parent, CreationMode mode) const
|
|
||||||
{
|
{
|
||||||
QList<qbs::ProductData> products;
|
QList<qbs::ProductData> products;
|
||||||
|
|
||||||
if (!canHandle(parent))
|
|
||||||
return QList<Core::Id>();
|
|
||||||
|
|
||||||
QbsProject *project = static_cast<QbsProject *>(parent->project());
|
QbsProject *project = static_cast<QbsProject *>(parent->project());
|
||||||
if (!project || !project->qbsProject().isValid())
|
if (!project || !project->qbsProject().isValid())
|
||||||
return QList<Core::Id>();
|
return {};
|
||||||
|
|
||||||
foreach (const qbs::ProductData &product, project->qbsProjectData().allProducts()) {
|
foreach (const qbs::ProductData &product, project->qbsProjectData().allProducts()) {
|
||||||
if (product.isRunnable() && product.isEnabled())
|
if (product.isRunnable() && product.isEnabled())
|
||||||
@@ -405,13 +380,17 @@ QList<Core::Id> QbsRunConfigurationFactory::availableCreationIds(Target *parent,
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Utils::transform(products, [project](const qbs::ProductData &product) {
|
return Utils::transform(products, [project](const qbs::ProductData &product) {
|
||||||
return idFromProduct(project, product);
|
return QString(QbsProject::uniqueProductName(product) + rcNameSeparator()
|
||||||
|
+ QbsProject::productDisplayName(project->qbsProject(), product));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QbsRunConfigurationFactory::displayNameForId(Core::Id id) const
|
QString QbsRunConfigurationFactory::displayNameForBuildTarget(const QString &buildTarget) const
|
||||||
{
|
{
|
||||||
return productDisplayNameFromId(id);
|
const int sepPos = buildTarget.indexOf(rcNameSeparator());
|
||||||
|
if (sepPos == -1)
|
||||||
|
return buildTarget;
|
||||||
|
return buildTarget.mid(sepPos + rcNameSeparator().count());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -108,12 +108,10 @@ class QbsRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFact
|
|||||||
public:
|
public:
|
||||||
explicit QbsRunConfigurationFactory(QObject *parent = 0);
|
explicit QbsRunConfigurationFactory(QObject *parent = 0);
|
||||||
|
|
||||||
bool canCreate(ProjectExplorer::Target *parent, Core::Id id) const override;
|
bool canCreateHelper(ProjectExplorer::Target *parent, const QString &suffix) const override;
|
||||||
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const override;
|
|
||||||
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const override;
|
|
||||||
|
|
||||||
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
QList<QString> availableBuildTargets(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
||||||
QString displayNameForId(Core::Id id) const override;
|
QString displayNameForBuildTarget(const QString &buildTarget) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -97,7 +97,7 @@ QString QmakeAndroidRunConfiguration::defaultDisplayName()
|
|||||||
return node->displayName();
|
return node->displayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
return displayNameForId(id());
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QmakeAndroidRunConfiguration::disabledReason() const
|
QString QmakeAndroidRunConfiguration::disabledReason() const
|
||||||
@@ -116,11 +116,6 @@ QString QmakeAndroidRunConfiguration::buildSystemTarget() const
|
|||||||
return qmakeProject()->mapProFilePathToTarget(m_proFilePath);
|
return qmakeProject()->mapProFilePathToTarget(m_proFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QmakeAndroidRunConfiguration::displayNameForId(Core::Id id)
|
|
||||||
{
|
|
||||||
return pathFromId(id).toFileInfo().completeBaseName();
|
|
||||||
}
|
|
||||||
|
|
||||||
QmakeProject *QmakeAndroidRunConfiguration::qmakeProject() const
|
QmakeProject *QmakeAndroidRunConfiguration::qmakeProject() const
|
||||||
{
|
{
|
||||||
Target *t = target();
|
Target *t = target();
|
||||||
|
@@ -50,8 +50,6 @@ public:
|
|||||||
|
|
||||||
QString buildSystemTarget() const final;
|
QString buildSystemTarget() const final;
|
||||||
|
|
||||||
static QString displayNameForId(Core::Id id);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class ProjectExplorer::IRunConfigurationFactory;
|
friend class ProjectExplorer::IRunConfigurationFactory;
|
||||||
void initialize(Core::Id id) override;
|
void initialize(Core::Id id) override;
|
||||||
|
@@ -49,42 +49,24 @@ static const char ANDROID_RC_ID_PREFIX[] = "Qt4ProjectManager.AndroidRunConfigur
|
|||||||
QmakeAndroidRunConfigurationFactory::QmakeAndroidRunConfigurationFactory(QObject *parent)
|
QmakeAndroidRunConfigurationFactory::QmakeAndroidRunConfigurationFactory(QObject *parent)
|
||||||
: IRunConfigurationFactory(parent)
|
: IRunConfigurationFactory(parent)
|
||||||
{
|
{
|
||||||
registerRunConfiguration<QmakeAndroidRunConfiguration>();
|
registerRunConfiguration<QmakeAndroidRunConfiguration>(ANDROID_RC_ID_PREFIX);
|
||||||
setSupportedProjectType<QmakeProject>();
|
setSupportedProjectType<QmakeProject>();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QmakeAndroidRunConfigurationFactory::displayNameForId(Core::Id id) const
|
QString QmakeAndroidRunConfigurationFactory::displayNameForBuildTarget(const QString &buildTarget) const
|
||||||
{
|
{
|
||||||
return QmakeAndroidRunConfiguration::displayNameForId(id);
|
return QFileInfo(buildTarget).completeBaseName();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmakeAndroidRunConfigurationFactory::canCreate(Target *parent, Core::Id id) const
|
bool QmakeAndroidRunConfigurationFactory::canCreateHelper(Target *parent, const QString &buildTarget) const
|
||||||
{
|
{
|
||||||
if (!canHandle(parent))
|
return availableBuildTargets(parent, UserCreate).contains(buildTarget);
|
||||||
return false;
|
|
||||||
return availableCreationIds(parent).contains(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmakeAndroidRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
|
QList<QString> QmakeAndroidRunConfigurationFactory::availableBuildTargets(Target *parent, CreationMode mode) const
|
||||||
{
|
{
|
||||||
if (!canHandle(parent))
|
|
||||||
return false;
|
|
||||||
return ProjectExplorer::idFromMap(map).name().startsWith(ANDROID_RC_ID_PREFIX);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QmakeAndroidRunConfigurationFactory::canClone(Target *parent, RunConfiguration *source) const
|
|
||||||
{
|
|
||||||
return canCreate(parent, source->id());
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<Core::Id> QmakeAndroidRunConfigurationFactory::availableCreationIds(Target *parent, CreationMode mode) const
|
|
||||||
{
|
|
||||||
if (!canHandle(parent))
|
|
||||||
return QList<Core::Id>();
|
|
||||||
|
|
||||||
auto project = static_cast<QmakeProject *>(parent->project());
|
auto project = static_cast<QmakeProject *>(parent->project());
|
||||||
return project->creationIds(ANDROID_RC_ID_PREFIX, mode,
|
return project->buildTargets(mode, {ProjectType::ApplicationTemplate, ProjectType::SharedLibraryTemplate});
|
||||||
{ProjectType::ApplicationTemplate, ProjectType::SharedLibraryTemplate});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmakeAndroidRunConfigurationFactory::canHandle(Target *t) const
|
bool QmakeAndroidRunConfigurationFactory::canHandle(Target *t) const
|
||||||
|
@@ -43,12 +43,10 @@ class QmakeAndroidRunConfigurationFactory : public ProjectExplorer::IRunConfigur
|
|||||||
public:
|
public:
|
||||||
explicit QmakeAndroidRunConfigurationFactory(QObject *parent = 0);
|
explicit QmakeAndroidRunConfigurationFactory(QObject *parent = 0);
|
||||||
|
|
||||||
QString displayNameForId(Core::Id id) const override;
|
QList<QString> availableBuildTargets(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
||||||
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode = UserCreate) const override;
|
QString displayNameForBuildTarget(const QString &buildTarget) const override;
|
||||||
|
|
||||||
bool canCreate(ProjectExplorer::Target *parent, Core::Id id) const override;
|
bool canCreateHelper(ProjectExplorer::Target *parent, const QString &suffix) const override;
|
||||||
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const override;
|
|
||||||
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const override;
|
|
||||||
|
|
||||||
QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Target *t,
|
QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Target *t,
|
||||||
ProjectExplorer::Node *n);
|
ProjectExplorer::Node *n);
|
||||||
|
@@ -67,11 +67,6 @@ const char PRO_FILE_KEY[] = "Qt4ProjectManager.Qt4RunConfiguration.ProFile";
|
|||||||
const char USE_DYLD_IMAGE_SUFFIX_KEY[] = "Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix";
|
const char USE_DYLD_IMAGE_SUFFIX_KEY[] = "Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix";
|
||||||
const char USE_LIBRARY_SEARCH_PATH[] = "QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath";
|
const char USE_LIBRARY_SEARCH_PATH[] = "QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath";
|
||||||
|
|
||||||
static Utils::FileName pathFromId(Core::Id id)
|
|
||||||
{
|
|
||||||
return Utils::FileName::fromString(id.suffixAfter(QMAKE_RC_PREFIX));
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// QmakeRunConfiguration
|
// QmakeRunConfiguration
|
||||||
//
|
//
|
||||||
@@ -96,7 +91,7 @@ DesktopQmakeRunConfiguration::DesktopQmakeRunConfiguration(Target *target)
|
|||||||
void DesktopQmakeRunConfiguration::initialize(Core::Id id)
|
void DesktopQmakeRunConfiguration::initialize(Core::Id id)
|
||||||
{
|
{
|
||||||
RunConfiguration::initialize(id);
|
RunConfiguration::initialize(id);
|
||||||
m_proFilePath = pathFromId(id);
|
m_proFilePath = FileName::fromString(id.suffixAfter(QMAKE_RC_PREFIX));
|
||||||
|
|
||||||
updateTargetInformation();
|
updateTargetInformation();
|
||||||
}
|
}
|
||||||
@@ -440,43 +435,26 @@ DesktopQmakeRunConfigurationFactory::DesktopQmakeRunConfigurationFactory(QObject
|
|||||||
QmakeRunConfigurationFactory(parent)
|
QmakeRunConfigurationFactory(parent)
|
||||||
{
|
{
|
||||||
setObjectName("DesktopQmakeRunConfigurationFactory");
|
setObjectName("DesktopQmakeRunConfigurationFactory");
|
||||||
registerRunConfiguration<DesktopQmakeRunConfiguration>();
|
registerRunConfiguration<DesktopQmakeRunConfiguration>(QMAKE_RC_PREFIX);
|
||||||
setSupportedProjectType<QmakeProject>();
|
setSupportedProjectType<QmakeProject>();
|
||||||
setSupportedTargetDeviceTypes({Constants::DESKTOP_DEVICE_TYPE});
|
setSupportedTargetDeviceTypes({Constants::DESKTOP_DEVICE_TYPE});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DesktopQmakeRunConfigurationFactory::canCreate(Target *parent, Core::Id id) const
|
bool DesktopQmakeRunConfigurationFactory::canCreateHelper(Target *parent, const QString &buildTarget) const
|
||||||
{
|
{
|
||||||
if (!canHandle(parent))
|
|
||||||
return false;
|
|
||||||
QmakeProject *project = static_cast<QmakeProject *>(parent->project());
|
QmakeProject *project = static_cast<QmakeProject *>(parent->project());
|
||||||
return project->hasApplicationProFile(pathFromId(id));
|
return project->hasApplicationProFile(Utils::FileName::fromString(buildTarget));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DesktopQmakeRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
|
QList<QString> DesktopQmakeRunConfigurationFactory::availableBuildTargets(Target *parent, CreationMode mode) const
|
||||||
{
|
{
|
||||||
if (!canHandle(parent))
|
|
||||||
return false;
|
|
||||||
return idFromMap(map).toString().startsWith(QLatin1String(QMAKE_RC_PREFIX));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DesktopQmakeRunConfigurationFactory::canClone(Target *parent, RunConfiguration *source) const
|
|
||||||
{
|
|
||||||
return canCreate(parent, source->id());
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<Core::Id> DesktopQmakeRunConfigurationFactory::availableCreationIds(Target *parent, CreationMode mode) const
|
|
||||||
{
|
|
||||||
if (!canHandle(parent))
|
|
||||||
return QList<Core::Id>();
|
|
||||||
|
|
||||||
QmakeProject *project = static_cast<QmakeProject *>(parent->project());
|
QmakeProject *project = static_cast<QmakeProject *>(parent->project());
|
||||||
return project->creationIds(QMAKE_RC_PREFIX, mode);
|
return project->buildTargets(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DesktopQmakeRunConfigurationFactory::displayNameForId(Core::Id id) const
|
QString DesktopQmakeRunConfigurationFactory::displayNameForBuildTarget(const QString &buildTarget) const
|
||||||
{
|
{
|
||||||
return pathFromId(id).toFileInfo().completeBaseName();
|
return QFileInfo(buildTarget).completeBaseName();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<RunConfiguration *> DesktopQmakeRunConfigurationFactory::runConfigurationsForNode(Target *t, const Node *n)
|
QList<RunConfiguration *> DesktopQmakeRunConfigurationFactory::runConfigurationsForNode(Target *t, const Node *n)
|
||||||
|
@@ -140,12 +140,10 @@ class DesktopQmakeRunConfigurationFactory : public QmakeRunConfigurationFactory
|
|||||||
public:
|
public:
|
||||||
explicit DesktopQmakeRunConfigurationFactory(QObject *parent = 0);
|
explicit DesktopQmakeRunConfigurationFactory(QObject *parent = 0);
|
||||||
|
|
||||||
bool canCreate(ProjectExplorer::Target *parent, Core::Id id) const override;
|
bool canCreateHelper(ProjectExplorer::Target *parent, const QString &suffix) const override;
|
||||||
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const override;
|
|
||||||
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const override;
|
|
||||||
|
|
||||||
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
QList<QString> availableBuildTargets(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
||||||
QString displayNameForId(Core::Id id) const override;
|
QString displayNameForBuildTarget(const QString &buildTarget) const override;
|
||||||
|
|
||||||
QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Target *t,
|
QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Target *t,
|
||||||
const ProjectExplorer::Node *n) override;
|
const ProjectExplorer::Node *n) override;
|
||||||
|
@@ -773,9 +773,8 @@ bool QmakeProject::hasApplicationProFile(const FileName &path) const
|
|||||||
return Utils::contains(list, Utils::equal(&QmakeProFile::filePath, path));
|
return Utils::contains(list, Utils::equal(&QmakeProFile::filePath, path));
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Core::Id> QmakeProject::creationIds(Core::Id base,
|
QList<QString> QmakeProject::buildTargets(IRunConfigurationFactory::CreationMode mode,
|
||||||
IRunConfigurationFactory::CreationMode mode,
|
const QList<ProjectType> &projectTypes)
|
||||||
const QList<ProjectType> &projectTypes)
|
|
||||||
{
|
{
|
||||||
QList<ProjectType> realTypes = projectTypes;
|
QList<ProjectType> realTypes = projectTypes;
|
||||||
if (realTypes.isEmpty())
|
if (realTypes.isEmpty())
|
||||||
@@ -790,9 +789,7 @@ QList<Core::Id> QmakeProject::creationIds(Core::Id base,
|
|||||||
temp = filtered.isEmpty() ? files : filtered;
|
temp = filtered.isEmpty() ? files : filtered;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Utils::transform(temp, [&base](QmakeProFile *f) {
|
return Utils::transform(temp, [](QmakeProFile *f) { return f->filePath().toString(); });
|
||||||
return base.withSuffix(f->filePath().toString());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmakeProject::activeTargetWasChanged()
|
void QmakeProject::activeTargetWasChanged()
|
||||||
|
@@ -48,12 +48,8 @@ namespace ProjectExplorer { class DeploymentData; }
|
|||||||
namespace QtSupport { class ProFileReader; }
|
namespace QtSupport { class ProFileReader; }
|
||||||
|
|
||||||
namespace QmakeProjectManager {
|
namespace QmakeProjectManager {
|
||||||
class QmakeBuildConfiguration;
|
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal { class CentralizedFolderWatcher; }
|
||||||
class CentralizedFolderWatcher;
|
|
||||||
class QmakeProjectFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
class QMAKEPROJECTMANAGER_EXPORT QmakeProject : public ProjectExplorer::Project
|
class QMAKEPROJECTMANAGER_EXPORT QmakeProject : public ProjectExplorer::Project
|
||||||
{
|
{
|
||||||
@@ -77,8 +73,7 @@ public:
|
|||||||
QList<QmakeProFile *> applicationProFiles(Parsing parse = ExactParse) const;
|
QList<QmakeProFile *> applicationProFiles(Parsing parse = ExactParse) const;
|
||||||
bool hasApplicationProFile(const Utils::FileName &path) const;
|
bool hasApplicationProFile(const Utils::FileName &path) const;
|
||||||
|
|
||||||
QList<Core::Id> creationIds(Core::Id base,
|
QList<QString> buildTargets(ProjectExplorer::IRunConfigurationFactory::CreationMode mode,
|
||||||
ProjectExplorer::IRunConfigurationFactory::CreationMode mode,
|
|
||||||
const QList<ProjectType> &projectTypes = {});
|
const QList<ProjectType> &projectTypes = {});
|
||||||
|
|
||||||
static void notifyChanged(const Utils::FileName &name);
|
static void notifyChanged(const Utils::FileName &name);
|
||||||
|
@@ -30,6 +30,8 @@
|
|||||||
namespace QmlProjectManager {
|
namespace QmlProjectManager {
|
||||||
namespace Constants {
|
namespace Constants {
|
||||||
|
|
||||||
|
const char QML_RC_ID[] = "QmlProjectManager.QmlRunConfiguration";
|
||||||
|
|
||||||
const char QML_VIEWER_RC_ID[] = "QmlProjectManager.QmlRunConfiguration";
|
const char QML_VIEWER_RC_ID[] = "QmlProjectManager.QmlRunConfiguration";
|
||||||
const char QML_SCENE_RC_ID[] = "QmlProjectManager.QmlRunConfiguration.QmlScene";
|
const char QML_SCENE_RC_ID[] = "QmlProjectManager.QmlRunConfiguration.QmlScene";
|
||||||
const char QML_VIEWER_ARGUMENTS_KEY[] = "QmlProjectManager.QmlRunConfiguration.QDeclarativeViewerArguments";
|
const char QML_VIEWER_ARGUMENTS_KEY[] = "QmlProjectManager.QmlRunConfiguration.QDeclarativeViewerArguments";
|
||||||
|
@@ -36,67 +36,58 @@
|
|||||||
namespace QmlProjectManager {
|
namespace QmlProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
const char QML_VIEWER_SUFFIX[] = "";
|
||||||
|
const char QML_SCENE_SUFFIX[] = ".QmlScene";
|
||||||
|
|
||||||
QmlProjectRunConfigurationFactory::QmlProjectRunConfigurationFactory(QObject *parent) :
|
QmlProjectRunConfigurationFactory::QmlProjectRunConfigurationFactory(QObject *parent) :
|
||||||
ProjectExplorer::IRunConfigurationFactory(parent)
|
ProjectExplorer::IRunConfigurationFactory(parent)
|
||||||
{
|
{
|
||||||
setObjectName("QmlProjectRunConfigurationFactory");
|
setObjectName("QmlProjectRunConfigurationFactory");
|
||||||
registerRunConfiguration<QmlProjectRunConfiguration>();
|
registerRunConfiguration<QmlProjectRunConfiguration>(Constants::QML_RC_ID);
|
||||||
setSupportedProjectType<QmlProject>();
|
setSupportedProjectType<QmlProject>();
|
||||||
setSupportedTargetDeviceTypes({ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE});
|
setSupportedTargetDeviceTypes({ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE});
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Core::Id> QmlProjectRunConfigurationFactory::availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode) const
|
QList<QString> QmlProjectRunConfigurationFactory::availableBuildTargets(ProjectExplorer::Target *parent, CreationMode) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(mode)
|
|
||||||
if (!canHandle(parent))
|
|
||||||
return QList<Core::Id>();
|
|
||||||
|
|
||||||
QtSupport::BaseQtVersion *version
|
QtSupport::BaseQtVersion *version
|
||||||
= QtSupport::QtKitInformation::qtVersion(parent->kit());
|
= QtSupport::QtKitInformation::qtVersion(parent->kit());
|
||||||
|
|
||||||
|
const QString viewer = QML_VIEWER_SUFFIX;
|
||||||
|
const QString scene = QML_SCENE_SUFFIX;
|
||||||
|
|
||||||
// First id will be the default run configuration
|
// First id will be the default run configuration
|
||||||
QList<Core::Id> list;
|
|
||||||
if (version && version->qtVersion() >= QtSupport::QtVersionNumber(5, 0, 0)) {
|
if (version && version->qtVersion() >= QtSupport::QtVersionNumber(5, 0, 0)) {
|
||||||
QmlProject *project = static_cast<QmlProject*>(parent->project());
|
QmlProject *project = static_cast<QmlProject*>(parent->project());
|
||||||
switch (project->defaultImport()) {
|
switch (project->defaultImport()) {
|
||||||
case QmlProject::QtQuick1Import:
|
case QmlProject::QtQuick1Import:
|
||||||
list << Core::Id(Constants::QML_VIEWER_RC_ID);
|
return {viewer};
|
||||||
break;
|
|
||||||
case QmlProject::QtQuick2Import:
|
case QmlProject::QtQuick2Import:
|
||||||
list << Core::Id(Constants::QML_SCENE_RC_ID);
|
return {scene};
|
||||||
break;
|
|
||||||
case QmlProject::UnknownImport:
|
case QmlProject::UnknownImport:
|
||||||
default:
|
default:
|
||||||
list << Core::Id(Constants::QML_SCENE_RC_ID);
|
return {scene, viewer};
|
||||||
list << Core::Id(Constants::QML_VIEWER_RC_ID);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
list << Core::Id(Constants::QML_VIEWER_RC_ID);
|
|
||||||
}
|
}
|
||||||
|
return {viewer};
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QmlProjectRunConfigurationFactory::displayNameForId(Core::Id id) const
|
QString QmlProjectRunConfigurationFactory::displayNameForBuildTarget(const QString &buildTarget) const
|
||||||
{
|
{
|
||||||
if (id == Constants::QML_VIEWER_RC_ID)
|
if (buildTarget == QML_VIEWER_SUFFIX)
|
||||||
return tr("QML Viewer");
|
return tr("QML Viewer");
|
||||||
if (id == Constants::QML_SCENE_RC_ID)
|
if (buildTarget == QML_SCENE_SUFFIX)
|
||||||
return tr("QML Scene");
|
return tr("QML Scene");
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlProjectRunConfigurationFactory::canCreate(ProjectExplorer::Target *parent,
|
bool QmlProjectRunConfigurationFactory::canCreateHelper(ProjectExplorer::Target *parent,
|
||||||
const Core::Id id) const
|
const QString &buildTarget) const
|
||||||
{
|
{
|
||||||
if (!canHandle(parent))
|
if (buildTarget == QML_VIEWER_SUFFIX)
|
||||||
return false;
|
|
||||||
|
|
||||||
if (id == Constants::QML_VIEWER_RC_ID)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (id == Constants::QML_SCENE_RC_ID) {
|
if (buildTarget == QML_SCENE_SUFFIX) {
|
||||||
// only support qmlscene if it's Qt5
|
// only support qmlscene if it's Qt5
|
||||||
QtSupport::BaseQtVersion *version
|
QtSupport::BaseQtVersion *version
|
||||||
= QtSupport::QtKitInformation::qtVersion(parent->kit());
|
= QtSupport::QtKitInformation::qtVersion(parent->kit());
|
||||||
@@ -105,16 +96,6 @@ bool QmlProjectRunConfigurationFactory::canCreate(ProjectExplorer::Target *paren
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlProjectRunConfigurationFactory::canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const
|
|
||||||
{
|
|
||||||
return parent && canCreate(parent, ProjectExplorer::idFromMap(map));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QmlProjectRunConfigurationFactory::canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const
|
|
||||||
{
|
|
||||||
return canCreate(parent, source->id());
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace QmlProjectManager
|
} // namespace QmlProjectManager
|
||||||
|
|
||||||
|
@@ -37,12 +37,10 @@ class QmlProjectRunConfigurationFactory : public ProjectExplorer::IRunConfigurat
|
|||||||
public:
|
public:
|
||||||
explicit QmlProjectRunConfigurationFactory(QObject *parent = 0);
|
explicit QmlProjectRunConfigurationFactory(QObject *parent = 0);
|
||||||
|
|
||||||
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
QList<QString> availableBuildTargets(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
||||||
QString displayNameForId(Core::Id id) const override;
|
QString displayNameForBuildTarget(const QString &buildTarget) const override;
|
||||||
|
|
||||||
bool canCreate(ProjectExplorer::Target *parent, Core::Id id) const override;
|
bool canCreateHelper(ProjectExplorer::Target *parent, const QString &suffix) const override;
|
||||||
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const override;
|
|
||||||
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -36,64 +36,33 @@
|
|||||||
namespace Qnx {
|
namespace Qnx {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
static Utils::FileName pathFromId(Core::Id id)
|
|
||||||
{
|
|
||||||
return Utils::FileName::fromString(id.suffixAfter(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX));
|
|
||||||
}
|
|
||||||
|
|
||||||
QnxRunConfigurationFactory::QnxRunConfigurationFactory(QObject *parent) :
|
QnxRunConfigurationFactory::QnxRunConfigurationFactory(QObject *parent) :
|
||||||
ProjectExplorer::IRunConfigurationFactory(parent)
|
ProjectExplorer::IRunConfigurationFactory(parent)
|
||||||
{
|
{
|
||||||
registerRunConfiguration<QnxRunConfiguration>();
|
registerRunConfiguration<QnxRunConfiguration>(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX);
|
||||||
setSupportedTargetDeviceTypes({Constants::QNX_QNX_OS_TYPE});
|
setSupportedTargetDeviceTypes({Constants::QNX_QNX_OS_TYPE});
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Core::Id> QnxRunConfigurationFactory::availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode) const
|
QList<QString> QnxRunConfigurationFactory::availableBuildTargets(ProjectExplorer::Target *parent, CreationMode mode) const
|
||||||
{
|
{
|
||||||
using QmakeProjectManager::QmakeProject;
|
auto project = qobject_cast<QmakeProjectManager::QmakeProject *>(parent->project());
|
||||||
if (!canHandle(parent))
|
|
||||||
return QList<Core::Id>();
|
|
||||||
|
|
||||||
auto project = qobject_cast<QmakeProject *>(parent->project());
|
|
||||||
if (!project)
|
if (!project)
|
||||||
return QList<Core::Id>();
|
return {};
|
||||||
|
return project->buildTargets(mode);
|
||||||
return project->creationIds(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX, mode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QnxRunConfigurationFactory::displayNameForId(Core::Id id) const
|
QString QnxRunConfigurationFactory::displayNameForBuildTarget(const QString &buildTarget) const
|
||||||
{
|
{
|
||||||
const Utils::FileName path = pathFromId(id);
|
if (buildTarget.isEmpty())
|
||||||
if (path.isEmpty())
|
|
||||||
return QString();
|
return QString();
|
||||||
|
return tr("%1 on QNX Device").arg(QFileInfo(buildTarget).completeBaseName());
|
||||||
if (id.name().startsWith(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX))
|
|
||||||
return tr("%1 on QNX Device").arg(path.toFileInfo().completeBaseName());
|
|
||||||
|
|
||||||
return QString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QnxRunConfigurationFactory::canCreate(ProjectExplorer::Target *parent, Core::Id id) const
|
bool QnxRunConfigurationFactory::canCreateHelper(ProjectExplorer::Target *parent,
|
||||||
|
const QString &buildTarget) const
|
||||||
{
|
{
|
||||||
if (!canHandle(parent) || !id.name().startsWith(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX))
|
auto project = qobject_cast<QmakeProjectManager::QmakeProject *>(parent->project());
|
||||||
return false;
|
return project->hasApplicationProFile(Utils::FileName::fromString(buildTarget));
|
||||||
|
|
||||||
QmakeProjectManager::QmakeProject *qt4Project = qobject_cast<QmakeProjectManager::QmakeProject *>(parent->project());
|
|
||||||
if (!qt4Project)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return qt4Project->hasApplicationProFile(pathFromId(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QnxRunConfigurationFactory::canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const
|
|
||||||
{
|
|
||||||
return canHandle(parent)
|
|
||||||
&& ProjectExplorer::idFromMap(map).name().startsWith(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QnxRunConfigurationFactory::canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const
|
|
||||||
{
|
|
||||||
return canCreate(parent, source->id());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -38,12 +38,10 @@ class QnxRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFact
|
|||||||
public:
|
public:
|
||||||
explicit QnxRunConfigurationFactory(QObject *parent = 0);
|
explicit QnxRunConfigurationFactory(QObject *parent = 0);
|
||||||
|
|
||||||
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
QList<QString> availableBuildTargets(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
||||||
QString displayNameForId(Core::Id id) const override;
|
QString displayNameForBuildTarget(const QString &buildTarget) const override;
|
||||||
|
|
||||||
bool canCreate(ProjectExplorer::Target *parent, Core::Id id) const override;
|
bool canCreateHelper(ProjectExplorer::Target *parent, const QString &suffix) const override;
|
||||||
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const override;
|
|
||||||
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -30,73 +30,40 @@
|
|||||||
#include "remotelinuxrunconfiguration.h"
|
#include "remotelinuxrunconfiguration.h"
|
||||||
|
|
||||||
#include <projectexplorer/buildtargetinfo.h>
|
#include <projectexplorer/buildtargetinfo.h>
|
||||||
#include <projectexplorer/kitinformation.h>
|
|
||||||
#include <projectexplorer/project.h>
|
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
|
|
||||||
namespace RemoteLinux {
|
namespace RemoteLinux {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
static QString stringFromId(Core::Id id)
|
|
||||||
{
|
|
||||||
QByteArray idStr = id.name();
|
|
||||||
if (!idStr.startsWith(RemoteLinuxRunConfiguration::IdPrefix))
|
|
||||||
return QString();
|
|
||||||
return QString::fromUtf8(idStr.mid(int(strlen(RemoteLinuxRunConfiguration::IdPrefix))));
|
|
||||||
}
|
|
||||||
|
|
||||||
// RemoteLinuxRunConfigurationFactory
|
// RemoteLinuxRunConfigurationFactory
|
||||||
|
|
||||||
RemoteLinuxRunConfigurationFactory::RemoteLinuxRunConfigurationFactory(QObject *parent)
|
RemoteLinuxRunConfigurationFactory::RemoteLinuxRunConfigurationFactory(QObject *parent)
|
||||||
: IRunConfigurationFactory(parent)
|
: IRunConfigurationFactory(parent)
|
||||||
{
|
{
|
||||||
setObjectName("RemoteLinuxRunConfigurationFactory");
|
setObjectName("RemoteLinuxRunConfigurationFactory");
|
||||||
registerRunConfiguration<RemoteLinuxRunConfiguration>();
|
registerRunConfiguration<RemoteLinuxRunConfiguration>(RemoteLinuxRunConfiguration::IdPrefix);
|
||||||
setSupportedTargetDeviceTypes({RemoteLinux::Constants::GenericLinuxOsType});
|
setSupportedTargetDeviceTypes({RemoteLinux::Constants::GenericLinuxOsType});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RemoteLinuxRunConfigurationFactory::canCreate(Target *parent, Core::Id id) const
|
bool RemoteLinuxRunConfigurationFactory::canCreateHelper(Target *parent, const QString &buildTarget) const
|
||||||
{
|
{
|
||||||
if (!canHandle(parent))
|
return parent->applicationTargets().hasTarget(buildTarget);
|
||||||
return false;
|
|
||||||
return parent->applicationTargets().hasTarget(stringFromId(id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RemoteLinuxRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
|
QList<QString>
|
||||||
|
RemoteLinuxRunConfigurationFactory::availableBuildTargets(Target *parent, CreationMode) const
|
||||||
{
|
{
|
||||||
if (!canHandle(parent))
|
return Utils::transform(parent->applicationTargets().list, [](const BuildTargetInfo &bti) {
|
||||||
return false;
|
return bti.targetName;
|
||||||
const Core::Id id = idFromMap(map);
|
});
|
||||||
return id.name().startsWith(RemoteLinuxRunConfiguration::IdPrefix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RemoteLinuxRunConfigurationFactory::canClone(Target *parent, RunConfiguration *source) const
|
QString RemoteLinuxRunConfigurationFactory::displayNameForBuildTarget(const QString &buildTarget) const
|
||||||
{
|
{
|
||||||
auto rlrc = qobject_cast<RemoteLinuxRunConfiguration *>(source);
|
return buildTarget + ' ' + tr("(on Remote Generic Linux Host)");
|
||||||
return rlrc && canCreate(parent, source->id());
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<Core::Id> RemoteLinuxRunConfigurationFactory::availableCreationIds(Target *parent, CreationMode mode) const
|
|
||||||
{
|
|
||||||
Q_UNUSED(mode)
|
|
||||||
QList<Core::Id> result;
|
|
||||||
if (!canHandle(parent))
|
|
||||||
return result;
|
|
||||||
|
|
||||||
const Core::Id base = Core::Id(RemoteLinuxRunConfiguration::IdPrefix);
|
|
||||||
foreach (const BuildTargetInfo &bti, parent->applicationTargets().list)
|
|
||||||
result << base.withSuffix(bti.targetName);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString RemoteLinuxRunConfigurationFactory::displayNameForId(Core::Id id) const
|
|
||||||
{
|
|
||||||
return stringFromId(id) + QLatin1Char(' ') + tr("(on Remote Generic Linux Host)");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoteLinuxCustomRunConfigurationFactory
|
// RemoteLinuxCustomRunConfigurationFactory
|
||||||
@@ -105,42 +72,17 @@ RemoteLinuxCustomRunConfigurationFactory::RemoteLinuxCustomRunConfigurationFacto
|
|||||||
: IRunConfigurationFactory(parent)
|
: IRunConfigurationFactory(parent)
|
||||||
{
|
{
|
||||||
setObjectName("RemoteLinuxCustomRunConfiguration");
|
setObjectName("RemoteLinuxCustomRunConfiguration");
|
||||||
registerRunConfiguration<RemoteLinuxCustomRunConfiguration>();
|
registerRunConfiguration<RemoteLinuxCustomRunConfiguration>
|
||||||
|
(RemoteLinuxCustomRunConfiguration::runConfigId());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RemoteLinuxCustomRunConfigurationFactory::canCreate(Target *parent, Core::Id id) const
|
QList<QString>
|
||||||
|
RemoteLinuxCustomRunConfigurationFactory::availableBuildTargets(Target *, CreationMode) const
|
||||||
{
|
{
|
||||||
if (!canHandle(parent))
|
return {QString()};
|
||||||
return false;
|
|
||||||
return id == RemoteLinuxCustomRunConfiguration::runConfigId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RemoteLinuxCustomRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
|
QString RemoteLinuxCustomRunConfigurationFactory::displayNameForBuildTarget(const QString &) const
|
||||||
{
|
|
||||||
if (!canHandle(parent))
|
|
||||||
return false;
|
|
||||||
const Core::Id id = idFromMap(map);
|
|
||||||
return id == RemoteLinuxCustomRunConfiguration::runConfigId();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RemoteLinuxCustomRunConfigurationFactory::canClone(Target *parent, RunConfiguration *source) const
|
|
||||||
{
|
|
||||||
auto rlrc = qobject_cast<RemoteLinuxCustomRunConfiguration *>(source);
|
|
||||||
return rlrc && canCreate(parent, source->id());
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<Core::Id> RemoteLinuxCustomRunConfigurationFactory::availableCreationIds(Target *parent, CreationMode mode) const
|
|
||||||
{
|
|
||||||
Q_UNUSED(mode)
|
|
||||||
QList<Core::Id> result;
|
|
||||||
if (!canHandle(parent))
|
|
||||||
return result;
|
|
||||||
|
|
||||||
result << RemoteLinuxCustomRunConfiguration::runConfigId();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString RemoteLinuxCustomRunConfigurationFactory::displayNameForId(Core::Id) const
|
|
||||||
{
|
{
|
||||||
return RemoteLinuxCustomRunConfiguration::runConfigDefaultDisplayName();
|
return RemoteLinuxCustomRunConfiguration::runConfigDefaultDisplayName();
|
||||||
}
|
}
|
||||||
|
@@ -37,12 +37,10 @@ class RemoteLinuxRunConfigurationFactory : public ProjectExplorer::IRunConfigura
|
|||||||
public:
|
public:
|
||||||
explicit RemoteLinuxRunConfigurationFactory(QObject *parent = 0);
|
explicit RemoteLinuxRunConfigurationFactory(QObject *parent = 0);
|
||||||
|
|
||||||
QString displayNameForId(Core::Id id) const override;
|
QList<QString> availableBuildTargets(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
||||||
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
QString displayNameForBuildTarget(const QString &buildTarget) const override;
|
||||||
|
|
||||||
bool canCreate(ProjectExplorer::Target *parent, Core::Id id) const override;
|
bool canCreateHelper(ProjectExplorer::Target *parent, const QString &suffix) const override;
|
||||||
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const override;
|
|
||||||
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class RemoteLinuxCustomRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory
|
class RemoteLinuxCustomRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory
|
||||||
@@ -52,12 +50,8 @@ class RemoteLinuxCustomRunConfigurationFactory : public ProjectExplorer::IRunCon
|
|||||||
public:
|
public:
|
||||||
explicit RemoteLinuxCustomRunConfigurationFactory(QObject *parent = 0);
|
explicit RemoteLinuxCustomRunConfigurationFactory(QObject *parent = 0);
|
||||||
|
|
||||||
QString displayNameForId(Core::Id id) const override;
|
QList<QString> availableBuildTargets(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
||||||
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
QString displayNameForBuildTarget(const QString &buildTarget) const override;
|
||||||
|
|
||||||
bool canCreate(ProjectExplorer::Target *parent, Core::Id id) const override;
|
|
||||||
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const override;
|
|
||||||
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -43,48 +43,28 @@ namespace Internal {
|
|||||||
|
|
||||||
WinRtRunConfigurationFactory::WinRtRunConfigurationFactory()
|
WinRtRunConfigurationFactory::WinRtRunConfigurationFactory()
|
||||||
{
|
{
|
||||||
registerRunConfiguration<WinRtRunConfiguration>();
|
registerRunConfiguration<WinRtRunConfiguration>(Constants::WINRT_RC_PREFIX);
|
||||||
setSupportedProjectType<QmakeProject>();
|
setSupportedProjectType<QmakeProject>();
|
||||||
setSupportedTargetDeviceTypes({Constants::WINRT_DEVICE_TYPE_LOCAL,
|
setSupportedTargetDeviceTypes({Constants::WINRT_DEVICE_TYPE_LOCAL,
|
||||||
Constants::WINRT_DEVICE_TYPE_PHONE,
|
Constants::WINRT_DEVICE_TYPE_PHONE,
|
||||||
Constants::WINRT_DEVICE_TYPE_EMULATOR});
|
Constants::WINRT_DEVICE_TYPE_EMULATOR});
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Core::Id> WinRtRunConfigurationFactory::availableCreationIds(Target *parent,
|
QList<QString> WinRtRunConfigurationFactory::availableBuildTargets(Target *parent,
|
||||||
CreationMode mode) const
|
CreationMode mode) const
|
||||||
{
|
{
|
||||||
if (!canHandle(parent))
|
|
||||||
return QList<Core::Id>();
|
|
||||||
|
|
||||||
QmakeProject *project = static_cast<QmakeProject *>(parent->project());
|
QmakeProject *project = static_cast<QmakeProject *>(parent->project());
|
||||||
return project->creationIds(Constants::WINRT_RC_PREFIX, mode);
|
return project->buildTargets(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString WinRtRunConfigurationFactory::displayNameForId(Core::Id id) const
|
QString WinRtRunConfigurationFactory::displayNameForBuildTarget(const QString &) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(id);
|
|
||||||
return tr("Run App Package");
|
return tr("Run App Package");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WinRtRunConfigurationFactory::canCreate(Target *parent, Core::Id id) const
|
bool WinRtRunConfigurationFactory::canCloneHelper(Target *, RunConfiguration *) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(id);
|
return false; // FIXME: Are they really unclonable?
|
||||||
return canHandle(parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WinRtRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
|
|
||||||
{
|
|
||||||
if (!canHandle(parent))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return idFromMap(map).toString().startsWith(QLatin1String(Constants::WINRT_RC_PREFIX));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WinRtRunConfigurationFactory::canClone(Target *parent, RunConfiguration *product) const
|
|
||||||
{
|
|
||||||
Q_UNUSED(parent);
|
|
||||||
Q_UNUSED(product);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -38,11 +38,10 @@ class WinRtRunConfigurationFactory : public ProjectExplorer::IRunConfigurationF
|
|||||||
public:
|
public:
|
||||||
WinRtRunConfigurationFactory();
|
WinRtRunConfigurationFactory();
|
||||||
|
|
||||||
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
QList<QString> availableBuildTargets(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
||||||
QString displayNameForId(Core::Id id) const override;
|
QString displayNameForBuildTarget(const QString &buildTarget) const override;
|
||||||
bool canCreate(ProjectExplorer::Target *parent, Core::Id id) const override;
|
|
||||||
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const override;
|
bool canCloneHelper(ProjectExplorer::Target *, ProjectExplorer::RunConfiguration *) const override;
|
||||||
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *product) const override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
Reference in New Issue
Block a user