1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Copyright (C) 2015 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com>
5** Contact: https://www.qt.io/licensing/
6**
7** This file is part of the QtCore module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial License Usage
11** Licensees holding valid commercial Qt licenses may use this file in
12** accordance with the commercial license agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and The Qt Company. For licensing terms
15** and conditions see https://www.qt.io/terms-conditions. For further
16** information use the contact form at https://www.qt.io/contact-us.
17**
18** GNU Lesser General Public License Usage
19** Alternatively, this file may be used under the terms of the GNU Lesser
20** General Public License version 3 as published by the Free Software
21** Foundation and appearing in the file LICENSE.LGPL3 included in the
22** packaging of this file. Please review the following information to
23** ensure the GNU Lesser General Public License version 3 requirements
24** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
25**
26** GNU General Public License Usage
27** Alternatively, this file may be used under the terms of the GNU
28** General Public License version 2.0 or (at your option) the GNU General
29** Public license version 3 or any later version approved by the KDE Free
30** Qt Foundation. The licenses are as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
32** included in the packaging of this file. Please review the following
33** information to ensure the GNU General Public License requirements will
34** be met: https://www.gnu.org/licenses/gpl-2.0.html and
35** https://www.gnu.org/licenses/gpl-3.0.html.
36**
37** $QT_END_LICENSE$
38**
39****************************************************************************/
40
41#ifndef QMIMETYPE_H
42#define QMIMETYPE_H
43
44#include <QtCore/qglobal.h>
45
46QT_REQUIRE_CONFIG(mimetype);
47
48#include <QtCore/qobjectdefs.h>
49#include <QtCore/qshareddata.h>
50#include <QtCore/qstring.h>
51#include <QtCore/qstringlist.h>
52
53QT_BEGIN_NAMESPACE
54
55class QMimeTypePrivate;
56class QMimeType;
57
58Q_CORE_EXPORT size_t qHash(const QMimeType &key, size_t seed = 0) noexcept;
59
60class Q_CORE_EXPORT QMimeType
61{
62 Q_GADGET
63 Q_PROPERTY(bool valid READ isValid CONSTANT)
64 Q_PROPERTY(bool isDefault READ isDefault CONSTANT)
65 Q_PROPERTY(QString name READ name CONSTANT)
66 Q_PROPERTY(QString comment READ comment CONSTANT)
67 Q_PROPERTY(QString genericIconName READ genericIconName CONSTANT)
68 Q_PROPERTY(QString iconName READ iconName CONSTANT)
69 Q_PROPERTY(QStringList globPatterns READ globPatterns CONSTANT)
70 Q_PROPERTY(QStringList parentMimeTypes READ parentMimeTypes CONSTANT)
71 Q_PROPERTY(QStringList allAncestors READ allAncestors CONSTANT)
72 Q_PROPERTY(QStringList aliases READ aliases CONSTANT)
73 Q_PROPERTY(QStringList suffixes READ suffixes CONSTANT)
74 Q_PROPERTY(QString preferredSuffix READ preferredSuffix CONSTANT)
75 Q_PROPERTY(QString filterString READ filterString CONSTANT)
76
77public:
78 QMimeType();
79 QMimeType(const QMimeType &other);
80 QMimeType &operator=(const QMimeType &other);
81 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QMimeType)
82 void swap(QMimeType &other) noexcept
83 {
84 qSwap(d, other.d);
85 }
86 explicit QMimeType(const QMimeTypePrivate &dd);
87 ~QMimeType();
88
89 bool operator==(const QMimeType &other) const;
90
91 inline bool operator!=(const QMimeType &other) const
92 {
93 return !operator==(other);
94 }
95
96 bool isValid() const;
97
98 bool isDefault() const;
99
100 QString name() const;
101 QString comment() const;
102 QString genericIconName() const;
103 QString iconName() const;
104 QStringList globPatterns() const;
105 QStringList parentMimeTypes() const;
106 QStringList allAncestors() const;
107 QStringList aliases() const;
108 QStringList suffixes() const;
109 QString preferredSuffix() const;
110
111 Q_INVOKABLE bool inherits(const QString &mimeTypeName) const;
112
113 QString filterString() const;
114
115protected:
116 friend class QMimeTypeParserBase;
117 friend class MimeTypeMapEntry;
118 friend class QMimeDatabasePrivate;
119 friend class QMimeXMLProvider;
120 friend class QMimeBinaryProvider;
121 friend class QMimeTypePrivate;
122 friend Q_CORE_EXPORT size_t qHash(const QMimeType &key, size_t seed) noexcept;
123
124 QExplicitlySharedDataPointer<QMimeTypePrivate> d;
125};
126
127Q_DECLARE_SHARED(QMimeType)
128
129#ifndef QT_NO_DEBUG_STREAM
130class QDebug;
131Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QMimeType &mime);
132#endif
133
134QT_END_NAMESPACE
135
136#endif // QMIMETYPE_H
137

source code of qtbase/src/corelib/mimetypes/qmimetype.h