diff --git a/src/plugins/coreplugin/CMakeLists.txt b/src/plugins/coreplugin/CMakeLists.txt index 10b5475e5fe..da833620f31 100644 --- a/src/plugins/coreplugin/CMakeLists.txt +++ b/src/plugins/coreplugin/CMakeLists.txt @@ -86,8 +86,6 @@ add_qtc_plugin(Core editormanager/ieditorfactory.cpp editormanager/ieditorfactory.h editormanager/ieditorfactory_p.h - editormanager/iexternaleditor.cpp - editormanager/iexternaleditor.h editormanager/openeditorsview.cpp editormanager/openeditorsview.h editormanager/openeditorswindow.cpp diff --git a/src/plugins/coreplugin/coreplugin.qbs b/src/plugins/coreplugin/coreplugin.qbs index 63fbe1520b9..000fbc22883 100644 --- a/src/plugins/coreplugin/coreplugin.qbs +++ b/src/plugins/coreplugin/coreplugin.qbs @@ -232,7 +232,6 @@ Project { "editorwindow.cpp", "editorwindow.h", "ieditor.cpp", "ieditor.h", "ieditorfactory.cpp", "ieditorfactory.h", "ieditorfactory_p.h", - "iexternaleditor.cpp", "iexternaleditor.h", "openeditorsview.cpp", "openeditorsview.h", "openeditorswindow.cpp", "openeditorswindow.h", "systemeditor.cpp", "systemeditor.h", diff --git a/src/plugins/coreplugin/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp index a529cb6ff98..97667be0a67 100644 --- a/src/plugins/coreplugin/documentmanager.cpp +++ b/src/plugins/coreplugin/documentmanager.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index fdcefe841b7..c102d75fa43 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -9,6 +9,8 @@ #include "editorview.h" #include "editorwindow.h" #include "ieditor.h" +#include "ieditorfactory.h" +#include "ieditorfactory_p.h" #include "openeditorsview.h" #include "openeditorswindow.h" #include "../actionmanager/actioncontainer.h" @@ -20,9 +22,6 @@ #include "../dialogs/readonlyfilesdialog.h" #include "../diffservice.h" #include "../documentmanager.h" -#include "../editormanager/ieditorfactory.h" -#include "../editormanager/ieditorfactory_p.h" -#include "../editormanager/iexternaleditor.h" #include "../fileutils.h" #include "../findplaceholder.h" #include "../icore.h" diff --git a/src/plugins/coreplugin/editormanager/ieditorfactory.cpp b/src/plugins/coreplugin/editormanager/ieditorfactory.cpp index 87940075005..eeb7e43ae34 100644 --- a/src/plugins/coreplugin/editormanager/ieditorfactory.cpp +++ b/src/plugins/coreplugin/editormanager/ieditorfactory.cpp @@ -298,4 +298,59 @@ void Internal::setUserPreferredEditorTypes(const QHash g_externalEditors; + +/*! + \internal +*/ +IExternalEditor::IExternalEditor() +{ + g_externalEditors.append(this); +} + +/*! + \internal +*/ +IExternalEditor::~IExternalEditor() +{ + g_externalEditors.removeOne(this); +} + +/*! + Returns all available external editors. +*/ +const ExternalEditorList IExternalEditor::allExternalEditors() +{ + return g_externalEditors; +} + +/*! + Returns all external editors available for this \a mimeType in the default + order (editors ordered by MIME type hierarchy). +*/ +const ExternalEditorList IExternalEditor::externalEditors(const Utils::MimeType &mimeType) +{ + ExternalEditorList rc; + const ExternalEditorList allEditors = IExternalEditor::allExternalEditors(); + Internal::mimeTypeFactoryLookup(mimeType, allEditors, &rc); + return rc; +} + } // Core diff --git a/src/plugins/coreplugin/editormanager/ieditorfactory.h b/src/plugins/coreplugin/editormanager/ieditorfactory.h index 670bd5b4f5d..e28694ffa0d 100644 --- a/src/plugins/coreplugin/editormanager/ieditorfactory.h +++ b/src/plugins/coreplugin/editormanager/ieditorfactory.h @@ -7,7 +7,6 @@ #include -#include #include #include @@ -26,6 +25,7 @@ class EditorType; using EditorFactoryList = QList; using EditorTypeList = QList; +using ExternalEditorList = QList; class CORE_EXPORT EditorType { @@ -77,4 +77,18 @@ private: std::function m_creator; }; +class CORE_EXPORT IExternalEditor : public EditorType +{ +public: + explicit IExternalEditor(); + ~IExternalEditor() override; + + static const ExternalEditorList allExternalEditors(); + static const ExternalEditorList externalEditors(const Utils::MimeType &mimeType); + + IExternalEditor *asExternalEditor() override { return this; } + + virtual bool startEditor(const Utils::FilePath &filePath, QString *errorMessage) = 0; +}; + } // namespace Core diff --git a/src/plugins/coreplugin/editormanager/iexternaleditor.cpp b/src/plugins/coreplugin/editormanager/iexternaleditor.cpp deleted file mode 100644 index 8176bf4d3ee..00000000000 --- a/src/plugins/coreplugin/editormanager/iexternaleditor.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 - -#include "iexternaleditor.h" - -#include "ieditorfactory_p.h" - -namespace Core { - -/*! - \class Core::IExternalEditor - \inheaderfile coreplugin/editormanager/iexternaleditor.h - \inmodule QtCreator - \ingroup mainclasses - - \brief The IExternalEditor class enables registering an external - editor in the \uicontrol{Open With} dialog. -*/ - -/*! - \fn bool Core::IExternalEditor::startEditor(const Utils::FilePath &fileName, QString *errorMessage) - - Opens the editor with \a fileName. Returns \c true on success or \c false - on failure along with the error in \a errorMessage. -*/ - -static QList g_externalEditors; - -/*! - \internal -*/ -IExternalEditor::IExternalEditor() -{ - g_externalEditors.append(this); -} - -/*! - \internal -*/ -IExternalEditor::~IExternalEditor() -{ - g_externalEditors.removeOne(this); -} - -/*! - Returns all available external editors. -*/ -const ExternalEditorList IExternalEditor::allExternalEditors() -{ - return g_externalEditors; -} - -/*! - Returns all external editors available for this \a mimeType in the default - order (editors ordered by MIME type hierarchy). -*/ -const ExternalEditorList IExternalEditor::externalEditors(const Utils::MimeType &mimeType) -{ - ExternalEditorList rc; - const ExternalEditorList allEditors = IExternalEditor::allExternalEditors(); - Internal::mimeTypeFactoryLookup(mimeType, allEditors, &rc); - return rc; -} - -} // Core diff --git a/src/plugins/coreplugin/editormanager/iexternaleditor.h b/src/plugins/coreplugin/editormanager/iexternaleditor.h deleted file mode 100644 index 49d0ffcfee9..00000000000 --- a/src/plugins/coreplugin/editormanager/iexternaleditor.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 - -#pragma once - -#include "ieditorfactory.h" - -#include - -#include - -#include - -namespace Utils { -class FilePath; -class MimeType; -} - -namespace Core { - -class IExternalEditor; - -using ExternalEditorList = QList; - -class CORE_EXPORT IExternalEditor : public EditorType -{ -public: - explicit IExternalEditor(); - ~IExternalEditor() override; - - static const ExternalEditorList allExternalEditors(); - static const ExternalEditorList externalEditors(const Utils::MimeType &mimeType); - - IExternalEditor *asExternalEditor() override { return this; } - - virtual bool startEditor(const Utils::FilePath &filePath, QString *errorMessage) = 0; -}; - -} // namespace Core diff --git a/src/plugins/coreplugin/editormanager/systemeditor.h b/src/plugins/coreplugin/editormanager/systemeditor.h index 96f29b8bf85..6218e63335f 100644 --- a/src/plugins/coreplugin/editormanager/systemeditor.h +++ b/src/plugins/coreplugin/editormanager/systemeditor.h @@ -3,10 +3,9 @@ #pragma once -#include "iexternaleditor.h" +#include "ieditorfactory.h" -namespace Core { -namespace Internal { +namespace Core::Internal { class SystemEditor : public IExternalEditor { @@ -16,5 +15,4 @@ public: bool startEditor(const Utils::FilePath &filePath, QString *errorMessage) override; }; -} // namespace Internal -} // namespace Core +} // namespace Core::Internal diff --git a/src/plugins/qtsupport/externaleditors.h b/src/plugins/qtsupport/externaleditors.h index 455e34a208b..1901046b658 100644 --- a/src/plugins/qtsupport/externaleditors.h +++ b/src/plugins/qtsupport/externaleditors.h @@ -3,7 +3,9 @@ #pragma once -#include +#include + +#include namespace QtSupport::Internal {