ProjectExplorer: Add a mechanism to access fixed data in ProjectNodes

To be used in CMakeTargetNode for Android-specific items, but possibly
useful for other combinations, too, at the price of (only) one empty hash
per _Project_Node.

Change-Id: I4ced56a6ddfa54a00f96be0507a556fa7b20b552
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-08-01 11:53:26 +02:00
parent eefabf2b11
commit 0dc97a51b5
2 changed files with 9 additions and 2 deletions

View File

@@ -944,8 +944,7 @@ ProjectNode *ProjectNode::projectNode(const Utils::FilePath &file) const
QVariant ProjectNode::data(Core::Id role) const QVariant ProjectNode::data(Core::Id role) const
{ {
Q_UNUSED(role) return m_fallbackData.value(role);
return QVariant();
} }
bool ProjectNode::setData(Core::Id role, const QVariant &value) const bool ProjectNode::setData(Core::Id role, const QVariant &value) const
@@ -955,6 +954,11 @@ bool ProjectNode::setData(Core::Id role, const QVariant &value) const
return false; return false;
} }
void ProjectNode::setFallbackData(Core::Id key, const QVariant &value)
{
m_fallbackData.insert(key, value);
}
bool FolderNode::isEmpty() const bool FolderNode::isEmpty() const
{ {
return m_nodes.size() == 0; return m_nodes.size() == 0;

View File

@@ -388,6 +388,8 @@ public:
// "build single file" case. // "build single file" case.
virtual void build() {} virtual void build() {}
void setFallbackData(Core::Id key, const QVariant &value);
protected: protected:
void setIsProduct() { m_isProduct = true; } void setIsProduct() { m_isProduct = true; }
@@ -395,6 +397,7 @@ protected:
private: private:
bool m_isProduct = false; bool m_isProduct = false;
QHash<Core::Id, QVariant> m_fallbackData; // Used in data(), unless overridden.
}; };
class PROJECTEXPLORER_EXPORT ContainerNode : public FolderNode class PROJECTEXPLORER_EXPORT ContainerNode : public FolderNode