Class sh::tools::filetypes::FileTypeManager

class sh::tools::filetypes::FileTypeManager : public QObject, public sh::base::Singleton

Utilities for dealing with file types.

It can determine the type of a file (png, plaintext, html, …), it can provide information about how to open them with an external program, and more.

For most tasks it uses a pluggable interface. Actual implementations of strategies for those tasks reside in separate classes in this namespace.

Public Functions

QString determineMimetype(sh::filesystem::Operation *op, std::shared_ptr<const sh::filesystem::Eurl> eurl)

Determines the mimetype for one file.

QHash<std::shared_ptr<const sh::filesystem::Eurl>, QString> determineMimetype(sh::filesystem::Operation *op, QList<std::shared_ptr<const sh::filesystem::Eurl>> items)

Determines the mimetypes for a list of files.

QList<std::shared_ptr<OpenMethod>> getOpenMethods(QString mimetype, QList<std::shared_ptr<sh::filesystem::FilesystemNode>> nodes)

Determines how to open a file with a given mimetype with an external program.

QList<std::shared_ptr<OpenMethod>> getAllOpenMethods()

Returns a list of all known infos how to open a file external programs.

This has roughly one entry for each installed program on the user’s system, which can graphically open files.

void doInitialize()

Executes singleton initialization.

void doShutdown()

Executes singleton shutdown.

void shutdown()

Shutdown down this singleton.

bool isAlive()

Returns if this singleton is alive (true until its shutdown begins).

Private Functions

FileTypeManager(QObject *parent = 0)

Private Members

QList<std::shared_ptr<MimetypeDeterminationStrategy>> _mimetypeDeterminationMethods
QList<std::shared_ptr<OpenMethodDeterminationStrategy>> _openMethodDeterminationMethods
QList<std::shared_ptr<MimetypeInformationRetrievalStrategy>> _mimetypeInformationRetrievalMethods
QMutex _mutex
class MimetypeDeterminationStrategy

Abstract base class for a mimetype determination strategy.

Subclassed by sh::tools::filetypes::FreedesktopOrgToolsMimetypeDeterminationStrategy, sh::tools::filetypes::SuffixListMimetypeDeterminationStrategy, sh::tools::filetypes::UnixFileToolMimetypeDeterminationStrategy

Public Functions

QHash<std::shared_ptr<const sh::filesystem::Eurl>, QString> determineMimetype(sh::filesystem::Operation *op, QList<std::shared_ptr<const sh::filesystem::Eurl>> items) = 0
~MimetypeDeterminationStrategy()
class MimetypeInformationRetrievalStrategy

Abstract base class for mimetype information retrieval strategy.

Subclassed by sh::tools::filetypes::FreeDesktopOrgMimetypeInformationRetrievalStrategy

Public Functions

QStringList getMimetypeSubclasses(QString mimetype)
~MimetypeInformationRetrievalStrategy()
class OpenMethodDeterminationStrategy

Abstract base class for a ‘open method’ determination strategy.

Subclassed by sh::tools::filetypes::FreedesktopOrgToolsOpenMethodDeterminationStrategy, sh::tools::filetypes::UserDefinedOpenMethodDeterminationStrategy

Public Functions

QList<std::shared_ptr<OpenMethod>> getOpenMethods(QString mimetype, QList<std::shared_ptr<sh::filesystem::FilesystemNode>> nodes) = 0
~OpenMethodDeterminationStrategy()