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:
@@ -40,6 +40,7 @@
|
||||
|
||||
#include <qmljstools/qmljstoolsconstants.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
|
||||
@@ -126,6 +127,7 @@ ResourceTopLevelNode::ResourceTopLevelNode(const QString &filePath, FolderNode *
|
||||
ResourceTopLevelNode::~ResourceTopLevelNode()
|
||||
{
|
||||
Core::DocumentManager::removeDocument(m_document);
|
||||
delete m_document;
|
||||
}
|
||||
|
||||
void ResourceTopLevelNode::update()
|
||||
@@ -253,7 +255,7 @@ bool ResourceTopLevelNode::removePrefix(const QString &prefix, const QString &la
|
||||
|
||||
ProjectExplorer::FolderNode::AddNewInformation ResourceTopLevelNode::addNewInformation(const QStringList &files, Node *context) const
|
||||
{
|
||||
QString name = tr("%1 Prefix: %2")
|
||||
QString name = QCoreApplication::translate("ResourceTopLevelNode", "%1 Prefix: %2")
|
||||
.arg(QFileInfo(path()).fileName())
|
||||
.arg(QLatin1Char('/'));
|
||||
|
||||
@@ -267,7 +269,7 @@ ProjectExplorer::FolderNode::AddNewInformation ResourceTopLevelNode::addNewInfor
|
||||
// The ResourceFolderNode '/' defers to us, as otherwise
|
||||
// two nodes would be responsible for '/'
|
||||
// Thus also return a high priority for it
|
||||
if (ResourceFolderNode *rfn = qobject_cast<ResourceFolderNode *>(context))
|
||||
if (ResourceFolderNode *rfn = dynamic_cast<ResourceFolderNode *>(context))
|
||||
if (rfn->prefix() == QLatin1String("/") && rfn->parentFolderNode() == this)
|
||||
p = 120;
|
||||
}
|
||||
@@ -387,7 +389,7 @@ bool ResourceFolderNode::renamePrefix(const QString &prefix, const QString &lang
|
||||
|
||||
ProjectExplorer::FolderNode::AddNewInformation ResourceFolderNode::addNewInformation(const QStringList &files, Node *context) const
|
||||
{
|
||||
QString name = tr("%1 Prefix: %2")
|
||||
QString name = QCoreApplication::translate("ResourceTopLevelNode", "%1 Prefix: %2")
|
||||
.arg(QFileInfo(m_topLevelNode->path()).fileName())
|
||||
.arg(displayName());
|
||||
|
||||
@@ -441,7 +443,7 @@ void ResourceFolderNode::updateFiles(QList<ProjectExplorer::FileNode *> newList)
|
||||
}
|
||||
|
||||
ResourceFileWatcher::ResourceFileWatcher(ResourceTopLevelNode *node)
|
||||
: IDocument(node), m_node(node)
|
||||
: IDocument(0), m_node(node)
|
||||
{
|
||||
setId("ResourceNodeWatcher");
|
||||
setMimeType(QLatin1String(ResourceEditor::Constants::C_RESOURCE_MIMETYPE));
|
||||
|
||||
Reference in New Issue
Block a user