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});
|
ProjectType::AuxTemplate});
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<RunConfiguration *> IosRunConfigurationFactory::runConfigurationsForNode(Target *t, const Node *n)
|
bool IosRunConfigurationFactory::hasRunConfigForProFile(RunConfiguration *rc, const Utils::FileName &n) const
|
||||||
{
|
{
|
||||||
QList<RunConfiguration *> result;
|
auto iosRc = qobject_cast<IosRunConfiguration *>(rc);
|
||||||
foreach (RunConfiguration *rc, t->runConfigurations()) {
|
return iosRc && iosRc->profilePath() == n;
|
||||||
if (IosRunConfiguration *qt4c = qobject_cast<IosRunConfiguration *>(rc)) {
|
|
||||||
if (qt4c->profilePath() == n->filePath())
|
|
||||||
result << rc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -48,9 +48,7 @@ public:
|
|||||||
|
|
||||||
bool canCreateHelper(ProjectExplorer::Target *parent, const QString &suffix) const override;
|
bool canCreateHelper(ProjectExplorer::Target *parent, const QString &suffix) const override;
|
||||||
|
|
||||||
QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Target *t,
|
bool hasRunConfigForProFile(ProjectExplorer::RunConfiguration *rc, const Utils::FileName &n) const override;
|
||||||
const ProjectExplorer::Node *n
|
|
||||||
) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -450,14 +450,10 @@ QList<BuildTargetInfo>
|
|||||||
return project->buildTargets(mode);
|
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;
|
auto qmakeRc = qobject_cast<DesktopQmakeRunConfiguration *>(rc);
|
||||||
foreach (RunConfiguration *rc, t->runConfigurations())
|
return qmakeRc && qmakeRc->proFilePath() == n;
|
||||||
if (DesktopQmakeRunConfiguration *qmakeRc = qobject_cast<DesktopQmakeRunConfiguration *>(rc))
|
|
||||||
if (qmakeRc->proFilePath() == n->filePath())
|
|
||||||
result << rc;
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -143,8 +143,7 @@ public:
|
|||||||
QList<ProjectExplorer::BuildTargetInfo>
|
QList<ProjectExplorer::BuildTargetInfo>
|
||||||
availableBuildTargets(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
availableBuildTargets(ProjectExplorer::Target *parent, CreationMode mode) const override;
|
||||||
|
|
||||||
QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Target *t,
|
bool hasRunConfigForProFile(ProjectExplorer::RunConfiguration *rc, const Utils::FileName &n) const override;
|
||||||
const ProjectExplorer::Node *n) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -38,6 +38,25 @@ using namespace Utils;
|
|||||||
|
|
||||||
namespace QmakeProjectManager {
|
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
|
\class QmakePriFileNode
|
||||||
Implements abstract ProjectNode class
|
Implements abstract ProjectNode class
|
||||||
@@ -68,10 +87,7 @@ bool QmakePriFileNode::deploysFolder(const QString &folder) const
|
|||||||
|
|
||||||
QList<RunConfiguration *> QmakePriFileNode::runConfigurations() const
|
QList<RunConfiguration *> QmakePriFileNode::runConfigurations() const
|
||||||
{
|
{
|
||||||
QmakeRunConfigurationFactory *factory = QmakeRunConfigurationFactory::find(m_project->activeTarget());
|
return qmakeRunConfigurationsForNode(m_project->activeTarget(), this);
|
||||||
if (factory)
|
|
||||||
return factory->runConfigurationsForNode(m_project->activeTarget(), this);
|
|
||||||
return QList<RunConfiguration *>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QmakeProFileNode *QmakePriFileNode::proFileNode() const
|
QmakeProFileNode *QmakePriFileNode::proFileNode() const
|
||||||
@@ -140,9 +156,7 @@ bool QmakePriFileNode::supportsAction(ProjectAction action, const Node *node) co
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (action == HasSubProjectRunConfigurations) {
|
if (action == HasSubProjectRunConfigurations) {
|
||||||
Target *target = m_project->activeTarget();
|
return !qmakeRunConfigurationsForNode(m_project->activeTarget(), node).isEmpty();
|
||||||
QmakeRunConfigurationFactory *factory = QmakeRunConfigurationFactory::find(target);
|
|
||||||
return factory && !factory->runConfigurationsForNode(target, node).isEmpty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@@ -33,17 +33,4 @@ QmakeRunConfigurationFactory::QmakeRunConfigurationFactory(QObject *parent) :
|
|||||||
ProjectExplorer::IRunConfigurationFactory(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
|
} // namespace QmakeProjectManager
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#include <projectexplorer/runconfiguration.h>
|
#include <projectexplorer/runconfiguration.h>
|
||||||
|
|
||||||
namespace ProjectExplorer { class Node; }
|
namespace Utils { class FileName; }
|
||||||
|
|
||||||
namespace QmakeProjectManager {
|
namespace QmakeProjectManager {
|
||||||
|
|
||||||
@@ -40,10 +40,7 @@ class QMAKEPROJECTMANAGER_EXPORT QmakeRunConfigurationFactory : public ProjectEx
|
|||||||
public:
|
public:
|
||||||
explicit QmakeRunConfigurationFactory(QObject *parent = 0);
|
explicit QmakeRunConfigurationFactory(QObject *parent = 0);
|
||||||
|
|
||||||
virtual QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Target *t,
|
virtual bool hasRunConfigForProFile(ProjectExplorer::RunConfiguration *rc, const Utils::FileName &n) const = 0;
|
||||||
const ProjectExplorer::Node *n) = 0;
|
|
||||||
|
|
||||||
static QmakeRunConfigurationFactory *find(ProjectExplorer::Target *t);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QmakeProjectManager
|
} // namespace QmakeProjectManager
|
||||||
|
Reference in New Issue
Block a user