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::IDocument *m_document = nullptr;
|
||||
IProjectManager *m_manager = nullptr;
|
||||
ProjectNode *m_rootProjectNode = nullptr;
|
||||
QList<Target *> m_targets;
|
||||
Target *m_activeTarget = nullptr;
|
||||
@@ -419,13 +418,6 @@ void Project::setDocument(Core::IDocument *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)
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
||||
IProjectManager *Project::projectManager() const
|
||||
{
|
||||
QTC_CHECK(d->m_manager);
|
||||
return d->m_manager;
|
||||
}
|
||||
|
||||
ProjectNode *Project::rootProjectNode() const
|
||||
{
|
||||
return d->m_rootProjectNode;
|
||||
|
@@ -47,7 +47,6 @@ namespace ProjectExplorer {
|
||||
|
||||
class BuildInfo;
|
||||
class EditorConfiguration;
|
||||
class IProjectManager;
|
||||
class NamedWidget;
|
||||
class ProjectImporter;
|
||||
class ProjectNode;
|
||||
@@ -80,8 +79,6 @@ public:
|
||||
Utils::FileName projectDirectory() const;
|
||||
static Utils::FileName projectDirectory(const Utils::FileName &top);
|
||||
|
||||
virtual IProjectManager *projectManager() const;
|
||||
|
||||
virtual ProjectNode *rootProjectNode() const;
|
||||
|
||||
bool hasActiveBuildSettings() const;
|
||||
@@ -176,7 +173,6 @@ protected:
|
||||
|
||||
void setId(Core::Id id);
|
||||
void setDocument(Core::IDocument *doc); // takes ownership!
|
||||
void setProjectManager(IProjectManager *manager);
|
||||
void setRootProjectNode(ProjectNode *root); // takes ownership!
|
||||
void setProjectContext(Core::Context context);
|
||||
void setProjectLanguages(Core::Context language);
|
||||
|
@@ -1711,7 +1711,6 @@ ProjectExplorerPlugin::OpenProjectResult ProjectExplorerPlugin::openProjects(con
|
||||
appendError(errorString,
|
||||
tr("Failed opening project \"%1\": Project is not a file").arg(fileName));
|
||||
} else if (Project *pro = manager->openProject(filePath)) {
|
||||
pro->setProjectManager(manager);
|
||||
QObject::connect(pro, &Project::parsingFinished, [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
|
||||
{
|
||||
return static_cast<QbsManager *>(projectManager())->profileForKit(t->kit());
|
||||
return QbsManager::profileForKit(t->kit());
|
||||
}
|
||||
|
||||
bool QbsProject::isParsing() const
|
||||
|
@@ -114,7 +114,7 @@ QString QbsManager::profileForKit(const ProjectExplorer::Kit *k)
|
||||
{
|
||||
if (!k)
|
||||
return QString();
|
||||
updateProfileIfNecessary(k);
|
||||
m_instance->updateProfileIfNecessary(k);
|
||||
return settings()->value(qtcProfilePrefix() + k->id().toString()).toString();
|
||||
}
|
||||
|
||||
|
@@ -57,7 +57,7 @@ public:
|
||||
ProjectExplorer::Project *openProject(const QString &fileName) override;
|
||||
|
||||
// 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 updateProfileIfNecessary(const ProjectExplorer::Kit *kit);
|
||||
|
@@ -626,7 +626,7 @@ bool QmakePriFile::saveModifiedEditors()
|
||||
|
||||
// force instant reload of ourselves
|
||||
QtSupport::ProFileCacheManager::instance()->discardFile(filePath().toString());
|
||||
m_project->projectManager()->notifyChanged(filePath());
|
||||
QmakeProject::notifyChanged(filePath());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -238,6 +238,8 @@ bool QmakeProjectFile::reload(QString *errorString, ReloadFlag flag, ChangeType
|
||||
return true;
|
||||
}
|
||||
|
||||
static QList<QmakeProject *> s_projects;
|
||||
|
||||
} // 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::QmakeProject(IProjectManager *manager, const QString &fileName) :
|
||||
QmakeProject::QmakeProject(const QString &fileName) :
|
||||
m_projectFiles(new QmakeProjectFiles),
|
||||
m_qmakeVfs(new QMakeVfs),
|
||||
m_cppCodeModelUpdater(new CppTools::CppProjectUpdater(this))
|
||||
{
|
||||
s_projects.append(this);
|
||||
setId(Constants::QMAKEPROJECT_ID);
|
||||
setProjectManager(manager);
|
||||
setDocument(new QmakeProjectFile(fileName));
|
||||
setProjectContext(Core::Context(QmakeProjectManager::Constants::PROJECT_ID));
|
||||
setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
|
||||
@@ -276,6 +278,7 @@ QmakeProject::QmakeProject(IProjectManager *manager, const QString &fileName) :
|
||||
|
||||
QmakeProject::~QmakeProject()
|
||||
{
|
||||
s_projects.removeOne(this);
|
||||
delete m_projectImporter;
|
||||
m_projectImporter = nullptr;
|
||||
delete m_cppCodeModelUpdater;
|
||||
@@ -286,7 +289,6 @@ QmakeProject::~QmakeProject()
|
||||
setRootProjectNode(nullptr);
|
||||
m_rootProFile.reset();
|
||||
|
||||
projectManager()->unregisterProject(this);
|
||||
delete m_projectFiles;
|
||||
m_cancelEvaluate = true;
|
||||
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
|
||||
m_activeTarget = activeTarget();
|
||||
if (m_activeTarget) {
|
||||
@@ -667,11 +667,6 @@ void QmakeProject::buildFinished(bool success)
|
||||
m_qmakeVfs->invalidateContents();
|
||||
}
|
||||
|
||||
QmakeManager *QmakeProject::projectManager() const
|
||||
{
|
||||
return static_cast<QmakeManager *>(Project::projectManager());
|
||||
}
|
||||
|
||||
bool QmakeProject::supportsKit(Kit *k, QString *errorMessage) const
|
||||
{
|
||||
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 (root->filePath() == fileName)
|
||||
result.append(root);
|
||||
|
||||
for (QmakePriFile *fn : root->children()) {
|
||||
if (auto pro = dynamic_cast<QmakeProFile *>(fn))
|
||||
result.append(findProFiles(fileName, pro));
|
||||
if (file->filePath() == fileName) {
|
||||
QtSupport::ProFileCacheManager::instance()->discardFile(fileName.toString());
|
||||
file->scheduleUpdate(QmakeProFile::ParseNow);
|
||||
}
|
||||
|
||||
return result;
|
||||
for (QmakePriFile *fn : file->children()) {
|
||||
if (auto pro = dynamic_cast<QmakeProFile *>(fn))
|
||||
notifyChangedHelper(fileName, pro);
|
||||
}
|
||||
}
|
||||
|
||||
void QmakeProject::notifyChanged(const FileName &name)
|
||||
{
|
||||
if (files(QmakeProject::SourceFiles).contains(name.toString())) {
|
||||
const QList<QmakeProFile *> list = findProFiles(name, rootProFile());
|
||||
for (QmakeProFile *file : list) {
|
||||
QtSupport::ProFileCacheManager::instance()->discardFile(name.toString());
|
||||
file->scheduleUpdate(QmakeProFile::ParseNow);
|
||||
}
|
||||
for (QmakeProject *project : s_projects) {
|
||||
if (project->files(QmakeProject::SourceFiles).contains(name.toString()))
|
||||
notifyChangedHelper(name, project->rootProFile());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -52,9 +52,7 @@ class QmakeBuildConfiguration;
|
||||
|
||||
namespace Internal {
|
||||
class CentralizedFolderWatcher;
|
||||
class QmakeProjectFile;
|
||||
class QmakeProjectFiles;
|
||||
class QmakeProjectConfigWidget;
|
||||
}
|
||||
|
||||
class QMAKEPROJECTMANAGER_EXPORT QmakeProject : public ProjectExplorer::Project
|
||||
@@ -62,13 +60,12 @@ class QMAKEPROJECTMANAGER_EXPORT QmakeProject : public ProjectExplorer::Project
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QmakeProject(ProjectExplorer::IProjectManager *manager, const QString &proFile);
|
||||
explicit QmakeProject(const QString &proFile);
|
||||
~QmakeProject() final;
|
||||
|
||||
QmakeProFile *rootProFile() const;
|
||||
|
||||
QString displayName() const final;
|
||||
QmakeManager *projectManager() const final;
|
||||
|
||||
bool supportsKit(ProjectExplorer::Kit *k, QString *errorMesage) const final;
|
||||
|
||||
@@ -89,7 +86,7 @@ public:
|
||||
ProjectExplorer::IRunConfigurationFactory::CreationMode mode,
|
||||
const QList<ProjectType> &projectTypes = {});
|
||||
|
||||
void notifyChanged(const Utils::FileName &name);
|
||||
static void notifyChanged(const Utils::FileName &name);
|
||||
|
||||
/// \internal
|
||||
QtSupport::ProFileReader *createProFileReader(const QmakeProFile *qmakeProFile);
|
||||
@@ -168,7 +165,6 @@ private:
|
||||
|
||||
static QList<QmakeProFile *> collectAllProFiles(QmakeProFile *file, Parsing parse,
|
||||
const QList<ProjectType> &projectTypes);
|
||||
static QList<QmakeProFile *> findProFiles(const Utils::FileName &fileName, QmakeProFile *root);
|
||||
|
||||
static bool equalFileList(const QStringList &a, const QStringList &b);
|
||||
|
||||
@@ -216,10 +212,6 @@ private:
|
||||
|
||||
ProjectExplorer::Target *m_activeTarget = 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
|
||||
|
@@ -53,22 +53,6 @@ using namespace TextEditor;
|
||||
|
||||
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
|
||||
{
|
||||
return QLatin1String(QmakeProjectManager::Constants::PROFILE_MIMETYPE);
|
||||
@@ -76,7 +60,7 @@ QString QmakeManager::mimeType() const
|
||||
|
||||
ProjectExplorer::Project *QmakeManager::openProject(const QString &fileName)
|
||||
{
|
||||
return new QmakeProject(this, fileName);
|
||||
return new QmakeProject(fileName);
|
||||
}
|
||||
|
||||
Node *QmakeManager::contextNode()
|
||||
|
@@ -41,17 +41,12 @@ class ToolChain;
|
||||
|
||||
namespace QmakeProjectManager {
|
||||
|
||||
class QmakeProject;
|
||||
|
||||
class QMAKEPROJECTMANAGER_EXPORT QmakeManager : public ProjectExplorer::IProjectManager
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
void registerProject(QmakeProject *project);
|
||||
void unregisterProject(QmakeProject *project);
|
||||
void notifyChanged(const Utils::FileName &name);
|
||||
|
||||
QString mimeType() const override;
|
||||
ProjectExplorer::Project *openProject(const QString &fileName) override;
|
||||
|
||||
@@ -73,7 +68,6 @@ public:
|
||||
void buildFile();
|
||||
|
||||
private:
|
||||
QList<QmakeProject *> m_projects;
|
||||
void handleSubDirContextMenu(Action action, bool isFileBuild);
|
||||
void handleSubDirContextMenu(QmakeManager::Action action, bool isFileBuild,
|
||||
ProjectExplorer::Project *contextProject,
|
||||
|
@@ -256,10 +256,7 @@ bool BaseQmakeProjectWizardDialog::writeUserFile(const QString &proFileName) con
|
||||
if (!m_targetSetupPage)
|
||||
return false;
|
||||
|
||||
QmakeManager *manager = ExtensionSystem::PluginManager::getObject<QmakeManager>();
|
||||
Q_ASSERT(manager);
|
||||
|
||||
QmakeProject *pro = new QmakeProject(manager, proFileName);
|
||||
QmakeProject *pro = new QmakeProject(proFileName);
|
||||
bool success = m_targetSetupPage->setupProject(pro);
|
||||
if (success)
|
||||
pro->saveSettings();
|
||||
|
Reference in New Issue
Block a user