forked from qt-creator/qt-creator
ProjectExplorer: Reduce qmake specific logic
- add a QString FileNode::buildKey(), returning the build key for a build represented by that node, if any. * for QmakeProFileNodes the build key is traditionally equal to the file name, so use that. * for QbsProductNode use the uniqueProductName() - add a Project::findNodeForBuildKey(QString buildKey) convenience function searching a Project(!)Node matching that build key. That's the only use case there is right now, and I see no reason yet to travers all files (yet). Change-Id: I388c0e06c03111e12d630899d762448e974a5737 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -872,6 +872,15 @@ bool Project::hasParsingData() const
|
||||
return d->m_hasParsingData;
|
||||
}
|
||||
|
||||
const ProjectNode *Project::findNodeForBuildKey(const QString &buildKey) const
|
||||
{
|
||||
const ProjectNode *result = nullptr;
|
||||
d->m_rootProjectNode->forEachProjectNode([buildKey](const ProjectNode *node) {
|
||||
return node->buildKey() == buildKey;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
ProjectImporter *Project::projectImporter() const
|
||||
{
|
||||
return nullptr;
|
||||
|
@@ -171,6 +171,8 @@ public:
|
||||
bool isParsing() const;
|
||||
bool hasParsingData() const;
|
||||
|
||||
const ProjectNode *findNodeForBuildKey(const QString &buildKey) const;
|
||||
|
||||
template<typename S, typename R, typename T, typename ...Args1, typename ...Args2>
|
||||
void subscribeSignal(void (S::*sig)(Args1...), R*recv, T (R::*sl)(Args2...)) {
|
||||
new Internal::ProjectSubscription([sig, recv, sl, this](ProjectConfiguration *pc) {
|
||||
|
@@ -145,6 +145,8 @@ public:
|
||||
virtual ContainerNode *asContainerNode() { return nullptr; }
|
||||
virtual const ContainerNode *asContainerNode() const { return nullptr; }
|
||||
|
||||
virtual QString buildKey() const { return QString(); }
|
||||
|
||||
static bool sortByPath(const Node *a, const Node *b);
|
||||
void setParentFolderNode(FolderNode *parentFolder);
|
||||
|
||||
|
@@ -438,6 +438,11 @@ bool QbsProductNode::renameFile(const QString &filePath, const QString &newFileP
|
||||
return prjNode->project()->renameFileInProduct(filePath, newFilePath, m_qbsProductData, grp);
|
||||
}
|
||||
|
||||
QString QbsProductNode::buildKey() const
|
||||
{
|
||||
return QbsProject::uniqueProductName(m_qbsProductData);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// QbsProjectNode:
|
||||
// --------------------------------------------------------------------
|
||||
|
@@ -110,6 +110,8 @@ public:
|
||||
bool removeFiles(const QStringList &filePaths, QStringList *notRemoved = nullptr) override;
|
||||
bool renameFile(const QString &filePath, const QString &newFilePath) override;
|
||||
|
||||
QString buildKey() const override;
|
||||
|
||||
const qbs::ProductData qbsProductData() const { return m_qbsProductData; }
|
||||
|
||||
private:
|
||||
|
@@ -165,10 +165,8 @@ void QbsRunConfiguration::updateTargetInformation()
|
||||
|
||||
bool QbsRunConfiguration::canRunForNode(const Node *node) const
|
||||
{
|
||||
if (auto pn = dynamic_cast<const QbsProductNode *>(node)) {
|
||||
const QString uniqueProductName = buildKey();
|
||||
return uniqueProductName == QbsProject::uniqueProductName(pn->qbsProductData());
|
||||
}
|
||||
if (auto pn = dynamic_cast<const QbsProductNode *>(node))
|
||||
return buildKey() == pn->buildKey();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@@ -223,6 +223,11 @@ bool QmakeProFileNode::showInSimpleTree() const
|
||||
return showInSimpleTree(projectType()) || m_project->rootProjectNode() == this;
|
||||
}
|
||||
|
||||
QString QmakeProFileNode::buildKey() const
|
||||
{
|
||||
return filePath().toString();
|
||||
}
|
||||
|
||||
QmakeProFile *QmakeProFileNode::proFile() const
|
||||
{
|
||||
return static_cast<QmakeProFile*>(QmakePriFileNode::priFile());
|
||||
|
@@ -91,6 +91,8 @@ public:
|
||||
|
||||
bool showInSimpleTree() const override;
|
||||
|
||||
QString buildKey() const override;
|
||||
|
||||
AddNewInformation addNewInformation(const QStringList &files, Node *context) const override;
|
||||
|
||||
QmakeProjectManager::ProjectType projectType() const;
|
||||
|
Reference in New Issue
Block a user