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 QMIMETYPE_H |
6 | #define QMIMETYPE_H |
7 | |
8 | #include <QtCore/qglobal.h> |
9 | |
10 | QT_REQUIRE_CONFIG(mimetype); |
11 | |
12 | #include <QtCore/qobjectdefs.h> |
13 | #include <QtCore/qshareddata.h> |
14 | #include <QtCore/qstring.h> |
15 | #include <QtCore/qstringlist.h> |
16 | |
17 | QT_BEGIN_NAMESPACE |
18 | |
19 | class QMimeTypePrivate; |
20 | class QMimeType; |
21 | |
22 | Q_CORE_EXPORT size_t qHash(const QMimeType &key, size_t seed = 0) noexcept; |
23 | |
24 | class Q_CORE_EXPORT QMimeType |
25 | { |
26 | Q_GADGET |
27 | Q_PROPERTY(bool valid READ isValid CONSTANT) |
28 | Q_PROPERTY(bool isDefault READ isDefault CONSTANT) |
29 | Q_PROPERTY(QString name READ name CONSTANT) |
30 | Q_PROPERTY(QString comment READ comment CONSTANT) |
31 | Q_PROPERTY(QString genericIconName READ genericIconName CONSTANT) |
32 | Q_PROPERTY(QString iconName READ iconName CONSTANT) |
33 | Q_PROPERTY(QStringList globPatterns READ globPatterns CONSTANT) |
34 | Q_PROPERTY(QStringList parentMimeTypes READ parentMimeTypes CONSTANT) |
35 | Q_PROPERTY(QStringList allAncestors READ allAncestors CONSTANT) |
36 | Q_PROPERTY(QStringList aliases READ aliases CONSTANT) |
37 | Q_PROPERTY(QStringList suffixes READ suffixes CONSTANT) |
38 | Q_PROPERTY(QString preferredSuffix READ preferredSuffix CONSTANT) |
39 | Q_PROPERTY(QString filterString READ filterString CONSTANT) |
40 | |
41 | public: |
42 | QMimeType(); |
43 | QMimeType(const QMimeType &other); |
44 | QMimeType &operator=(const QMimeType &other); |
45 | QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QMimeType) |
46 | void swap(QMimeType &other) noexcept |
47 | { |
48 | d.swap(other&: other.d); |
49 | } |
50 | explicit QMimeType(const QMimeTypePrivate &dd); |
51 | ~QMimeType(); |
52 | |
53 | bool operator==(const QMimeType &other) const; |
54 | |
55 | inline bool operator!=(const QMimeType &other) const |
56 | { |
57 | return !operator==(other); |
58 | } |
59 | |
60 | bool isValid() const; |
61 | |
62 | bool isDefault() const; |
63 | |
64 | QString name() const; |
65 | QString () const; |
66 | QString genericIconName() const; |
67 | QString iconName() const; |
68 | QStringList globPatterns() const; |
69 | QStringList parentMimeTypes() const; |
70 | QStringList allAncestors() const; |
71 | QStringList aliases() const; |
72 | QStringList suffixes() const; |
73 | QString preferredSuffix() const; |
74 | |
75 | Q_INVOKABLE bool inherits(const QString &mimeTypeName) const; |
76 | |
77 | QString filterString() const; |
78 | |
79 | protected: |
80 | friend class QMimeTypeParserBase; |
81 | friend class MimeTypeMapEntry; |
82 | friend class QMimeDatabasePrivate; |
83 | friend class QMimeXMLProvider; |
84 | friend class QMimeBinaryProvider; |
85 | friend class QMimeTypePrivate; |
86 | friend Q_CORE_EXPORT size_t qHash(const QMimeType &key, size_t seed) noexcept; |
87 | |
88 | QExplicitlySharedDataPointer<QMimeTypePrivate> d; |
89 | }; |
90 | |
91 | Q_DECLARE_SHARED(QMimeType) |
92 | |
93 | #ifndef QT_NO_DEBUG_STREAM |
94 | class QDebug; |
95 | Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QMimeType &mime); |
96 | #endif |
97 | |
98 | QT_END_NAMESPACE |
99 | |
100 | #endif // QMIMETYPE_H |
101 | |