File indexing completed on 2024-05-12 15:59:03
0001 /* 0002 * SPDX-FileCopyrightText: 2016 Boudewijn Rempt <boud@valdyas.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 #ifndef KISMIMEDATABASE_H 0007 #define KISMIMEDATABASE_H 0008 0009 #include <QByteArray> 0010 #include <QString> 0011 #include <QStringList> 0012 #include <QList> 0013 0014 #include "kritaplugin_export.h" 0015 0016 /** 0017 * @brief The KisMimeDatabase class maps file extensions to mimetypes and vice versa 0018 */ 0019 class KRITAPLUGIN_EXPORT KisMimeDatabase 0020 { 0021 public: 0022 0023 /// Find the mimetype for the given filename. The filename must include a suffix. 0024 static QString mimeTypeForFile(const QString &file, bool checkExistingFiles = true); 0025 /// Find the mimetype for a given extension. The extension may have the form "*.xxx" or "xxx" 0026 static QString mimeTypeForSuffix(const QString &suffix); 0027 /// Find the mimetype through analyzing the contents. This does not work for Krita's 0028 /// extended mimetypes. 0029 static QString mimeTypeForData(const QByteArray ba); 0030 /// Find the user-readable description for the given mimetype 0031 static QString descriptionForMimeType(const QString &mimeType); 0032 /// Find the list of possible extensions for the given mimetype. 0033 /// The preferred suffix is the first one. 0034 static QStringList suffixesForMimeType(const QString &mimeType); 0035 /// The default icon name for the given mimetype 0036 static QString iconNameForMimeType(const QString &mimeType); 0037 0038 private: 0039 0040 struct KisMimeType { 0041 QByteArray mimeType; 0042 QStringList suffixes; 0043 QString description; 0044 }; 0045 0046 static QList<KisMimeType> s_mimeDatabase; 0047 static void fillMimeData(); 0048 0049 }; 0050 0051 #endif // KISMIMEDATABASE_H