Core::IDocumentFactory Class

class Core::IDocumentFactory

The IDocumentFactory class is used to open files that are not opened in an editor. More...

Header: #include <coreplugin/idocumentfactory.cpp>

Public Functions

IDocumentFactory()
void addMimeType(const QString &mimeType)
void addMimeType(const char *mimeType)
bool isProjectFactory() const
QStringList mimeTypes() const
Core::IDocument *open(const Utils::FilePath &filePath)
void setIsProjectFactory(bool isProjectFactory)
void setMimeTypes(const QStringList &mimeTypes)
void setOpener(const Core::IDocumentFactory::Opener &opener)

Detailed Description

When users open a document, the document factory responsible for the corresponding MIME type is determined by checking the mimeTypes() of the factories.

Document factories that are project factories are not considered if the user specifically requests to open a file.

See also setMimeTypes(), addMimeType(), setIsProjectFactory(), and setOpener().

Member Function Documentation

IDocumentFactory::IDocumentFactory()

Creates a new document factory.

void IDocumentFactory::addMimeType(const QString &mimeType)

Adds the MIME type with name mimeType to the list of mime types that this factory can open.

void IDocumentFactory::addMimeType(const char *mimeType)

Adds the mimeType to the list of mime types that this factory can open.

bool IDocumentFactory::isProjectFactory() const

Returns whether this factory is used to open projects.

Defaults to false.

See also setIsProjectFactory().

QStringList IDocumentFactory::mimeTypes() const

Returns the list of mime types that this factory can open.

See also setMimeTypes() and addMimeType().

Core::IDocument *IDocumentFactory::open(const Utils::FilePath &filePath)

Opens the file at filePath.

This uses the opener function set by setOpener() to open the file. Returns the document that was opened or nullptr if an error occurred.

See also setOpener().

void IDocumentFactory::setIsProjectFactory(bool isProjectFactory)

Sets whether this factory is used to open projects to isProjectFactory.

Factories that are not used to open projects are considered when the user triggers File > Open File.

See also isProjectFactory().

void IDocumentFactory::setMimeTypes(const QStringList &mimeTypes)

Sets the mimeTypes that this factory can open.

See also mimeTypes().

void IDocumentFactory::setOpener(const Core::IDocumentFactory::Opener &opener)

Sets the opener function that is called to open a file.