ProjectExplorer: Follow up on too-much-magic in IProjectManager

Use a ProjectManager::registerProjectType<Project>(MimeType) function,
removing cryptic IProjectManager object ownership.

Change-Id: I212cd25bd4ee757022a8cb0decb4b8de3a112d12
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
hjk
2017-03-03 18:16:34 +01:00
parent 57144e28da
commit c1bfc5d8ec
54 changed files with 152 additions and 532 deletions

View File

@@ -43,10 +43,10 @@
#include <projectexplorer/runconfiguration.h>
#include <projectexplorer/runconfigurationaspects.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectmanager.h>
#include <projectexplorer/projectnodes.h>
#include <projectexplorer/runnables.h>
#include <projectexplorer/target.h>
#include <projectexplorer/iprojectmanager.h>
#include <projectexplorer/projectnodes.h>
#include <texteditor/texteditorconstants.h>
@@ -77,7 +77,6 @@ const char PythonProjectContext[] = "PythonProjectContext";
class PythonRunConfiguration;
class PythonProjectFile;
class PythonProject;
static QString scriptFromId(Core::Id id)
{
@@ -92,7 +91,7 @@ static Core::Id idFromScript(const QString &target)
class PythonProject : public Project
{
public:
explicit PythonProject(const QString &filename);
explicit PythonProject(const Utils::FileName &filename);
QString displayName() const override { return m_projectName; }
@@ -123,11 +122,11 @@ private:
class PythonProjectFile : public Core::IDocument
{
public:
PythonProjectFile(PythonProject *parent, QString fileName) : m_project(parent)
PythonProjectFile(PythonProject *parent, const FileName &fileName) : m_project(parent)
{
setId("Generic.ProjectFile");
setMimeType(PythonMimeType);
setFilePath(FileName::fromString(fileName));
setFilePath(fileName);
}
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override
@@ -350,13 +349,6 @@ PythonRunConfigurationWidget::PythonRunConfigurationWidget(PythonRunConfiguratio
setEnabled(runConfiguration->isEnabled());
}
class PythonProjectManager : public IProjectManager
{
public:
QString mimeType() const override { return QLatin1String(PythonMimeType); }
Project *openProject(const QString &fileName) override { return new PythonProject(fileName); }
};
class PythonRunConfigurationFactory : public IRunConfigurationFactory
{
public:
@@ -427,7 +419,7 @@ private:
}
};
PythonProject::PythonProject(const QString &fileName)
PythonProject::PythonProject(const FileName &fileName)
{
setId(PythonProjectId);
setDocument(new PythonProjectFile(this, fileName));
@@ -858,7 +850,8 @@ bool PythonEditorPlugin::initialize(const QStringList &arguments, QString *error
Q_UNUSED(arguments)
Q_UNUSED(errorMessage)
addAutoReleasedObject(new PythonProjectManager);
ProjectManager::registerProjectType<PythonProject>(PythonMimeType);
addAutoReleasedObject(new PythonEditorFactory);
addAutoReleasedObject(new PythonRunConfigurationFactory);
addAutoReleasedObject(new PythonRunControlFactory);