forked from qt-creator/qt-creator
Refactor ProjectExplorer::Node and remove NodesWatcher
The idea behind NodesWatcher was that it was the central place to catch node related signals, so that users didn't need to connect to each individual node and the nodes didn't need to be QObjects. Somehow Nodes ended up being QObjects anyway. Both the recently added ProjectTree and the FlatModels consume the signals the NodesWatcher sends. Unfortunately there's a ordering dependency between the ProjectTree and the FlatModels. This patch removes all NodesWatcher and instead makes the ProjectTree singleton the emitter of various project tree related signals. The ProjectTree also ensures that the ordering between the FlatModel and itself is taken into account. And it makes Node not derive from QObject, saving some memory in that process. Task-number: QTCREATORBUG-13756 Change-Id: I8b0d357863f1dc1d2d440ce8172502594138b9fb Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
#include <projectexplorer/nodesvisitor.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projecttree.h>
|
||||
#include <projectexplorer/session.h>
|
||||
#include <resourceeditor/resourcenode.h>
|
||||
|
||||
@@ -75,7 +76,7 @@ void QrcFilesVisitor::visitFolderNode(FolderNode *folderNode)
|
||||
if (fileNode->fileType() == ProjectExplorer::ResourceType)
|
||||
m_qrcFiles.append(fileNode->path());
|
||||
}
|
||||
if (qobject_cast<ResourceEditor::ResourceTopLevelNode *>(folderNode))
|
||||
if (dynamic_cast<ResourceEditor::ResourceTopLevelNode *>(folderNode))
|
||||
m_qrcFiles.append(folderNode->path());
|
||||
}
|
||||
|
||||
@@ -83,25 +84,23 @@ void QrcFilesVisitor::visitFolderNode(FolderNode *folderNode)
|
||||
ResourceHandler::ResourceHandler(QDesignerFormWindowInterface *fw) :
|
||||
QObject(fw),
|
||||
m_form(fw),
|
||||
m_sessionNode(0),
|
||||
m_sessionWatcher(0),
|
||||
m_initialized(false),
|
||||
m_handlingResources(false)
|
||||
{
|
||||
}
|
||||
|
||||
void ResourceHandler::ensureInitialized()
|
||||
{
|
||||
if (m_sessionNode)
|
||||
if (m_initialized)
|
||||
return;
|
||||
|
||||
m_sessionNode = ProjectExplorer::SessionManager::sessionNode();
|
||||
m_sessionWatcher = new ProjectExplorer::NodesWatcher();
|
||||
m_initialized = true;
|
||||
ProjectTree *tree = ProjectTree::instance();
|
||||
|
||||
connect(m_sessionWatcher, SIGNAL(filesAdded()), this, SLOT(updateResources()));
|
||||
connect(m_sessionWatcher, SIGNAL(filesRemoved()), this, SLOT(updateResources()));
|
||||
connect(m_sessionWatcher, SIGNAL(foldersAdded()), this, SLOT(updateResources()));
|
||||
connect(m_sessionWatcher, SIGNAL(foldersRemoved()), this, SLOT(updateResources()));
|
||||
m_sessionNode->registerWatcher(m_sessionWatcher);
|
||||
connect(tree, SIGNAL(filesAdded()), this, SLOT(updateResources()));
|
||||
connect(tree, SIGNAL(filesRemoved()), this, SLOT(updateResources()));
|
||||
connect(tree, SIGNAL(foldersAdded()), this, SLOT(updateResources()));
|
||||
connect(tree, SIGNAL(foldersRemoved()), this, SLOT(updateResources()));
|
||||
m_originalUiQrcPaths = m_form->activeResourceFilePaths();
|
||||
if (Designer::Constants::Internal::debug)
|
||||
qDebug() << "ResourceHandler::ensureInitialized() origPaths=" << m_originalUiQrcPaths;
|
||||
@@ -109,11 +108,7 @@ void ResourceHandler::ensureInitialized()
|
||||
|
||||
ResourceHandler::~ResourceHandler()
|
||||
{
|
||||
// Close: Delete the Designer form window via embedding widget
|
||||
if (m_sessionNode && m_sessionWatcher) {
|
||||
m_sessionNode->unregisterWatcher(m_sessionWatcher);
|
||||
delete m_sessionWatcher;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ResourceHandler::updateResources(bool updateProjectResources)
|
||||
|
||||
Reference in New Issue
Block a user