forked from qt-creator/qt-creator
ProjectExplorer: Move OpenProjectResult off ProjectExplorerPlugin class
It's not really related to the "Plugin-ness", and I'd generally like to get away from exported ExtensionSystem::IPlugin derived classes as "entrypoint" with the resulting fat plugin pimpl in favor of more separate isolated access points. Change-Id: I445df6109f4231e37750aa15eaa210d6669805e3 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -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 {};
|
||||
|
@@ -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();
|
||||
|
@@ -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()) {
|
||||
|
@@ -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<Project*> openedPro;
|
||||
QList<Project *> 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);
|
||||
}
|
||||
|
@@ -43,22 +43,9 @@ class MiniProjectTargetSelector;
|
||||
using RecentProjectsEntry = QPair<Utils::FilePath, QString>;
|
||||
using RecentProjectsEntries = QList<RecentProjectsEntry>;
|
||||
|
||||
class PROJECTEXPLORER_EXPORT ProjectExplorerPlugin : public ExtensionSystem::IPlugin
|
||||
class PROJECTEXPLORER_EXPORT OpenProjectResult
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "ProjectExplorer.json")
|
||||
|
||||
friend class ProjectExplorerPluginPrivate;
|
||||
|
||||
public:
|
||||
ProjectExplorerPlugin();
|
||||
~ProjectExplorerPlugin() override;
|
||||
|
||||
static ProjectExplorerPlugin *instance();
|
||||
|
||||
class OpenProjectResult
|
||||
{
|
||||
public:
|
||||
OpenProjectResult(const QList<Project *> &projects, const QList<Project *> &alreadyOpen,
|
||||
const QString &errorMessage)
|
||||
: m_projects(projects), m_alreadyOpen(alreadyOpen),
|
||||
@@ -89,11 +76,25 @@ public:
|
||||
{
|
||||
return m_alreadyOpen;
|
||||
}
|
||||
private:
|
||||
|
||||
private:
|
||||
QList<Project *> m_projects;
|
||||
QList<Project *> m_alreadyOpen;
|
||||
QString m_errorMessage;
|
||||
};
|
||||
};
|
||||
|
||||
class PROJECTEXPLORER_EXPORT ProjectExplorerPlugin : public ExtensionSystem::IPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "ProjectExplorer.json")
|
||||
|
||||
friend class ProjectExplorerPluginPrivate;
|
||||
|
||||
public:
|
||||
ProjectExplorerPlugin();
|
||||
~ProjectExplorerPlugin() override;
|
||||
|
||||
static ProjectExplorerPlugin *instance();
|
||||
|
||||
static OpenProjectResult openProject(const Utils::FilePath &filePath);
|
||||
static OpenProjectResult openProjects(const Utils::FilePaths &filePaths);
|
||||
|
@@ -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<Project *> projects = result.projects();
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user