Commit d144ea58 authored by Tobias Hunger's avatar Tobias Hunger

Project: Add setRootProjectNode method

Add setRootProjectNode method and a default implementation of
rootProjectNode to Project. Use that in all derived classes.

Change-Id: Id28cde04457a20a8963d43020785ef9d77fea57c
Reviewed-by: default avatarNiels Weber <niels.weber@theqtcompany.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 219b2d9c
...@@ -78,24 +78,18 @@ AutotoolsProject::AutotoolsProject(AutotoolsManager *manager, const QString &fil ...@@ -78,24 +78,18 @@ AutotoolsProject::AutotoolsProject(AutotoolsManager *manager, const QString &fil
setId(Constants::AUTOTOOLS_PROJECT_ID); setId(Constants::AUTOTOOLS_PROJECT_ID);
setProjectManager(manager); setProjectManager(manager);
setDocument(new AutotoolsProjectFile(fileName)); setDocument(new AutotoolsProjectFile(fileName));
m_rootNode = new AutotoolsProjectNode(projectFilePath()); setRootProjectNode(new AutotoolsProjectNode(projectFilePath()));
setProjectContext(Core::Context(Constants::PROJECT_CONTEXT)); setProjectContext(Core::Context(Constants::PROJECT_CONTEXT));
setProjectLanguages(Core::Context(ProjectExplorer::Constants::LANG_CXX)); setProjectLanguages(Core::Context(ProjectExplorer::Constants::LANG_CXX));
const QFileInfo fileInfo = projectFilePath().toFileInfo(); const QFileInfo fileInfo = projectFilePath().toFileInfo();
m_projectName = fileInfo.absoluteDir().dirName(); m_projectName = fileInfo.absoluteDir().dirName();
m_rootNode->setDisplayName(fileInfo.absoluteDir().dirName()); rootProjectNode()->setDisplayName(m_projectName);
} }
AutotoolsProject::~AutotoolsProject() AutotoolsProject::~AutotoolsProject()
{ {
// Although ProjectExplorer::ProjectNode is a QObject, the ctor setRootProjectNode(0);
// does not allow to specify the parent. Manually setting the
// parent would be possible, but we use the same approach as in the
// other project managers and delete the node manually (TBD).
//
delete m_rootNode;
m_rootNode = 0;
if (m_makefileParserThread != 0) { if (m_makefileParserThread != 0) {
m_makefileParserThread->wait(); m_makefileParserThread->wait();
...@@ -114,11 +108,6 @@ QString AutotoolsProject::defaultBuildDirectory(const QString &projectPath) ...@@ -114,11 +108,6 @@ QString AutotoolsProject::defaultBuildDirectory(const QString &projectPath)
return QFileInfo(projectPath).absolutePath(); return QFileInfo(projectPath).absolutePath();
} }
ProjectNode *AutotoolsProject::rootProjectNode() const
{
return m_rootNode;
}
QStringList AutotoolsProject::files(FilesMode fileMode) const QStringList AutotoolsProject::files(FilesMode fileMode) const
{ {
Q_UNUSED(fileMode); Q_UNUSED(fileMode);
...@@ -261,7 +250,7 @@ void AutotoolsProject::buildFileNodeTree(const QDir &directory, ...@@ -261,7 +250,7 @@ void AutotoolsProject::buildFileNodeTree(const QDir &directory,
// This allows to reuse existing nodes and to remove obsolete // This allows to reuse existing nodes and to remove obsolete
// nodes later. // nodes later.
QHash<QString, Node *> nodeHash; QHash<QString, Node *> nodeHash;
foreach (Node * node, nodes(m_rootNode)) foreach (Node *node, nodes(rootProjectNode()))
nodeHash.insert(node->filePath().toString(), node); nodeHash.insert(node->filePath().toString(), node);
// Add the sources to the filenode project tree. Sources // Add the sources to the filenode project tree. Sources
...@@ -291,7 +280,7 @@ void AutotoolsProject::buildFileNodeTree(const QDir &directory, ...@@ -291,7 +280,7 @@ void AutotoolsProject::buildFileNodeTree(const QDir &directory,
parentFolder = insertFolderNode(QDir(subDir), nodeHash); parentFolder = insertFolderNode(QDir(subDir), nodeHash);
if (parentFolder == 0) { if (parentFolder == 0) {
// No node gets created for the root folder // No node gets created for the root folder
parentFolder = m_rootNode; parentFolder = rootProjectNode();
} }
} }
QTC_ASSERT(parentFolder, return); QTC_ASSERT(parentFolder, return);
...@@ -332,7 +321,7 @@ void AutotoolsProject::buildFileNodeTree(const QDir &directory, ...@@ -332,7 +321,7 @@ void AutotoolsProject::buildFileNodeTree(const QDir &directory,
FolderNode *grandParent = parent->parentFolderNode(); FolderNode *grandParent = parent->parentFolderNode();
grandParent->removeFolderNodes(QList<FolderNode *>() << parent); grandParent->removeFolderNodes(QList<FolderNode *>() << parent);
parent = grandParent; parent = grandParent;
if (parent == m_rootNode) if (parent == rootProjectNode())
break; break;
} }
} }
...@@ -343,7 +332,7 @@ void AutotoolsProject::buildFileNodeTree(const QDir &directory, ...@@ -343,7 +332,7 @@ void AutotoolsProject::buildFileNodeTree(const QDir &directory,
FolderNode *AutotoolsProject::insertFolderNode(const QDir &nodeDir, QHash<QString, Node *> &nodes) FolderNode *AutotoolsProject::insertFolderNode(const QDir &nodeDir, QHash<QString, Node *> &nodes)
{ {
const Utils::FileName nodePath = Utils::FileName::fromString(nodeDir.absolutePath()); const Utils::FileName nodePath = Utils::FileName::fromString(nodeDir.absolutePath());
QFileInfo rootInfo = m_rootNode->filePath().toFileInfo(); QFileInfo rootInfo = rootProjectNode()->filePath().toFileInfo();
const Utils::FileName rootPath = Utils::FileName::fromString(rootInfo.absolutePath()); const Utils::FileName rootPath = Utils::FileName::fromString(rootInfo.absolutePath());
// Do not create a folder for the root node // Do not create a folder for the root node
...@@ -356,7 +345,7 @@ FolderNode *AutotoolsProject::insertFolderNode(const QDir &nodeDir, QHash<QStrin ...@@ -356,7 +345,7 @@ FolderNode *AutotoolsProject::insertFolderNode(const QDir &nodeDir, QHash<QStrin
// Get parent-folder. If it does not exist, create it recursively. // Get parent-folder. If it does not exist, create it recursively.
// Take care that the m_rootNode is considered as top folder. // Take care that the m_rootNode is considered as top folder.
FolderNode *parentFolder = m_rootNode; FolderNode *parentFolder = rootProjectNode();
if ((rootPath != folder->filePath()) && dir.cdUp()) { if ((rootPath != folder->filePath()) && dir.cdUp()) {
const QString parentDir = dir.absolutePath(); const QString parentDir = dir.absolutePath();
if (!nodes.contains(parentDir)) { if (!nodes.contains(parentDir)) {
......
...@@ -74,7 +74,6 @@ public: ...@@ -74,7 +74,6 @@ public:
~AutotoolsProject() override; ~AutotoolsProject() override;
QString displayName() const override; QString displayName() const override;
ProjectExplorer::ProjectNode *rootProjectNode() const override;
QStringList files(FilesMode fileMode) const override; QStringList files(FilesMode fileMode) const override;
static QString defaultBuildDirectory(const QString &projectPath); static QString defaultBuildDirectory(const QString &projectPath);
QStringList buildTargets() const; QStringList buildTargets() const;
...@@ -140,9 +139,6 @@ private: ...@@ -140,9 +139,6 @@ private:
/// Return value for AutotoolsProject::files() /// Return value for AutotoolsProject::files()
QStringList m_files; QStringList m_files;
/// Return value for AutotoolsProject::rootProjectNode()
AutotoolsProjectNode *m_rootNode;
/// Watches project files for changes. /// Watches project files for changes.
Utils::FileSystemWatcher *m_fileWatcher; Utils::FileSystemWatcher *m_fileWatcher;
QStringList m_watchedFiles; QStringList m_watchedFiles;
......
...@@ -88,16 +88,16 @@ using namespace Utils; ...@@ -88,16 +88,16 @@ using namespace Utils;
\class CMakeProject \class CMakeProject
*/ */
CMakeProject::CMakeProject(CMakeManager *manager, const FileName &fileName) : CMakeProject::CMakeProject(CMakeManager *manager, const FileName &fileName) :
m_rootNode(new CMakeProjectNode(fileName)),
m_watcher(new QFileSystemWatcher(this)) m_watcher(new QFileSystemWatcher(this))
{ {
setId(Constants::CMAKEPROJECT_ID); setId(Constants::CMAKEPROJECT_ID);
setProjectManager(manager); setProjectManager(manager);
setDocument(new CMakeFile(fileName)); setDocument(new CMakeFile(fileName));
setRootProjectNode(new CMakeProjectNode(fileName));
setProjectContext(Core::Context(CMakeProjectManager::Constants::PROJECTCONTEXT)); setProjectContext(Core::Context(CMakeProjectManager::Constants::PROJECTCONTEXT));
setProjectLanguages(Core::Context(ProjectExplorer::Constants::LANG_CXX)); setProjectLanguages(Core::Context(ProjectExplorer::Constants::LANG_CXX));
m_rootNode->setDisplayName(fileName.parentDir().fileName()); rootProjectNode()->setDisplayName(fileName.parentDir().fileName());
connect(this, &CMakeProject::buildTargetsChanged, this, &CMakeProject::updateRunConfigurations); connect(this, &CMakeProject::buildTargetsChanged, this, &CMakeProject::updateRunConfigurations);
connect(m_watcher, &QFileSystemWatcher::fileChanged, this, &CMakeProject::fileChanged); connect(m_watcher, &QFileSystemWatcher::fileChanged, this, &CMakeProject::fileChanged);
...@@ -106,7 +106,6 @@ CMakeProject::CMakeProject(CMakeManager *manager, const FileName &fileName) : ...@@ -106,7 +106,6 @@ CMakeProject::CMakeProject(CMakeManager *manager, const FileName &fileName) :
CMakeProject::~CMakeProject() CMakeProject::~CMakeProject()
{ {
m_codeModelFuture.cancel(); m_codeModelFuture.cancel();
delete m_rootNode;
} }
void CMakeProject::fileChanged(const QString &fileName) void CMakeProject::fileChanged(const QString &fileName)
...@@ -265,7 +264,7 @@ bool CMakeProject::parseCMakeLists() ...@@ -265,7 +264,7 @@ bool CMakeProject::parseCMakeLists()
Kit *k = activeTarget()->kit(); Kit *k = activeTarget()->kit();
// setFolderName // setFolderName
m_rootNode->setDisplayName(QFileInfo(cbpFile).completeBaseName()); rootProjectNode()->setDisplayName(QFileInfo(cbpFile).completeBaseName());
CMakeCbpParser cbpparser; CMakeCbpParser cbpparser;
// Parsing // Parsing
//qDebug()<<"Parsing file "<<cbpFile; //qDebug()<<"Parsing file "<<cbpFile;
...@@ -282,7 +281,7 @@ bool CMakeProject::parseCMakeLists() ...@@ -282,7 +281,7 @@ bool CMakeProject::parseCMakeLists()
// how can we ensure that it is completely written? // how can we ensure that it is completely written?
m_watcher->addPath(cbpFile); m_watcher->addPath(cbpFile);
m_rootNode->setDisplayName(cbpparser.projectName()); rootProjectNode()->setDisplayName(cbpparser.projectName());
//qDebug()<<"Building Tree"; //qDebug()<<"Building Tree";
QList<ProjectExplorer::FileNode *> fileList = cbpparser.fileList(); QList<ProjectExplorer::FileNode *> fileList = cbpparser.fileList();
...@@ -306,7 +305,7 @@ bool CMakeProject::parseCMakeLists() ...@@ -306,7 +305,7 @@ bool CMakeProject::parseCMakeLists()
m_files.append(fn->filePath().toString()); m_files.append(fn->filePath().toString());
m_files.sort(); m_files.sort();
buildTree(m_rootNode, fileList); buildTree(static_cast<CMakeProjectNode *>(rootProjectNode()), fileList);
//qDebug()<<"Adding Targets"; //qDebug()<<"Adding Targets";
m_buildTargets = cbpparser.buildTargets(); m_buildTargets = cbpparser.buildTargets();
...@@ -506,15 +505,9 @@ ProjectExplorer::FolderNode *CMakeProject::findOrCreateFolder(CMakeProjectNode * ...@@ -506,15 +505,9 @@ ProjectExplorer::FolderNode *CMakeProject::findOrCreateFolder(CMakeProjectNode *
QString CMakeProject::displayName() const QString CMakeProject::displayName() const
{ {
return m_rootNode->displayName(); return rootProjectNode()->displayName();
} }
ProjectExplorer::ProjectNode *CMakeProject::rootProjectNode() const
{
return m_rootNode;
}
QStringList CMakeProject::files(FilesMode fileMode) const QStringList CMakeProject::files(FilesMode fileMode) const
{ {
Q_UNUSED(fileMode) Q_UNUSED(fileMode)
......
...@@ -100,8 +100,6 @@ public: ...@@ -100,8 +100,6 @@ public:
QString displayName() const override; QString displayName() const override;
ProjectExplorer::ProjectNode *rootProjectNode() const override;
QStringList files(FilesMode fileMode) const override; QStringList files(FilesMode fileMode) const override;
QStringList buildTargetTitles(bool runnable = false) const; QStringList buildTargetTitles(bool runnable = false) const;
QList<CMakeBuildTarget> buildTargets() const; QList<CMakeBuildTarget> buildTargets() const;
...@@ -149,7 +147,6 @@ private: ...@@ -149,7 +147,6 @@ private:
ProjectExplorer::Target *m_activeTarget = 0; ProjectExplorer::Target *m_activeTarget = 0;
// TODO probably need a CMake specific node structure // TODO probably need a CMake specific node structure
Internal::CMakeProjectNode *m_rootNode;
QStringList m_files; QStringList m_files;
QList<CMakeBuildTarget> m_buildTargets; QList<CMakeBuildTarget> m_buildTargets;
QFileSystemWatcher *m_watcher; QFileSystemWatcher *m_watcher;
......
...@@ -50,7 +50,6 @@ public: ...@@ -50,7 +50,6 @@ public:
~TestProject() override; ~TestProject() override;
QString displayName() const override { return m_name; } QString displayName() const override { return m_name; }
ProjectExplorer::ProjectNode *rootProjectNode() const override { return 0; }
QStringList files(FilesMode fileMode) const override { Q_UNUSED(fileMode); return QStringList(); } QStringList files(FilesMode fileMode) const override { Q_UNUSED(fileMode); return QStringList(); }
......
...@@ -72,6 +72,7 @@ GenericProject::GenericProject(Manager *manager, const QString &fileName) ...@@ -72,6 +72,7 @@ GenericProject::GenericProject(Manager *manager, const QString &fileName)
setId(Constants::GENERICPROJECT_ID); setId(Constants::GENERICPROJECT_ID);
setProjectManager(manager); setProjectManager(manager);
setDocument(new GenericProjectFile(this, fileName, GenericProject::Everything)); setDocument(new GenericProjectFile(this, fileName, GenericProject::Everything));
setRootProjectNode(new GenericProjectNode(this));
setProjectContext(Context(GenericProjectManager::Constants::PROJECTCONTEXT)); setProjectContext(Context(GenericProjectManager::Constants::PROJECTCONTEXT));
setProjectLanguages(Context(ProjectExplorer::Constants::LANG_CXX)); setProjectLanguages(Context(ProjectExplorer::Constants::LANG_CXX));
...@@ -92,8 +93,6 @@ GenericProject::GenericProject(Manager *manager, const QString &fileName) ...@@ -92,8 +93,6 @@ GenericProject::GenericProject(Manager *manager, const QString &fileName)
DocumentManager::addDocument(m_includesIDocument); DocumentManager::addDocument(m_includesIDocument);
DocumentManager::addDocument(m_configIDocument); DocumentManager::addDocument(m_configIDocument);
m_rootNode = new GenericProjectNode(this);
FileNode *projectFilesNode = new FileNode(Utils::FileName::fromString(m_filesFileName), FileNode *projectFilesNode = new FileNode(Utils::FileName::fromString(m_filesFileName),
ProjectFileType, ProjectFileType,
/* generated = */ false); /* generated = */ false);
...@@ -106,10 +105,8 @@ GenericProject::GenericProject(Manager *manager, const QString &fileName) ...@@ -106,10 +105,8 @@ GenericProject::GenericProject(Manager *manager, const QString &fileName)
ProjectFileType, ProjectFileType,
/* generated = */ false); /* generated = */ false);
m_rootNode->addFileNodes(QList<FileNode *>() rootProjectNode()->addFileNodes(QList<FileNode *>() << projectFilesNode
<< projectFilesNode << projectIncludesNode << projectConfigNode);
<< projectIncludesNode
<< projectConfigNode);
projectManager()->registerProject(this); projectManager()->registerProject(this);
} }
...@@ -118,8 +115,6 @@ GenericProject::~GenericProject() ...@@ -118,8 +115,6 @@ GenericProject::~GenericProject()
{ {
m_codeModelFuture.cancel(); m_codeModelFuture.cancel();
projectManager()->unregisterProject(this); projectManager()->unregisterProject(this);
delete m_rootNode;
} }
QString GenericProject::filesFileName() const QString GenericProject::filesFileName() const
...@@ -281,7 +276,7 @@ void GenericProject::refresh(RefreshOptions options) ...@@ -281,7 +276,7 @@ void GenericProject::refresh(RefreshOptions options)
parseProject(options); parseProject(options);
if (options & Files) if (options & Files)
m_rootNode->refresh(oldFileList); static_cast<GenericProjectNode *>(rootProjectNode())->refresh(oldFileList);
refreshCppCodeModel(); refreshCppCodeModel();
} }
...@@ -392,11 +387,6 @@ Manager *GenericProject::projectManager() const ...@@ -392,11 +387,6 @@ Manager *GenericProject::projectManager() const
return static_cast<Manager *>(Project::projectManager()); return static_cast<Manager *>(Project::projectManager());
} }
GenericProjectNode *GenericProject::rootProjectNode() const
{
return m_rootNode;
}
QStringList GenericProject::files(FilesMode fileMode) const QStringList GenericProject::files(FilesMode fileMode) const
{ {
Q_UNUSED(fileMode); Q_UNUSED(fileMode);
......
...@@ -63,7 +63,6 @@ public: ...@@ -63,7 +63,6 @@ public:
QString displayName() const override; QString displayName() const override;
Manager *projectManager() const override; Manager *projectManager() const override;
GenericProjectNode *rootProjectNode() const override;
QStringList files(FilesMode fileMode) const override; QStringList files(FilesMode fileMode) const override;
QStringList buildTargets() const; QStringList buildTargets() const;
...@@ -109,7 +108,6 @@ private: ...@@ -109,7 +108,6 @@ private:
QStringList m_rawProjectIncludePaths; QStringList m_rawProjectIncludePaths;
QStringList m_projectIncludePaths; QStringList m_projectIncludePaths;
GenericProjectNode *m_rootNode;
QFuture<void> m_codeModelFuture; QFuture<void> m_codeModelFuture;
}; };
......
...@@ -207,7 +207,7 @@ QString IosRunConfiguration::applicationName() const ...@@ -207,7 +207,7 @@ QString IosRunConfiguration::applicationName() const
QmakeProject *pro = qobject_cast<QmakeProject *>(target()->project()); QmakeProject *pro = qobject_cast<QmakeProject *>(target()->project());
const QmakeProFileNode *node = 0; const QmakeProFileNode *node = 0;
if (pro) if (pro)
node = pro->rootQmakeProjectNode(); node = pro->rootProjectNode();
if (node) if (node)
node = node->findProFileFor(profilePath()); node = node->findProFileFor(profilePath());
if (node) { if (node) {
...@@ -233,7 +233,7 @@ FileName IosRunConfiguration::bundleDirectory() const ...@@ -233,7 +233,7 @@ FileName IosRunConfiguration::bundleDirectory() const
QmakeProject *pro = qobject_cast<QmakeProject *>(target()->project()); QmakeProject *pro = qobject_cast<QmakeProject *>(target()->project());
const QmakeProFileNode *node = 0; const QmakeProFileNode *node = 0;
if (pro) if (pro)
node = pro->rootQmakeProjectNode(); node = pro->rootProjectNode();
if (node) if (node)
node = node->findProFileFor(profilePath()); node = node->findProFileFor(profilePath());
if (node) { if (node) {
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "editorconfiguration.h" #include "editorconfiguration.h"
#include "kit.h" #include "kit.h"
#include "projectexplorer.h" #include "projectexplorer.h"
#include "projectnodes.h"
#include "target.h" #include "target.h"
#include "session.h" #include "session.h"
#include "settingsaccessor.h" #include "settingsaccessor.h"
...@@ -95,6 +96,7 @@ public: ...@@ -95,6 +96,7 @@ public:
Core::Id m_id; Core::Id m_id;
Core::IDocument *m_document = 0; Core::IDocument *m_document = 0;
IProjectManager *m_manager = 0; IProjectManager *m_manager = 0;
ProjectNode *m_rootProjectNode = 0;
QList<Target *> m_targets; QList<Target *> m_targets;
Target *m_activeTarget = 0; Target *m_activeTarget = 0;
EditorConfiguration m_editorConfiguration; EditorConfiguration m_editorConfiguration;
...@@ -111,8 +113,13 @@ public: ...@@ -111,8 +113,13 @@ public:
ProjectPrivate::~ProjectPrivate() ProjectPrivate::~ProjectPrivate()
{ {
delete m_accessor; // Make sure our root node is 0 when deleting
ProjectNode *oldNode = m_rootProjectNode;
m_rootProjectNode = 0;
delete oldNode;
delete m_document; delete m_document;
delete m_accessor;
} }
Project::Project() : d(new ProjectPrivate) Project::Project() : d(new ProjectPrivate)
...@@ -432,6 +439,13 @@ void Project::setProjectManager(IProjectManager *manager) ...@@ -432,6 +439,13 @@ void Project::setProjectManager(IProjectManager *manager)
d->m_manager = manager; d->m_manager = manager;
} }
void Project::setRootProjectNode(ProjectNode *root)
{
ProjectNode *oldNode = d->m_rootProjectNode;
d->m_rootProjectNode = root;
delete oldNode;
}
Target *Project::restoreTarget(const QVariantMap &data) Target *Project::restoreTarget(const QVariantMap &data)
{ {
Core::Id id = idFromMap(data); Core::Id id = idFromMap(data);
...@@ -522,6 +536,11 @@ IProjectManager *Project::projectManager() const ...@@ -522,6 +536,11 @@ IProjectManager *Project::projectManager() const
return d->m_manager; return d->m_manager;
} }
ProjectNode *Project::rootProjectNode() const
{
return d->m_rootProjectNode;
}
Project::RestoreResult Project::fromMap(const QVariantMap &map, QString *errorMessage) Project::RestoreResult Project::fromMap(const QVariantMap &map, QString *errorMessage)
{ {
Q_UNUSED(errorMessage); Q_UNUSED(errorMessage);
......
...@@ -88,6 +88,8 @@ public: ...@@ -88,6 +88,8 @@ public:
virtual IProjectManager *projectManager() const; virtual IProjectManager *projectManager() const;
virtual ProjectNode *rootProjectNode() const;
bool hasActiveBuildSettings() const; bool hasActiveBuildSettings() const;
// EditorConfiguration: // EditorConfiguration:
...@@ -112,8 +114,6 @@ public: ...@@ -112,8 +114,6 @@ public:
enum class RestoreResult { Ok, Error, UserAbort }; enum class RestoreResult { Ok, Error, UserAbort };
RestoreResult restoreSettings(QString *errorMessage); RestoreResult restoreSettings(QString *errorMessage);
virtual ProjectNode *rootProjectNode() const = 0;
enum FilesMode { AllFiles, ExcludeGeneratedFiles }; enum FilesMode { AllFiles, ExcludeGeneratedFiles };
virtual QStringList files(FilesMode fileMode) const = 0; virtual QStringList files(FilesMode fileMode) const = 0;
// TODO: generalize to find source(s) of generated files? // TODO: generalize to find source(s) of generated files?
...@@ -175,6 +175,7 @@ protected: ...@@ -175,6 +175,7 @@ protected:
void setId(Core::Id id); void setId(Core::Id id);
void setDocument(Core::IDocument *doc); // takes ownership! void setDocument(Core::IDocument *doc); // takes ownership!
void setProjectManager(IProjectManager *manager); void setProjectManager(IProjectManager *manager);
void setRootProjectNode(ProjectNode *root); // takes ownership!
void setProjectContext(Core::Context context); void setProjectContext(Core::Context context);
void setProjectLanguages(Core::Context language); void setProjectLanguages(Core::Context language);
void addProjectLanguage(Core::Id id); void addProjectLanguage(Core::Id id);
......
...@@ -251,7 +251,6 @@ public: ...@@ -251,7 +251,6 @@ public:
QString displayName() const override { return m_projectName; } QString displayName() const override { return m_projectName; }
PythonProjectManager *projectManager() const override; PythonProjectManager *projectManager() const override;
ProjectNode *rootProjectNode() const override;
QStringList files(FilesMode) const override { return m_files; } QStringList files(FilesMode) const override { return m_files; }
QStringList files() const { return m_files; } QStringList files() const { return m_files; }
...@@ -274,8 +273,6 @@ private: ...@@ -274,8 +273,6 @@ private:
QStringList m_rawFileList; QStringList m_rawFileList;
QStringList m_files; QStringList m_files;
QHash<QString, QString> m_rawListEntries; QHash<QString, QString> m_rawListEntries;
ProjectNode *m_rootNode;
}; };
class PythonProjectFile : public Core::IDocument class PythonProjectFile : public Core::IDocument
...@@ -620,6 +617,7 @@ PythonProject::PythonProject(PythonProjectManager *manager, const QString &fileN ...@@ -620,6 +617,7 @@ PythonProject::PythonProject(PythonProjectManager *manager, const QString &fileN
setProjectManager(manager); setProjectManager(manager);
setDocument(new PythonProjectFile(this, fileName)); setDocument(new PythonProjectFile(this, fileName));
DocumentManager::addDocument(document()); DocumentManager::addDocument(document());
setRootProjectNode(new PythonProjectNode(this));
setProjectContext(Context(PythonProjectContext)); setProjectContext(Context(PythonProjectContext));
setProjectLanguages(Context(ProjectExplorer::Constants::LANG_CXX)); setProjectLanguages(Context(ProjectExplorer::Constants::LANG_CXX));
...@@ -627,7 +625,6 @@ PythonProject::PythonProject(PythonProjectManager *manager, const QString &fileN ...@@ -627,7 +625,6 @@ PythonProject::PythonProject(PythonProjectManager *manager, const QString &fileN
QFileInfo fileInfo = projectFilePath().toFileInfo(); QFileInfo fileInfo = projectFilePath().toFileInfo();
m_projectName = fileInfo.completeBaseName(); m_projectName = fileInfo.completeBaseName();
m_rootNode = new PythonProjectNode(this);
projectManager()->registerProject(this); projectManager()->registerProject(this);
} }
...@@ -635,8 +632,6 @@ PythonProject::PythonProject(PythonProjectManager *manager, const QString &fileN ...@@ -635,8 +632,6 @@ PythonProject::PythonProject(PythonProjectManager *manager, const QString &fileN
PythonProject::~PythonProject() PythonProject::~PythonProject()
{ {
projectManager()->unregisterProject(this); projectManager()->unregisterProject(this);
delete m_rootNode;
} }
PythonProjectManager *PythonProject::projectManager() const PythonProjectManager *PythonProject::projectManager() const
...@@ -775,7 +770,7 @@ private: ...@@ -775,7 +770,7 @@ private:
void PythonProject::refresh() void PythonProject::refresh()
{ {
m_rootNode->removeFileNodes(m_rootNode->fileNodes()); rootProjectNode()->removeFileNodes(rootProjectNode()->fileNodes());
parseProject(); parseProject();
QDir baseDir(projectDirectory().toString()); QDir baseDir(projectDirectory().toString());
...@@ -786,7 +781,7 @@ void PythonProject::refresh() ...@@ -786,7 +781,7 @@ void PythonProject::refresh()
fileNodes.append(new PythonFileNode(FileName::fromString(file), displayName)); fileNodes.append(new PythonFileNode(FileName::fromString(file), displayName));
} }
m_rootNode->addFileNodes(fileNodes); rootProjectNode()->addFileNodes(fileNodes);
} }
/** /**
...@@ -844,11 +839,6 @@ QStringList PythonProject::processEntries(const QStringList &paths, ...@@ -844,11 +839,6 @@ QStringList PythonProject::processEntries(const QStringList &paths,
return absolutePaths; return absolutePaths;
}