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

@@ -1,5 +1,6 @@
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "cmakeprojectconverter.h"
#include "cmakeprojectconverterdialog.h"
#include "generatecmakelists.h"
@@ -11,7 +12,7 @@
#include <coreplugin/icore.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/session.h>
#include <projectexplorer/projectmanager.h>
#include <projectexplorer/target.h>
#include <qmlprojectmanager/qmlprojectmanagerconstants.h>
@@ -41,10 +42,10 @@ void CmakeProjectConverter::generateMenuEntry(QObject *parent)
Core::Command *cmd = Core::ActionManager::registerAction(action, "QmlProject.ConvertToCmakeProject");
exportMenu->addAction(cmd, QmlProjectManager::Constants::G_EXPORT_CONVERT);
action->setEnabled(isProjectConvertable(ProjectExplorer::SessionManager::startupProject()));
QObject::connect(ProjectExplorer::SessionManager::instance(),
&ProjectExplorer::SessionManager::startupProjectChanged, [action]() {
action->setEnabled(isProjectConvertable(ProjectExplorer::SessionManager::startupProject()));
action->setEnabled(isProjectConvertable(ProjectExplorer::ProjectManager::startupProject()));
QObject::connect(ProjectExplorer::ProjectManager::instance(),
&ProjectExplorer::ProjectManager::startupProjectChanged, [action]() {
action->setEnabled(isProjectConvertable(ProjectExplorer::ProjectManager::startupProject()));
});
}
@@ -83,7 +84,7 @@ bool CmakeProjectConverter::isProjectCurrentFormat(const ProjectExplorer::Projec
void CmakeProjectConverter::onConvertProject()
{
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject();
ProjectExplorer::Project *project = ProjectExplorer::ProjectManager::startupProject();
const QmlProjectManager::QmlProject *qmlProject =
qobject_cast<const QmlProjectManager::QmlProject*>(project);
if (qmlProject) {

View File

@@ -2,6 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "generatecmakelists.h"
#include "generatecmakelistsconstants.h"
#include "cmakegeneratordialog.h"
#include "../qmlprojectmanagertr.h"
@@ -10,9 +11,9 @@
#include <coreplugin/actionmanager/actioncontainer.h>
#include <projectexplorer/buildsystem.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/project.h>
#include <projectexplorer/session.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectmanager.h>
#include <projectexplorer/target.h>
#include <qmlprojectmanager/qmlmainfileaspect.h>
@@ -79,18 +80,18 @@ void generateMenuEntry(QObject *parent)
exportMenu->addAction(cmd, QmlProjectManager::Constants::G_EXPORT_GENERATE);
action->setEnabled(false);
QObject::connect(ProjectExplorer::SessionManager::instance(),
&ProjectExplorer::SessionManager::startupProjectChanged,
QObject::connect(ProjectExplorer::ProjectManager::instance(),
&ProjectExplorer::ProjectManager::startupProjectChanged,
[action]() {
auto qmlProject = qobject_cast<QmlProject *>(
ProjectExplorer::SessionManager::startupProject());
ProjectExplorer::ProjectManager::startupProject());
action->setEnabled(qmlProject != nullptr);
});
}
void onGenerateCmakeLists()
{
FilePath rootDir = ProjectExplorer::SessionManager::startupProject()->projectDirectory();
FilePath rootDir = ProjectExplorer::ProjectManager::startupProject()->projectDirectory();
int projectDirErrors = isProjectCorrectlyFormed(rootDir);
if (projectDirErrors != NoError) {
@@ -246,7 +247,7 @@ const QString projectEnvironmentVariable(const QString &key)
{
QString value = {};
auto *target = ProjectExplorer::SessionManager::startupProject()->activeTarget();
auto *target = ProjectExplorer::ProjectManager::startupProject()->activeTarget();
if (target && target->buildSystem()) {
auto buildSystem = qobject_cast<QmlProjectManager::QmlBuildSystem *>(target->buildSystem());
if (buildSystem) {
@@ -304,7 +305,7 @@ const char ADD_SUBDIR[] = "add_subdirectory(%1)\n";
void CmakeFileGenerator::generateMainCmake(const FilePath &rootDir)
{
//TODO startupProject() may be a terrible way to try to get "current project". It's not necessarily the same thing at all.
QString projectName = ProjectExplorer::SessionManager::startupProject()->displayName();
QString projectName = ProjectExplorer::ProjectManager::startupProject()->displayName();
QString appName = projectName + "App";
QString fileSection = "";
@@ -523,7 +524,7 @@ bool CmakeFileGenerator::isDirBlacklisted(const FilePath &dir)
bool CmakeFileGenerator::includeFile(const FilePath &filePath)
{
if (m_checkFileIsInProject) {
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject();
ProjectExplorer::Project *project = ProjectExplorer::ProjectManager::startupProject();
if (!project->isKnownFile(filePath))
return false;
}
@@ -570,7 +571,7 @@ bool CmakeFileGenerator::generateMainCpp(const FilePath &dir)
bool envHeaderOk = true;
QString environment;
auto *target = ProjectExplorer::SessionManager::startupProject()->activeTarget();
auto *target = ProjectExplorer::ProjectManager::startupProject()->activeTarget();
if (target && target->buildSystem()) {
auto buildSystem = qobject_cast<QmlProjectManager::QmlBuildSystem *>(target->buildSystem());
if (buildSystem) {

View File

@@ -18,7 +18,7 @@ QRegularExpression qdsVerRegexp(R"x(qdsVersion: "(.*)")x");
const Utils::FilePaths rootCmakeFiles(ProjectExplorer::Project *project)
{
if (!project)
project = ProjectExplorer::SessionManager::startupProject();
project = ProjectExplorer::ProjectManager::startupProject();
if (!project)
return {};
return project->projectDirectory().dirEntries({QList<QString>({"CMakeLists.txt"}), QDir::Files});

View File

@@ -6,7 +6,7 @@
#include "qmlprojectmanager_global.h"
#include <projectexplorer/projectmanager.h>
#include <projectexplorer/session.h>
#include <projectexplorer/projectmanager.h>
#include <utils/fileutils.h>

View File

@@ -10,8 +10,8 @@
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectmanager.h>
#include <projectexplorer/runcontrol.h>
#include <projectexplorer/session.h>
#include <projectexplorer/target.h>
static bool isMultilanguagePresent()
@@ -114,7 +114,7 @@ void QmlMultiLanguageAspect::fromMap(const QVariantMap &map)
QmlMultiLanguageAspect *QmlMultiLanguageAspect::current()
{
if (auto project = ProjectExplorer::SessionManager::startupProject())
if (auto project = ProjectExplorer::ProjectManager::startupProject())
return current(project);
return {};
}

View File

@@ -23,7 +23,7 @@
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/kitmanager.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/session.h>
#include <projectexplorer/projectmanager.h>
#include <projectexplorer/target.h>
#include <qtsupport/baseqtversion.h>
@@ -97,7 +97,7 @@ QmlProject::QmlProject(const Utils::FilePath &fileName)
if (QmlProject::isQtDesignStudio()) {
if (allowOnlySingleProject()) {
EditorManager::closeAllDocuments();
SessionManager::closeAllProjects();
ProjectManager::closeAllProjects();
}
m_openFileConnection

View File

@@ -26,7 +26,7 @@
#include <projectexplorer/projectnodes.h>
#include <projectexplorer/projecttree.h>
#include <projectexplorer/runcontrol.h>
#include <projectexplorer/session.h>
#include <projectexplorer/projectmanager.h>
#include <projectexplorer/target.h>
#include <qmljs/qmljsmodelmanagerinterface.h>
@@ -181,7 +181,7 @@ const Utils::FilePath findQmlProjectUpwards(const Utils::FilePath &folder)
static bool findAndOpenProject(const Utils::FilePath &filePath)
{
ProjectExplorer::Project *project
= ProjectExplorer::SessionManager::projectForFile(filePath);
= ProjectExplorer::ProjectManager::projectForFile(filePath);
if (project) {
if (project->projectFilePath().suffix() == "qmlproject") {
@@ -437,7 +437,7 @@ void QmlProjectPlugin::updateQmlLandingPageProjectInfo(const Utils::FilePath &pr
Utils::FilePath QmlProjectPlugin::projectFilePath()
{
auto project = ProjectExplorer::SessionManager::startupProject();
auto project = ProjectExplorer::ProjectManager::startupProject();
const QmlProjectManager::QmlProject *qmlProject = qobject_cast<const QmlProjectManager::QmlProject*>(project);
if (qmlProject) {
return qmlProject->projectFilePath();

View File

@@ -21,7 +21,7 @@
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/runconfigurationaspects.h>
#include <projectexplorer/runcontrol.h>
#include <projectexplorer/session.h>
#include <projectexplorer/projectmanager.h>
#include <projectexplorer/target.h>
#include <qtsupport/qtkitinformation.h>
@@ -274,7 +274,7 @@ void QmlProjectRunConfiguration::createQtVersionAspect()
if (!newTarget)
newTarget = project->addTargetForKit(kits.first());
SessionManager::setActiveTarget(project, newTarget, SetActive::Cascade);
project->setActiveTarget(newTarget, SetActive::Cascade);
/* Reset the aspect. We changed the target and this aspect should not change. */
m_qtversionAspect->blockSignals(true);