forked from qt-creator/qt-creator
ProjectExplorer: Use a setter for the Node's type
Change-Id: I3cc496151888cdecff0be54043a24fefe5ee2b02 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -249,8 +249,7 @@ QStringList relativeDirsList(Utils::FileName currentPath, const Utils::FileName
|
||||
FolderNode *addChildFolderNode(FolderNode *parent, const QString &childName)
|
||||
{
|
||||
Utils::FileName parentPath = parent->filePath();
|
||||
auto node = std::make_unique<FolderNode>(
|
||||
parentPath.appendPath(childName), NodeType::Folder);
|
||||
auto node = std::make_unique<FolderNode>(parentPath.appendPath(childName));
|
||||
FolderNode *childNode = node.get();
|
||||
childNode->setDisplayName(childName);
|
||||
parent->addNode(std::move(node));
|
||||
|
@@ -119,9 +119,7 @@ static FolderNode *recursiveFindOrCreateFolderNode(FolderNode *folder,
|
||||
\sa ProjectExplorer::NodesWatcher
|
||||
*/
|
||||
|
||||
Node::Node(NodeType nodeType)
|
||||
: m_nodeType(nodeType)
|
||||
{ }
|
||||
Node::Node() = default;
|
||||
|
||||
void Node::setPriority(int p)
|
||||
{
|
||||
@@ -310,6 +308,11 @@ FileType Node::fileTypeForFileName(const Utils::FileName &file)
|
||||
Utils::MimeMatchMode::MatchExtension));
|
||||
}
|
||||
|
||||
void Node::setNodeType(NodeType nodeType)
|
||||
{
|
||||
m_nodeType = nodeType;
|
||||
}
|
||||
|
||||
/*!
|
||||
\class ProjectExplorer::FileNode
|
||||
|
||||
@@ -321,7 +324,6 @@ FileType Node::fileTypeForFileName(const Utils::FileName &file)
|
||||
*/
|
||||
|
||||
FileNode::FileNode(const Utils::FileName &filePath, const FileType fileType) :
|
||||
Node(NodeType::File),
|
||||
m_fileType(fileType)
|
||||
{
|
||||
setFilePath(filePath);
|
||||
@@ -422,9 +424,9 @@ bool FileNode::supportsAction(ProjectAction action, const Node *node) const
|
||||
|
||||
\sa ProjectExplorer::FileNode, ProjectExplorer::ProjectNode
|
||||
*/
|
||||
FolderNode::FolderNode(const Utils::FileName &folderPath, NodeType nodeType) :
|
||||
Node(nodeType)
|
||||
FolderNode::FolderNode(const Utils::FileName &folderPath)
|
||||
{
|
||||
setNodeType(NodeType::Folder);
|
||||
setFilePath(folderPath);
|
||||
setPriority(DefaultFolderPriority);
|
||||
setListInProject(false);
|
||||
@@ -781,8 +783,9 @@ bool FolderNode::showWhenEmpty() const
|
||||
\sa ProjectExplorer::FileNode, ProjectExplorer::ProjectNode
|
||||
*/
|
||||
VirtualFolderNode::VirtualFolderNode(const Utils::FileName &folderPath, int priority) :
|
||||
FolderNode(folderPath, NodeType::VirtualFolder)
|
||||
FolderNode(folderPath)
|
||||
{
|
||||
setNodeType(NodeType::VirtualFolder);
|
||||
setPriority(priority);
|
||||
}
|
||||
|
||||
@@ -807,8 +810,9 @@ QString VirtualFolderNode::addFileFilter() const
|
||||
Creates an uninitialized project node object.
|
||||
*/
|
||||
ProjectNode::ProjectNode(const Utils::FileName &projectFilePath) :
|
||||
FolderNode(projectFilePath, NodeType::Project)
|
||||
FolderNode(projectFilePath)
|
||||
{
|
||||
setNodeType(NodeType::Project);
|
||||
setPriority(DefaultProjectPriority);
|
||||
setListInProject(true);
|
||||
setDisplayName(projectFilePath.fileName());
|
||||
@@ -917,8 +921,10 @@ void FolderNode::handleSubTreeChanged(FolderNode *node)
|
||||
}
|
||||
|
||||
ContainerNode::ContainerNode(Project *project)
|
||||
: FolderNode(project->projectDirectory(), NodeType::Project), m_project(project)
|
||||
{}
|
||||
: FolderNode(project->projectDirectory()), m_project(project)
|
||||
{
|
||||
setNodeType(NodeType::Project);
|
||||
}
|
||||
|
||||
QString ContainerNode::displayName() const
|
||||
{
|
||||
|
@@ -111,7 +111,7 @@ public:
|
||||
};
|
||||
|
||||
virtual ~Node();
|
||||
Node(const Node &other) = delete;
|
||||
|
||||
NodeType nodeType() const;
|
||||
int priority() const;
|
||||
|
||||
@@ -159,8 +159,10 @@ public:
|
||||
static FileType fileTypeForFileName(const Utils::FileName &file);
|
||||
|
||||
protected:
|
||||
explicit Node(NodeType nodeType);
|
||||
Node();
|
||||
Node(const Node &other) = delete;
|
||||
|
||||
void setNodeType(NodeType nodeType);
|
||||
void setPriority(int priority);
|
||||
void setLine(int line);
|
||||
void setFilePath(const Utils::FileName &filePath);
|
||||
@@ -170,7 +172,8 @@ private:
|
||||
Utils::FileName m_filePath;
|
||||
int m_line = -1;
|
||||
int m_priority = DefaultPriority;
|
||||
const NodeType m_nodeType;
|
||||
NodeType m_nodeType = NodeType::File;
|
||||
|
||||
enum NodeFlag : quint16 {
|
||||
FlagNone = 0,
|
||||
FlagIsEnabled = 1 << 0,
|
||||
@@ -206,7 +209,7 @@ private:
|
||||
class PROJECTEXPLORER_EXPORT FolderNode : public Node
|
||||
{
|
||||
public:
|
||||
explicit FolderNode(const Utils::FileName &folderPath, NodeType nodeType = NodeType::Folder);
|
||||
explicit FolderNode(const Utils::FileName &folderPath);
|
||||
|
||||
QString displayName() const override;
|
||||
QIcon icon() const;
|
||||
|
@@ -214,8 +214,7 @@ std::unique_ptr<QbsRootProjectNode> QbsNodeTreeBuilder::buildTree(QbsProject *pr
|
||||
auto root = std::make_unique<QbsRootProjectNode>(project);
|
||||
setupProjectNode(root.get(), project->qbsProjectData(), project->qbsProject());
|
||||
auto buildSystemFiles
|
||||
= std::make_unique<ProjectExplorer::FolderNode>(project->projectDirectory(),
|
||||
ProjectExplorer::NodeType::Folder);
|
||||
= std::make_unique<ProjectExplorer::FolderNode>(project->projectDirectory());
|
||||
buildSystemFiles->setDisplayName(QCoreApplication::translate("QbsRootProjectNode", "Qbs files"));
|
||||
|
||||
Utils::FileName base = project->projectDirectory();
|
||||
|
Reference in New Issue
Block a user