forked from qt-creator/qt-creator
ProjectExplorer: Let RunConfiguration declare what nodes it belongs to
This feature in question is the availability of the "Run" button in the context menu of certain project nodes in the project tree to run something presumably related to/build from that (sub)project. Previously, the decision was made for certain qmake based projects (those targeting Desktop, iOS and VxWorks) by some indirection through the corresponding RunConfigurationFactories. The patch lets the RunConfigurations decide themselves directly and removes the indirection, potentially opening the feature for other qmake based RCs, as well as other combinations (e.g. PythonRunConfiguration could be associated with its .py file, without the need to have a dummy project) Change-Id: Ic489bd1dfa25fcd9102ffa4fa30125565dd2e40e Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -25,7 +25,6 @@
|
||||
|
||||
#include "qmakenodes.h"
|
||||
#include "qmakeproject.h"
|
||||
#include "qmakerunconfigurationfactory.h"
|
||||
|
||||
#include <projectexplorer/buildconfiguration.h>
|
||||
#include <projectexplorer/target.h>
|
||||
@@ -38,26 +37,6 @@ using namespace Utils;
|
||||
|
||||
namespace QmakeProjectManager {
|
||||
|
||||
static QList<RunConfiguration *> qmakeRunConfigurationsForNode(Target *t, const Node *node)
|
||||
{
|
||||
QList<RunConfiguration *> result;
|
||||
if (!t)
|
||||
return result; // Project was not set up yet.
|
||||
|
||||
const FileName file = node->filePath();
|
||||
for (auto factory : RunConfigurationFactory::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
|
||||
@@ -86,11 +65,6 @@ bool QmakePriFileNode::deploysFolder(const QString &folder) const
|
||||
return pri ? pri->deploysFolder(folder) : false;
|
||||
}
|
||||
|
||||
QList<RunConfiguration *> QmakePriFileNode::runConfigurations() const
|
||||
{
|
||||
return qmakeRunConfigurationsForNode(m_project->activeTarget(), this);
|
||||
}
|
||||
|
||||
QmakeProFileNode *QmakePriFileNode::proFileNode() const
|
||||
{
|
||||
return m_qmakeProFileNode;
|
||||
@@ -157,7 +131,11 @@ bool QmakePriFileNode::supportsAction(ProjectAction action, const Node *node) co
|
||||
}
|
||||
|
||||
if (action == HasSubProjectRunConfigurations) {
|
||||
return !qmakeRunConfigurationsForNode(m_project->activeTarget(), node).isEmpty();
|
||||
if (Target *t = m_project->activeTarget()) {
|
||||
auto canRunForNode = [node](RunConfiguration *rc) { return rc->canRunForNode(node); };
|
||||
if (Utils::anyOf(t->runConfigurations(), canRunForNode))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user