ProjectExplorer: Move some not-fully-session related bits

... out of SessionManager.

The idea is to later move SessionManager into the Core plugin,
which both is sensible conceptually and also prerequisite to
merge the Bookmark plugin into TextEditor plugin.

Currently, only the interface is split, as the load/save
implemetations are non-mechanical to disentangle.

Change-Id: I31631db3094ea192825a2ccaa6add6188662940b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
hjk
2023-02-14 15:47:22 +01:00
parent 03e1c18f78
commit 3e7d93c788
170 changed files with 1176 additions and 1040 deletions

View File

@@ -41,7 +41,7 @@
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectexplorertr.h>
#include <projectexplorer/session.h>
#include <projectexplorer/projectmanager.h>
#include <projectexplorer/target.h>
#include <projectexplorer/taskhub.h>

View File

@@ -8,8 +8,9 @@
#include "cmaketool.h"
#include <projectexplorer/project.h>
#include <projectexplorer/session.h>
#include <projectexplorer/projectmanager.h>
#include <projectexplorer/target.h>
#include <texteditor/codeassist/assistinterface.h>
#include <QFileInfo>
@@ -39,7 +40,7 @@ IAssistProposal *CMakeFileCompletionAssist::performAsync()
Keywords kw;
const Utils::FilePath &filePath = interface()->filePath();
if (!filePath.isEmpty() && filePath.toFileInfo().isFile()) {
Project *p = SessionManager::projectForFile(filePath);
Project *p = ProjectManager::projectForFile(filePath);
if (p && p->activeTarget()) {
CMakeTool *cmake = CMakeKitAspect::cmakeTool(p->activeTarget()->kit());
if (cmake && cmake->isValid())

View File

@@ -12,7 +12,7 @@
#include <projectexplorer/buildmanager.h>
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/session.h>
#include <projectexplorer/projectmanager.h>
#include <projectexplorer/target.h>
#include <utils/algorithm.h>
@@ -29,9 +29,9 @@ namespace CMakeProjectManager::Internal {
CMakeTargetLocatorFilter::CMakeTargetLocatorFilter()
{
connect(SessionManager::instance(), &SessionManager::projectAdded,
connect(ProjectManager::instance(), &ProjectManager::projectAdded,
this, &CMakeTargetLocatorFilter::projectListUpdated);
connect(SessionManager::instance(), &SessionManager::projectRemoved,
connect(ProjectManager::instance(), &ProjectManager::projectRemoved,
this, &CMakeTargetLocatorFilter::projectListUpdated);
// Initialize the filter
@@ -41,7 +41,7 @@ CMakeTargetLocatorFilter::CMakeTargetLocatorFilter()
void CMakeTargetLocatorFilter::prepareSearch(const QString &entry)
{
m_result.clear();
const QList<Project *> projects = SessionManager::projects();
const QList<Project *> projects = ProjectManager::projects();
for (Project *p : projects) {
auto cmakeProject = qobject_cast<const CMakeProject *>(p);
if (!cmakeProject || !cmakeProject->activeTarget())
@@ -87,7 +87,7 @@ QList<LocatorFilterEntry> CMakeTargetLocatorFilter::matchesFor(
void CMakeTargetLocatorFilter::projectListUpdated()
{
// Enable the filter if there's at least one CMake project
setEnabled(Utils::contains(SessionManager::projects(),
setEnabled(Utils::contains(ProjectManager::projects(),
[](Project *p) { return qobject_cast<CMakeProject *>(p); }));
}
@@ -116,7 +116,7 @@ void BuildCMakeTargetLocatorFilter::accept(const LocatorFilterEntry &selection,
// Get the project containing the target selected
const auto cmakeProject = qobject_cast<CMakeProject *>(
Utils::findOrDefault(SessionManager::projects(), [projectPath](Project *p) {
Utils::findOrDefault(ProjectManager::projects(), [projectPath](Project *p) {
return p->projectFilePath() == projectPath;
}));
if (!cmakeProject || !cmakeProject->activeTarget()

View File

@@ -16,12 +16,14 @@
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/icore.h>
#include <coreplugin/messagemanager.h>
#include <cppeditor/cpptoolsreuse.h>
#include <projectexplorer/buildmanager.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectmanager.h>
#include <projectexplorer/projecttree.h>
#include <projectexplorer/session.h>
#include <projectexplorer/target.h>
#include <utils/parameteraction.h>
@@ -59,7 +61,7 @@ CMakeManager::CMakeManager()
command->setAttribute(Core::Command::CA_Hide);
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD);
connect(m_runCMakeAction, &QAction::triggered, this, [this] {
runCMake(SessionManager::startupBuildSystem());
runCMake(ProjectManager::startupBuildSystem());
});
command = Core::ActionManager::registerAction(m_clearCMakeCacheAction,
@@ -68,7 +70,7 @@ CMakeManager::CMakeManager()
command->setAttribute(Core::Command::CA_Hide);
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD);
connect(m_clearCMakeCacheAction, &QAction::triggered, this, [this] {
clearCMakeCache(SessionManager::startupBuildSystem());
clearCMakeCache(ProjectManager::startupBuildSystem());
});
command = Core::ActionManager::registerAction(m_runCMakeActionContextMenu,
@@ -111,7 +113,7 @@ CMakeManager::CMakeManager()
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD);
connect(m_buildFileAction, &QAction::triggered, this, [this] { buildFile(); });
connect(SessionManager::instance(), &SessionManager::startupProjectChanged, this, [this] {
connect(ProjectManager::instance(), &ProjectManager::startupProjectChanged, this, [this] {
updateCmakeActions(ProjectTree::currentNode());
});
connect(BuildManager::instance(), &BuildManager::buildStateChanged, this, [this] {
@@ -127,7 +129,7 @@ CMakeManager::CMakeManager()
void CMakeManager::updateCmakeActions(Node *node)
{
auto project = qobject_cast<CMakeProject *>(SessionManager::startupProject());
auto project = qobject_cast<CMakeProject *>(ProjectManager::startupProject());
const bool visible = project && !BuildManager::isBuilding(project);
m_runCMakeAction->setVisible(visible);
m_runCMakeActionContextMenu->setEnabled(visible);