forked from qt-creator/qt-creator
Core: Merge iexternaleditor.{h,cpp} into ieditorfactory.{h,cpp}
Naming is still inconsistent, these should be all some kind of
factories, but now is at least the 'distance' to the base class
('EditorType') the same for both siblings.
Also remove unneeded #include
Change-Id: I73aa0cbc2aab14605fe6a1101d388b10a9108b63
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -86,8 +86,6 @@ add_qtc_plugin(Core
|
|||||||
editormanager/ieditorfactory.cpp
|
editormanager/ieditorfactory.cpp
|
||||||
editormanager/ieditorfactory.h
|
editormanager/ieditorfactory.h
|
||||||
editormanager/ieditorfactory_p.h
|
editormanager/ieditorfactory_p.h
|
||||||
editormanager/iexternaleditor.cpp
|
|
||||||
editormanager/iexternaleditor.h
|
|
||||||
editormanager/openeditorsview.cpp
|
editormanager/openeditorsview.cpp
|
||||||
editormanager/openeditorsview.h
|
editormanager/openeditorsview.h
|
||||||
editormanager/openeditorswindow.cpp
|
editormanager/openeditorswindow.cpp
|
||||||
|
|||||||
@@ -232,7 +232,6 @@ Project {
|
|||||||
"editorwindow.cpp", "editorwindow.h",
|
"editorwindow.cpp", "editorwindow.h",
|
||||||
"ieditor.cpp", "ieditor.h",
|
"ieditor.cpp", "ieditor.h",
|
||||||
"ieditorfactory.cpp", "ieditorfactory.h", "ieditorfactory_p.h",
|
"ieditorfactory.cpp", "ieditorfactory.h", "ieditorfactory_p.h",
|
||||||
"iexternaleditor.cpp", "iexternaleditor.h",
|
|
||||||
"openeditorsview.cpp", "openeditorsview.h",
|
"openeditorsview.cpp", "openeditorsview.h",
|
||||||
"openeditorswindow.cpp", "openeditorswindow.h",
|
"openeditorswindow.cpp", "openeditorswindow.h",
|
||||||
"systemeditor.cpp", "systemeditor.h",
|
"systemeditor.cpp", "systemeditor.h",
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
#include <coreplugin/editormanager/editorview.h>
|
#include <coreplugin/editormanager/editorview.h>
|
||||||
#include <coreplugin/editormanager/ieditor.h>
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
#include <coreplugin/editormanager/ieditorfactory.h>
|
#include <coreplugin/editormanager/ieditorfactory.h>
|
||||||
#include <coreplugin/editormanager/iexternaleditor.h>
|
|
||||||
#include <coreplugin/systemsettings.h>
|
#include <coreplugin/systemsettings.h>
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
#include "editorview.h"
|
#include "editorview.h"
|
||||||
#include "editorwindow.h"
|
#include "editorwindow.h"
|
||||||
#include "ieditor.h"
|
#include "ieditor.h"
|
||||||
|
#include "ieditorfactory.h"
|
||||||
|
#include "ieditorfactory_p.h"
|
||||||
#include "openeditorsview.h"
|
#include "openeditorsview.h"
|
||||||
#include "openeditorswindow.h"
|
#include "openeditorswindow.h"
|
||||||
#include "../actionmanager/actioncontainer.h"
|
#include "../actionmanager/actioncontainer.h"
|
||||||
@@ -20,9 +22,6 @@
|
|||||||
#include "../dialogs/readonlyfilesdialog.h"
|
#include "../dialogs/readonlyfilesdialog.h"
|
||||||
#include "../diffservice.h"
|
#include "../diffservice.h"
|
||||||
#include "../documentmanager.h"
|
#include "../documentmanager.h"
|
||||||
#include "../editormanager/ieditorfactory.h"
|
|
||||||
#include "../editormanager/ieditorfactory_p.h"
|
|
||||||
#include "../editormanager/iexternaleditor.h"
|
|
||||||
#include "../fileutils.h"
|
#include "../fileutils.h"
|
||||||
#include "../findplaceholder.h"
|
#include "../findplaceholder.h"
|
||||||
#include "../icore.h"
|
#include "../icore.h"
|
||||||
|
|||||||
@@ -298,4 +298,59 @@ void Internal::setUserPreferredEditorTypes(const QHash<Utils::MimeType, EditorTy
|
|||||||
g_userPreferredEditorTypes = factories;
|
g_userPreferredEditorTypes = factories;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\class Core::IExternalEditor
|
||||||
|
\inheaderfile coreplugin/editormanager/ieditorfactory.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<IExternalEditor *> 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
|
} // Core
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include <utils/id.h>
|
#include <utils/id.h>
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
@@ -26,6 +25,7 @@ class EditorType;
|
|||||||
|
|
||||||
using EditorFactoryList = QList<IEditorFactory *>;
|
using EditorFactoryList = QList<IEditorFactory *>;
|
||||||
using EditorTypeList = QList<EditorType *>;
|
using EditorTypeList = QList<EditorType *>;
|
||||||
|
using ExternalEditorList = QList<IExternalEditor *>;
|
||||||
|
|
||||||
class CORE_EXPORT EditorType
|
class CORE_EXPORT EditorType
|
||||||
{
|
{
|
||||||
@@ -77,4 +77,18 @@ private:
|
|||||||
std::function<IEditor *()> m_creator;
|
std::function<IEditor *()> 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
|
} // namespace Core
|
||||||
|
|||||||
@@ -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<IExternalEditor *> 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
|
|
||||||
@@ -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 <coreplugin/core_global.h>
|
|
||||||
|
|
||||||
#include <utils/id.h>
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
namespace Utils {
|
|
||||||
class FilePath;
|
|
||||||
class MimeType;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Core {
|
|
||||||
|
|
||||||
class IExternalEditor;
|
|
||||||
|
|
||||||
using ExternalEditorList = QList<IExternalEditor *>;
|
|
||||||
|
|
||||||
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
|
|
||||||
@@ -3,10 +3,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "iexternaleditor.h"
|
#include "ieditorfactory.h"
|
||||||
|
|
||||||
namespace Core {
|
namespace Core::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class SystemEditor : public IExternalEditor
|
class SystemEditor : public IExternalEditor
|
||||||
{
|
{
|
||||||
@@ -16,5 +15,4 @@ public:
|
|||||||
bool startEditor(const Utils::FilePath &filePath, QString *errorMessage) override;
|
bool startEditor(const Utils::FilePath &filePath, QString *errorMessage) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Core::Internal
|
||||||
} // namespace Core
|
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <coreplugin/editormanager/iexternaleditor.h>
|
#include <coreplugin/editormanager/ieditorfactory.h>
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
namespace QtSupport::Internal {
|
namespace QtSupport::Internal {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user