forked from lxqt/libqtxdg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxdgmimetype.h
128 lines (106 loc) · 4.01 KB
/
xdgmimetype.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
* libqtxdg - An Qt implementation of freedesktop.org xdg specs
* Copyright (C) 2014 Luís Pereira <luis.artur.pereira@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#ifndef QTXDG_MIMETYPE_H
#define QTXDG_MIMETYPE_H
#include <QMimeType>
#include <QIcon>
#include <QString>
#include <QSharedData>
#include <QDebug>
class XdgMimeTypePrivate;
//! Describes types of file or data, represented by a MIME type string.
/*! This class is an QMimeType descendent. The differences are the icon() and
* iconName() methods. @see icon() @see iconName()
*
* Some parts of the documentation are based on QMimeType documentation.
* @see http://qt-project.org/doc/qt-5/qmimetype.html
*
* @author Luís Pereira (luis.artur.pereira@gmail.com)
*/
class XdgMimeType : public QMimeType {
public:
/*! Constructs an XdgMimeType object initialized with default property
values that indicate an invalid MIME type.
@see QMimeType::QMimeType()
*/
XdgMimeType();
/*! Constructs an XdgMimeType object from an QMimeType object
* @see QMimeType
*/
XdgMimeType(const QMimeType& mime);
//! Constructs an XdgMimeType object from another XdgMimeType object
XdgMimeType(const XdgMimeType& mime);
/*! Assigns the data of other to this XdgMimeType object.
* @return a reference to this object.
*/
XdgMimeType &operator=(const XdgMimeType &other);
/*! Compares the other XdgMimeType object to this XdgMimeType object.
* @return true if other equals this XdgMimeType object, otherwise returns
* false. The name is the unique identifier for a mimetype, so two mimetypes
* with the same name, are equal.
* @see QMimeType::operator==()
*/
bool operator==(const XdgMimeType &other) const
{
return QMimeType::operator==(other);
}
inline bool operator!=(const XdgMimeType &other) const
{
return QMimeType::operator==(other);
}
void swap(XdgMimeType &other)
{
QMimeType::swap(other);
qSwap(dx, other.dx);
}
//! Destructs the mimetype
~XdgMimeType();
//! Returns the name of the MIME type.
/*! The same as QMimeType::name(). Provided for compatibilty with deprecated
* XdgMimeInfo::mimeType().
* @see QMimeType::name()
*/
inline QString mimeType() const { return QMimeType::name(); }
//! Returns an icon associated with the mimetype.
/*! @return an icon from the current icon theme associated with the
* mimetype. If the icon theme doesn't provide one it returns QIcon().
* It gets the icon name from iconName() and then gives it to
* XdgIcon::fromTheme().
* @see iconName() @see XdgIcon::fromTheme()
*/
QIcon icon() const;
//! Returns an icon name associated with the mimetype.
/*! @return an icon name from the current icon theme associated with the
* mimetype. If the current icon theme doesn't provide one, it returns an
* empty QString.
* The returned icon name is suitable to be given to XdgIcon::fromTheme()
* to load the icon.
* @see XdgIcon::fromTheme()
*/
QString iconName() const;
protected:
friend class XdgMimeTypePrivate;
QExplicitlySharedDataPointer<XdgMimeTypePrivate> dx;
};
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
#else
Q_DECLARE_SHARED(XdgMimeType)
#endif
#endif // QTXDG_MIMETYPE_H