1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // Copyright (C) 2015 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com> |
3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
4 | |
5 | #ifndef QMIMEDATABASE_H |
6 | #define QMIMEDATABASE_H |
7 | |
8 | #include <QtCore/qmimetype.h> |
9 | |
10 | QT_REQUIRE_CONFIG(mimetype); |
11 | |
12 | #include <QtCore/qstringlist.h> |
13 | |
14 | QT_BEGIN_NAMESPACE |
15 | |
16 | class QByteArray; |
17 | class QFileInfo; |
18 | class QIODevice; |
19 | class QUrl; |
20 | |
21 | class QMimeDatabasePrivate; |
22 | class Q_CORE_EXPORT QMimeDatabase |
23 | { |
24 | Q_DISABLE_COPY(QMimeDatabase) |
25 | |
26 | public: |
27 | QMimeDatabase(); |
28 | ~QMimeDatabase(); |
29 | |
30 | QMimeType mimeTypeForName(const QString &nameOrAlias) const; |
31 | |
32 | enum MatchMode { |
33 | MatchDefault = 0x0, |
34 | MatchExtension = 0x1, |
35 | MatchContent = 0x2 |
36 | }; |
37 | |
38 | QMimeType mimeTypeForFile(const QString &fileName, MatchMode mode = MatchDefault) const; |
39 | QMimeType mimeTypeForFile(const QFileInfo &fileInfo, MatchMode mode = MatchDefault) const; |
40 | QList<QMimeType> mimeTypesForFileName(const QString &fileName) const; |
41 | |
42 | QMimeType mimeTypeForData(const QByteArray &data) const; |
43 | QMimeType mimeTypeForData(QIODevice *device) const; |
44 | |
45 | QMimeType mimeTypeForUrl(const QUrl &url) const; |
46 | QMimeType mimeTypeForFileNameAndData(const QString &fileName, QIODevice *device) const; |
47 | QMimeType mimeTypeForFileNameAndData(const QString &fileName, const QByteArray &data) const; |
48 | |
49 | QString suffixForFileName(const QString &fileName) const; |
50 | |
51 | QList<QMimeType> allMimeTypes() const; |
52 | |
53 | private: |
54 | QMimeDatabasePrivate *d; |
55 | }; |
56 | |
57 | QT_END_NAMESPACE |
58 | |
59 | #endif // QMIMEDATABASE_H |
60 | |