Namespace sh::tools::filetypes¶
-
namespace
sh::tools
::
filetypes
Tools for determining a file’s type (pdf, image, mp3, et al) and ways how to deal with that.
See sh::tools::filetypes::FileTypeManager for more.
-
class
FileTypeManager
: public QObject, public sh::base::Singleton - #include <filetypemanager.h>
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
Determines the mimetype for one file.
Determines the mimetypes for a list of files.
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
- #include <filetypemanager.h>
Abstract base class for a mimetype determination strategy.
Subclassed by sh::tools::filetypes::FreedesktopOrgToolsMimetypeDeterminationStrategy, sh::tools::filetypes::SuffixListMimetypeDeterminationStrategy, sh::tools::filetypes::UnixFileToolMimetypeDeterminationStrategy
Public Functions
-
~MimetypeDeterminationStrategy
()
-
-
class
MimetypeInformationRetrievalStrategy
- #include <filetypemanager.h>
Abstract base class for mimetype information retrieval strategy.
Subclassed by sh::tools::filetypes::FreeDesktopOrgMimetypeInformationRetrievalStrategy
Public Functions
-
QStringList
getMimetypeSubclasses
(QString mimetype)
-
~MimetypeInformationRetrievalStrategy
()
-
QStringList
-
class
OpenMethodDeterminationStrategy
- #include <filetypemanager.h>
Abstract base class for a ‘open method’ determination strategy.
Subclassed by sh::tools::filetypes::FreedesktopOrgToolsOpenMethodDeterminationStrategy, sh::tools::filetypes::UserDefinedOpenMethodDeterminationStrategy
Public Functions
-
~OpenMethodDeterminationStrategy
()
-
-
class
FreeDesktopOrgMimetypeInformationRetrievalStrategy
: public sh::tools::filetypes::FileTypeManager::MimetypeInformationRetrievalStrategy - #include <freedesktoporgmimetypeinformationretrievalstrategy.h>
Tries to determine some mimetype information with the freedesktop.org specs.
Public Functions
-
FreeDesktopOrgMimetypeInformationRetrievalStrategy
()
-
QStringList
getMimetypeSubclasses
(QString mimetype)
Private Members
-
QHash<QString, QStringList>
_mimeSubclassOf
-
QMutex
_mutex
-
QWaitCondition
_cond_inited
-
bool
_inited
= false
-
class
MimetypeInfo
: public QXmlDefaultHandler Public Functions
-
MimetypeInfo
() = default
-
bool
startElement
(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
-
bool
endElement
(const QString &namespaceURI, const QString &localName, const QString &qName)
Public Members
-
QStringList
subClassOf
-
-
-
class
FreedesktopOrgToolsMimetypeDeterminationStrategy
: public sh::tools::filetypes::FileTypeManager::MimetypeDeterminationStrategy - #include <freedesktoporgtoolsmimetypedeterminationmethod.h>
Tries to determine a file’s mimetype with the freedesktop.org tools.
Public Functions
-
FreedesktopOrgToolsMimetypeDeterminationStrategy
(sh::tools::filetypes::FileTypeManager *manager)
Private Members
-
QMutex
_mutex
-
QString
_pathToFileTool
-
const QRegularExpression
_reMimetype
Private Static Attributes
-
std::shared_ptr<sh::configuration::ConfigurationValue>
cfgvalXdgmimePath
= sh::configuration::ConfigurationManager::instance()->registerConfigValue("sh::tools::filetypes::FreedesktopOrgToolsMimetypeDeterminationStrategy.XdgmimePath", "/usr/bin/xdg-mime", sh::configuration::ConfigurationValue::valueTypeLocalFilePath(), QObject::tr("Path to the 'xdg-mime' tool"), sh::configuration::ConfigurationCategory::CategoryExternalTools, QObject::tr("This tool is possibly used for file type detection."))
-
-
class
FreedesktopOrgToolsOpenMethodDeterminationStrategy
: public sh::tools::filetypes::FileTypeManager::OpenMethodDeterminationStrategy - #include <freedesktoporgtoolsopenmethoddeterminationmethod.h>
Tries to determine a ‘open method’ for a file with the freedesktop.org tools.
Public Functions
-
FreedesktopOrgToolsOpenMethodDeterminationStrategy
()
-
~FreedesktopOrgToolsOpenMethodDeterminationStrategy
()
Private Functions
-
QString
_parseValue
(QStringList content, QString key)
-
void
_parseExecLine
(QString execline, QString *command, QStringList *arguments)
-
QString
_escapeExecLineToken
(QString s)
Private Members
-
QMultiMap<QString, ApplicationEntry*>
_mimetype2applicationEntry
-
QMutex
_mutex
-
QWaitCondition
_cond_inited
-
bool
_inited
= false
-
struct
ApplicationEntry
Public Members
-
QString
name
-
QStringList
mimetypes
-
QString
command
-
QStringList
commandargs
-
QIcon
icon
-
QString
-
-
struct
OpenMethod
- #include <filetypemanager.h>
Commandline and infos for opening a file with an external program.
Public Functions
-
OpenMethod
(QString name, QString command, QStringList arguments, QIcon icon = QIcon(), int precedence = 0)
Public Members
-
const QString
name
-
const QString
command
-
const QStringList
arguments
-
const QIcon
icon
-
const int
precedence
-
-
class
SuffixListMimetypeDeterminationStrategy
: public sh::tools::filetypes::FileTypeManager::MimetypeDeterminationStrategy - #include <suffixlistmimetypedeterminationmethod.h>
Tries to determine a file’s mimetype with an internal lookup table of file extensions.
Public Functions
-
SuffixListMimetypeDeterminationStrategy
()
Private Members
-
QHash<QString, QString>
_suffixToMimetype
-
QMutex
_mutex
-
-
class
UnixFileToolMimetypeDeterminationStrategy
: public sh::tools::filetypes::FileTypeManager::MimetypeDeterminationStrategy - #include <unixfiletoolmimetypedeterminationmethod.h>
Tries to determine a file’s mimetype with the unix
file
tool.Public Functions
-
UnixFileToolMimetypeDeterminationStrategy
(sh::tools::filetypes::FileTypeManager *manager)
Public Static Attributes
-
std::shared_ptr<sh::configuration::ConfigurationValue>
cfgvalFilePath
= sh::configuration::ConfigurationManager::instance()->registerConfigValue("sh::tools::filetypes::UnixFileToolMimetypeDeterminationStrategy.FilePath", "/usr/bin/file", sh::configuration::ConfigurationValue::valueTypeLocalFilePath(), QObject::tr("Path to the 'file' tool"), sh::configuration::ConfigurationCategory::CategoryExternalTools, QObject::tr("This tool is possibly used for file type detection."))
Private Members
-
QString
_pathToFileTool
-
const QRegularExpression
_reMimetype
-
QMutex
_mutex
-
-
class
UserDefinedOpenMethodDeterminationStrategy
: public sh::tools::filetypes::FileTypeManager::OpenMethodDeterminationStrategy, public sh::base::Singleton - #include <userdefinedopenmethoddeterminationstrategy.h>
Tries to determine a ‘open method’ for a file by information the user stored before.
Public Functions
Stores a custom open method.
-
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
-
UserDefinedOpenMethodDeterminationStrategy
()
Private Members
-
QMutex
_mutex
-
class