summaryrefslogtreecommitdiff
path: root/src/plugins/resourceeditor
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2017-05-31 15:48:45 +0200
committerTim Jenssen <tim.jenssen@qt.io>2017-08-01 11:24:53 +0000
commit45046f7071f6f4886d697547b508cbd087daf342 (patch)
tree5524bb8e5bb0b559323b84b4381a967b8f901eee /src/plugins/resourceeditor
parentbbb54cdebae2d2a2a275c69e4d4309a83087a02a (diff)
downloadqt-creator-45046f7071f6f4886d697547b508cbd087daf342.tar.gz
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 <tobias.hunger@qt.io>
Diffstat (limited to 'src/plugins/resourceeditor')
-rw-r--r--src/plugins/resourceeditor/resourceeditorplugin.cpp26
-rw-r--r--src/plugins/resourceeditor/resourcenode.cpp10
-rw-r--r--src/plugins/resourceeditor/resourcenode.h6
3 files changed, 21 insertions, 21 deletions
diff --git a/src/plugins/resourceeditor/resourceeditorplugin.cpp b/src/plugins/resourceeditor/resourceeditorplugin.cpp
index 75cce17542..07c532f4ef 100644
--- a/src/plugins/resourceeditor/resourceeditorplugin.cpp
+++ b/src/plugins/resourceeditor/resourceeditorplugin.cpp
@@ -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);
diff --git a/src/plugins/resourceeditor/resourcenode.cpp b/src/plugins/resourceeditor/resourcenode.cpp
index cb7b5be887..48bdac0a9b 100644
--- a/src/plugins/resourceeditor/resourcenode.cpp
+++ b/src/plugins/resourceeditor/resourcenode.cpp
@@ -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;
diff --git a/src/plugins/resourceeditor/resourcenode.h b/src/plugins/resourceeditor/resourcenode.h
index e2f84e005a..02cb296805 100644
--- a/src/plugins/resourceeditor/resourcenode.h
+++ b/src/plugins/resourceeditor/resourcenode.h
@@ -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;
@@ -68,7 +68,7 @@ public:
ResourceFolderNode(const QString &prefix, const QString &lang, ResourceTopLevelNode *parent);
~ResourceFolderNode() override;
- bool supportsAction(ProjectExplorer::ProjectAction action, Node *node) const override;
+ bool supportsAction(ProjectExplorer::ProjectAction action, const Node *node) const override;
QString displayName() const override;
@@ -98,7 +98,7 @@ public:
QString displayName() const override;
QString qrcPath() const;
- bool supportsAction(ProjectExplorer::ProjectAction action, Node *node) const override;
+ bool supportsAction(ProjectExplorer::ProjectAction action, const Node *node) const override;
private:
QString m_qrcPath;