summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2019-02-28 17:19:18 +0100
committerhjk <hjk@qt.io>2019-03-01 08:44:22 +0000
commit729c74379afe799ee1a729d0db51b3304b2f5f73 (patch)
tree52150ca8a0ca1219c67667f0e3fc9e31ebdb883f
parent89c9eed127977f2ddb5409ba7aefeefe51f64fa7 (diff)
downloadqt-creator-729c74379afe799ee1a729d0db51b3304b2f5f73.tar.gz
ProjectExplorer: Merge Node::isFileNodeType and asFileNode
They were identifying the same set of nodes. Change-Id: I3316cbc434ff740547bcf0baf9e5f1544f6e3f56 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--src/plugins/modeleditor/pxnodeutilities.cpp2
-rw-r--r--src/plugins/nim/project/nimprojectnode.cpp2
-rw-r--r--src/plugins/projectexplorer/foldernavigationwidget.cpp4
-rw-r--r--src/plugins/projectexplorer/projectexplorer.cpp10
-rw-r--r--src/plugins/projectexplorer/projectnodes.cpp2
-rw-r--r--src/plugins/projectexplorer/projectnodes.h3
-rw-r--r--src/plugins/projectexplorer/projecttree.cpp4
-rw-r--r--src/plugins/projectexplorer/projecttreewidget.cpp2
-rw-r--r--src/plugins/pythoneditor/pythoneditorplugin.cpp2
-rw-r--r--src/plugins/qbsprojectmanager/qbsnodes.cpp2
-rw-r--r--src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp2
-rw-r--r--src/plugins/qmakeprojectmanager/qmakenodes.cpp2
-rw-r--r--src/plugins/qmlpreview/qmlpreviewplugin.cpp2
-rw-r--r--src/plugins/qmlprojectmanager/qmlprojectnodes.cpp2
14 files changed, 19 insertions, 22 deletions
diff --git a/src/plugins/modeleditor/pxnodeutilities.cpp b/src/plugins/modeleditor/pxnodeutilities.cpp
index 861f05bd91..cfd071aac7 100644
--- a/src/plugins/modeleditor/pxnodeutilities.cpp
+++ b/src/plugins/modeleditor/pxnodeutilities.cpp
@@ -66,7 +66,7 @@ void PxNodeUtilities::setDiagramSceneController(qmt::DiagramSceneController *dia
QString PxNodeUtilities::calcRelativePath(const ProjectExplorer::Node *node,
const QString &anchorFolder)
{
- const QString nodePath = node->isFileNodeType()
+ const QString nodePath = node->asFileNode()
? node->filePath().toFileInfo().path()
: node->filePath().toString();
diff --git a/src/plugins/nim/project/nimprojectnode.cpp b/src/plugins/nim/project/nimprojectnode.cpp
index 5396a73688..1993004a2c 100644
--- a/src/plugins/nim/project/nimprojectnode.cpp
+++ b/src/plugins/nim/project/nimprojectnode.cpp
@@ -39,7 +39,7 @@ NimProjectNode::NimProjectNode(NimProject &project,
bool NimProjectNode::supportsAction(ProjectAction action, const Node *node) const
{
- if (node->isFileNodeType()) {
+ if (node->asFileNode()) {
return action == ProjectAction::Rename
|| action == ProjectAction::RemoveFile;
}
diff --git a/src/plugins/projectexplorer/foldernavigationwidget.cpp b/src/plugins/projectexplorer/foldernavigationwidget.cpp
index a34d1494cb..b41ae6b0f9 100644
--- a/src/plugins/projectexplorer/foldernavigationwidget.cpp
+++ b/src/plugins/projectexplorer/foldernavigationwidget.cpp
@@ -201,7 +201,7 @@ static QVector<FolderNode *> renamableFolderNodes(const Utils::FileName &before,
{
QVector<FolderNode *> folderNodes;
ProjectTree::forEachNode([&](Node *node) {
- if (node->isFileNodeType()
+ if (node->asFileNode()
&& node->filePath() == before
&& node->parentFolderNode()
&& node->parentFolderNode()->canRenameFile(before.toString(), after.toString())) {
@@ -532,7 +532,7 @@ static QVector<FolderNode *> removableFolderNodes(const Utils::FileName &filePat
{
QVector<FolderNode *> folderNodes;
ProjectTree::forEachNode([&](Node *node) {
- if (node->isFileNodeType()
+ if (node->asFileNode()
&& node->filePath() == filePath
&& node->parentFolderNode()
&& node->parentFolderNode()->supportsAction(RemoveFile, node)) {
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp
index de08fb8aa3..a7ad0f4e7b 100644
--- a/src/plugins/projectexplorer/projectexplorer.cpp
+++ b/src/plugins/projectexplorer/projectexplorer.cpp
@@ -1460,7 +1460,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
connect(dd->m_filePropertiesAction, &QAction::triggered, this, []() {
const Node *currentNode = ProjectTree::findCurrentNode();
- QTC_ASSERT(currentNode && currentNode->isFileNodeType(), return);
+ QTC_ASSERT(currentNode && currentNode->asFileNode(), return);
DocumentManager::showFilePropertiesDialog(currentNode->filePath());
});
connect(dd->m_removeFileAction, &QAction::triggered,
@@ -3507,7 +3507,7 @@ void ProjectExplorerPluginPrivate::openTerminalHere(const EnvironmentGetter &env
void ProjectExplorerPluginPrivate::removeFile()
{
const Node *currentNode = ProjectTree::findCurrentNode();
- QTC_ASSERT(currentNode && currentNode->isFileNodeType(), return);
+ QTC_ASSERT(currentNode && currentNode->asFileNode(), return);
const Utils::FileName filePath = currentNode->filePath();
Utils::RemoveFileDialog removeFileDialog(filePath.toString(), ICore::mainWindow());
@@ -3518,7 +3518,7 @@ void ProjectExplorerPluginPrivate::removeFile()
// Re-read the current node, in case the project is re-parsed while the dialog is open
if (currentNode != ProjectTree::findCurrentNode()) {
currentNode = ProjectTreeWidget::nodeForFile(filePath);
- QTC_ASSERT(currentNode && currentNode->isFileNodeType(), return);
+ QTC_ASSERT(currentNode && currentNode->asFileNode(), return);
}
// remove from project
@@ -3542,7 +3542,7 @@ void ProjectExplorerPluginPrivate::removeFile()
void ProjectExplorerPluginPrivate::duplicateFile()
{
Node *currentNode = ProjectTree::findCurrentNode();
- QTC_ASSERT(currentNode && currentNode->isFileNodeType(), return);
+ QTC_ASSERT(currentNode && currentNode->asFileNode(), return);
FileNode *fileNode = currentNode->asFileNode();
QString filePath = currentNode->filePath().toString();
@@ -3573,7 +3573,7 @@ void ProjectExplorerPluginPrivate::duplicateFile()
void ProjectExplorerPluginPrivate::deleteFile()
{
Node *currentNode = ProjectTree::findCurrentNode();
- QTC_ASSERT(currentNode && currentNode->isFileNodeType(), return);
+ QTC_ASSERT(currentNode && currentNode->asFileNode(), return);
FileNode *fileNode = currentNode->asFileNode();
diff --git a/src/plugins/projectexplorer/projectnodes.cpp b/src/plugins/projectexplorer/projectnodes.cpp
index 2d971a7747..0750850339 100644
--- a/src/plugins/projectexplorer/projectnodes.cpp
+++ b/src/plugins/projectexplorer/projectnodes.cpp
@@ -165,7 +165,7 @@ Node::~Node() = default;
NodeType Node::nodeType() const
{
- if (isFileNodeType())
+ if (asFileNode())
return NodeType::File;
if (isFolderNodeType())
return NodeType::Folder;
diff --git a/src/plugins/projectexplorer/projectnodes.h b/src/plugins/projectexplorer/projectnodes.h
index 415c06d5a8..790112e100 100644
--- a/src/plugins/projectexplorer/projectnodes.h
+++ b/src/plugins/projectexplorer/projectnodes.h
@@ -112,7 +112,6 @@ public:
virtual ~Node();
- virtual bool isFileNodeType() const { return false; }
virtual bool isFolderNodeType() const { return false; }
virtual bool isProjectNodeType() const { return false; }
virtual bool isVirtualFolderType() const { return false; }
@@ -199,8 +198,6 @@ public:
FileNode *asFileNode() final { return this; }
const FileNode *asFileNode() const final { return this; }
- bool isFileNodeType() const final { return true; }
-
static QList<FileNode *>
scanForFiles(const Utils::FileName &directory,
const std::function<FileNode *(const Utils::FileName &fileName)> factory,
diff --git a/src/plugins/projectexplorer/projecttree.cpp b/src/plugins/projectexplorer/projecttree.cpp
index 9b63cd32fa..6b00620b8a 100644
--- a/src/plugins/projectexplorer/projecttree.cpp
+++ b/src/plugins/projectexplorer/projecttree.cpp
@@ -341,7 +341,7 @@ void ProjectTree::showContextMenu(ProjectTreeWidget *focus, const QPoint &global
contextMenu = Core::ActionManager::actionContainer(Constants::M_SUBPROJECTCONTEXT)->menu();
} else if (node->isVirtualFolderType() || node->isFolderNodeType()) {
contextMenu = Core::ActionManager::actionContainer(Constants::M_FOLDERCONTEXT)->menu();
- } else if (node->isFileNodeType()) {
+ } else if (node->asFileNode()) {
contextMenu = Core::ActionManager::actionContainer(Constants::M_FILECONTEXT)->menu();
}
@@ -425,7 +425,7 @@ Node *ProjectTree::nodeForFile(const FileName &fileName)
projectNode->forEachGenericNode([&](Node *n) {
if (n->filePath() == fileName) {
// prefer file nodes
- if (!node || (!node->isFileNodeType() && n->isFileNodeType()))
+ if (!node || (!node->asFileNode() && n->asFileNode()))
node = n;
}
});
diff --git a/src/plugins/projectexplorer/projecttreewidget.cpp b/src/plugins/projectexplorer/projecttreewidget.cpp
index 55f93c212b..38748ff28d 100644
--- a/src/plugins/projectexplorer/projecttreewidget.cpp
+++ b/src/plugins/projectexplorer/projecttreewidget.cpp
@@ -524,7 +524,7 @@ void ProjectTreeWidget::showContextMenu(const QPoint &pos)
void ProjectTreeWidget::openItem(const QModelIndex &mainIndex)
{
Node *node = m_model->nodeForIndex(mainIndex);
- if (!node || !node->isFileNodeType())
+ if (!node || !node->asFileNode())
return;
IEditor *editor = EditorManager::openEditor(node->filePath().toString());
if (editor && node->line() >= 0)
diff --git a/src/plugins/pythoneditor/pythoneditorplugin.cpp b/src/plugins/pythoneditor/pythoneditorplugin.cpp
index 6abb9146ca..4acb367622 100644
--- a/src/plugins/pythoneditor/pythoneditorplugin.cpp
+++ b/src/plugins/pythoneditor/pythoneditorplugin.cpp
@@ -618,7 +618,7 @@ bool PythonProjectNode::showInSimpleTree() const
bool PythonProjectNode::supportsAction(ProjectAction action, const Node *node) const
{
- if (node->isFileNodeType()) {
+ if (node->asFileNode()) {
return action == ProjectAction::Rename
|| action == ProjectAction::RemoveFile;
}
diff --git a/src/plugins/qbsprojectmanager/qbsnodes.cpp b/src/plugins/qbsprojectmanager/qbsnodes.cpp
index 8e26c4bf28..c5830b176a 100644
--- a/src/plugins/qbsprojectmanager/qbsnodes.cpp
+++ b/src/plugins/qbsprojectmanager/qbsnodes.cpp
@@ -223,7 +223,7 @@ static bool supportsNodeAction(ProjectAction action, const Node *node)
};
if (action == RemoveFile || action == Rename) {
- if (node->isFileNodeType())
+ if (node->asFileNode())
return !Utils::contains(project->qbsProject().buildSystemFiles(), equalsNodeFilePath);
}
diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp b/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp
index 0b0897e642..32976a99c5 100644
--- a/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp
+++ b/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp
@@ -286,7 +286,7 @@ void QbsProjectManagerPlugin::updateContextActions()
&& project && !project->isParsing()
&& node && node->isEnabled();
- const bool isFile = project && node && node->isFileNodeType();
+ const bool isFile = project && node && node->asFileNode();
const bool isProduct = project && node && dynamic_cast<const QbsProductNode *>(node);
const auto subproject = dynamic_cast<const QbsProjectNode *>(node);
bool isSubproject = project && subproject && subproject != project->rootProjectNode();
diff --git a/src/plugins/qmakeprojectmanager/qmakenodes.cpp b/src/plugins/qmakeprojectmanager/qmakenodes.cpp
index 7e74172805..fc1cdc4e5a 100644
--- a/src/plugins/qmakeprojectmanager/qmakenodes.cpp
+++ b/src/plugins/qmakeprojectmanager/qmakenodes.cpp
@@ -171,7 +171,7 @@ bool QmakePriFileNode::addFiles(const QStringList &filePaths, QStringList *notAd
if (!pri)
return false;
QList<Node *> matchingNodes = findNodes([filePaths](const Node *n) {
- return n->isFileNodeType() && filePaths.contains(n->filePath().toString());
+ return n->asFileNode() && filePaths.contains(n->filePath().toString());
});
matchingNodes = filtered(matchingNodes, [](const Node *n) {
for (const Node *parent = n->parentFolderNode(); parent;
diff --git a/src/plugins/qmlpreview/qmlpreviewplugin.cpp b/src/plugins/qmlpreview/qmlpreviewplugin.cpp
index 36b9d4f449..0094e9211b 100644
--- a/src/plugins/qmlpreview/qmlpreviewplugin.cpp
+++ b/src/plugins/qmlpreview/qmlpreviewplugin.cpp
@@ -298,7 +298,7 @@ void QmlPreviewPlugin::setFileLoader(QmlPreviewFileLoader fileLoader)
void QmlPreviewPlugin::previewCurrentFile()
{
const Node *currentNode = ProjectTree::findCurrentNode();
- if (!currentNode || !currentNode->isFileNodeType()
+ if (!currentNode || !currentNode->asFileNode()
|| currentNode->asFileNode()->fileType() != FileType::QML)
return;
diff --git a/src/plugins/qmlprojectmanager/qmlprojectnodes.cpp b/src/plugins/qmlprojectmanager/qmlprojectnodes.cpp
index 68f3fc2416..32d4f5292a 100644
--- a/src/plugins/qmlprojectmanager/qmlprojectnodes.cpp
+++ b/src/plugins/qmlprojectmanager/qmlprojectnodes.cpp
@@ -64,7 +64,7 @@ bool QmlProjectNode::supportsAction(ProjectAction action, const Node *node) cons
return true;
QTC_ASSERT(node, return false);
- if (action == Rename && node->isFileNodeType()) {
+ if (action == Rename && node->asFileNode()) {
const FileNode *fileNode = node->asFileNode();
QTC_ASSERT(fileNode, return false);
return fileNode->fileType() != FileType::Project;