forked from qt-creator/qt-creator
ProjectExplorer: Allow for disabled nodes in the project tree
Change-Id: I82d8284777f5691eb3ba9cf4ef92da05057aac18 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -134,7 +134,10 @@ QString Node::tooltip() const
|
||||
|
||||
bool Node::isEnabled() const
|
||||
{
|
||||
return parentFolderNode()->isEnabled();
|
||||
if (!m_isEnabled)
|
||||
return false;
|
||||
FolderNode *parent = parentFolderNode();
|
||||
return parent ? parent->isEnabled() : true;
|
||||
}
|
||||
|
||||
QList<ProjectAction> Node::supportedActions(Node *node) const
|
||||
@@ -144,6 +147,14 @@ QList<ProjectAction> Node::supportedActions(Node *node) const
|
||||
return list;
|
||||
}
|
||||
|
||||
void Node::setEnabled(bool enabled)
|
||||
{
|
||||
if (m_isEnabled == enabled)
|
||||
return;
|
||||
m_isEnabled = enabled;
|
||||
emitNodeUpdated();
|
||||
}
|
||||
|
||||
void Node::setProjectNode(ProjectNode *project)
|
||||
{
|
||||
m_projectNode = project;
|
||||
|
||||
@@ -115,10 +115,11 @@ public:
|
||||
int line() const;
|
||||
virtual QString displayName() const;
|
||||
virtual QString tooltip() const;
|
||||
virtual bool isEnabled() const;
|
||||
bool isEnabled() const;
|
||||
|
||||
virtual QList<ProjectAction> supportedActions(Node *node) const;
|
||||
|
||||
void setEnabled(bool enabled);
|
||||
void setAbsoluteFilePathAndLine(const Utils::FileName &filePath, int line);
|
||||
|
||||
void emitNodeUpdated();
|
||||
@@ -143,6 +144,7 @@ private:
|
||||
Utils::FileName m_filePath;
|
||||
int m_line;
|
||||
NodeType m_nodeType;
|
||||
bool m_isEnabled = true;
|
||||
};
|
||||
|
||||
class PROJECTEXPLORER_EXPORT FileNode : public Node
|
||||
@@ -270,8 +272,6 @@ public:
|
||||
|
||||
void accept(NodesVisitor *visitor) override;
|
||||
|
||||
bool isEnabled() const override { return true; }
|
||||
|
||||
// to be called in implementation of
|
||||
// the corresponding public functions
|
||||
void addProjectNodes(const QList<ProjectNode*> &subProjects);
|
||||
@@ -306,8 +306,6 @@ public:
|
||||
|
||||
void accept(NodesVisitor *visitor) override;
|
||||
|
||||
bool isEnabled() const override { return true; }
|
||||
|
||||
bool showInSimpleTree() const override;
|
||||
void projectDisplayNameChanged(Node *node);
|
||||
|
||||
|
||||
@@ -330,14 +330,6 @@ QbsGroupNode::QbsGroupNode(const qbs::GroupData &grp, const QString &productPath
|
||||
updateQbsGroupData(grp, productPath, true, true);
|
||||
}
|
||||
|
||||
bool QbsGroupNode::isEnabled() const
|
||||
{
|
||||
if (!parentFolderNode() || !m_qbsGroupData.isValid())
|
||||
return false;
|
||||
return static_cast<QbsProductNode *>(parentFolderNode())->isEnabled()
|
||||
&& m_qbsGroupData.isEnabled();
|
||||
}
|
||||
|
||||
QList<ProjectExplorer::ProjectAction> QbsGroupNode::supportedActions(ProjectExplorer::Node *node) const
|
||||
{
|
||||
return supportedNodeActions(node, true);
|
||||
@@ -413,6 +405,8 @@ void QbsGroupNode::updateQbsGroupData(const qbs::GroupData &grp, const QString &
|
||||
bool groupIsEnabled = productIsEnabled && grp.isEnabled();
|
||||
bool updateExisting = groupWasEnabled != groupIsEnabled;
|
||||
|
||||
setEnabled(groupIsEnabled);
|
||||
|
||||
m_productPath = productPath;
|
||||
m_qbsGroupData = grp;
|
||||
|
||||
@@ -598,11 +592,6 @@ QbsProductNode::QbsProductNode(const qbs::Project &project, const qbs::ProductDa
|
||||
setQbsProductData(project, prd);
|
||||
}
|
||||
|
||||
bool QbsProductNode::isEnabled() const
|
||||
{
|
||||
return m_qbsProductData.isEnabled();
|
||||
}
|
||||
|
||||
bool QbsProductNode::showInSimpleTree() const
|
||||
{
|
||||
return true;
|
||||
@@ -675,6 +664,8 @@ void QbsProductNode::setQbsProductData(const qbs::Project &project, const qbs::P
|
||||
bool productIsEnabled = prd.isEnabled();
|
||||
bool updateExisting = productWasEnabled != productIsEnabled;
|
||||
|
||||
setEnabled(prd.isEnabled());
|
||||
|
||||
setDisplayName(QbsProject::productDisplayName(project, prd));
|
||||
setAbsoluteFilePathAndLine(Utils::FileName::fromString(prd.location().filePath()), line());
|
||||
const QString &productPath = QFileInfo(prd.location().filePath()).absolutePath();
|
||||
|
||||
@@ -92,7 +92,6 @@ class QbsGroupNode : public QbsBaseProjectNode
|
||||
public:
|
||||
QbsGroupNode(const qbs::GroupData &grp, const QString &productPath);
|
||||
|
||||
bool isEnabled() const override;
|
||||
QList<ProjectExplorer::ProjectAction> supportedActions(Node *node) const override;
|
||||
bool addFiles(const QStringList &filePaths, QStringList *notAdded = 0) override;
|
||||
bool removeFiles(const QStringList &filePaths, QStringList *notRemoved = 0) override;
|
||||
@@ -130,7 +129,6 @@ class QbsProductNode : public QbsBaseProjectNode
|
||||
public:
|
||||
explicit QbsProductNode(const qbs::Project &project, const qbs::ProductData &prd);
|
||||
|
||||
bool isEnabled() const override;
|
||||
bool showInSimpleTree() const override;
|
||||
QList<ProjectExplorer::ProjectAction> supportedActions(Node *node) const override;
|
||||
bool addFiles(const QStringList &filePaths, QStringList *notAdded = 0) override;
|
||||
|
||||
Reference in New Issue
Block a user