1 // vim: set tabstop=4 shiftwidth=4 expandtab
2 /*
3 Gwenview - A simple image viewer for KDE
4 Copyright 2006 Aurelien Gateau <agateau@kde.org>
5 
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 
20 */
21 #ifndef MIMETYPEUTILS_H
22 #define MIMETYPEUTILS_H
23 
24 #include <QString>
25 #include <lib/gwenviewlib_export.h>
26 // Local
27 class QStringList;
28 
29 class KFileItem;
30 class KFileItemList;
31 class QUrl;
32 class QMimeData;
33 
34 namespace Gwenview
35 {
36 namespace MimeTypeUtils
37 {
38 GWENVIEWLIB_EXPORT const QStringList &rasterImageMimeTypes();
39 GWENVIEWLIB_EXPORT const QStringList &svgImageMimeTypes();
40 GWENVIEWLIB_EXPORT const QStringList &imageMimeTypes();
41 
42 GWENVIEWLIB_EXPORT QString urlMimeType(const QUrl &);
43 
44 enum Kind {
45     KIND_UNKNOWN = 0,
46     KIND_DIR = 1,
47     KIND_ARCHIVE = 1 << 2,
48     KIND_FILE = 1 << 3,
49     KIND_RASTER_IMAGE = 1 << 4,
50     KIND_SVG_IMAGE = 1 << 5,
51     KIND_VIDEO = 1 << 6,
52 };
53 Q_DECLARE_FLAGS(Kinds, Kind)
54 
55 GWENVIEWLIB_EXPORT Kind fileItemKind(const KFileItem &);
56 GWENVIEWLIB_EXPORT Kind urlKind(const QUrl &);
57 GWENVIEWLIB_EXPORT Kind mimeTypeKind(const QString &mimeType);
58 
59 enum MimeTarget {
60     ClipboardTarget,
61     DropTarget,
62 };
63 
64 /**
65  * Returns the image data (and also the URL, unless the image
66  * is edited/unsaved) if there is a single image selected.
67  * Otherwise, returns a list of URLs for all selected images.
68  */
69 GWENVIEWLIB_EXPORT QMimeData *selectionMimeData(const KFileItemList &selectedFiles, MimeTarget mimeTarget);
70 
71 } // namespace MimeTypeUtils
72 
73 } // namespace Gwenview
74 
75 Q_DECLARE_OPERATORS_FOR_FLAGS(Gwenview::MimeTypeUtils::Kinds)
76 
77 #endif /* MIMETYPEUTILS_H */
78