forked from qt-creator/qt-creator
ProjectManager: Cut ties between Project and IProjectManager
Not needed, less code. Change-Id: Ie0d5c3a60f0392f30ed2ee9d2c5a32156b4e67e1 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -90,7 +90,6 @@ public:
|
|||||||
|
|
||||||
Core::Id m_id;
|
Core::Id m_id;
|
||||||
Core::IDocument *m_document = nullptr;
|
Core::IDocument *m_document = nullptr;
|
||||||
IProjectManager *m_manager = nullptr;
|
|
||||||
ProjectNode *m_rootProjectNode = nullptr;
|
ProjectNode *m_rootProjectNode = nullptr;
|
||||||
QList<Target *> m_targets;
|
QList<Target *> m_targets;
|
||||||
Target *m_activeTarget = nullptr;
|
Target *m_activeTarget = nullptr;
|
||||||
@@ -419,13 +418,6 @@ void Project::setDocument(Core::IDocument *doc)
|
|||||||
d->m_document = doc;
|
d->m_document = doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Project::setProjectManager(IProjectManager *manager)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(manager, return);
|
|
||||||
QTC_ASSERT(!d->m_manager, return);
|
|
||||||
d->m_manager = manager;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Project::setRootProjectNode(ProjectNode *root)
|
void Project::setRootProjectNode(ProjectNode *root)
|
||||||
{
|
{
|
||||||
ProjectNode *oldNode = d->m_rootProjectNode;
|
ProjectNode *oldNode = d->m_rootProjectNode;
|
||||||
@@ -529,12 +521,6 @@ Utils::FileName Project::projectDirectory(const Utils::FileName &top)
|
|||||||
return Utils::FileName::fromString(top.toFileInfo().absoluteDir().path());
|
return Utils::FileName::fromString(top.toFileInfo().absoluteDir().path());
|
||||||
}
|
}
|
||||||
|
|
||||||
IProjectManager *Project::projectManager() const
|
|
||||||
{
|
|
||||||
QTC_CHECK(d->m_manager);
|
|
||||||
return d->m_manager;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProjectNode *Project::rootProjectNode() const
|
ProjectNode *Project::rootProjectNode() const
|
||||||
{
|
{
|
||||||
return d->m_rootProjectNode;
|
return d->m_rootProjectNode;
|
||||||
|
@@ -47,7 +47,6 @@ namespace ProjectExplorer {
|
|||||||
|
|
||||||
class BuildInfo;
|
class BuildInfo;
|
||||||
class EditorConfiguration;
|
class EditorConfiguration;
|
||||||
class IProjectManager;
|
|
||||||
class NamedWidget;
|
class NamedWidget;
|
||||||
class ProjectImporter;
|
class ProjectImporter;
|
||||||
class ProjectNode;
|
class ProjectNode;
|
||||||
@@ -80,8 +79,6 @@ public:
|
|||||||
Utils::FileName projectDirectory() const;
|
Utils::FileName projectDirectory() const;
|
||||||
static Utils::FileName projectDirectory(const Utils::FileName &top);
|
static Utils::FileName projectDirectory(const Utils::FileName &top);
|
||||||
|
|
||||||
virtual IProjectManager *projectManager() const;
|
|
||||||
|
|
||||||
virtual ProjectNode *rootProjectNode() const;
|
virtual ProjectNode *rootProjectNode() const;
|
||||||
|
|
||||||
bool hasActiveBuildSettings() const;
|
bool hasActiveBuildSettings() const;
|
||||||
@@ -176,7 +173,6 @@ 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 setRootProjectNode(ProjectNode *root); // takes ownership!
|
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);
|
||||||
|
@@ -1711,7 +1711,6 @@ ProjectExplorerPlugin::OpenProjectResult ProjectExplorerPlugin::openProjects(con
|
|||||||
appendError(errorString,
|
appendError(errorString,
|
||||||
tr("Failed opening project \"%1\": Project is not a file").arg(fileName));
|
tr("Failed opening project \"%1\": Project is not a file").arg(fileName));
|
||||||
} else if (Project *pro = manager->openProject(filePath)) {
|
} else if (Project *pro = manager->openProject(filePath)) {
|
||||||
pro->setProjectManager(manager);
|
|
||||||
QObject::connect(pro, &Project::parsingFinished, [pro]() {
|
QObject::connect(pro, &Project::parsingFinished, [pro]() {
|
||||||
emit SessionManager::instance()->projectFinishedParsing(pro);
|
emit SessionManager::instance()->projectFinishedParsing(pro);
|
||||||
});
|
});
|
||||||
|
@@ -426,7 +426,7 @@ qbs::InstallJob *QbsProject::install(const qbs::InstallOptions &opts)
|
|||||||
|
|
||||||
QString QbsProject::profileForTarget(const Target *t) const
|
QString QbsProject::profileForTarget(const Target *t) const
|
||||||
{
|
{
|
||||||
return static_cast<QbsManager *>(projectManager())->profileForKit(t->kit());
|
return QbsManager::profileForKit(t->kit());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QbsProject::isParsing() const
|
bool QbsProject::isParsing() const
|
||||||
|
@@ -114,7 +114,7 @@ QString QbsManager::profileForKit(const ProjectExplorer::Kit *k)
|
|||||||
{
|
{
|
||||||
if (!k)
|
if (!k)
|
||||||
return QString();
|
return QString();
|
||||||
updateProfileIfNecessary(k);
|
m_instance->updateProfileIfNecessary(k);
|
||||||
return settings()->value(qtcProfilePrefix() + k->id().toString()).toString();
|
return settings()->value(qtcProfilePrefix() + k->id().toString()).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -57,7 +57,7 @@ public:
|
|||||||
ProjectExplorer::Project *openProject(const QString &fileName) override;
|
ProjectExplorer::Project *openProject(const QString &fileName) override;
|
||||||
|
|
||||||
// QBS profiles management:
|
// QBS profiles management:
|
||||||
QString profileForKit(const ProjectExplorer::Kit *k);
|
static QString profileForKit(const ProjectExplorer::Kit *k);
|
||||||
void setProfileForKit(const QString &name, const ProjectExplorer::Kit *k);
|
void setProfileForKit(const QString &name, const ProjectExplorer::Kit *k);
|
||||||
|
|
||||||
void updateProfileIfNecessary(const ProjectExplorer::Kit *kit);
|
void updateProfileIfNecessary(const ProjectExplorer::Kit *kit);
|
||||||
|
@@ -626,7 +626,7 @@ bool QmakePriFile::saveModifiedEditors()
|
|||||||
|
|
||||||
// force instant reload of ourselves
|
// force instant reload of ourselves
|
||||||
QtSupport::ProFileCacheManager::instance()->discardFile(filePath().toString());
|
QtSupport::ProFileCacheManager::instance()->discardFile(filePath().toString());
|
||||||
m_project->projectManager()->notifyChanged(filePath());
|
QmakeProject::notifyChanged(filePath());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -238,6 +238,8 @@ bool QmakeProjectFile::reload(QString *errorString, ReloadFlag flag, ChangeType
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QList<QmakeProject *> s_projects;
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -246,13 +248,13 @@ bool QmakeProjectFile::reload(QString *errorString, ReloadFlag flag, ChangeType
|
|||||||
QmakeProject manages information about an individual Qt 4 (.pro) project file.
|
QmakeProject manages information about an individual Qt 4 (.pro) project file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QmakeProject::QmakeProject(IProjectManager *manager, const QString &fileName) :
|
QmakeProject::QmakeProject(const QString &fileName) :
|
||||||
m_projectFiles(new QmakeProjectFiles),
|
m_projectFiles(new QmakeProjectFiles),
|
||||||
m_qmakeVfs(new QMakeVfs),
|
m_qmakeVfs(new QMakeVfs),
|
||||||
m_cppCodeModelUpdater(new CppTools::CppProjectUpdater(this))
|
m_cppCodeModelUpdater(new CppTools::CppProjectUpdater(this))
|
||||||
{
|
{
|
||||||
|
s_projects.append(this);
|
||||||
setId(Constants::QMAKEPROJECT_ID);
|
setId(Constants::QMAKEPROJECT_ID);
|
||||||
setProjectManager(manager);
|
|
||||||
setDocument(new QmakeProjectFile(fileName));
|
setDocument(new QmakeProjectFile(fileName));
|
||||||
setProjectContext(Core::Context(QmakeProjectManager::Constants::PROJECT_ID));
|
setProjectContext(Core::Context(QmakeProjectManager::Constants::PROJECT_ID));
|
||||||
setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
|
setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
|
||||||
@@ -276,6 +278,7 @@ QmakeProject::QmakeProject(IProjectManager *manager, const QString &fileName) :
|
|||||||
|
|
||||||
QmakeProject::~QmakeProject()
|
QmakeProject::~QmakeProject()
|
||||||
{
|
{
|
||||||
|
s_projects.removeOne(this);
|
||||||
delete m_projectImporter;
|
delete m_projectImporter;
|
||||||
m_projectImporter = nullptr;
|
m_projectImporter = nullptr;
|
||||||
delete m_cppCodeModelUpdater;
|
delete m_cppCodeModelUpdater;
|
||||||
@@ -286,7 +289,6 @@ QmakeProject::~QmakeProject()
|
|||||||
setRootProjectNode(nullptr);
|
setRootProjectNode(nullptr);
|
||||||
m_rootProFile.reset();
|
m_rootProFile.reset();
|
||||||
|
|
||||||
projectManager()->unregisterProject(this);
|
|
||||||
delete m_projectFiles;
|
delete m_projectFiles;
|
||||||
m_cancelEvaluate = true;
|
m_cancelEvaluate = true;
|
||||||
Q_ASSERT(m_qmakeGlobalsRefCnt == 0);
|
Q_ASSERT(m_qmakeGlobalsRefCnt == 0);
|
||||||
@@ -324,8 +326,6 @@ Project::RestoreResult QmakeProject::fromMap(const QVariantMap &map, QString *er
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
projectManager()->registerProject(this);
|
|
||||||
|
|
||||||
// On active buildconfiguration changes, reevaluate the .pro files
|
// On active buildconfiguration changes, reevaluate the .pro files
|
||||||
m_activeTarget = activeTarget();
|
m_activeTarget = activeTarget();
|
||||||
if (m_activeTarget) {
|
if (m_activeTarget) {
|
||||||
@@ -667,11 +667,6 @@ void QmakeProject::buildFinished(bool success)
|
|||||||
m_qmakeVfs->invalidateContents();
|
m_qmakeVfs->invalidateContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
QmakeManager *QmakeProject::projectManager() const
|
|
||||||
{
|
|
||||||
return static_cast<QmakeManager *>(Project::projectManager());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QmakeProject::supportsKit(Kit *k, QString *errorMessage) const
|
bool QmakeProject::supportsKit(Kit *k, QString *errorMessage) const
|
||||||
{
|
{
|
||||||
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
|
||||||
@@ -950,28 +945,24 @@ void QmakeProject::setAllBuildConfigurationsEnabled(bool enabled)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QmakeProFile *> QmakeProject::findProFiles(const FileName &fileName, QmakeProFile *root)
|
static void notifyChangedHelper(const FileName &fileName, QmakeProFile *file)
|
||||||
{
|
{
|
||||||
QList<QmakeProFile *> result;
|
if (file->filePath() == fileName) {
|
||||||
if (root->filePath() == fileName)
|
QtSupport::ProFileCacheManager::instance()->discardFile(fileName.toString());
|
||||||
result.append(root);
|
file->scheduleUpdate(QmakeProFile::ParseNow);
|
||||||
|
|
||||||
for (QmakePriFile *fn : root->children()) {
|
|
||||||
if (auto pro = dynamic_cast<QmakeProFile *>(fn))
|
|
||||||
result.append(findProFiles(fileName, pro));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
for (QmakePriFile *fn : file->children()) {
|
||||||
|
if (auto pro = dynamic_cast<QmakeProFile *>(fn))
|
||||||
|
notifyChangedHelper(fileName, pro);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmakeProject::notifyChanged(const FileName &name)
|
void QmakeProject::notifyChanged(const FileName &name)
|
||||||
{
|
{
|
||||||
if (files(QmakeProject::SourceFiles).contains(name.toString())) {
|
for (QmakeProject *project : s_projects) {
|
||||||
const QList<QmakeProFile *> list = findProFiles(name, rootProFile());
|
if (project->files(QmakeProject::SourceFiles).contains(name.toString()))
|
||||||
for (QmakeProFile *file : list) {
|
notifyChangedHelper(name, project->rootProFile());
|
||||||
QtSupport::ProFileCacheManager::instance()->discardFile(name.toString());
|
|
||||||
file->scheduleUpdate(QmakeProFile::ParseNow);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -52,9 +52,7 @@ class QmakeBuildConfiguration;
|
|||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
class CentralizedFolderWatcher;
|
class CentralizedFolderWatcher;
|
||||||
class QmakeProjectFile;
|
|
||||||
class QmakeProjectFiles;
|
class QmakeProjectFiles;
|
||||||
class QmakeProjectConfigWidget;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class QMAKEPROJECTMANAGER_EXPORT QmakeProject : public ProjectExplorer::Project
|
class QMAKEPROJECTMANAGER_EXPORT QmakeProject : public ProjectExplorer::Project
|
||||||
@@ -62,13 +60,12 @@ class QMAKEPROJECTMANAGER_EXPORT QmakeProject : public ProjectExplorer::Project
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QmakeProject(ProjectExplorer::IProjectManager *manager, const QString &proFile);
|
explicit QmakeProject(const QString &proFile);
|
||||||
~QmakeProject() final;
|
~QmakeProject() final;
|
||||||
|
|
||||||
QmakeProFile *rootProFile() const;
|
QmakeProFile *rootProFile() const;
|
||||||
|
|
||||||
QString displayName() const final;
|
QString displayName() const final;
|
||||||
QmakeManager *projectManager() const final;
|
|
||||||
|
|
||||||
bool supportsKit(ProjectExplorer::Kit *k, QString *errorMesage) const final;
|
bool supportsKit(ProjectExplorer::Kit *k, QString *errorMesage) const final;
|
||||||
|
|
||||||
@@ -89,7 +86,7 @@ public:
|
|||||||
ProjectExplorer::IRunConfigurationFactory::CreationMode mode,
|
ProjectExplorer::IRunConfigurationFactory::CreationMode mode,
|
||||||
const QList<ProjectType> &projectTypes = {});
|
const QList<ProjectType> &projectTypes = {});
|
||||||
|
|
||||||
void notifyChanged(const Utils::FileName &name);
|
static void notifyChanged(const Utils::FileName &name);
|
||||||
|
|
||||||
/// \internal
|
/// \internal
|
||||||
QtSupport::ProFileReader *createProFileReader(const QmakeProFile *qmakeProFile);
|
QtSupport::ProFileReader *createProFileReader(const QmakeProFile *qmakeProFile);
|
||||||
@@ -168,7 +165,6 @@ private:
|
|||||||
|
|
||||||
static QList<QmakeProFile *> collectAllProFiles(QmakeProFile *file, Parsing parse,
|
static QList<QmakeProFile *> collectAllProFiles(QmakeProFile *file, Parsing parse,
|
||||||
const QList<ProjectType> &projectTypes);
|
const QList<ProjectType> &projectTypes);
|
||||||
static QList<QmakeProFile *> findProFiles(const Utils::FileName &fileName, QmakeProFile *root);
|
|
||||||
|
|
||||||
static bool equalFileList(const QStringList &a, const QStringList &b);
|
static bool equalFileList(const QStringList &a, const QStringList &b);
|
||||||
|
|
||||||
@@ -216,10 +212,6 @@ private:
|
|||||||
|
|
||||||
ProjectExplorer::Target *m_activeTarget = nullptr;
|
ProjectExplorer::Target *m_activeTarget = nullptr;
|
||||||
mutable ProjectExplorer::ProjectImporter *m_projectImporter = nullptr;
|
mutable ProjectExplorer::ProjectImporter *m_projectImporter = nullptr;
|
||||||
|
|
||||||
friend class Internal::QmakeProjectFile;
|
|
||||||
friend class Internal::QmakeProjectConfigWidget;
|
|
||||||
friend class QmakeManager; // to schedule a async update if the unconfigured settings change
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QmakeProjectManager
|
} // namespace QmakeProjectManager
|
||||||
|
@@ -53,22 +53,6 @@ using namespace TextEditor;
|
|||||||
|
|
||||||
namespace QmakeProjectManager {
|
namespace QmakeProjectManager {
|
||||||
|
|
||||||
void QmakeManager::registerProject(QmakeProject *project)
|
|
||||||
{
|
|
||||||
m_projects.append(project);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmakeManager::unregisterProject(QmakeProject *project)
|
|
||||||
{
|
|
||||||
m_projects.removeOne(project);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmakeManager::notifyChanged(const Utils::FileName &name)
|
|
||||||
{
|
|
||||||
foreach (QmakeProject *pro, m_projects)
|
|
||||||
pro->notifyChanged(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString QmakeManager::mimeType() const
|
QString QmakeManager::mimeType() const
|
||||||
{
|
{
|
||||||
return QLatin1String(QmakeProjectManager::Constants::PROFILE_MIMETYPE);
|
return QLatin1String(QmakeProjectManager::Constants::PROFILE_MIMETYPE);
|
||||||
@@ -76,7 +60,7 @@ QString QmakeManager::mimeType() const
|
|||||||
|
|
||||||
ProjectExplorer::Project *QmakeManager::openProject(const QString &fileName)
|
ProjectExplorer::Project *QmakeManager::openProject(const QString &fileName)
|
||||||
{
|
{
|
||||||
return new QmakeProject(this, fileName);
|
return new QmakeProject(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
Node *QmakeManager::contextNode()
|
Node *QmakeManager::contextNode()
|
||||||
|
@@ -41,17 +41,12 @@ class ToolChain;
|
|||||||
|
|
||||||
namespace QmakeProjectManager {
|
namespace QmakeProjectManager {
|
||||||
|
|
||||||
class QmakeProject;
|
|
||||||
|
|
||||||
class QMAKEPROJECTMANAGER_EXPORT QmakeManager : public ProjectExplorer::IProjectManager
|
class QMAKEPROJECTMANAGER_EXPORT QmakeManager : public ProjectExplorer::IProjectManager
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void registerProject(QmakeProject *project);
|
|
||||||
void unregisterProject(QmakeProject *project);
|
|
||||||
void notifyChanged(const Utils::FileName &name);
|
void notifyChanged(const Utils::FileName &name);
|
||||||
|
|
||||||
QString mimeType() const override;
|
QString mimeType() const override;
|
||||||
ProjectExplorer::Project *openProject(const QString &fileName) override;
|
ProjectExplorer::Project *openProject(const QString &fileName) override;
|
||||||
|
|
||||||
@@ -73,7 +68,6 @@ public:
|
|||||||
void buildFile();
|
void buildFile();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<QmakeProject *> m_projects;
|
|
||||||
void handleSubDirContextMenu(Action action, bool isFileBuild);
|
void handleSubDirContextMenu(Action action, bool isFileBuild);
|
||||||
void handleSubDirContextMenu(QmakeManager::Action action, bool isFileBuild,
|
void handleSubDirContextMenu(QmakeManager::Action action, bool isFileBuild,
|
||||||
ProjectExplorer::Project *contextProject,
|
ProjectExplorer::Project *contextProject,
|
||||||
|
@@ -256,10 +256,7 @@ bool BaseQmakeProjectWizardDialog::writeUserFile(const QString &proFileName) con
|
|||||||
if (!m_targetSetupPage)
|
if (!m_targetSetupPage)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QmakeManager *manager = ExtensionSystem::PluginManager::getObject<QmakeManager>();
|
QmakeProject *pro = new QmakeProject(proFileName);
|
||||||
Q_ASSERT(manager);
|
|
||||||
|
|
||||||
QmakeProject *pro = new QmakeProject(manager, proFileName);
|
|
||||||
bool success = m_targetSetupPage->setupProject(pro);
|
bool success = m_targetSetupPage->setupProject(pro);
|
||||||
if (success)
|
if (success)
|
||||||
pro->saveSettings();
|
pro->saveSettings();
|
||||||
|
Reference in New Issue
Block a user