forked from qt-creator/qt-creator
QmakeProject: Centralize some code for subproject runconfig handling
Change-Id: Iecd8c326fc7fd1b1e7e5406fd899befc9fdd3c5b Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -68,16 +68,10 @@ QList<BuildTargetInfo>
|
||||
ProjectType::AuxTemplate});
|
||||
}
|
||||
|
||||
QList<RunConfiguration *> IosRunConfigurationFactory::runConfigurationsForNode(Target *t, const Node *n)
|
||||
bool IosRunConfigurationFactory::hasRunConfigForProFile(RunConfiguration *rc, const Utils::FileName &n) const
|
||||
{
|
||||
QList<RunConfiguration *> result;
|
||||
foreach (RunConfiguration *rc, t->runConfigurations()) {
|
||||
if (IosRunConfiguration *qt4c = qobject_cast<IosRunConfiguration *>(rc)) {
|
||||
if (qt4c->profilePath() == n->filePath())
|
||||
result << rc;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
auto iosRc = qobject_cast<IosRunConfiguration *>(rc);
|
||||
return iosRc && iosRc->profilePath() == n;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -48,9 +48,7 @@ public:
|
||||
|
||||
bool canCreateHelper(ProjectExplorer::Target *parent, const QString &suffix) const override;
|
||||
|
||||
QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Target *t,
|
||||
const ProjectExplorer::Node *n
|
||||
) override;
|
||||
bool hasRunConfigForProFile(ProjectExplorer::RunConfiguration *rc, const Utils::FileName &n) const override;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -450,14 +450,10 @@ QList<BuildTargetInfo>
|
||||
return project->buildTargets(mode);
|
||||
}
|
||||
|
||||
QList<RunConfiguration *> DesktopQmakeRunConfigurationFactory::runConfigurationsForNode(Target *t, const Node *n)
|
||||
bool DesktopQmakeRunConfigurationFactory::hasRunConfigForProFile(RunConfiguration *rc, const Utils::FileName &n) const
|
||||
{
|
||||
QList<RunConfiguration *> result;
|
||||
foreach (RunConfiguration *rc, t->runConfigurations())
|
||||
if (DesktopQmakeRunConfiguration *qmakeRc = qobject_cast<DesktopQmakeRunConfiguration *>(rc))
|
||||
if (qmakeRc->proFilePath() == n->filePath())
|
||||
result << rc;
|
||||
return result;
|
||||
auto qmakeRc = qobject_cast<DesktopQmakeRunConfiguration *>(rc);
|
||||
return qmakeRc && qmakeRc->proFilePath() == n;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -143,8 +143,7 @@ public:
|
||||
QList<ProjectExplorer::BuildTargetInfo>
|
||||
availableBuildTargets(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
||||
|
||||
QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Target *t,
|
||||
const ProjectExplorer::Node *n) override;
|
||||
bool hasRunConfigForProFile(ProjectExplorer::RunConfiguration *rc, const Utils::FileName &n) const override;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -38,6 +38,25 @@ using namespace Utils;
|
||||
|
||||
namespace QmakeProjectManager {
|
||||
|
||||
static QList<RunConfiguration *> qmakeRunConfigurationsForNode(Target *t, const Node *node)
|
||||
{
|
||||
QList<RunConfiguration *> result;
|
||||
QTC_ASSERT(t, return result);
|
||||
|
||||
const FileName file = node->filePath();
|
||||
for (auto factory : IRunConfigurationFactory::allRunConfigurationFactories()) {
|
||||
if (auto qmakeFactory = qobject_cast<QmakeRunConfigurationFactory *>(factory)) {
|
||||
if (qmakeFactory->canHandle(t)) {
|
||||
result.append(Utils::filtered(t->runConfigurations(), [qmakeFactory, file](RunConfiguration *rc) {
|
||||
return qmakeFactory->hasRunConfigForProFile(rc, file);
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QmakePriFileNode
|
||||
Implements abstract ProjectNode class
|
||||
@@ -68,10 +87,7 @@ bool QmakePriFileNode::deploysFolder(const QString &folder) const
|
||||
|
||||
QList<RunConfiguration *> QmakePriFileNode::runConfigurations() const
|
||||
{
|
||||
QmakeRunConfigurationFactory *factory = QmakeRunConfigurationFactory::find(m_project->activeTarget());
|
||||
if (factory)
|
||||
return factory->runConfigurationsForNode(m_project->activeTarget(), this);
|
||||
return QList<RunConfiguration *>();
|
||||
return qmakeRunConfigurationsForNode(m_project->activeTarget(), this);
|
||||
}
|
||||
|
||||
QmakeProFileNode *QmakePriFileNode::proFileNode() const
|
||||
@@ -140,9 +156,7 @@ bool QmakePriFileNode::supportsAction(ProjectAction action, const Node *node) co
|
||||
}
|
||||
|
||||
if (action == HasSubProjectRunConfigurations) {
|
||||
Target *target = m_project->activeTarget();
|
||||
QmakeRunConfigurationFactory *factory = QmakeRunConfigurationFactory::find(target);
|
||||
return factory && !factory->runConfigurationsForNode(target, node).isEmpty();
|
||||
return !qmakeRunConfigurationsForNode(m_project->activeTarget(), node).isEmpty();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -33,17 +33,4 @@ QmakeRunConfigurationFactory::QmakeRunConfigurationFactory(QObject *parent) :
|
||||
ProjectExplorer::IRunConfigurationFactory(parent)
|
||||
{ }
|
||||
|
||||
QmakeRunConfigurationFactory *QmakeRunConfigurationFactory::find(ProjectExplorer::Target *t)
|
||||
{
|
||||
if (t) {
|
||||
for (auto factory : IRunConfigurationFactory::allRunConfigurationFactories()) {
|
||||
if (auto qmakeFactory = qobject_cast<QmakeRunConfigurationFactory *>(factory)) {
|
||||
if (qmakeFactory->canHandle(t))
|
||||
return qmakeFactory;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace QmakeProjectManager
|
||||
|
@@ -29,7 +29,7 @@
|
||||
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
|
||||
namespace ProjectExplorer { class Node; }
|
||||
namespace Utils { class FileName; }
|
||||
|
||||
namespace QmakeProjectManager {
|
||||
|
||||
@@ -40,10 +40,7 @@ class QMAKEPROJECTMANAGER_EXPORT QmakeRunConfigurationFactory : public ProjectEx
|
||||
public:
|
||||
explicit QmakeRunConfigurationFactory(QObject *parent = 0);
|
||||
|
||||
virtual QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Target *t,
|
||||
const ProjectExplorer::Node *n) = 0;
|
||||
|
||||
static QmakeRunConfigurationFactory *find(ProjectExplorer::Target *t);
|
||||
virtual bool hasRunConfigForProFile(ProjectExplorer::RunConfiguration *rc, const Utils::FileName &n) const = 0;
|
||||
};
|
||||
|
||||
} // namespace QmakeProjectManager
|
||||
|
Reference in New Issue
Block a user