forked from qt-creator/qt-creator
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:
@@ -116,8 +116,8 @@ private:
|
||||
// QbsProject:
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
QbsProject::QbsProject(const QString &fileName) :
|
||||
m_projectName(QFileInfo(fileName).completeBaseName()),
|
||||
QbsProject::QbsProject(const FileName &fileName) :
|
||||
m_projectName(fileName.toFileInfo().completeBaseName()),
|
||||
m_qbsProjectParser(0),
|
||||
m_qbsUpdateFutureInterface(0),
|
||||
m_parsingScheduled(false),
|
||||
@@ -766,7 +766,7 @@ void QbsProject::updateDocuments(const QSet<QString> &files)
|
||||
}
|
||||
QSet<IDocument *> toAdd;
|
||||
foreach (const QString &f, filesToAdd)
|
||||
toAdd.insert(new QbsProjectFile(this, f));
|
||||
toAdd.insert(new QbsProjectFile(this, FileName::fromString(f)));
|
||||
|
||||
DocumentManager::addDocuments(toAdd.toList());
|
||||
m_qbsDocuments.unite(toAdd);
|
||||
|
||||
@@ -58,7 +58,7 @@ class QbsProject : public ProjectExplorer::Project
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QbsProject(const QString &filename);
|
||||
explicit QbsProject(const Utils::FileName &filename);
|
||||
~QbsProject() override;
|
||||
|
||||
QString displayName() const override;
|
||||
|
||||
@@ -31,12 +31,12 @@
|
||||
namespace QbsProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
QbsProjectFile::QbsProjectFile(QbsProject *parent, QString fileName) : Core::IDocument(parent),
|
||||
QbsProjectFile::QbsProjectFile(QbsProject *parent, const Utils::FileName &fileName) : Core::IDocument(parent),
|
||||
m_project(parent)
|
||||
{
|
||||
setId("Qbs.ProjectFile");
|
||||
setMimeType(QLatin1String(Constants::MIME_TYPE));
|
||||
setFilePath(Utils::FileName::fromString(fileName));
|
||||
setMimeType(Constants::MIME_TYPE);
|
||||
setFilePath(fileName);
|
||||
}
|
||||
|
||||
Core::IDocument::ReloadBehavior QbsProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
|
||||
|
||||
@@ -35,7 +35,7 @@ class QbsProject;
|
||||
class QbsProjectFile : public Core::IDocument
|
||||
{
|
||||
public:
|
||||
QbsProjectFile(QbsProject *parent, QString fileName);
|
||||
QbsProjectFile(QbsProject *parent, const Utils::FileName &fileName);
|
||||
|
||||
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override;
|
||||
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
|
||||
|
||||
@@ -100,16 +100,6 @@ QbsManager::~QbsManager()
|
||||
m_instance = nullptr;
|
||||
}
|
||||
|
||||
QString QbsManager::mimeType() const
|
||||
{
|
||||
return QLatin1String(QmlJSTools::Constants::QBS_MIMETYPE);
|
||||
}
|
||||
|
||||
ProjectExplorer::Project *QbsManager::openProject(const QString &fileName)
|
||||
{
|
||||
return new QbsProject(fileName);
|
||||
}
|
||||
|
||||
QString QbsManager::profileForKit(const ProjectExplorer::Kit *k)
|
||||
{
|
||||
if (!k)
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
|
||||
#include "qbsprojectmanager_global.h"
|
||||
|
||||
#include <projectexplorer/iprojectmanager.h>
|
||||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QVariantMap>
|
||||
@@ -45,7 +43,7 @@ namespace Internal {
|
||||
class DefaultPropertyProvider;
|
||||
class QbsLogSink;
|
||||
|
||||
class QbsManager : public ProjectExplorer::IProjectManager
|
||||
class QbsManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -53,9 +51,6 @@ public:
|
||||
QbsManager();
|
||||
~QbsManager();
|
||||
|
||||
QString mimeType() const override;
|
||||
ProjectExplorer::Project *openProject(const QString &fileName) override;
|
||||
|
||||
// QBS profiles management:
|
||||
static QString profileForKit(const ProjectExplorer::Kit *k);
|
||||
void setProfileForKit(const QString &name, const ProjectExplorer::Kit *k);
|
||||
|
||||
@@ -46,14 +46,18 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <coreplugin/fileiconprovider.h>
|
||||
|
||||
#include <projectexplorer/buildmanager.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/projecttree.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/projectmanager.h>
|
||||
#include <projectexplorer/projecttree.h>
|
||||
#include <projectexplorer/session.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <qtsupport/qtsupportconstants.h>
|
||||
#include <qmljstools/qmljstoolsconstants.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -87,6 +91,8 @@ bool QbsProjectManagerPlugin::initialize(const QStringList &arguments, QString *
|
||||
|
||||
Core::FileIconProvider::registerIconOverlayForSuffix(ProjectExplorer::Constants::FILEOVERLAY_QT, "qbs");
|
||||
|
||||
ProjectManager::registerProjectType<QbsProject>(QmlJSTools::Constants::QBS_MIMETYPE);
|
||||
|
||||
//create and register objects
|
||||
addAutoReleasedObject(new QbsManager);
|
||||
addAutoReleasedObject(new QbsBuildConfigurationFactory);
|
||||
|
||||
Reference in New Issue
Block a user