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>

Public Functions

IEditorFactory()
IEditor *createEditor() const
QString displayName() const
Utils::Id id() const
QStringList mimeTypes() const

Static Public Members

const EditorFactoryList defaultEditorFactories(const Utils::MimeType &mimeType)

Protected Functions

void addMimeType(const QString &mimeType)
void setDisplayName(const QString &displayName)
void setEditorCreator(const std::function<IEditor *()> &creator)
void setId(Utils::Id id)
void setMimeTypes(const QStringList &mimeTypes)

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.

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

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

Member Function Documentation

IEditorFactory::IEditorFactory()

Creates an IEditorFactory.

Registers the IEditorFactory in Qt Creator.

[protected] void IEditorFactory::addMimeType(const QString &mimeType)

Adds mimeType to the list of MIME types supported by this editor type.

See also mimeTypes() and setMimeTypes().

IEditor *IEditorFactory::createEditor() const

Creates an editor.

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

See also setEditorCreator().

[static] const EditorFactoryList IEditorFactory::defaultEditorFactories(const Utils::MimeType &mimeType)

Returns all available editor factories for the mimeType in the default order (editor types 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 editors' document type.

See also setId().

QStringList IEditorFactory::mimeTypes() const

Returns the list of supported MIME types of this editor factory.

See also addMimeType() and setMimeTypes().

[protected] void IEditorFactory::setDisplayName(const QString &displayName)

Sets the displayName of the editor type. This is for example shown in the Open With menu and the MIME type preferences.

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() to creator.

See also createEditor().

[protected] void IEditorFactory::setId(Utils::Id id)

Sets the id of the editors' document type. This must be the same as the IDocument::id() of the documents returned by created editors.

See also id().

[protected] void IEditorFactory::setMimeTypes(const QStringList &mimeTypes)

Sets the MIME types supported by the editor type to mimeTypes.

See also addMimeType() and mimeTypes().