Commit 70c9c51e authored by Daniel Teske's avatar Daniel Teske
Browse files

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: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 44a7db50
......@@ -53,8 +53,6 @@ class AutotoolsProject;
*/
class AutotoolsProjectNode : public ProjectExplorer::ProjectNode
{
Q_OBJECT
public:
AutotoolsProjectNode(AutotoolsProject *project, Core::IDocument *projectFile);
......
......@@ -38,7 +38,6 @@ namespace Internal {
class CMakeProjectNode : public ProjectExplorer::ProjectNode
{
Q_OBJECT
friend class CMakeProject;
public:
CMakeProjectNode(const QString &fileName);
......
......@@ -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)
......
......@@ -38,10 +38,7 @@ QT_BEGIN_NAMESPACE
class QDesignerFormWindowInterface;
QT_END_NAMESPACE
namespace ProjectExplorer {
class SessionNode;
class NodesWatcher;
}
namespace ProjectExplorer { class SessionNode; }
namespace Designer {
namespace Internal {
......@@ -70,8 +67,7 @@ private:
void ensureInitialized();
QDesignerFormWindowInterface * const m_form;
QStringList m_originalUiQrcPaths;
ProjectExplorer::SessionNode *m_sessionNode;
ProjectExplorer::NodesWatcher *m_sessionWatcher;
bool m_initialized;
bool m_handlingResources;
};
......
......@@ -35,7 +35,6 @@
#include <QFutureInterface>
#include <QMutex>
#include <QPointer>
namespace ProjectExplorer {
......@@ -57,7 +56,7 @@ private slots:
void markFilesAsOutOfDate();
private:
QPointer<Project> m_project;
Project *m_project;
};
} // namespace Internal
......
......@@ -1935,7 +1935,7 @@ static QString pathOrDirectoryFor(Node *node, bool dir)
{
QString path = node->path();
QString location;
FolderNode *folder = qobject_cast<FolderNode *>(node);
FolderNode *folder = dynamic_cast<FolderNode *>(node);
if (node->nodeType() == VirtualFolderNodeType && folder) {
// Virtual Folder case
// If there are files directly below or no subfolders, take the folder path
......@@ -2291,7 +2291,7 @@ void ProjectExplorerPlugin::runProjectWithoutDeploy()
void ProjectExplorerPlugin::runProjectContextMenu()
{
ProjectNode *projectNode = qobject_cast<ProjectNode*>(ProjectTree::currentNode());
ProjectNode *projectNode = dynamic_cast<ProjectNode*>(ProjectTree::currentNode());
if (projectNode == ProjectTree::currentProject()->rootProjectNode() || !projectNode) {
runProject(ProjectTree::currentProject(), NormalRunMode);
} else {
......@@ -2810,7 +2810,7 @@ void ProjectExplorerPluginPrivate::updateContextMenuActions()
if (currentNode && currentNode->projectNode()) {
QList<ProjectAction> actions = currentNode->supportedActions(currentNode);
if (ProjectNode *pn = qobject_cast<ProjectNode *>(currentNode)) {
if (ProjectNode *pn = dynamic_cast<ProjectNode *>(currentNode)) {
if (ProjectTree::currentProject() && pn == ProjectTree::currentProject()->rootProjectNode()) {
dd->m_runActionContextMenu->setVisible(true);
} else {
......@@ -2831,7 +2831,7 @@ void ProjectExplorerPluginPrivate::updateContextMenuActions()
}
}
}
if (qobject_cast<FolderNode*>(currentNode)) {
if (dynamic_cast<FolderNode*>(currentNode)) {
// Also handles ProjectNode
dd->m_addNewFileAction->setEnabled(actions.contains(AddNewFile)
&& !ICore::isNewItemDialogRunning());
......@@ -2843,7 +2843,7 @@ void ProjectExplorerPluginPrivate::updateContextMenuActions()
dd->m_addExistingFilesAction->setEnabled(actions.contains(AddExistingFile));
dd->m_addExistingDirectoryAction->setEnabled(actions.contains(AddExistingDirectory));
dd->m_renameFileAction->setEnabled(actions.contains(Rename));
} else if (qobject_cast<FileNode*>(currentNode)) {
} else if (dynamic_cast<FileNode*>(currentNode)) {
// Enable and show remove / delete in magic ways:
// If both are disabled show Remove
// If both are enabled show both (can't happen atm)
......@@ -2942,7 +2942,7 @@ void ProjectExplorerPlugin::addExistingDirectory()
void ProjectExplorerPlugin::addExistingFiles(const QStringList &filePaths)
{
FolderNode *folderNode = qobject_cast<FolderNode *>(ProjectTree::currentNode());
FolderNode *folderNode = dynamic_cast<FolderNode *>(ProjectTree::currentNode());
addExistingFiles(folderNode, filePaths);
}
......@@ -2971,8 +2971,8 @@ void ProjectExplorerPlugin::addExistingFiles(FolderNode *folderNode, const QStri
void ProjectExplorerPlugin::removeProject()
{
ProjectNode *subProjectNode = qobject_cast<ProjectNode*>(ProjectTree::currentNode()->projectNode());
ProjectNode *projectNode = qobject_cast<ProjectNode *>(subProjectNode->parentFolderNode());
ProjectNode *subProjectNode = dynamic_cast<ProjectNode*>(ProjectTree::currentNode()->projectNode());
ProjectNode *projectNode = dynamic_cast<ProjectNode *>(subProjectNode->parentFolderNode());
if (projectNode) {
RemoveFileDialog removeFileDialog(subProjectNode->path(), ICore::mainWindow());
removeFileDialog.setDeleteFileVisible(false);
......@@ -3010,7 +3010,7 @@ void ProjectExplorerPlugin::removeFile()
Node *currentNode = ProjectTree::currentNode();
QTC_ASSERT(currentNode && currentNode->nodeType() == FileNodeType, return);
FileNode *fileNode = qobject_cast<FileNode*>(currentNode);
FileNode *fileNode = dynamic_cast<FileNode*>(currentNode);
QString filePath = currentNode->path();
RemoveFileDialog removeFileDialog(filePath, ICore::mainWindow());
......@@ -3039,7 +3039,7 @@ void ProjectExplorerPlugin::deleteFile()
Node *currentNode = ProjectTree::currentNode();
QTC_ASSERT(currentNode && currentNode->nodeType() == FileNodeType, return);
FileNode *fileNode = qobject_cast<FileNode*>(currentNode);
FileNode *fileNode = dynamic_cast<FileNode*>(currentNode);
QString filePath = currentNode->path();
QMessageBox::StandardButton button =
......
......@@ -33,6 +33,7 @@
#include "project.h"
#include "projectnodes.h"
#include "projectexplorer.h"
#include "projecttree.h"
#include <coreplugin/fileiconprovider.h>
#include <utils/algorithm.h>
......@@ -58,8 +59,8 @@ bool sortNodes(Node *n1, Node *n2)
const NodeType n2Type = n2->nodeType();
// project files
FileNode *file1 = qobject_cast<FileNode*>(n1);
FileNode *file2 = qobject_cast<FileNode*>(n2);
FileNode *file1 = dynamic_cast<FileNode*>(n1);
FileNode *file2 = dynamic_cast<FileNode*>(n2);
if (file1 && file1->fileType() == ProjectFileType) {
if (file2 && file2->fileType() == ProjectFileType) {
const QString fileName1 = QFileInfo(file1->path()).fileName();
......@@ -177,42 +178,41 @@ FlatModel::FlatModel(SessionNode *rootNode, QObject *parent)
m_startupProject(0),
m_parentFolderForChange(0)
{
NodesWatcher *watcher = new NodesWatcher(this);
m_rootNode->registerWatcher(watcher);
ProjectTree *tree = ProjectTree::instance();
connect(watcher, SIGNAL(aboutToChangeShowInSimpleTree(ProjectExplorer::FolderNode*)),
this, SLOT(aboutToShowInSimpleTreeChanged(ProjectExplorer::FolderNode*)));
connect(tree, &ProjectTree::aboutToChangeShowInSimpleTree,
this, &FlatModel::aboutToShowInSimpleTreeChanged);
connect(watcher, SIGNAL(showInSimpleTreeChanged(ProjectExplorer::FolderNode*)),
this, SLOT(showInSimpleTreeChanged(ProjectExplorer::FolderNode*)));
connect(tree, &ProjectTree::showInSimpleTreeChanged,
this, &FlatModel::showInSimpleTreeChanged);
connect(watcher, SIGNAL(foldersAboutToBeAdded(FolderNode*,QList<FolderNode*>)),
this, SLOT(foldersAboutToBeAdded(FolderNode*,QList<FolderNode*>)));
connect(watcher, SIGNAL(foldersAdded()),
this, SLOT(foldersAdded()));
connect(tree, &ProjectTree::foldersAboutToBeAdded,
this, &FlatModel::foldersAboutToBeAdded);
connect(tree, &ProjectTree::foldersAdded,
this, &FlatModel::foldersAdded);
connect(watcher, SIGNAL(foldersAboutToBeRemoved(FolderNode*,QList<FolderNode*>)),
this, SLOT(foldersAboutToBeRemoved(FolderNode*,QList<FolderNode*>)));
connect(watcher, SIGNAL(foldersRemoved()),
this, SLOT(foldersRemoved()));
connect(tree, &ProjectTree::foldersAboutToBeRemoved,
this, &FlatModel::foldersAboutToBeRemoved);
connect(tree, &ProjectTree::foldersRemoved,
this, &FlatModel::foldersRemoved);
connect(watcher, SIGNAL(filesAboutToBeAdded(FolderNode*,QList<FileNode*>)),
this, SLOT(filesAboutToBeAdded(FolderNode*,QList<FileNode*>)));
connect(watcher, SIGNAL(filesAdded()),
this, SLOT(filesAdded()));
connect(tree, &ProjectTree::filesAboutToBeAdded,
this, &FlatModel::filesAboutToBeAdded);
connect(tree, &ProjectTree::filesAdded,
this, &FlatModel::filesAdded);
connect(watcher, SIGNAL(filesAboutToBeRemoved(FolderNode*,QList<FileNode*>)),
this, SLOT(filesAboutToBeRemoved(FolderNode*,QList<FileNode*>)));
connect(watcher, SIGNAL(filesRemoved()),
this, SLOT(filesRemoved()));
connect(tree, &ProjectTree::filesAboutToBeRemoved,
this, &FlatModel::filesAboutToBeRemoved);
connect(tree, &ProjectTree::filesRemoved,
this, &FlatModel::filesRemoved);
connect(watcher, SIGNAL(nodeSortKeyAboutToChange(Node*)),
this, SLOT(nodeSortKeyAboutToChange(Node*)));
connect(watcher, SIGNAL(nodeSortKeyChanged()),
this, SLOT(nodeSortKeyChanged()));
connect(tree, &ProjectTree::nodeSortKeyAboutToChange,
this, &FlatModel::nodeSortKeyAboutToChange);
connect(tree, &ProjectTree::nodeSortKeyChanged,
this, &FlatModel::nodeSortKeyChanged);
connect(watcher, SIGNAL(nodeUpdated(ProjectExplorer::Node*)),
this, SLOT(nodeUpdated(ProjectExplorer::Node*)));
connect(tree, &ProjectTree::nodeUpdated,
this, &FlatModel::nodeUpdated);
}
QModelIndex FlatModel::index(int row, int column, const QModelIndex &parent) const
......@@ -221,7 +221,7 @@ QModelIndex FlatModel::index(int row, int column, const QModelIndex &parent) con
if (!parent.isValid() && row == 0 && column == 0) { // session
result = createIndex(0, 0, m_rootNode);
} else if (parent.isValid() && column == 0) {
FolderNode *parentNode = qobject_cast<FolderNode*>(nodeForIndex(parent));
FolderNode *parentNode = dynamic_cast<FolderNode*>(nodeForIndex(parent));
Q_ASSERT(parentNode);
QHash<FolderNode*, QList<Node*> >::const_iterator it = m_childNodes.constFind(parentNode);
if (it == m_childNodes.constEnd()) {
......@@ -270,7 +270,7 @@ QVariant FlatModel::data(const QModelIndex &index, int role) const
QVariant result;
if (Node *node = nodeForIndex(index)) {
FolderNode *folderNode = qobject_cast<FolderNode*>(node);
FolderNode *folderNode = dynamic_cast<FolderNode*>(node);
switch (role) {
case Qt::DisplayRole: {
QString name = node->displayName();
......@@ -334,11 +334,11 @@ Qt::ItemFlags FlatModel::flags(const QModelIndex &index) const
if (Node *node = nodeForIndex(index)) {
if (node == m_rootNode)
return 0; // no flags for session node...
if (!qobject_cast<ProjectNode *>(node)) {
if (!dynamic_cast<ProjectNode *>(node)) {
// either folder or file node
if (node->supportedActions(node).contains(Rename))
f = f | Qt::ItemIsEditable;
if (qobject_cast<FileNode *>(node))
if (dynamic_cast<FileNode *>(node))
f = f | Qt::ItemIsDragEnabled;
}
}
......@@ -369,7 +369,7 @@ int FlatModel::rowCount(const QModelIndex &parent) const
if (!parent.isValid()) {
rows = 1;
} else {
FolderNode *folderNode = qobject_cast<FolderNode*>(nodeForIndex(parent));
FolderNode *folderNode = dynamic_cast<FolderNode*>(nodeForIndex(parent));
if (folderNode && m_childNodes.contains(folderNode))
rows = m_childNodes.value(folderNode).size();
}
......@@ -386,7 +386,7 @@ bool FlatModel::hasChildren(const QModelIndex &parent) const
if (!parent.isValid())
return true;
FolderNode *folderNode = qobject_cast<FolderNode*>(nodeForIndex(parent));
FolderNode *folderNode = dynamic_cast<FolderNode*>(nodeForIndex(parent));
if (!folderNode)
return false;
......@@ -403,7 +403,7 @@ bool FlatModel::canFetchMore(const QModelIndex & parent) const
if (!parent.isValid()) {
return false;
} else {
if (FolderNode *folderNode = qobject_cast<FolderNode*>(nodeForIndex(parent)))
if (FolderNode *folderNode = dynamic_cast<FolderNode*>(nodeForIndex(parent)))
return !m_childNodes.contains(folderNode);
else
return false;
......@@ -473,7 +473,7 @@ void FlatModel::fetchMore(FolderNode *folderNode) const
void FlatModel::fetchMore(const QModelIndex &parent)
{
FolderNode *folderNode = qobject_cast<FolderNode*>(nodeForIndex(parent));
FolderNode *folderNode = dynamic_cast<FolderNode*>(nodeForIndex(parent));
Q_ASSERT(folderNode);
fetchMore(folderNode);
......@@ -514,7 +514,7 @@ QMimeData *FlatModel::mimeData(const QModelIndexList &indexes) const
auto data = new Utils::FileDropMimeData;
foreach (const QModelIndex &index, indexes) {
Node *node = nodeForIndex(index);
if (qobject_cast<FileNode *>(node))
if (dynamic_cast<FileNode *>(node))
data->addFile(node->path());
}
return data;
......@@ -601,10 +601,10 @@ FolderNode *FlatModel::visibleFolderNode(FolderNode *node) const
bool FlatModel::filter(Node *node) const
{
bool isHidden = false;
if (FolderNode *folderNode = qobject_cast<FolderNode*>(node)) {
if (FolderNode *folderNode = dynamic_cast<FolderNode*>(node)) {
if (m_filterProjects)
isHidden = !folderNode->showInSimpleTree();
} else if (FileNode *fileNode = qobject_cast<FileNode*>(node)) {
} else if (FileNode *fileNode = dynamic_cast<FileNode*>(node)) {
if (m_filterGeneratedFiles)
isHidden = fileNode->isGenerated();
}
......@@ -803,7 +803,7 @@ void FlatModel::aboutToShowInSimpleTreeChanged(FolderNode* node)
QList<Node *> staleFolders;
recursiveAddFolderNodesImpl(node, &staleFolders);
foreach (Node *n, staleFolders)
if (FolderNode *fn = qobject_cast<FolderNode *>(n))
if (FolderNode *fn = dynamic_cast<FolderNode *>(n))
m_childNodes.remove(fn);
}
......
......@@ -32,6 +32,7 @@
#include "nodesvisitor.h"
#include "projectexplorerconstants.h"
#include "projecttree.h"
#include <coreplugin/mimedatabase.h>
#include <coreplugin/fileiconprovider.h>
......@@ -65,30 +66,30 @@ using namespace ProjectExplorer;
Node::Node(NodeType nodeType,
const QString &filePath, int line)
: QObject(),
m_nodeType(nodeType),
: m_nodeType(nodeType),
m_line(line),
m_projectNode(0),
m_folderNode(0),
m_path(filePath),
m_line(line)
m_path(filePath)
{
}
Node::~Node()
{
}
void Node::emitNodeSortKeyAboutToChange()
{
if (ProjectNode *project = projectNode()) {
foreach (NodesWatcher *watcher, project->watchers())
emit watcher->nodeSortKeyAboutToChange(this);
}
if (parentFolderNode())
ProjectTree::instance()->emitNodeSortKeyAboutToChange(this);
}
void Node::emitNodeSortKeyChanged()
{
if (ProjectNode *project = projectNode()) {
foreach (NodesWatcher *watcher, project->watchers())
emit watcher->nodeSortKeyChanged();
}
if (parentFolderNode())
ProjectTree::instance()->emitNodeSortKeyChanged();
}
/*!
......@@ -199,9 +200,8 @@ void Node::setProjectNode(ProjectNode *project)
void Node::emitNodeUpdated()
{
if (ProjectNode *node = projectNode())
foreach (NodesWatcher *watcher, node->watchers())
emit watcher->nodeUpdated(this);
if (parentFolderNode())
ProjectTree::instance()->emitNodeUpdated(this);
}
void Node::setParentFolderNode(FolderNode *parentFolder)
......@@ -362,19 +362,17 @@ FolderNode::AddNewInformation FolderNode::addNewInformation(const QStringList &f
void FolderNode::addFileNodes(const QList<FileNode *> &files)
{
Q_ASSERT(projectNode());
ProjectNode *pn = projectNode();
if (files.isEmpty())
return;
foreach (NodesWatcher *watcher, pn->watchers())
emit watcher->filesAboutToBeAdded(this, files);
emit ProjectTree::instance()->emitFilesAboutToBeAdded(this, files);
foreach (FileNode *file, files) {
QTC_ASSERT(!file->parentFolderNode(),
qDebug("File node has already a parent folder"));
file->setParentFolderNode(this);
file->setProjectNode(pn);
file->setProjectNode(projectNode());
// Now find the correct place to insert file
if (m_fileNodes.count() == 0
|| m_fileNodes.last() < file) {
......@@ -389,8 +387,7 @@ void FolderNode::addFileNodes(const QList<FileNode *> &files)
}
}
foreach (NodesWatcher *watcher, pn->watchers())
emit watcher->filesAdded();
ProjectTree::instance()->emitFilesAdded();
}
/*!
......@@ -404,7 +401,6 @@ void FolderNode::addFileNodes(const QList<FileNode *> &files)
void FolderNode::removeFileNodes(const QList<FileNode *> &files)
{
Q_ASSERT(projectNode());
ProjectNode *pn = projectNode();
if (files.isEmpty())
return;
......@@ -412,8 +408,7 @@ void FolderNode::removeFileNodes(const QList<FileNode *> &files)
QList<FileNode*> toRemove = files;
Utils::sort(toRemove);
foreach (NodesWatcher *watcher, pn->watchers())
emit watcher->filesAboutToBeRemoved(this, toRemove);
ProjectTree::instance()->emitFilesAboutToBeRemoved(this, toRemove);
QList<FileNode*>::const_iterator toRemoveIter = toRemove.constBegin();
QList<FileNode*>::iterator filesIter = m_fileNodes.begin();
......@@ -427,8 +422,7 @@ void FolderNode::removeFileNodes(const QList<FileNode *> &files)
filesIter = m_fileNodes.erase(filesIter);
}
foreach (NodesWatcher *watcher, pn->watchers())
emit watcher->filesRemoved();
ProjectTree::instance()->emitFilesRemoved();
}
/*!
......@@ -438,19 +432,16 @@ void FolderNode::removeFileNodes(const QList<FileNode *> &files)
void FolderNode::addFolderNodes(const QList<FolderNode*> &subFolders)
{
Q_ASSERT(projectNode());
ProjectNode *pn = projectNode();
if (subFolders.isEmpty())
return;
foreach (NodesWatcher *watcher, pn->watchers())
watcher->foldersAboutToBeAdded(this, subFolders);
ProjectTree::instance()->emitFoldersAboutToBeAdded(this, subFolders);
foreach (FolderNode *folder, subFolders) {
QTC_ASSERT(!folder->parentFolderNode(),
qDebug("Project node has already a parent folder"));
folder->setParentFolderNode(this);
folder->setProjectNode(pn);
folder->setProjectNode(projectNode());
// Find the correct place to insert
if (m_subFolderNodes.count() == 0
......@@ -471,8 +462,7 @@ void FolderNode::addFolderNodes(const QList<FolderNode*> &subFolders)
qDebug("project nodes have to be added via addProjectNodes"));
}
foreach (NodesWatcher *watcher, pn->watchers())
emit watcher->foldersAdded();
ProjectTree::instance()->emitFoldersAdded();
}
/*!
......@@ -484,7 +474,6 @@ void FolderNode::addFolderNodes(const QList<FolderNode*> &subFolders)
void FolderNode::removeFolderNodes(const QList<FolderNode*> &subFolders)
{
Q_ASSERT(projectNode());
ProjectNode *pn = projectNode();
if (subFolders.isEmpty())
return;
......@@ -492,8 +481,7 @@ void FolderNode::removeFolderNodes(const QList<FolderNode*> &subFolders)
QList<FolderNode*> toRemove = subFolders;
Utils::sort(toRemove);
foreach (NodesWatcher *watcher, pn->watchers())
emit watcher->foldersAboutToBeRemoved(this, toRemove);
ProjectTree::instance()->emitFoldersAboutToBeRemoved(this, toRemove);
QList<FolderNode*>::const_iterator toRemoveIter = toRemove.constBegin();
QList<FolderNode*>::iterator folderIter = m_subFolderNodes.begin();
......@@ -509,20 +497,7 @@ void FolderNode::removeFolderNodes(const QList<FolderNode*> &subFolders)
folderIter = m_subFolderNodes.erase(folderIter);
}
foreach (NodesWatcher *watcher, pn->watchers())
emit watcher->foldersRemoved();
}
void FolderNode::aboutToChangeShowInSimpleTree()
{
foreach (NodesWatcher *watcher, projectNode()->watchers())
emit watcher->aboutToChangeShowInSimpleTree(this);
}
void FolderNode::showInSimpleTreeChanged()
{
foreach (NodesWatcher *watcher, projectNode()->watchers())
emit watcher->showInSimpleTreeChanged(this);
ProjectTree::instance()->emitFoldersRemoved();
}
bool FolderNode::showInSimpleTree() const
......@@ -629,40 +604,6 @@ QList<RunConfiguration *> ProjectNode::runConfigurations() const
return QList<RunConfiguration *>();
}
QList<NodesWatcher*> ProjectNode::watchers() const
{
return m_watchers;
}
/*!
Registers \a watcher for the current project and all subprojects.
It does not take ownership of the watcher.