forked from qt-creator/qt-creator
ProjectManager: Remove SessionNode
Instead, get root project nodes directly from the project. Change-Id: I5cf95a7dce1fa29c1adc26013ad03cc017f38a6d Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -39,6 +39,9 @@
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <coreplugin/icontext.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/iversioncontrol.h>
|
||||
#include <coreplugin/vcsmanager.h>
|
||||
|
||||
#include <projectexplorer/buildmanager.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/projecttree.h>
|
||||
@@ -80,18 +83,52 @@ const char PLUGIN_SETTINGS_KEY[] = "ProjectExplorer.Project.PluginSettings";
|
||||
} // namespace
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
class ContainerNode : public ProjectNode
|
||||
{
|
||||
public:
|
||||
ContainerNode(Project *project)
|
||||
: ProjectNode(Utils::FileName()),
|
||||
m_project(project)
|
||||
{}
|
||||
|
||||
QString displayName() const final
|
||||
{
|
||||
QString name = m_project->displayName();
|
||||
|
||||
const QFileInfo fi = m_project->projectFilePath().toFileInfo();
|
||||
const QString dir = fi.isDir() ? fi.absoluteFilePath() : fi.absolutePath();
|
||||
if (Core::IVersionControl *vc = Core::VcsManager::findVersionControlForDirectory(dir)) {
|
||||
QString vcsTopic = vc->vcsTopic(dir);
|
||||
if (!vcsTopic.isEmpty())
|
||||
name += " [" + vcsTopic + ']';
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
QList<ProjectAction> supportedActions(Node *) const final
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
private:
|
||||
Project *m_project;
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Project
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
class ProjectPrivate
|
||||
{
|
||||
public:
|
||||
ProjectPrivate(Project *owner) : m_containerNode(owner) {}
|
||||
~ProjectPrivate();
|
||||
|
||||
Core::Id m_id;
|
||||
Core::IDocument *m_document = nullptr;
|
||||
ProjectNode *m_rootProjectNode = nullptr;
|
||||
ContainerNode m_containerNode;
|
||||
QList<Target *> m_targets;
|
||||
Target *m_activeTarget = nullptr;
|
||||
EditorConfiguration m_editorConfiguration;
|
||||
@@ -117,7 +154,7 @@ ProjectPrivate::~ProjectPrivate()
|
||||
delete m_accessor;
|
||||
}
|
||||
|
||||
Project::Project() : d(new ProjectPrivate)
|
||||
Project::Project() : d(new ProjectPrivate(this))
|
||||
{
|
||||
d->m_macroExpander.setDisplayName(tr("Project"));
|
||||
d->m_macroExpander.registerVariable("Project:Name", tr("Project Name"),
|
||||
@@ -427,8 +464,11 @@ void Project::setRootProjectNode(ProjectNode *root)
|
||||
ProjectTree::applyTreeManager(root);
|
||||
|
||||
d->m_rootProjectNode = root;
|
||||
emit projectTreeChanged(this, QPrivateSignal());
|
||||
// Do not delete oldNode! The ProjectTree owns that!
|
||||
if (root)
|
||||
d->m_rootProjectNode->setParentFolderNode(&d->m_containerNode);
|
||||
ProjectTree::emitSubtreeChanged(d->m_rootProjectNode);
|
||||
|
||||
delete d->m_rootProjectNode;
|
||||
}
|
||||
|
||||
Target *Project::restoreTarget(const QVariantMap &data)
|
||||
@@ -532,6 +572,11 @@ ProjectNode *Project::rootProjectNode() const
|
||||
return d->m_rootProjectNode;
|
||||
}
|
||||
|
||||
ProjectNode *Project::containerNode() const
|
||||
{
|
||||
return &d->m_containerNode;
|
||||
}
|
||||
|
||||
Project::RestoreResult Project::fromMap(const QVariantMap &map, QString *errorMessage)
|
||||
{
|
||||
Q_UNUSED(errorMessage);
|
||||
|
||||
Reference in New Issue
Block a user