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; ...@@ -53,8 +53,6 @@ class AutotoolsProject;
*/ */
class AutotoolsProjectNode : public ProjectExplorer::ProjectNode class AutotoolsProjectNode : public ProjectExplorer::ProjectNode
{ {
Q_OBJECT
public: public:
AutotoolsProjectNode(AutotoolsProject *project, Core::IDocument *projectFile); AutotoolsProjectNode(AutotoolsProject *project, Core::IDocument *projectFile);
......
...@@ -38,7 +38,6 @@ namespace Internal { ...@@ -38,7 +38,6 @@ namespace Internal {
class CMakeProjectNode : public ProjectExplorer::ProjectNode class CMakeProjectNode : public ProjectExplorer::ProjectNode
{ {
Q_OBJECT
friend class CMakeProject; friend class CMakeProject;
public: public:
CMakeProjectNode(const QString &fileName); CMakeProjectNode(const QString &fileName);
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <projectexplorer/projectnodes.h> #include <projectexplorer/projectnodes.h>
#include <projectexplorer/nodesvisitor.h> #include <projectexplorer/nodesvisitor.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <projectexplorer/projecttree.h>
#include <projectexplorer/session.h> #include <projectexplorer/session.h>
#include <resourceeditor/resourcenode.h> #include <resourceeditor/resourcenode.h>
...@@ -75,7 +76,7 @@ void QrcFilesVisitor::visitFolderNode(FolderNode *folderNode) ...@@ -75,7 +76,7 @@ void QrcFilesVisitor::visitFolderNode(FolderNode *folderNode)
if (fileNode->fileType() == ProjectExplorer::ResourceType) if (fileNode->fileType() == ProjectExplorer::ResourceType)
m_qrcFiles.append(fileNode->path()); m_qrcFiles.append(fileNode->path());
} }
if (qobject_cast<ResourceEditor::ResourceTopLevelNode *>(folderNode)) if (dynamic_cast<ResourceEditor::ResourceTopLevelNode *>(folderNode))
m_qrcFiles.append(folderNode->path()); m_qrcFiles.append(folderNode->path());
} }
...@@ -83,25 +84,23 @@ void QrcFilesVisitor::visitFolderNode(FolderNode *folderNode) ...@@ -83,25 +84,23 @@ void QrcFilesVisitor::visitFolderNode(FolderNode *folderNode)
ResourceHandler::ResourceHandler(QDesignerFormWindowInterface *fw) : ResourceHandler::ResourceHandler(QDesignerFormWindowInterface *fw) :
QObject(fw), QObject(fw),
m_form(fw), m_form(fw),
m_sessionNode(0), m_initialized(false),
m_sessionWatcher(0),
m_handlingResources(false) m_handlingResources(false)
{ {
} }
void ResourceHandler::ensureInitialized() void ResourceHandler::ensureInitialized()
{ {
if (m_sessionNode) if (m_initialized)
return; return;
m_sessionNode = ProjectExplorer::SessionManager::sessionNode(); m_initialized = true;
m_sessionWatcher = new ProjectExplorer::NodesWatcher(); ProjectTree *tree = ProjectTree::instance();
connect(m_sessionWatcher, SIGNAL(filesAdded()), this, SLOT(updateResources())); connect(tree, SIGNAL(filesAdded()), this, SLOT(updateResources()));
connect(m_sessionWatcher, SIGNAL(filesRemoved()), this, SLOT(updateResources())); connect(tree, SIGNAL(filesRemoved()), this, SLOT(updateResources()));
connect(m_sessionWatcher, SIGNAL(foldersAdded()), this, SLOT(updateResources())); connect(tree, SIGNAL(foldersAdded()), this, SLOT(updateResources()));
connect(m_sessionWatcher, SIGNAL(foldersRemoved()), this, SLOT(updateResources())); connect(tree, SIGNAL(foldersRemoved()), this, SLOT(updateResources()));
m_sessionNode->registerWatcher(m_sessionWatcher);
m_originalUiQrcPaths = m_form->activeResourceFilePaths(); m_originalUiQrcPaths = m_form->activeResourceFilePaths();
if (Designer::Constants::Internal::debug) if (Designer::Constants::Internal::debug)
qDebug() << "ResourceHandler::ensureInitialized() origPaths=" << m_originalUiQrcPaths; qDebug() << "ResourceHandler::ensureInitialized() origPaths=" << m_originalUiQrcPaths;
...@@ -109,11 +108,7 @@ void ResourceHandler::ensureInitialized() ...@@ -109,11 +108,7 @@ void ResourceHandler::ensureInitialized()
ResourceHandler::~ResourceHandler() 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) void ResourceHandler::updateResources(bool updateProjectResources)
......
...@@ -38,10 +38,7 @@ QT_BEGIN_NAMESPACE ...@@ -38,10 +38,7 @@ QT_BEGIN_NAMESPACE
class QDesignerFormWindowInterface; class QDesignerFormWindowInterface;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace ProjectExplorer { namespace ProjectExplorer { class SessionNode; }
class SessionNode;
class NodesWatcher;
}
namespace Designer { namespace Designer {
namespace Internal { namespace Internal {
...@@ -70,8 +67,7 @@ private: ...@@ -70,8 +67,7 @@ private:
void ensureInitialized(); void ensureInitialized();
QDesignerFormWindowInterface * const m_form; QDesignerFormWindowInterface * const m_form;
QStringList m_originalUiQrcPaths; QStringList m_originalUiQrcPaths;
ProjectExplorer::SessionNode *m_sessionNode; bool m_initialized;
ProjectExplorer::NodesWatcher *m_sessionWatcher;
bool m_handlingResources; bool m_handlingResources;
}; };
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include <QFutureInterface> #include <QFutureInterface>
#include <QMutex> #include <QMutex>
#include <QPointer>
namespace ProjectExplorer { namespace ProjectExplorer {
...@@ -57,7 +56,7 @@ private slots: ...@@ -57,7 +56,7 @@ private slots:
void markFilesAsOutOfDate(); void markFilesAsOutOfDate();
private: private:
QPointer<Project> m_project; Project *m_project;
}; };
} // namespace Internal } // namespace Internal
......
...@@ -1935,7 +1935,7 @@ static QString pathOrDirectoryFor(Node *node, bool dir) ...@@ -1935,7 +1935,7 @@ static QString pathOrDirectoryFor(Node *node, bool dir)
{ {
QString path = node->path(); QString path = node->path();
QString location; QString location;
FolderNode *folder = qobject_cast<FolderNode *>(node); FolderNode *folder = dynamic_cast<FolderNode *>(node);
if (node->nodeType() == VirtualFolderNodeType && folder) { if (node->nodeType() == VirtualFolderNodeType && folder) {
// Virtual Folder case // Virtual Folder case
// If there are files directly below or no subfolders, take the folder path // If there are files directly below or no subfolders, take the folder path
...@@ -2291,7 +2291,7 @@ void ProjectExplorerPlugin::runProjectWithoutDeploy() ...@@ -2291,7 +2291,7 @@ void ProjectExplorerPlugin::runProjectWithoutDeploy()
void ProjectExplorerPlugin::runProjectContextMenu() void ProjectExplorerPlugin::runProjectContextMenu()
{ {
ProjectNode *projectNode = qobject_cast<ProjectNode*>(ProjectTree::currentNode()); ProjectNode *projectNode = dynamic_cast<ProjectNode*>(ProjectTree::currentNode());
if (projectNode == ProjectTree::currentProject()->rootProjectNode() || !projectNode) { if (projectNode == ProjectTree::currentProject()->rootProjectNode() || !projectNode) {
runProject(ProjectTree::currentProject(), NormalRunMode); runProject(ProjectTree::currentProject(), NormalRunMode);
} else { } else {
...@@ -2810,7 +2810,7 @@ void ProjectExplorerPluginPrivate::updateContextMenuActions() ...@@ -2810,7 +2810,7 @@ void ProjectExplorerPluginPrivate::updateContextMenuActions()
if (currentNode && currentNode->projectNode()) { if (currentNode && currentNode->projectNode()) {
QList<ProjectAction> actions = currentNode->supportedActions(currentNode); 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()) { if (ProjectTree::currentProject() && pn == ProjectTree::currentProject()->rootProjectNode()) {
dd->m_runActionContextMenu->setVisible(true); dd->m_runActionContextMenu->setVisible(true);
} else { } else {
...@@ -2831,7 +2831,7 @@ void ProjectExplorerPluginPrivate::updateContextMenuActions() ...@@ -2831,7 +2831,7 @@ void ProjectExplorerPluginPrivate::updateContextMenuActions()
} }
} }
} }
if (qobject_cast<FolderNode*>(currentNode)) { if (dynamic_cast<FolderNode*>(currentNode)) {
// Also handles ProjectNode // Also handles ProjectNode
dd->m_addNewFileAction->setEnabled(actions.contains(AddNewFile) dd->m_addNewFileAction->setEnabled(actions.contains(AddNewFile)
&& !ICore::isNewItemDialogRunning()); && !ICore::isNewItemDialogRunning());
...@@ -2843,7 +2843,7 @@ void ProjectExplorerPluginPrivate::updateContextMenuActions() ...@@ -2843,7 +2843,7 @@ void ProjectExplorerPluginPrivate::updateContextMenuActions()
dd->m_addExistingFilesAction->setEnabled(actions.contains(AddExistingFile)); dd->m_addExistingFilesAction->setEnabled(actions.contains(AddExistingFile));
dd->m_addExistingDirectoryAction->setEnabled(actions.contains(AddExistingDirectory)); dd->m_addExistingDirectoryAction->setEnabled(actions.contains(AddExistingDirectory));
dd->m_renameFileAction->setEnabled(actions.contains(Rename)); 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: // Enable and show remove / delete in magic ways:
// If both are disabled show Remove // If both are disabled show Remove
// If both are enabled show both (can't happen atm) // If both are enabled show both (can't happen atm)
...@@ -2942,7 +2942,7 @@ void ProjectExplorerPlugin::addExistingDirectory() ...@@ -2942,7 +2942,7 @@ void ProjectExplorerPlugin::addExistingDirectory()
void ProjectExplorerPlugin::addExistingFiles(const QStringList &filePaths) void ProjectExplorerPlugin::addExistingFiles(const QStringList &filePaths)
{ {
FolderNode *folderNode = qobject_cast<FolderNode *>(ProjectTree::currentNode()); FolderNode *folderNode = dynamic_cast<FolderNode *>(ProjectTree::currentNode());
addExistingFiles(folderNode, filePaths); addExistingFiles(folderNode, filePaths);
} }
...@@ -2971,8 +2971,8 @@ void ProjectExplorerPlugin::addExistingFiles(FolderNode *folderNode, const QStri ...@@ -2971,8 +2971,8 @@ void ProjectExplorerPlugin::addExistingFiles(FolderNode *folderNode, const QStri
void ProjectExplorerPlugin::removeProject() void ProjectExplorerPlugin::removeProject()
{ {
ProjectNode *subProjectNode = qobject_cast<ProjectNode*>(ProjectTree::currentNode()->projectNode()); ProjectNode *subProjectNode = dynamic_cast<ProjectNode*>(ProjectTree::currentNode()->projectNode());
ProjectNode *projectNode = qobject_cast<ProjectNode *>(subProjectNode->parentFolderNode()); ProjectNode *projectNode = dynamic_cast<ProjectNode *>(subProjectNode->parentFolderNode());
if (projectNode) { if (projectNode) {
RemoveFileDialog removeFileDialog(subProjectNode->path(), ICore::mainWindow()); RemoveFileDialog removeFileDialog(subProjectNode->path(), ICore::mainWindow());
removeFileDialog.setDeleteFileVisible(false); removeFileDialog.setDeleteFileVisible(false);
...@@ -3010,7 +3010,7 @@ void ProjectExplorerPlugin::removeFile() ...@@ -3010,7 +3010,7 @@ void ProjectExplorerPlugin::removeFile()
Node *currentNode = ProjectTree::currentNode(); Node *currentNode = ProjectTree::currentNode();
QTC_ASSERT(currentNode && currentNode->nodeType() == FileNodeType, return); QTC_ASSERT(currentNode && currentNode->nodeType() == FileNodeType, return);
FileNode *fileNode = qobject_cast<FileNode*>(currentNode); FileNode *fileNode = dynamic_cast<FileNode*>(currentNode);
QString filePath = currentNode->path(); QString filePath = currentNode->path();
RemoveFileDialog removeFileDialog(filePath, ICore::mainWindow()); RemoveFileDialog removeFileDialog(filePath, ICore::mainWindow());
...@@ -3039,7 +3039,7 @@ void ProjectExplorerPlugin::deleteFile() ...@@ -3039,7 +3039,7 @@ void ProjectExplorerPlugin::deleteFile()
Node *currentNode = ProjectTree::currentNode(); Node *currentNode = ProjectTree::currentNode();
QTC_ASSERT(currentNode && currentNode->nodeType() == FileNodeType, return); QTC_ASSERT(currentNode && currentNode->nodeType() == FileNodeType, return);
FileNode *fileNode = qobject_cast<FileNode*>(currentNode); FileNode *fileNode = dynamic_cast<FileNode*>(currentNode);
QString filePath = currentNode->path(); QString filePath = currentNode->path();
QMessageBox::StandardButton button = QMessageBox::StandardButton button =
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "project.h" #include "project.h"
#include "projectnodes.h" #include "projectnodes.h"
#include "projectexplorer.h" #include "projectexplorer.h"
#include "projecttree.h"
#include <coreplugin/fileiconprovider.h> #include <coreplugin/fileiconprovider.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
...@@ -58,8 +59,8 @@ bool sortNodes(Node *n1, Node *n2) ...@@ -58,8 +59,8 @@ bool sortNodes(Node *n1, Node *n2)
const NodeType n2Type = n2->nodeType(); const NodeType n2Type = n2->nodeType();
// project files // project files
FileNode *file1 = qobject_cast<FileNode*>(n1); FileNode *file1 = dynamic_cast<FileNode*>(n1);
FileNode *file2 = qobject_cast<FileNode*>(n2); FileNode *file2 = dynamic_cast<FileNode*>(n2);
if (file1 && file1->fileType() == ProjectFileType) { if (file1 && file1->fileType() == ProjectFileType) {
if (file2 && file2->fileType() == ProjectFileType) { if (file2 && file2->fileType() == ProjectFileType) {
const QString fileName1 = QFileInfo(file1->path()).fileName(); const QString fileName1 = QFileInfo(file1->path()).fileName();
...@@ -177,42 +178,41 @@ FlatModel::FlatModel(SessionNode *rootNode, QObject *parent) ...@@ -177,42 +178,41 @@ FlatModel::FlatModel(SessionNode *rootNode, QObject *parent)
m_startupProject(0), m_startupProject(0),
m_parentFolderForChange(0) m_parentFolderForChange(0)
{ {
NodesWatcher *watcher = new NodesWatcher(this); ProjectTree *tree = ProjectTree::instance();
m_rootNode->registerWatcher(watcher);
connect(watcher, SIGNAL(aboutToChangeShowInSimpleTree(ProjectExplorer::FolderNode*)), connect(tree, &ProjectTree::aboutToChangeShowInSimpleTree,
this, SLOT(aboutToShowInSimpleTreeChanged(ProjectExplorer::FolderNode*))); this, &FlatModel::aboutToShowInSimpleTreeChanged);
connect(watcher, SIGNAL(showInSimpleTreeChanged(ProjectExplorer::FolderNode*)), connect(tree, &ProjectTree::showInSimpleTreeChanged,
this, SLOT(showInSimpleTreeChanged(ProjectExplorer::FolderNode*))); this, &FlatModel::showInSimpleTreeChanged);
connect(watcher, SIGNAL(foldersAboutToBeAdded(FolderNode*,QList<FolderNode*>)), connect(tree, &ProjectTree::foldersAboutToBeAdded,
this, SLOT(foldersAboutToBeAdded(FolderNode*,QList<FolderNode*>))); this, &FlatModel::foldersAboutToBeAdded);
connect(watcher, SIGNAL(foldersAdded()), connect(tree, &ProjectTree::foldersAdded,
this, SLOT(foldersAdded())); this, &FlatModel::foldersAdded);
connect(watcher, SIGNAL(foldersAboutToBeRemoved(FolderNode*,QList<FolderNode*>)), connect(tree, &ProjectTree::foldersAboutToBeRemoved,
this, SLOT(foldersAboutToBeRemoved(FolderNode*,QList<FolderNode*>))); this, &FlatModel::foldersAboutToBeRemoved);
connect(watcher, SIGNAL(foldersRemoved()), connect(tree, &ProjectTree::foldersRemoved,
this, SLOT(foldersRemoved())); this, &FlatModel::foldersRemoved);
connect(watcher, SIGNAL(filesAboutToBeAdded(FolderNode*,QList<FileNode*>)), connect(tree, &ProjectTree::filesAboutToBeAdded,
this, SLOT(filesAboutToBeAdded(FolderNode*,QList<FileNode*>))); this, &FlatModel::filesAboutToBeAdded);
connect(watcher, SIGNAL(filesAdded()), connect(tree, &ProjectTree::filesAdded,
this, SLOT(filesAdded())); this, &FlatModel::filesAdded);
connect(watcher, SIGNAL(filesAboutToBeRemoved(FolderNode*,QList<FileNode*>)), connect(tree, &ProjectTree::filesAboutToBeRemoved,
this, SLOT(filesAboutToBeRemoved(FolderNode*,QList<FileNode*>))); this, &FlatModel::filesAboutToBeRemoved);
connect(watcher, SIGNAL(filesRemoved()), connect(tree, &ProjectTree::filesRemoved,
this, SLOT(filesRemoved())); this, &FlatModel::filesRemoved);
connect(watcher, SIGNAL(nodeSortKeyAboutToChange(Node*)), connect(tree, &ProjectTree::nodeSortKeyAboutToChange,
this, SLOT(nodeSortKeyAboutToChange(Node*))); this, &FlatModel::nodeSortKeyAboutToChange);
connect(watcher, SIGNAL(nodeSortKeyChanged()), connect(tree, &ProjectTree::nodeSortKeyChanged,
this, SLOT(nodeSortKeyChanged())); this, &FlatModel::nodeSortKeyChanged);
connect(watcher, SIGNAL(nodeUpdated(ProjectExplorer::Node*)), connect(tree, &ProjectTree::nodeUpdated,
this, SLOT(nodeUpdated(ProjectExplorer::Node*))); this, &FlatModel::nodeUpdated);
} }
QModelIndex FlatModel::index(int row, int column, const QModelIndex &parent) const 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 ...@@ -221,7 +221,7 @@ QModelIndex FlatModel::index(int row, int column, const QModelIndex &parent) con
if (!parent.isValid() && row == 0 && column == 0) { // session if (!parent.isValid() && row == 0 && column == 0) { // session
result = createIndex(0, 0, m_rootNode); result = createIndex(0, 0, m_rootNode);
} else if (parent.isValid() && column == 0) { } else if (parent.isValid() && column == 0) {
FolderNode *parentNode = qobject_cast<FolderNode*>(nodeForIndex(parent)); FolderNode *parentNode = dynamic_cast<FolderNode*>(nodeForIndex(parent));
Q_ASSERT(parentNode); Q_ASSERT(parentNode);
QHash<FolderNode*, QList<Node*> >::const_iterator it = m_childNodes.constFind(parentNode); QHash<FolderNode*, QList<Node*> >::const_iterator it = m_childNodes.constFind(parentNode);
if (it == m_childNodes.constEnd()) { if (it == m_childNodes.constEnd()) {
...@@ -270,7 +270,7 @@ QVariant FlatModel::data(const QModelIndex &index, int role) const ...@@ -270,7 +270,7 @@ QVariant FlatModel::data(const QModelIndex &index, int role) const
QVariant result; QVariant result;
if (Node *node = nodeForIndex(index)) { if (Node *node = nodeForIndex(index)) {
FolderNode *folderNode = qobject_cast<FolderNode*>(node); FolderNode *folderNode = dynamic_cast<FolderNode*>(node);
switch (role) { switch (role) {
case Qt::DisplayRole: { case Qt::DisplayRole: {
QString name = node->displayName(); QString name = node->displayName();
...@@ -334,11 +334,11 @@ Qt::ItemFlags FlatModel::flags(const QModelIndex &index) const ...@@ -334,11 +334,11 @@ Qt::ItemFlags FlatModel::flags(const QModelIndex &index) const
if (Node *node = nodeForIndex(index)) { if (Node *node = nodeForIndex(index)) {
if (node == m_rootNode) if (node == m_rootNode)
return 0; // no flags for session node... return 0; // no flags for session node...
if (!qobject_cast<ProjectNode *>(node)) { if (!dynamic_cast<ProjectNode *>(node)) {
// either folder or file node // either folder or file node
if (node->supportedActions(node).contains(Rename)) if (node->supportedActions(node).contains(Rename))
f = f | Qt::ItemIsEditable; f = f | Qt::ItemIsEditable;
if (qobject_cast<FileNode *>(node)) if (dynamic_cast<FileNode *>(node))
f = f | Qt::ItemIsDragEnabled; f = f | Qt::ItemIsDragEnabled;
} }
} }
...@@ -369,7 +369,7 @@ int FlatModel::rowCount(const QModelIndex &parent) const ...@@ -369,7 +369,7 @@ int FlatModel::rowCount(const QModelIndex &parent) const
if (!parent.isValid()) { if (!parent.isValid()) {
rows = 1; rows = 1;
} else { } else {
FolderNode *folderNode = qobject_cast<FolderNode*>(nodeForIndex(parent)); FolderNode *folderNode = dynamic_cast<FolderNode*>(nodeForIndex(parent));
if (folderNode && m_childNodes.contains(folderNode)) if (folderNode && m_childNodes.contains(folderNode))
rows = m_childNodes.value(folderNode).size(); rows = m_childNodes.value(folderNode).size();
} }
...@@ -386,7 +386,7 @@ bool FlatModel::hasChildren(const QModelIndex &parent) const ...@@ -386,7 +386,7 @@ bool FlatModel::hasChildren(const QModelIndex &parent) const
if (!parent.isValid()) if (!parent.isValid())
return true; return true;
FolderNode *folderNode = qobject_cast<FolderNode*>(nodeForIndex(parent)); FolderNode *folderNode = dynamic_cast<FolderNode*>(nodeForIndex(parent));
if (!folderNode) if (!folderNode)
return false; return false;
...@@ -403,7 +403,7 @@ bool FlatModel::canFetchMore(const QModelIndex & parent) const ...@@ -403,7 +403,7 @@ bool FlatModel::canFetchMore(const QModelIndex & parent) const
if (!parent.isValid()) { if (!parent.isValid()) {
return false; return false;
} else { } else {
if (FolderNode *folderNode = qobject_cast<FolderNode*>(nodeForIndex(parent))) if (FolderNode *folderNode = dynamic_cast<FolderNode*>(nodeForIndex(parent)))
return !m_childNodes.contains(folderNode); return !m_childNodes.contains(folderNode);
else else
return false; return false;
...@@ -473,7 +473,7 @@ void FlatModel::fetchMore(FolderNode *folderNode) const ...@@ -473,7 +473,7 @@ void FlatModel::fetchMore(FolderNode *folderNode) const
void FlatModel::fetchMore(const QModelIndex &parent) void FlatModel::fetchMore(const QModelIndex &parent)
{ {
FolderNode *folderNode = qobject_cast<FolderNode*>(nodeForIndex(parent)); FolderNode *folderNode = dynamic_cast<FolderNode*>(nodeForIndex(parent));
Q_ASSERT(folderNode); Q_ASSERT(folderNode);
fetchMore(folderNode); fetchMore(folderNode);
...@@ -514,7 +514,7 @@ QMimeData *FlatModel::mimeData(const QModelIndexList &indexes) const ...@@ -514,7 +514,7 @@ QMimeData *FlatModel::mimeData(const QModelIndexList &indexes) const
auto data = new Utils::FileDropMimeData; auto data = new Utils::FileDropMimeData;
foreach (const QModelIndex &index, indexes) { foreach (const QModelIndex &index, indexes) {
Node *node = nodeForIndex(index); Node *node = nodeForIndex(index);
if (qobject_cast<FileNode *>(node)) if (dynamic_cast<FileNode *>(node))
data->addFile(node->path()); data->addFile(node->path());
} }
return data; return data;
...@@ -601,10 +601,10 @@ FolderNode *FlatModel::visibleFolderNode(FolderNode *node) const ...@@ -601,10 +601,10 @@ FolderNode *FlatModel::visibleFolderNode(FolderNode *node) const
bool FlatModel::filter(Node *node) const bool FlatModel::filter(Node *node) const
{ {
bool isHidden = false; bool isHidden = false;
if (FolderNode *folderNode = qobject_cast<FolderNode*>(node)) { if (FolderNode *folderNode = dynamic_cast<FolderNode*>(node)) {
if (m_filterProjects) if (m_filterProjects)
isHidden = !folderNode->showInSimpleTree(); isHidden = !folderNode->showInSimpleTree();
} else if (FileNode *fileNode = qobject_cast<FileNode*>(node)) { } else if (FileNode *fileNode = dynamic_cast<FileNode*>(node)) {
if (m_filterGeneratedFiles) if (m_filterGeneratedFiles)
isHidden = fileNode->isGenerated(); isHidden = fileNode->isGenerated();
} }
...@@ -803,7 +803,7 @@ void FlatModel::aboutToShowInSimpleTreeChanged(FolderNode* node) ...@@ -803,7 +803,7 @@ void FlatModel::aboutToShowInSimpleTreeChanged(FolderNode* node)
QList<Node *> staleFolders; QList<Node *> staleFolders;
recursiveAddFolderNodesImpl(node, &staleFolders); recursiveAddFolderNodesImpl(node, &staleFolders);
foreach (Node *n, staleFolders) foreach (Node *n, staleFolders)
if (FolderNode *fn = qobject_cast<FolderNode *>(n)) if (FolderNode *fn = dynamic_cast<FolderNode *>(n))
m_childNodes.remove(fn); m_childNodes.remove(fn);
} }
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "nodesvisitor.h" #include "nodesvisitor.h"
#include "projectexplorerconstants.h" #include "projectexplorerconstants.h"
#include "projecttree.h"
#include <coreplugin/mimedatabase.h> #include <coreplugin/mimedatabase.h>
#include <coreplugin/fileiconprovider.h> #include <coreplugin/fileiconprovider.h>
...@@ -65,30 +66,30 @@ using namespace ProjectExplorer; ...@@ -65,30 +66,30 @@ using namespace ProjectExplorer;
Node::Node(NodeType nodeType, Node::Node(NodeType nodeType,
const QString &filePath, int line) const QString &filePath, int line)
: QObject(), : m_nodeType(nodeType),
m_nodeType(nodeType), m_line(line),
m_projectNode(0), m_projectNode(0),
m_folderNode(0), m_folderNode(0),
m_path(filePath), m_path(filePath)