Commit 8850d2e7 authored by Tobias Hunger's avatar Tobias Hunger

ProjectExplorer: Allow for const-correct use of Nodes

Change-Id: Ic1f145e3b429d80c0dcff642b900cb3a3f78f06b
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 327f09c2
......@@ -171,26 +171,6 @@ Node *Node::trim(const QSet<Node *> &keepers)
return keepers.contains(this) ? nullptr : this;
}
FileNode *Node::asFileNode()
{
return nullptr;
}
FolderNode *Node::asFolderNode()
{
return nullptr;
}
ProjectNode *Node::asProjectNode()
{
return nullptr;
}
SessionNode *Node::asSessionNode()
{
return nullptr;
}
bool Node::sortByPath(Node *a, Node *b)
{
return a->filePath() < b->filePath();
......@@ -231,11 +211,6 @@ bool FileNode::isGenerated() const
return m_generated;
}
FileNode *FileNode::asFileNode()
{
return this;
}
static QList<FileNode *> scanForFilesRecursively(const Utils::FileName &directory,
const std::function<FileNode *(const Utils::FileName &)> factory,
QSet<QString> &visited, QFutureInterface<QList<FileNode*>> *future,
......@@ -703,11 +678,6 @@ void FolderNode::removeFolderNodes(const QList<FolderNode*> &subFolders)
ProjectTree::instance()->emitFoldersRemoved(this);
}
FolderNode *FolderNode::asFolderNode()
{
return this;
}
bool FolderNode::showInSimpleTree() const
{
return false;
......@@ -921,11 +891,6 @@ void ProjectNode::removeProjectNodes(const QList<ProjectNode*> &subProjects)
}
}
ProjectNode *ProjectNode::asProjectNode()
{
return this;
}
Node *ProjectNode::trim(const QSet<Node *> &keepers)
{
if (keepers.contains(this))
......@@ -976,11 +941,6 @@ void SessionNode::projectDisplayNameChanged(Node *node)
ProjectTree::instance()->emitNodeSortKeyChanged(node);
}
SessionNode *SessionNode::asSessionNode()
{
return this;
}
QList<ProjectNode*> SessionNode::projectNodes() const
{
return m_projectNodes;
......
......@@ -126,10 +126,14 @@ public:
virtual Node *trim(const QSet<Node *> &keepers);
virtual FileNode *asFileNode();
virtual FolderNode *asFolderNode();
virtual ProjectNode *asProjectNode();
virtual SessionNode *asSessionNode();
virtual FileNode *asFileNode() { return nullptr; }
virtual const FileNode *asFileNode() const { return nullptr; }
virtual FolderNode *asFolderNode() { return nullptr; }
virtual const FolderNode *asFolderNode() const { return nullptr; }
virtual ProjectNode *asProjectNode() { return nullptr; }
virtual const ProjectNode *asProjectNode() const { return nullptr; }
virtual SessionNode *asSessionNode() { return nullptr; }
virtual const SessionNode *asSessionNode() const { return nullptr; }
static bool sortByPath(Node *a, Node *b);
......@@ -159,7 +163,8 @@ public:
FileType fileType() const;
bool isGenerated() const;
FileNode *asFileNode() override;
FileNode *asFileNode() final { return this; }
const FileNode *asFileNode() const final { return this; }
static QList<FileNode *> scanForFiles(const Utils::FileName &directory,
const std::function<FileNode *(const Utils::FileName &fileName)> factory,
......@@ -232,7 +237,8 @@ public:
void addFolderNodes(const QList<FolderNode*> &subFolders);
void removeFolderNodes(const QList<FolderNode*> &subFolders);
FolderNode *asFolderNode() override;
FolderNode *asFolderNode() final { return this; }
const FolderNode *asFolderNode() const final { return this; }
protected:
QList<FolderNode*> m_folderNodes;
......@@ -285,7 +291,8 @@ public:
void addProjectNodes(const QList<ProjectNode*> &subProjects);
void removeProjectNodes(const QList<ProjectNode*> &subProjects);
ProjectNode *asProjectNode() override;
ProjectNode *asProjectNode() final { return this; }
const ProjectNode *asProjectNode() const final { return this; }
Node *trim(const QSet<Node *> &keepers) override;
......@@ -319,7 +326,9 @@ public:
bool showInSimpleTree() const override;
void projectDisplayNameChanged(Node *node);
SessionNode *asSessionNode() override;
SessionNode *asSessionNode() final { return this; }
const SessionNode *asSessionNode() const final { return this; }
protected:
void addProjectNodes(const QList<ProjectNode*> &projectNodes);
void removeProjectNodes(const QList<ProjectNode*> &projectNodes);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment