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