summaryrefslogtreecommitdiffstats
path: root/src/imports/mimetypes/qdeclarativemimedatabase.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/imports/mimetypes/qdeclarativemimedatabase.cpp')
-rw-r--r--src/imports/mimetypes/qdeclarativemimedatabase.cpp131
1 files changed, 121 insertions, 10 deletions
diff --git a/src/imports/mimetypes/qdeclarativemimedatabase.cpp b/src/imports/mimetypes/qdeclarativemimedatabase.cpp
index c913fff..8edd0cb 100644
--- a/src/imports/mimetypes/qdeclarativemimedatabase.cpp
+++ b/src/imports/mimetypes/qdeclarativemimedatabase.cpp
@@ -60,19 +60,99 @@ extern bool isQMimeDatabaseDebuggingActivated;
/*!
\qmlclass MimeDatabase QDeclarativeMimeDatabase
\brief The QML MimeDatabase element maintains a database of MIME types.
+
+ The MIME type database is provided by the freedesktop.org shared-mime-info
+ project. If the MIME type database cannot be found on the system, Qt
+ will use its own copy of it.
+
+ Applications which want to define custom MIME types need to install an
+ XML file into the locations searched for MIME definitions.
+ These locations can be queried with
+ QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime/packages"),
+ QStandardPaths::LocateDirectory);
+ On a typical Unix system, this will be /usr/share/mime/packages/, but it is also
+ possible to extend the list of directories by setting the environment variable
+ XDG_DATA_DIRS. For instance adding /opt/myapp/share to XDG_DATA_DIRS will result
+ in /opt/myapp/share/mime/packages/ being searched for MIME definitions.
+
+ Here is an example of MIME XML:
+ \code
+ <?xml version="1.0" encoding="UTF-8"?>
+ <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
+ <mime-type type="application/vnd.nokia.qt.qmakeprofile">
+ <comment xml:lang="en">Qt qmake Profile</comment>
+ <glob pattern="*.pro" weight="50"/>
+ </mime-type>
+ </mime-info>
+ \endcode
+
+ For more details about the syntax of XML MIME definitions, including defining
+ "magic" in order to detect MIME types based on data as well, read the
+ Shared Mime Info specification at
+ http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html
+
+ On Unix systems, a binary cache is used for more performance. This cache is generated
+ by the command "update-mime-database path", where path would be /opt/myapp/share/mime
+ in the above example. Make sure to run this command when installing the MIME type
+ definition file.
+
+ The class is protected by a QMutex and can therefore be accessed by threads.
+
+ \sa QMimeType
*/
// ------------------------------------------------------------------------------------------------
/*!
+ \internal
\class QDeclarativeMimeDatabase
\brief The QDeclarativeMimeDatabase class is the QML wrapper for the class QMimeDatabase which maintains a database of MIME types.
\inherits QObject
+
+ The MIME type database is provided by the freedesktop.org shared-mime-info
+ project. If the MIME type database cannot be found on the system, Qt
+ will use its own copy of it.
+
+ Applications which want to define custom MIME types need to install an
+ XML file into the locations searched for MIME definitions.
+ These locations can be queried with
+ QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime/packages"),
+ QStandardPaths::LocateDirectory);
+ On a typical Unix system, this will be /usr/share/mime/packages/, but it is also
+ possible to extend the list of directories by setting the environment variable
+ XDG_DATA_DIRS. For instance adding /opt/myapp/share to XDG_DATA_DIRS will result
+ in /opt/myapp/share/mime/packages/ being searched for MIME definitions.
+
+ Here is an example of MIME XML:
+ \code
+ <?xml version="1.0" encoding="UTF-8"?>
+ <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
+ <mime-type type="application/vnd.nokia.qt.qmakeprofile">
+ <comment xml:lang="en">Qt qmake Profile</comment>
+ <glob pattern="*.pro" weight="50"/>
+ </mime-type>
+ </mime-info>
+ \endcode
+
+ For more details about the syntax of XML MIME definitions, including defining
+ "magic" in order to detect MIME types based on data as well, read the
+ Shared Mime Info specification at
+ http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html
+
+ On Unix systems, a binary cache is used for more performance. This cache is generated
+ by the command "update-mime-database path", where path would be /opt/myapp/share/mime
+ in the above example. Make sure to run this command when installing the MIME type
+ definition file.
+
+ The class is protected by a QMutex and can therefore be accessed by threads.
+
+ \sa QMimeType
*/
// ------------------------------------------------------------------------------------------------
/*!
+ \internal
\fn QDeclarativeMimeDatabase::QDeclarativeMimeDatabase(QObject *theParent);
\brief Performs default initialization of the contained MimeDatabase, and attaches the object to the specified \a theParent for destruction.
*/
@@ -86,8 +166,9 @@ QDeclarativeMimeDatabase::QDeclarativeMimeDatabase(QObject *theParent) :
// ------------------------------------------------------------------------------------------------
/*!
+ \internal
\fn QDeclarativeMimeDatabase::~QDeclarativeMimeDatabase();
- \brief Destroys the the contained MimeDatabase.
+ \brief Destroys the contained MimeDatabase.
*/
QDeclarativeMimeDatabase::~QDeclarativeMimeDatabase()
{
@@ -97,6 +178,7 @@ QDeclarativeMimeDatabase::~QDeclarativeMimeDatabase()
// ------------------------------------------------------------------------------------------------
/*!
+ \internal
\fn QMimeDatabase &QDeclarativeMimeDatabase::mimeDatabase()
\brief Returns the contained MimeDatabase.
*/
@@ -108,8 +190,44 @@ QMimeDatabase &QDeclarativeMimeDatabase::mimeDatabase()
// ------------------------------------------------------------------------------------------------
/*!
- \qmlproperty QVariantList MimeDatabase::mimeTypeNames
- list of registered MIME types
+ \qmlproperty bool MimeDatabase::isDebuggingActivated
+ Holds the indication if debugging for the class is activated.
+ */
+
+// ------------------------------------------------------------------------------------------------
+
+/*!
+ \internal
+ \property QDeclarativeMimeDatabase::isDebuggingActivated
+ Holds the indication if debugging for the class is activated.
+ */
+
+// ------------------------------------------------------------------------------------------------
+
+bool QDeclarativeMimeDatabase::isDebuggingActivated() const
+{
+ return isQMimeDatabaseDebuggingActivated;
+}
+
+// ------------------------------------------------------------------------------------------------
+
+void QDeclarativeMimeDatabase::setIsDebuggingActivated(const bool newIsDebuggingActivated)
+{
+ isQMimeDatabaseDebuggingActivated = newIsDebuggingActivated;
+}
+
+// ------------------------------------------------------------------------------------------------
+
+/*!
+ \qmlproperty list<string> MimeDatabase::mimeTypeNames
+ Holds the list of registered MIME types.
+ */
+
+// ------------------------------------------------------------------------------------------------
+
+/*!
+ \property QDeclarativeMimeDatabase::mimeTypeNames
+ Holds the list of registered MIME types.
*/
// ------------------------------------------------------------------------------------------------
@@ -134,13 +252,6 @@ QVariantList QDeclarativeMimeDatabase::mimeTypeNames() const
// ------------------------------------------------------------------------------------------------
-/*!
- \property QDeclarativeMimeDatabase::mimeTypeNames
- \brief the list of registered MIME types
- */
-
-// ------------------------------------------------------------------------------------------------
-
QDeclarativeMimeType *QDeclarativeMimeDatabase::mimeTypeForName (
const QString &nameOrAlias
)