diff --git a/src/plugins/cppeditor/cpptoolstestcase.cpp b/src/plugins/cppeditor/cpptoolstestcase.cpp index 420e551847d..37b5d855d0a 100644 --- a/src/plugins/cppeditor/cpptoolstestcase.cpp +++ b/src/plugins/cppeditor/cpptoolstestcase.cpp @@ -391,8 +391,7 @@ ProjectOpenerAndCloser::~ProjectOpenerAndCloser() ProjectInfo::ConstPtr ProjectOpenerAndCloser::open(const FilePath &projectFile, bool configureAsExampleProject, Kit *kit) { - ProjectExplorerPlugin::OpenProjectResult result = - ProjectExplorerPlugin::openProject(projectFile); + OpenProjectResult result = ProjectExplorerPlugin::openProject(projectFile); if (!result) { qWarning() << result.errorMessage() << result.alreadyOpen(); return {}; diff --git a/src/plugins/projectexplorer/customwizard/customwizard.cpp b/src/plugins/projectexplorer/customwizard/customwizard.cpp index 9d060624386..c18926cbfc9 100644 --- a/src/plugins/projectexplorer/customwizard/customwizard.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizard.cpp @@ -529,8 +529,7 @@ bool CustomProjectWizard::postGenerateOpen(const GeneratedFiles &l, QString *err // Post-Generate: Open the project and the editors as desired for (const GeneratedFile &file : l) { if (file.attributes() & GeneratedFile::OpenProjectAttribute) { - ProjectExplorerPlugin::OpenProjectResult result - = ProjectExplorerPlugin::openProject(file.filePath()); + OpenProjectResult result = ProjectExplorerPlugin::openProject(file.filePath()); if (!result) { if (errorMessage) *errorMessage = result.errorMessage(); diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp index 17fc1e736c0..83b8b81bef6 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp @@ -445,8 +445,7 @@ void JsonWizard::openFiles(const JsonWizard::GeneratorFiles &files) break; } if (file.attributes() & Core::GeneratedFile::OpenProjectAttribute) { - ProjectExplorerPlugin::OpenProjectResult result - = ProjectExplorerPlugin::openProject(file.filePath()); + OpenProjectResult result = ProjectExplorerPlugin::openProject(file.filePath()); if (!result) { errorMessage = result.errorMessage(); if (errorMessage.isEmpty()) { diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index a3076aa2789..11e0fbb0f9f 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -1970,7 +1970,7 @@ void ProjectExplorerPluginPrivate::loadAction() if (filePath.isEmpty()) return; - ProjectExplorerPlugin::OpenProjectResult result = ProjectExplorerPlugin::openProject(filePath); + OpenProjectResult result = ProjectExplorerPlugin::openProject(filePath); if (!result) ProjectExplorerPlugin::showOpenProjectError(result); @@ -2273,7 +2273,7 @@ void ProjectExplorerPlugin::openProjectWelcomePage(const FilePath &filePath) showOpenProjectError(result); } -ProjectExplorerPlugin::OpenProjectResult ProjectExplorerPlugin::openProject(const FilePath &filePath) +OpenProjectResult ProjectExplorerPlugin::openProject(const FilePath &filePath) { OpenProjectResult result = openProjects({filePath}); Project *project = result.project(); @@ -2323,7 +2323,7 @@ static void appendError(QString &errorString, const QString &error) errorString.append(error); } -ProjectExplorerPlugin::OpenProjectResult ProjectExplorerPlugin::openProjects(const FilePaths &filePaths) +OpenProjectResult ProjectExplorerPlugin::openProjects(const FilePaths &filePaths) { QList openedPro; QList alreadyOpen; @@ -3198,8 +3198,7 @@ void ProjectExplorerPluginPrivate::clearRecentProjects() void ProjectExplorerPluginPrivate::openRecentProject(const FilePath &filePath) { if (!filePath.isEmpty()) { - ProjectExplorerPlugin::OpenProjectResult result - = ProjectExplorerPlugin::openProject(filePath); + OpenProjectResult result = ProjectExplorerPlugin::openProject(filePath); if (!result) ProjectExplorerPlugin::showOpenProjectError(result); } diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index ced2d4e0f09..c9b55143be6 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -43,6 +43,46 @@ class MiniProjectTargetSelector; using RecentProjectsEntry = QPair; using RecentProjectsEntries = QList; +class PROJECTEXPLORER_EXPORT OpenProjectResult +{ +public: + OpenProjectResult(const QList &projects, const QList &alreadyOpen, + const QString &errorMessage) + : m_projects(projects), m_alreadyOpen(alreadyOpen), + m_errorMessage(errorMessage) + { } + + explicit operator bool() const + { + return m_errorMessage.isEmpty() && m_alreadyOpen.isEmpty(); + } + + Project *project() const + { + return m_projects.isEmpty() ? nullptr : m_projects.first(); + } + + QList projects() const + { + return m_projects; + } + + QString errorMessage() const + { + return m_errorMessage; + } + + QList alreadyOpen() const + { + return m_alreadyOpen; + } + +private: + QList m_projects; + QList m_alreadyOpen; + QString m_errorMessage; +}; + class PROJECTEXPLORER_EXPORT ProjectExplorerPlugin : public ExtensionSystem::IPlugin { Q_OBJECT @@ -56,45 +96,6 @@ public: static ProjectExplorerPlugin *instance(); - class OpenProjectResult - { - public: - OpenProjectResult(const QList &projects, const QList &alreadyOpen, - const QString &errorMessage) - : m_projects(projects), m_alreadyOpen(alreadyOpen), - m_errorMessage(errorMessage) - { } - - explicit operator bool() const - { - return m_errorMessage.isEmpty() && m_alreadyOpen.isEmpty(); - } - - Project *project() const - { - return m_projects.isEmpty() ? nullptr : m_projects.first(); - } - - QList projects() const - { - return m_projects; - } - - QString errorMessage() const - { - return m_errorMessage; - } - - QList alreadyOpen() const - { - return m_alreadyOpen; - } - private: - QList m_projects; - QList m_alreadyOpen; - QString m_errorMessage; - }; - static OpenProjectResult openProject(const Utils::FilePath &filePath); static OpenProjectResult openProjects(const Utils::FilePaths &filePaths); static void showOpenProjectError(const OpenProjectResult &result); diff --git a/src/plugins/projectexplorer/projectmanager.cpp b/src/plugins/projectexplorer/projectmanager.cpp index 4943773f4b0..35335bde131 100644 --- a/src/plugins/projectexplorer/projectmanager.cpp +++ b/src/plugins/projectexplorer/projectmanager.cpp @@ -637,7 +637,7 @@ void ProjectManagerPrivate::restoreProjects(const FilePaths &fileList) // Keep projects that failed to load in the session! m_failedProjects = fileList; if (!fileList.isEmpty()) { - ProjectExplorerPlugin::OpenProjectResult result = ProjectExplorerPlugin::openProjects(fileList); + OpenProjectResult result = ProjectExplorerPlugin::openProjects(fileList); if (!result) ProjectExplorerPlugin::showOpenProjectError(result); const QList projects = result.projects(); diff --git a/src/plugins/qmlprojectmanager/cmakegen/cmakeprojectconverter.cpp b/src/plugins/qmlprojectmanager/cmakegen/cmakeprojectconverter.cpp index 21a538c7c51..da32379b029 100644 --- a/src/plugins/qmlprojectmanager/cmakegen/cmakeprojectconverter.cpp +++ b/src/plugins/qmlprojectmanager/cmakegen/cmakeprojectconverter.cpp @@ -114,7 +114,7 @@ bool CmakeProjectConverter::convertProject(const QmlProjectManager::QmlProject * if (retVal) { QMessageBox::information(Core::ICore::dialogParent(), SUCCESS_TITLE, SUCCESS_TEXT); - ProjectExplorer::ProjectExplorerPlugin::OpenProjectResult result + ProjectExplorer::OpenProjectResult result = ProjectExplorer::ProjectExplorerPlugin::openProject(newProjectFile()); if (!result) ProjectExplorer::ProjectExplorerPlugin::showOpenProjectError(result); diff --git a/src/plugins/qtsupport/gettingstartedwelcomepage.cpp b/src/plugins/qtsupport/gettingstartedwelcomepage.cpp index 7256afc050a..f5b5c0ac49f 100644 --- a/src/plugins/qtsupport/gettingstartedwelcomepage.cpp +++ b/src/plugins/qtsupport/gettingstartedwelcomepage.cpp @@ -203,7 +203,8 @@ static void openProject(const ExampleItem *item) // don't try to load help and files if loading the help request is being cancelled if (proFile.isEmpty()) return; - ProjectExplorerPlugin::OpenProjectResult result = ProjectExplorerPlugin::openProject(proFile); + + OpenProjectResult result = ProjectExplorerPlugin::openProject(proFile); if (result) { ICore::openFiles(filesToOpen); ModeManager::activateMode(Core::Constants::MODE_EDIT); diff --git a/src/plugins/studiowelcome/studiowelcomeplugin.cpp b/src/plugins/studiowelcome/studiowelcomeplugin.cpp index 5a494f5b4ef..b48d87121f8 100644 --- a/src/plugins/studiowelcome/studiowelcomeplugin.cpp +++ b/src/plugins/studiowelcome/studiowelcomeplugin.cpp @@ -252,7 +252,7 @@ public: const FilePath projectFile = FilePath::fromVariant( data(index(row, 0), ProjectModel::FilePathRole)); if (projectFile.exists()) { - const ProjectExplorerPlugin::OpenProjectResult result + const OpenProjectResult result = ProjectExplorer::ProjectExplorerPlugin::openProject(projectFile); if (!result && !result.alreadyOpen().isEmpty()) { const auto fileToOpen = getMainUiFileWithFallback();