Commit 45046f70 authored by Tobias Hunger's avatar Tobias Hunger Committed by Tim Jenssen

ProjectNodes: Do not derive Project Nodes from QObject

That should save some memory per node, and since creator has a lot of nodes
(e.g. opening the LLVM project adds about 1 000 000 nodes) this should be
noticeable:-)

Calling update inside ProjectTree::currentNode() and rename it to
findCurrentNode() to make sure it is an still existing pointer.
Also, try to reduce the somehow more expensive currentNode() calls
and sprinkle some const around that usage.

Change-Id: I6a7c5db01a71d53d39544d3013cad557d5b96cdc
Reviewed-by: Tobias Hunger's avatarTobias Hunger <tobias.hunger@qt.io>
parent bbb54cde
......@@ -114,8 +114,8 @@ void CMakeProjectPlugin::extensionsInitialized()
void CMakeProjectPlugin::updateContextActions()
{
Project *project = ProjectTree::currentProject();
Node *node = ProjectTree::currentNode();
CMakeTargetNode *targetNode = dynamic_cast<CMakeTargetNode *>(node);
const Node *node = ProjectTree::findCurrentNode();
const CMakeTargetNode *targetNode = dynamic_cast<const CMakeTargetNode *>(node);
// as targetNode can be deleted while the menu is open, we keep only the
const QString targetDisplayName = targetNode ? targetNode->displayName() : QString();
CMakeProject *cmProject = dynamic_cast<CMakeProject *>(project);
......
......@@ -126,7 +126,7 @@ public:
bool showInSimpleTree() const override { return true; }
bool supportsAction(ProjectAction action, Node *) const override
bool supportsAction(ProjectAction action, const Node *) const override
{
return action == AddNewFile
|| action == AddExistingFile
......
......@@ -188,7 +188,7 @@ void ModelsManager::onAboutToShowContextMenu(ProjectExplorer::Project *project,
void ModelsManager::onOpenDiagramFromProjectExplorer()
{
if (ProjectExplorer::ProjectTree::instance()->currentNode() == d->contextMenuOwnerNode) {
if (ProjectExplorer::ProjectTree::findCurrentNode() == d->contextMenuOwnerNode) {
qmt::MDiagram *diagram = 0;
foreach (const ManagedModel &managedModel, d->managedModels) {
if ((diagram = managedModel.m_documentController->pxNodeController()->findDiagramForExplorerNode(d->contextMenuOwnerNode))) {
......
......@@ -37,7 +37,7 @@ NimProjectNode::NimProjectNode(NimProject &project,
, m_project(project)
{}
bool NimProjectNode::supportsAction(ProjectAction action, Node *node) const
bool NimProjectNode::supportsAction(ProjectAction action, const Node *node) const
{
switch (node->nodeType()) {
case NodeType::File:
......
......@@ -38,7 +38,7 @@ class NimProjectNode : public ProjectExplorer::ProjectNode
public:
NimProjectNode(NimProject &project, const Utils::FileName &projectFilePath);
bool supportsAction(ProjectExplorer::ProjectAction action, Node *node) const override;
bool supportsAction(ProjectExplorer::ProjectAction action, const Node *node) const override;
bool addFiles(const QStringList &filePaths, QStringList *) override;
bool removeFiles(const QStringList &filePaths, QStringList *) override;
bool deleteFiles(const QStringList &) override;
......
......@@ -49,7 +49,7 @@ class WrapperNode : public Utils::TypedTreeItem<WrapperNode>
{
public:
explicit WrapperNode(Node *node) : m_node(node) {}
QPointer<Node> m_node;
Node *m_node = nullptr;
};
class FlatModel : public Utils::TreeModel<WrapperNode, WrapperNode>
......
......@@ -248,7 +248,7 @@ bool Node::isGenerated() const
return (m_flags & FlagIsGenerated) == FlagIsGenerated;
}
bool Node::supportsAction(ProjectAction, Node *) const
bool Node::supportsAction(ProjectAction, const Node *) const
{
return false;
}
......@@ -403,7 +403,7 @@ FileNode::scanForFilesWithVersionControls(const Utils::FileName &directory,
return scanForFilesRecursively(directory, factory, visited, future, 0.0, 1000000.0, versionControls);
}
bool FileNode::supportsAction(ProjectAction action, Node *node) const
bool FileNode::supportsAction(ProjectAction action, const Node *node) const
{
if (action == InheritedFromParent)
return true;
......@@ -653,7 +653,7 @@ QString FolderNode::addFileFilter() const
return fn ? fn->addFileFilter() : QString();
}
bool FolderNode::supportsAction(ProjectAction action, Node *node) const
bool FolderNode::supportsAction(ProjectAction action, const Node *node) const
{
if (action == InheritedFromParent)
return true;
......@@ -831,7 +831,7 @@ bool ProjectNode::renameFile(const QString &filePath, const QString &newFilePath
return false;
}
bool ProjectNode::supportsAction(ProjectAction, Node *) const
bool ProjectNode::supportsAction(ProjectAction, const Node *) const
{
return false;
}
......@@ -886,9 +886,9 @@ QString ContainerNode::displayName() const
return name;
}
bool ContainerNode::supportsAction(ProjectAction action, Node *node) const
bool ContainerNode::supportsAction(ProjectAction action, const Node *node) const
{
Node *rootNode = m_project->rootProjectNode();
const Node *rootNode = m_project->rootProjectNode();
return rootNode && rootNode->supportsAction(action, node);
}
......
......@@ -29,7 +29,6 @@
#include <QFutureInterface>
#include <QIcon>
#include <QObject>
#include <QStringList>
#include <utils/fileutils.h>
......@@ -98,9 +97,8 @@ class ProjectNode;
class ContainerNode;
// Documentation inside.
class PROJECTEXPLORER_EXPORT Node : public QObject
class PROJECTEXPLORER_EXPORT Node
{
Q_OBJECT
public:
enum PriorityLevel {
DefaultPriority = 0,
......@@ -133,7 +131,7 @@ public:
bool listInProject() const;
bool isGenerated() const;
virtual bool supportsAction(ProjectAction action, Node *node) const;
virtual bool supportsAction(ProjectAction action, const Node *node) const;
void setEnabled(bool enabled);
void setAbsoluteFilePathAndLine(const Utils::FileName &filePath, int line);
......@@ -199,7 +197,7 @@ public:
const std::function<FileNode *(const Utils::FileName &fileName)> factory,
const QList<Core::IVersionControl *> &versionControls,
QFutureInterface<QList<FileNode *>> *future = nullptr);
bool supportsAction(ProjectAction action, Node *node) const override;
bool supportsAction(ProjectAction action, const Node *node) const override;
private:
FileType m_fileType;
......@@ -257,7 +255,7 @@ public:
virtual QString addFileFilter() const;
bool supportsAction(ProjectAction action, Node *node) const override;
bool supportsAction(ProjectAction action, const Node *node) const override;
virtual bool addFiles(const QStringList &filePaths, QStringList *notAdded = 0);
virtual bool removeFiles(const QStringList &filePaths, QStringList *notRemoved = 0);
......@@ -323,7 +321,7 @@ public:
bool deleteFiles(const QStringList &filePaths) override;
bool canRenameFile(const QString &filePath, const QString &newFilePath) override;
bool renameFile(const QString &filePath, const QString &newFilePath) override;
bool supportsAction(ProjectAction action, Node *node) const override;
bool supportsAction(ProjectAction action, const Node *node) const override;
// by default returns false
virtual bool deploysFolder(const QString &folder) const;
......@@ -345,7 +343,7 @@ public:
ContainerNode(Project *project);
QString displayName() const final;
bool supportsAction(ProjectAction action, Node *node) const final;
bool supportsAction(ProjectAction action, const Node *node) const final;
ContainerNode *asContainerNode() final { return this; }
const ContainerNode *asContainerNode() const final { return this; }
......
......@@ -103,8 +103,9 @@ Project *ProjectTree::currentProject()
return s_instance->m_currentProject;
}
Node *ProjectTree::currentNode()
Node *ProjectTree::findCurrentNode()
{
s_instance->update();
return s_instance->m_currentNode;
}
......
......@@ -51,7 +51,7 @@ public:
static ProjectTree *instance();
static Project *currentProject();
static Node *currentNode();
static Node *findCurrentNode();
// Integration with ProjectTreeWidget
static void registerWidget(Internal::ProjectTreeWidget *widget);
......@@ -102,7 +102,7 @@ private:
static ProjectTree *s_instance;
QList<QPointer<Internal::ProjectTreeWidget>> m_projectTreeWidgets;
QVector<TreeManagerFunction> m_treeManagers;
QPointer<Node> m_currentNode;
Node *m_currentNode = nullptr;
Project *m_currentProject = nullptr;
Internal::ProjectTreeWidget *m_focusForContextMenu = nullptr;
Core::Context m_lastProjectContext;
......
......@@ -279,7 +279,7 @@ ProjectTreeWidget::ProjectTreeWidget(QWidget *parent) : QWidget(parent)
connect(m_toggleSync, &QAbstractButton::clicked,
this, &ProjectTreeWidget::toggleAutoSynchronization);
setCurrentItem(ProjectTree::currentNode());
setCurrentItem(ProjectTree::findCurrentNode());
setAutoSynchronization(true);
m_projectTreeWidgets << this;
......
......@@ -67,20 +67,20 @@ static QIcon generateIcon(const QString &overlay)
namespace QbsProjectManager {
namespace Internal {
static QbsProjectNode *parentQbsProjectNode(ProjectExplorer::Node *node)
static const QbsProjectNode *parentQbsProjectNode(const ProjectExplorer::Node *node)
{
for (ProjectExplorer::FolderNode *pn = node->managingProject(); pn; pn = pn->parentProjectNode()) {
QbsProjectNode *prjNode = dynamic_cast<QbsProjectNode *>(pn);
for (const ProjectExplorer::FolderNode *pn = node->managingProject(); pn; pn = pn->parentProjectNode()) {
const QbsProjectNode *prjNode = dynamic_cast<const QbsProjectNode *>(pn);
if (prjNode)
return prjNode;
}
return 0;
}
static QbsProductNode *parentQbsProductNode(ProjectExplorer::Node *node)
static const QbsProductNode *parentQbsProductNode(const ProjectExplorer::Node *node)
{
for (; node; node = node->parentFolderNode()) {
QbsProductNode *prdNode = dynamic_cast<QbsProductNode *>(node);
const QbsProductNode *prdNode = dynamic_cast<const QbsProductNode *>(node);
if (prdNode)
return prdNode;
}
......@@ -225,7 +225,7 @@ public:
};
static bool supportsNodeAction(ProjectAction action, Node *node)
static bool supportsNodeAction(ProjectAction action, const Node *node)
{
const QbsProject * const project = parentQbsProjectNode(node)->project();
if (!project->isProjectEditable())
......@@ -270,7 +270,7 @@ QbsFolderNode::QbsFolderNode(const Utils::FileName &folderPath, ProjectExplorer:
{
}
bool QbsFolderNode::supportsAction(ProjectAction action, Node *node) const
bool QbsFolderNode::supportsAction(ProjectAction action, const Node *node) const
{
return supportsNodeAction(action, node);
}
......@@ -302,7 +302,7 @@ QbsGroupNode::QbsGroupNode(const qbs::GroupData &grp, const QString &productPath
m_qbsGroupData = grp;
}
bool QbsGroupNode::supportsAction(ProjectAction action, Node *node) const
bool QbsGroupNode::supportsAction(ProjectAction action, const Node *node) const
{
if (action == AddNewFile || action == AddExistingFile)
return true;
......@@ -316,13 +316,13 @@ bool QbsGroupNode::addFiles(const QStringList &filePaths, QStringList *notAdded)
if (!notAdded)
notAdded = &notAddedDummy;
QbsProjectNode *prjNode = parentQbsProjectNode(this);
const QbsProjectNode *prjNode = parentQbsProjectNode(this);
if (!prjNode || !prjNode->qbsProject().isValid()) {
*notAdded += filePaths;
return false;
}
QbsProductNode *prdNode = parentQbsProductNode(this);
const QbsProductNode *prdNode = parentQbsProductNode(this);
if (!prdNode || !prdNode->qbsProductData().isValid()) {
*notAdded += filePaths;
return false;
......@@ -338,13 +338,13 @@ bool QbsGroupNode::removeFiles(const QStringList &filePaths, QStringList *notRem
if (!notRemoved)
notRemoved = &notRemovedDummy;
QbsProjectNode *prjNode = parentQbsProjectNode(this);
const QbsProjectNode *prjNode = parentQbsProjectNode(this);
if (!prjNode || !prjNode->qbsProject().isValid()) {
*notRemoved += filePaths;
return false;
}
QbsProductNode *prdNode = parentQbsProductNode(this);
const QbsProductNode *prdNode = parentQbsProductNode(this);
if (!prdNode || !prdNode->qbsProductData().isValid()) {
*notRemoved += filePaths;
return false;
......@@ -356,10 +356,10 @@ bool QbsGroupNode::removeFiles(const QStringList &filePaths, QStringList *notRem
bool QbsGroupNode::renameFile(const QString &filePath, const QString &newFilePath)
{
QbsProjectNode * const prjNode = parentQbsProjectNode(this);
const QbsProjectNode *prjNode = parentQbsProjectNode(this);
if (!prjNode || !prjNode->qbsProject().isValid())
return false;
QbsProductNode * const prdNode = parentQbsProductNode(this);
const QbsProductNode *prdNode = parentQbsProductNode(this);
if (!prdNode || !prdNode->qbsProductData().isValid())
return false;
......@@ -384,7 +384,7 @@ bool QbsProductNode::showInSimpleTree() const
return true;
}
bool QbsProductNode::supportsAction(ProjectAction action, Node *node) const
bool QbsProductNode::supportsAction(ProjectAction action, const Node *node) const
{
if (action == AddNewFile || action == AddExistingFile)
return true;
......@@ -398,7 +398,7 @@ bool QbsProductNode::addFiles(const QStringList &filePaths, QStringList *notAdde
if (!notAdded)
notAdded = &notAddedDummy;
QbsProjectNode *prjNode = parentQbsProjectNode(this);
const QbsProjectNode *prjNode = parentQbsProjectNode(this);
if (!prjNode || !prjNode->qbsProject().isValid()) {
*notAdded += filePaths;
return false;
......@@ -418,7 +418,7 @@ bool QbsProductNode::removeFiles(const QStringList &filePaths, QStringList *notR
if (!notRemoved)
notRemoved = &notRemovedDummy;
QbsProjectNode *prjNode = parentQbsProjectNode(this);
const QbsProjectNode *prjNode = parentQbsProjectNode(this);
if (!prjNode || !prjNode->qbsProject().isValid()) {
*notRemoved += filePaths;
return false;
......@@ -435,7 +435,7 @@ bool QbsProductNode::removeFiles(const QStringList &filePaths, QStringList *notR
bool QbsProductNode::renameFile(const QString &filePath, const QString &newFilePath)
{
QbsProjectNode * const prjNode = parentQbsProjectNode(this);
const QbsProjectNode * prjNode = parentQbsProjectNode(this);
if (!prjNode || !prjNode->qbsProject().isValid())
return false;
const qbs::GroupData grp = findMainQbsGroup(m_qbsProductData);
......
......@@ -55,7 +55,7 @@ public:
const QString &displayName);
private:
bool supportsAction(ProjectExplorer::ProjectAction action, Node *node) const final;
bool supportsAction(ProjectExplorer::ProjectAction action, const Node *node) const final;
};
// ---------------------------------------------------------------------------
......@@ -81,7 +81,7 @@ class QbsGroupNode : public QbsBaseProjectNode
public:
QbsGroupNode(const qbs::GroupData &grp, const QString &productPath);
bool supportsAction(ProjectExplorer::ProjectAction action, Node *node) const final;
bool supportsAction(ProjectExplorer::ProjectAction action, const Node *node) const final;
bool addFiles(const QStringList &filePaths, QStringList *notAdded = 0) override;
bool removeFiles(const QStringList &filePaths, QStringList *notRemoved = 0) override;
bool renameFile(const QString &filePath, const QString &newFilePath) override;
......@@ -103,7 +103,7 @@ public:
explicit QbsProductNode(const qbs::ProductData &prd);
bool showInSimpleTree() const override;
bool supportsAction(ProjectExplorer::ProjectAction action, Node *node) const final;
bool supportsAction(ProjectExplorer::ProjectAction action, const Node *node) const final;
bool addFiles(const QStringList &filePaths, QStringList *notAdded = 0) override;
bool removeFiles(const QStringList &filePaths, QStringList *notRemoved = 0) override;
bool renameFile(const QString &filePath, const QString &newFilePath) override;
......
......@@ -304,14 +304,14 @@ void QbsProjectManagerPlugin::projectWasAdded(Project *project)
void QbsProjectManagerPlugin::updateContextActions()
{
QbsProject *project = qobject_cast<Internal::QbsProject *>(ProjectTree::currentProject());
Node *node = ProjectTree::currentNode();
const Node *node = ProjectTree::findCurrentNode();
bool isEnabled = !BuildManager::isBuilding(project)
&& project && !project->isParsing()
&& node && node->isEnabled();
bool isFile = project && node && (node->nodeType() == NodeType::File);
bool isProduct = project && node && dynamic_cast<QbsProductNode *>(node);
QbsProjectNode *subproject = dynamic_cast<QbsProjectNode *>(node);
const bool isProduct = project && node && dynamic_cast<const QbsProductNode *>(node);
const QbsProjectNode *subproject = dynamic_cast<const QbsProjectNode *>(node);
bool isSubproject = project && subproject && subproject != project->rootProjectNode();
m_reparseQbsCtx->setEnabled(isEnabled);
......@@ -407,7 +407,7 @@ void QbsProjectManagerPlugin::projectChanged()
void QbsProjectManagerPlugin::buildFileContextMenu()
{
Node *node = ProjectTree::currentNode();
const Node *node = ProjectTree::findCurrentNode();
QTC_ASSERT(node, return);
QbsProject *project = dynamic_cast<QbsProject *>(ProjectTree::currentProject());
QTC_ASSERT(project, return);
......@@ -444,12 +444,12 @@ void QbsProjectManagerPlugin::rebuildProductContextMenu()
void QbsProjectManagerPlugin::runStepsForProductContextMenu(const QList<Core::Id> &stepTypes)
{
Node *node = ProjectTree::currentNode();
const Node *node = ProjectTree::findCurrentNode();
QTC_ASSERT(node, return);
QbsProject *project = dynamic_cast<QbsProject *>(ProjectTree::currentProject());
QTC_ASSERT(project, return);
const QbsProductNode * const productNode = dynamic_cast<QbsProductNode *>(node);
const QbsProductNode * const productNode = dynamic_cast<const QbsProductNode *>(node);
QTC_ASSERT(productNode, return);
runStepsForProducts(project, {QbsProject::uniqueProductName(productNode->qbsProductData())},
......@@ -509,12 +509,12 @@ void QbsProjectManagerPlugin::rebuildSubprojectContextMenu()
void QbsProjectManagerPlugin::runStepsForSubprojectContextMenu(const QList<Core::Id> &stepTypes)
{
Node *node = ProjectTree::currentNode();
const Node *node = ProjectTree::findCurrentNode();
QTC_ASSERT(node, return);
QbsProject *project = dynamic_cast<QbsProject *>(ProjectTree::currentProject());
QTC_ASSERT(project, return);
QbsProjectNode *subProject = dynamic_cast<QbsProjectNode *>(node);
const QbsProjectNode *subProject = dynamic_cast<const QbsProjectNode *>(node);
QTC_ASSERT(subProject, return);
QStringList toBuild;
......
......@@ -74,12 +74,12 @@ QmakeProFileNode *QmakePriFileNode::proFileNode() const
return m_qmakeProFileNode;
}
bool QmakePriFileNode::supportsAction(ProjectAction action, Node *node) const
bool QmakePriFileNode::supportsAction(ProjectAction action, const Node *node) const
{
if (action == Rename || action == DuplicateFile) {
FileNode *fileNode = node->asFileNode();
const FileNode *fileNode = node->asFileNode();
return (fileNode && fileNode->fileType() != FileType::Project)
|| dynamic_cast<ResourceEditor::ResourceTopLevelNode *>(node);
|| dynamic_cast<const ResourceEditor::ResourceTopLevelNode *>(node);
}
const FolderNode *folderNode = this;
......@@ -109,7 +109,7 @@ bool QmakePriFileNode::supportsAction(ProjectAction action, Node *node) const
bool addExistingFiles = true;
if (node->nodeType() == NodeType::VirtualFolder) {
// A virtual folder, we do what the projectexplorer does
FolderNode *folder = node->asFolderNode();
const FolderNode *folder = node->asFolderNode();
if (folder) {
QStringList list;
foreach (FolderNode *f, folder->folderNodes())
......
......@@ -47,7 +47,7 @@ public:
QmakePriFile *priFile() const;
// ProjectNode interface
bool supportsAction(ProjectExplorer::ProjectAction action, Node *node) const override;
bool supportsAction(ProjectExplorer::ProjectAction action, const Node *node) const override;
bool showInSimpleTree() const override { return false; }
......
......@@ -55,7 +55,7 @@ namespace QmakeProjectManager {
Node *QmakeManager::contextNode()
{
return ProjectTree::currentNode();
return ProjectTree::findCurrentNode();
}
Project *QmakeManager::contextProject()
......
......@@ -326,22 +326,22 @@ void QmakeProjectManagerPlugin::updateRunQMakeAction()
void QmakeProjectManagerPlugin::updateContextActions()
{
Node *node = ProjectTree::currentNode();
const Node *node = ProjectTree::findCurrentNode();
Project *project = ProjectTree::currentProject();
ContainerNode *containerNode = node ? node->asContainerNode() : nullptr;
QmakeProFileNode *proFileNode = dynamic_cast<QmakeProFileNode *>(containerNode ? containerNode->rootProjectNode() : node);
const ContainerNode *containerNode = node ? node->asContainerNode() : nullptr;
const QmakeProFileNode *proFileNode = dynamic_cast<const QmakeProFileNode *>(containerNode ? containerNode->rootProjectNode() : node);
m_addLibraryActionContextMenu->setEnabled(proFileNode);
QmakeProject *qmakeProject = qobject_cast<QmakeProject *>(QmakeManager::contextProject());
QmakeProFileNode *subProjectNode = nullptr;
if (node) {
auto subPriFileNode = dynamic_cast<QmakePriFileNode *>(node);
auto subPriFileNode = dynamic_cast<const QmakePriFileNode *>(node);
if (!subPriFileNode)
subPriFileNode = dynamic_cast<QmakePriFileNode *>(node->parentProjectNode());
subProjectNode = subPriFileNode ? subPriFileNode->proFileNode() : nullptr;
}
FileNode *fileNode = node ? node->asFileNode() : nullptr;
const FileNode *fileNode = node ? node->asFileNode() : nullptr;
bool buildFilePossible = subProjectNode && fileNode && (fileNode->fileType() == FileType::Source);
bool subProjectActionsVisible = false;
......
......@@ -57,13 +57,13 @@ bool QmlProjectNode::showInSimpleTree() const
return true;
}
bool QmlProjectNode::supportsAction(ProjectAction action, Node *node) const
bool QmlProjectNode::supportsAction(ProjectAction action, const Node *node) const
{
if (action == AddNewFile || action == EraseFile)
return true;
if (action == Rename && node->nodeType() == NodeType::File) {
FileNode *fileNode = static_cast<FileNode *>(node);
const FileNode *fileNode = dynamic_cast<const FileNode *>(node);
return fileNode->fileType() != FileType::Project;
}
......
......@@ -39,7 +39,7 @@ public:
QmlProjectNode(QmlProject *project);
bool showInSimpleTree() const override;
bool supportsAction(ProjectExplorer::ProjectAction action, Node *node) const override;
bool supportsAction(ProjectExplorer::ProjectAction action, const Node *node) const override;
bool addFiles(const QStringList &filePaths, QStringList *notAdded = 0) override;
bool deleteFiles(const QStringList &filePaths) override;
bool renameFile(const QString &filePath, const QString &newFilePath) override;
......
......@@ -245,7 +245,7 @@ void ResourceEditorPlugin::onRefresh()
void ResourceEditorPlugin::addPrefixContextMenu()
{
auto topLevel = dynamic_cast<ResourceTopLevelNode *>(ProjectTree::currentNode());
auto topLevel = dynamic_cast<ResourceTopLevelNode *>(ProjectTree::findCurrentNode());
QTC_ASSERT(topLevel, return);
PrefixLangDialog dialog(tr("Add Prefix"), QString(), QString(), Core::ICore::mainWindow());
if (dialog.exec() != QDialog::Accepted)
......@@ -258,7 +258,7 @@ void ResourceEditorPlugin::addPrefixContextMenu()
void ResourceEditorPlugin::removePrefixContextMenu()
{
auto rfn = dynamic_cast<ResourceFolderNode *>(ProjectTree::currentNode());
auto rfn = dynamic_cast<ResourceFolderNode *>(ProjectTree::findCurrentNode());
QTC_ASSERT(rfn, return);
if (QMessageBox::question(Core::ICore::mainWindow(),
tr("Remove Prefix"),
......@@ -271,7 +271,7 @@ void ResourceEditorPlugin::removePrefixContextMenu()
void ResourceEditorPlugin::removeNonExisting()
{
auto topLevel = dynamic_cast<ResourceTopLevelNode *>(ProjectTree::currentNode());
auto topLevel = dynamic_cast<ResourceTopLevelNode *>(ProjectTree::findCurrentNode());
QTC_ASSERT(topLevel, return);
topLevel->removeNonExistingFiles();
}
......@@ -283,7 +283,7 @@ void ResourceEditorPlugin::renameFileContextMenu()
void ResourceEditorPlugin::removeFileContextMenu()
{
auto rfn = dynamic_cast<ResourceFolderNode *>(ProjectTree::currentNode());
auto rfn = dynamic_cast<ResourceFolderNode *>(ProjectTree::findCurrentNode());
QTC_ASSERT(rfn, return);
QString path = rfn->filePath().toString();
FolderNode *parent = rfn->parentFolderNode();
......@@ -296,26 +296,26 @@ void ResourceEditorPlugin::removeFileContextMenu()
void ResourceEditorPlugin::openEditorContextMenu()
{
Core::EditorManager::openEditor(ProjectTree::currentNode()->filePath().toString());
Core::EditorManager::openEditor(ProjectTree::findCurrentNode()->filePath().toString());
}
void ResourceEditorPlugin::copyPathContextMenu()
{
auto node = dynamic_cast<ResourceFileNode *>(ProjectTree::currentNode());
auto node = dynamic_cast<ResourceFileNode *>(ProjectTree::findCurrentNode());
QTC_ASSERT(node, return);
QApplication::clipboard()->setText(QLatin1String(resourcePrefix) + node->qrcPath());
}
void ResourceEditorPlugin::copyUrlContextMenu()
{
auto node = dynamic_cast<ResourceFileNode *>(ProjectTree::currentNode());
auto node = dynamic_cast<ResourceFileNode *>(ProjectTree::findCurrentNode());
QTC_ASSERT(node, return);
QApplication::clipboard()->setText(QLatin1String(urlPrefix) + node->qrcPath());
}
void ResourceEditorPlugin::renamePrefixContextMenu()
{
auto node = dynamic_cast<ResourceFolderNode *>(ProjectTree::currentNode());
auto node = dynamic_cast<ResourceFolderNode *>(ProjectTree::findCurrentNode());
QTC_ASSERT(node, return);
PrefixLangDialog dialog(tr("Rename Prefix"), node->prefix(), node->lang(), Core::ICore::mainWindow());
......@@ -330,8 +330,8 @@ void ResourceEditorPlugin::renamePrefixContextMenu()
void ResourceEditorPlugin::updateContextActions()
{
Node *node = ProjectTree::currentNode();
bool isResourceNode = dynamic_cast<ResourceTopLevelNode *>(node);
const Node *node = ProjectTree::findCurrentNode();
const bool isResourceNode = dynamic_cast<const ResourceTopLevelNode *>(node);
m_addPrefix->setEnabled(isResourceNode);
m_addPrefix->setVisible(isResourceNode);
......@@ -352,7 +352,7 @@ void ResourceEditorPlugin::updateContextActions()
m_openInEditor->setEnabled(isResourceNode);
m_openInEditor->setVisible(isResourceNode);
bool isResourceFolder = dynamic_cast<ResourceFolderNode *>(node);
const bool isResourceFolder = dynamic_cast<const ResourceFolderNode *>(node);
m_removePrefix->setEnabled(isResourceFolder);
m_removePrefix->setVisible(isResourceFolder);
......@@ -368,13 +368,13 @@ void ResourceEditorPlugin::updateContextActions()
m_openWithMenu->clear();
m_openWithMenu->menuAction()->setVisible(!m_openWithMenu->actions().isEmpty());
bool isResourceFile = dynamic_cast<ResourceFileNode *>(node);
const bool isResourceFile = dynamic_cast<const ResourceFileNode *>(node);
m_copyPath->setEnabled(isResourceFile);
m_copyPath->setVisible(isResourceFile);
m_copyUrl->setEnabled(isResourceFile);
m_copyUrl->setVisible(isResourceFile);
if (isResourceFile) {
auto fileNode = dynamic_cast<ResourceFileNode *>(node);
auto fileNode = dynamic_cast<const ResourceFileNode *>(node);
QTC_ASSERT(fileNode, return);
QString qrcPath = fileNode->qrcPath();
m_copyPath->setParameter(QLatin1String(resourcePrefix) + qrcPath);
......
......@@ -160,7 +160,7 @@ public:
ResourceTopLevelNode *topLevel, ResourceFolderNode *prefixNode);
QString displayName() const final;
bool supportsAction(ProjectAction, Node *node) const final;
bool supportsAction(ProjectAction, const Node *node) const final;
bool addFiles(const QStringList &filePaths, QStringList *notAdded) final;
bool removeFiles(const QStringList &filePaths, QStringList *notRemoved) final;
bool renameFile(const QString &filePath, const QString &newFilePath) final;
......@@ -199,7 +199,7 @@ SimpleResourceFolderNode::SimpleResourceFolderNode(const QString &afolderName, c
}
bool SimpleResourceFolderNode::supportsAction(ProjectAction action, Node *) const
bool SimpleResourceFolderNode::supportsAction(ProjectAction action, const Node *) const
{
return action == AddNewFile
|| action == AddExistingFile
......@@ -389,7 +389,7 @@ QString ResourceTopLevelNode::addFileFilter() const
return QLatin1String("*.png; *.jpg; *.gif; *.svg; *.ico; *.qml; *.qml.ui");
}
bool ResourceTopLevelNode::supportsAction(ProjectAction action, Node *node) const
bool ResourceTopLevelNode::supportsAction(ProjectAction action, const Node *node) const
{
if (node != this)
return false;
......@@ -507,7 +507,7 @@ ResourceFolderNode::~ResourceFolderNode()
}
bool ResourceFolderNode::supportsAction(ProjectAction action, Node *node) const
bool ResourceFolderNode::supportsAction(ProjectAction action, const Node *node) const
{
Q_UNUSED(node)
......@@ -672,7 +672,7 @@ QString ResourceFileNode::qrcPath() const
return m_qrcPath;
}
bool ResourceFileNode::supportsAction(ProjectAction action, Node *node) const
bool ResourceFileNode::supportsAction(ProjectAction action, const Node *node) const
{
if (action == HidePathActions)
return false;
......
......@@ -42,7 +42,7 @@ public:
QString addFileFilter() const override;
bool supportsAction(ProjectExplorer::ProjectAction action, Node *node) const override;
bool supportsAction(ProjectExplorer::ProjectAction action, const Node *node) const override;
bool addFiles(const QStringList &filePaths, QStringList *notAdded) override;
bool removeFiles(const QStringList &filePaths, QStringList *notRemoved) override;