Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef KLFMIME_H
00025 #define KLFMIME_H
00026
00027 #include <QString>
00028 #include <QList>
00029 #include <QStringList>
00030 #include <QByteArray>
00031 #include <QMap>
00032 #include <QImage>
00033 #include <QImageWriter>
00034 #include <QMimeData>
00035 #include <QTemporaryFile>
00036
00037 #include <klfdefs.h>
00038 #include <klfbackend.h>
00039
00040
00055 class KLF_EXPORT KLFMimeExporter
00056 {
00057 public:
00058 KLFMimeExporter() { }
00059 virtual ~KLFMimeExporter() { }
00060
00061 virtual QString exporterName() const = 0;
00062
00063 virtual QStringList keys() const = 0;
00064 virtual QByteArray data(const QString& key, const KLFBackend::klfOutput& klfoutput) = 0;
00065
00066
00067
00068
00069
00070
00071 virtual QString windowsFormatName(const QString& key) const { return key; }
00072
00076 virtual bool supportsKey(const QString& key) const;
00077
00080 static KLFMimeExporter * mimeExporterLookup(const QString& key);
00081
00086 static KLFMimeExporter * mimeExporterLookupByName(const QString& exporter, const QString& key = QString());
00087
00088 static QList<KLFMimeExporter *> mimeExporterList();
00093 static void registerMimeExporter(KLFMimeExporter *exporter, bool overrides = true);
00094 static void unregisterMimeExporter(KLFMimeExporter *exporter);
00095
00096 private:
00097 static void initMimeExporterList();
00098 static QList<KLFMimeExporter*> p_mimeExporterList;
00099 };
00100
00103 class KLF_EXPORT KLFMimeExportProfile
00104 {
00105 public:
00106 struct ExportType {
00107 ExportType(const QString& mime = QString(), const QString& win = QString(), const QString& exp = QString())
00108 : mimetype(mime), wintype(win), exporter(exp) { }
00109 QString mimetype;
00110 QString wintype;
00111 QString exporter;
00112 };
00113
00114 KLFMimeExportProfile(const QString& pname, const QString& desc, const QList<ExportType>& exporttypes);
00115 KLFMimeExportProfile(const KLFMimeExportProfile& copy);
00116
00117
00118 QString profileName() const { return p_profileName; }
00119 QString description() const { return p_description; }
00120
00122 inline QList<ExportType> exportTypes() const { return p_exportTypes; }
00124 inline int exportTypesCount() const { return p_exportTypes.size(); }
00126 inline ExportType exportType(int n) const { return p_exportTypes[n]; }
00127
00132 KLFMimeExporter * exporterLookupFor(int n, bool warnNotFound = true) const;
00133
00138 QStringList mimeTypes() const;
00139
00141 int indexOfMimeType(const QString& mimeType) const;
00142
00147 QStringList respectiveWinTypes() const;
00148
00153 QString respectiveWinType(int k) const;
00154
00155
00160 QStringList availableExporterMimeTypes() const;
00161
00162
00163 static QList<KLFMimeExportProfile> exportProfileList();
00164 static void addExportProfile(const KLFMimeExportProfile& exportProfile);
00165
00166 static KLFMimeExportProfile findExportProfile(const QString& pname);
00167
00168 private:
00169
00170 QString p_profileName;
00171 QString p_description;
00172 QList<ExportType> p_exportTypes;
00173
00174 static void ensureLoadedExportProfileList();
00175 static void loadFromXMLFile(const QString& fname);
00176 static QList<KLFMimeExportProfile> p_exportProfileList;
00177 };
00178
00179
00180
00188 class KLF_EXPORT KLFMimeData : public QMimeData
00189 {
00190 Q_OBJECT
00191 public:
00192 KLFMimeData(const QString& exportProfileName, const KLFBackend::klfOutput& output);
00193 virtual ~KLFMimeData();
00194
00195 QStringList formats() const;
00196
00197 protected:
00198 QVariant retrieveData(const QString &mimetype, QVariant::Type type) const;
00199
00200 private:
00201 KLFMimeExportProfile pExportProfile;
00202 KLFBackend::klfOutput pOutput;
00203
00204 void set_possible_qt_image_data();
00205
00206 mutable QStringList pQtOwnedFormats;
00207 };
00208
00209
00210
00211
00212
00213 #endif