IEditorFactory Class

class Core::IEditorFactory

The IEditorFactory class creates suitable editors for documents according to their MIME type. More...

Header: #include <coreplugin/editormanager/ieditorfactory.h>
Inherits: Core::EditorType

Public Functions

IEditorFactory()
Core::IEditor *createEditor() const

Static Public Members

const Core::EditorFactoryList preferredEditorFactories(const Utils::FilePath &filePath)

Protected Functions

void setEditorCreator(const std::function<IEditor *()> &creator)

Detailed Description

Whenever a user wants to edit or create a document, the EditorManager scans all IEditorFactory instances for suitable editors. The selected IEditorFactory is then asked to create an editor.

Implementations should set the properties of the IEditorFactory subclass in their constructor with EditorType::setId(), EditorType::setDisplayName(), EditorType::setMimeTypes(), and setEditorCreator()

IEditorFactory instances automatically register themselves in Qt Creator in their constructor.

See also Core::EditorType, Core::IEditor, Core::IDocument, and Core::EditorManager.

Member Function Documentation

IEditorFactory::IEditorFactory()

Creates an IEditorFactory.

Registers the IEditorFactory in Qt Creator.

Core::IEditor *IEditorFactory::createEditor() const

Creates an editor.

Uses the function set with setEditorCreator() to create the editor.

See also setEditorCreator().

[static] const Core::EditorFactoryList IEditorFactory::preferredEditorFactories(const Utils::FilePath &filePath)

Returns the available editor factories for filePath in order of preference. That is the default order for the document's MIME type but with a user overridden default editor first, and the binary editor as the very first item if a text document is too large to be opened as a text file.

[protected] void IEditorFactory::setEditorCreator(const std::function<IEditor *()> &creator)

Sets the function that is used to create an editor instance in createEditor() to creator.

See also createEditor().