IEditorFactory Class
class Core::IEditorFactoryThe IEditorFactory class creates suitable editors for documents according to their MIME type. More...
Header: | #include <coreplugin/editormanager/ieditorfactory.h> |
Inherits: | QObject |
Public Functions
Core::IEditor * | createEditor() const |
QString | displayName() const |
Utils::Id | id() const |
QStringList | mimeTypes() const |
Static Public Members
const Core::EditorFactoryList | defaultEditorFactories(const Utils::MimeType &mimeType) |
const Core::EditorFactoryList | preferredEditorFactories(const QString &fileName) |
Protected Functions
void | addMimeType(const QString &mimeType) |
void | setDisplayName(const QString &displayName) |
void | setEditorCreator(const std::function<IEditor *()> &creator) |
void | setMimeTypes(const QStringList &mimeTypes) |
Detailed Description
Whenever a user wants to edit or create a document, the EditorManager scans all IEditorFactory interfaces for suitable editors. The selected IEditorFactory is then asked to create an editor.
Guidelines for the implementation:
- displayName() is used as a user visible description of the editor type that is created. For example, the name displayed in the Open With menu.
- If duplication is supported (IEditor::duplicateSupported()), you need to ensure that all duplicates return the same document().
See also Core::IEditor and Core::EditorManager.
Member Function Documentation
[protected]
void IEditorFactory::addMimeType(const QString &mimeType)
Adds mimeType to the list of MIME types supported by this editor type.
Core::IEditor *IEditorFactory::createEditor() const
Creates an editor.
Either override this in a subclass, or set the function to use for creating an editor instance with setEditorCreator().
[static]
const Core::EditorFactoryList IEditorFactory::defaultEditorFactories(const Utils::MimeType &mimeType)
Returns all available editors for this mimeType in the default order (editors ordered by MIME type hierarchy).
QString IEditorFactory::displayName() const
Returns a user-visible description of the editor type.
See also setDisplayName().
Utils::Id IEditorFactory::id() const
Returns the ID of the factory or editor type.
QStringList IEditorFactory::mimeTypes() const
Returns a list of MIME types that the editor supports.
See also setMimeTypes().
[static]
const Core::EditorFactoryList IEditorFactory::preferredEditorFactories(const QString &fileName)
Returns the available editors for fileName in order of preference. That is the default order for the document's MIME type but with a user overridden default editor first, and if the document is a too large text file, with the binary editor as the very first.
[protected]
void IEditorFactory::setDisplayName(const QString &displayName)
Sets the displayName of the factory or editor type.
See also displayName().
[protected]
void IEditorFactory::setEditorCreator(const std::function<IEditor *()> &creator)
Sets the function that is used to create an editor instance in createEditor() by default to creator.
[protected]
void IEditorFactory::setMimeTypes(const QStringList &mimeTypes)
Sets the MIME types supported by the editor to mimeTypes.
See also mimeTypes().