1 | /****************************************************************************
|
---|
2 | ** $Id: qmime.h 8 2005-11-16 19:36:46Z dmik $
|
---|
3 | **
|
---|
4 | ** Definition of mime classes
|
---|
5 | **
|
---|
6 | ** Created : 981204
|
---|
7 | **
|
---|
8 | ** Copyright (C) 1998-2000 Trolltech AS. All rights reserved.
|
---|
9 | **
|
---|
10 | ** This file is part of the kernel module of the Qt GUI Toolkit.
|
---|
11 | **
|
---|
12 | ** This file may be distributed under the terms of the Q Public License
|
---|
13 | ** as defined by Trolltech AS of Norway and appearing in the file
|
---|
14 | ** LICENSE.QPL included in the packaging of this file.
|
---|
15 | **
|
---|
16 | ** This file may be distributed and/or modified under the terms of the
|
---|
17 | ** GNU General Public License version 2 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
19 | ** packaging of this file.
|
---|
20 | **
|
---|
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
22 | ** licenses may use this file in accordance with the Qt Commercial License
|
---|
23 | ** Agreement provided with the Software.
|
---|
24 | **
|
---|
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
27 | **
|
---|
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
29 | ** information about Qt Commercial License Agreements.
|
---|
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
32 | **
|
---|
33 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
34 | ** not clear to you.
|
---|
35 | **
|
---|
36 | **********************************************************************/
|
---|
37 |
|
---|
38 | #ifndef QMIME_H
|
---|
39 | #define QMIME_H
|
---|
40 |
|
---|
41 | #ifndef QT_H
|
---|
42 | #include "qwindowdefs.h"
|
---|
43 | #include "qmap.h"
|
---|
44 | #endif // QT_H
|
---|
45 |
|
---|
46 | #ifndef QT_NO_MIME
|
---|
47 |
|
---|
48 | class QImageDrag;
|
---|
49 | class QTextDrag;
|
---|
50 |
|
---|
51 | class Q_EXPORT QMimeSource
|
---|
52 | {
|
---|
53 | friend class QClipboardData;
|
---|
54 |
|
---|
55 | public:
|
---|
56 | QMimeSource();
|
---|
57 | virtual ~QMimeSource();
|
---|
58 | virtual const char* format( int n = 0 ) const = 0;
|
---|
59 | virtual bool provides( const char* ) const;
|
---|
60 | virtual QByteArray encodedData( const char* ) const = 0;
|
---|
61 | int serialNumber() const;
|
---|
62 |
|
---|
63 | private:
|
---|
64 | int ser_no;
|
---|
65 | enum { NoCache, Text, Graphics } cacheType;
|
---|
66 | union
|
---|
67 | {
|
---|
68 | struct
|
---|
69 | {
|
---|
70 | QString *str;
|
---|
71 | QCString *subtype;
|
---|
72 | } txt;
|
---|
73 | struct
|
---|
74 | {
|
---|
75 | QImage *img;
|
---|
76 | QPixmap *pix;
|
---|
77 | } gfx;
|
---|
78 | } cache;
|
---|
79 | void clearCache();
|
---|
80 |
|
---|
81 | // friends for caching
|
---|
82 | friend class QImageDrag;
|
---|
83 | friend class QTextDrag;
|
---|
84 |
|
---|
85 | };
|
---|
86 |
|
---|
87 | inline int QMimeSource::serialNumber() const
|
---|
88 | { return ser_no; }
|
---|
89 |
|
---|
90 | class QStringList;
|
---|
91 | class QMimeSourceFactoryData;
|
---|
92 |
|
---|
93 | class Q_EXPORT QMimeSourceFactory {
|
---|
94 | public:
|
---|
95 | QMimeSourceFactory();
|
---|
96 | virtual ~QMimeSourceFactory();
|
---|
97 |
|
---|
98 | static QMimeSourceFactory* defaultFactory();
|
---|
99 | static void setDefaultFactory( QMimeSourceFactory* );
|
---|
100 | static QMimeSourceFactory* takeDefaultFactory();
|
---|
101 | static void addFactory( QMimeSourceFactory *f );
|
---|
102 | static void removeFactory( QMimeSourceFactory *f );
|
---|
103 |
|
---|
104 | virtual const QMimeSource* data(const QString& abs_name) const;
|
---|
105 | virtual QString makeAbsolute(const QString& abs_or_rel_name, const QString& context) const;
|
---|
106 | const QMimeSource* data(const QString& abs_or_rel_name, const QString& context) const;
|
---|
107 |
|
---|
108 | virtual void setText( const QString& abs_name, const QString& text );
|
---|
109 | virtual void setImage( const QString& abs_name, const QImage& im );
|
---|
110 | virtual void setPixmap( const QString& abs_name, const QPixmap& pm );
|
---|
111 | virtual void setData( const QString& abs_name, QMimeSource* data );
|
---|
112 | virtual void setFilePath( const QStringList& );
|
---|
113 | virtual QStringList filePath() const;
|
---|
114 | void addFilePath( const QString& );
|
---|
115 | virtual void setExtensionType( const QString& ext, const char* mimetype );
|
---|
116 |
|
---|
117 | private:
|
---|
118 | QMimeSource *dataInternal(const QString& abs_name, const QMap<QString, QString> &extensions ) const;
|
---|
119 | QMimeSourceFactoryData* d;
|
---|
120 | };
|
---|
121 |
|
---|
122 | #if defined(Q_WS_WIN)
|
---|
123 |
|
---|
124 | #ifndef QT_H
|
---|
125 | #include "qptrlist.h" // down here for GCC 2.7.* compatibility
|
---|
126 | #endif // QT_H
|
---|
127 |
|
---|
128 | /*
|
---|
129 | Encapsulation of conversion between MIME and Windows CLIPFORMAT.
|
---|
130 | Not need on X11, as the underlying protocol uses the MIME standard
|
---|
131 | directly.
|
---|
132 | */
|
---|
133 |
|
---|
134 | class Q_EXPORT QWindowsMime {
|
---|
135 | public:
|
---|
136 | QWindowsMime();
|
---|
137 | virtual ~QWindowsMime();
|
---|
138 |
|
---|
139 | static void initialize();
|
---|
140 |
|
---|
141 | static QPtrList<QWindowsMime> all();
|
---|
142 | static QWindowsMime* convertor( const char* mime, int cf );
|
---|
143 | static const char* cfToMime(int cf);
|
---|
144 |
|
---|
145 | static int registerMimeType(const char *mime);
|
---|
146 |
|
---|
147 | virtual const char* convertorName()=0;
|
---|
148 | virtual int countCf()=0;
|
---|
149 | virtual int cf(int index)=0;
|
---|
150 | virtual bool canConvert( const char* mime, int cf )=0;
|
---|
151 | virtual const char* mimeFor(int cf)=0;
|
---|
152 | virtual int cfFor(const char* )=0;
|
---|
153 | virtual QByteArray convertToMime( QByteArray data, const char* mime, int cf )=0;
|
---|
154 | virtual QByteArray convertFromMime( QByteArray data, const char* mime, int cf )=0;
|
---|
155 | };
|
---|
156 |
|
---|
157 | #endif // Q_WS_WIN
|
---|
158 |
|
---|
159 | #if defined(Q_WS_PM)
|
---|
160 |
|
---|
161 | #ifndef QT_H
|
---|
162 | #include "qptrlist.h" // down here for GCC 2.7.* compatibility
|
---|
163 | #endif // QT_H
|
---|
164 |
|
---|
165 | /*
|
---|
166 | Encapsulation of conversion between MIME and OS/2 PM clipboard formats.
|
---|
167 | Not need on X11, as the underlying protocol uses the MIME standard
|
---|
168 | directly.
|
---|
169 | */
|
---|
170 |
|
---|
171 | class Q_EXPORT QPMMime {
|
---|
172 | public:
|
---|
173 | enum { CFI_Storage = CFI_POINTER & CFI_HANDLE };
|
---|
174 |
|
---|
175 | QPMMime();
|
---|
176 | virtual ~QPMMime();
|
---|
177 |
|
---|
178 | static void initialize();
|
---|
179 |
|
---|
180 | static QPtrList<QPMMime> all();
|
---|
181 | static QPMMime* convertor( const char* mime, ulong cf );
|
---|
182 | static const char* cfToMime( ulong cf );
|
---|
183 |
|
---|
184 | static ulong registerMimeType( const char *mime );
|
---|
185 |
|
---|
186 | virtual const char* convertorName() = 0;
|
---|
187 | virtual int countCf() = 0;
|
---|
188 | virtual ulong cf( int index ) = 0;
|
---|
189 | virtual ulong flFor( ulong cf ) = 0;
|
---|
190 | virtual ulong cfFor( const char* ) = 0;
|
---|
191 | virtual const char* mimeFor( ulong cf ) = 0;
|
---|
192 | virtual bool canConvert( const char* mime, ulong cf ) = 0;
|
---|
193 | virtual QByteArray convertToMime( QByteArray data, const char *mime, ulong cf ) = 0;
|
---|
194 | virtual QByteArray convertFromMime( QByteArray data, const char *mime, ulong cf ) = 0;
|
---|
195 | };
|
---|
196 |
|
---|
197 | #endif // Q_WS_PM
|
---|
198 |
|
---|
199 | #if defined(Q_WS_MAC)
|
---|
200 |
|
---|
201 | #ifndef QT_H
|
---|
202 | #include "qptrlist.h" // down here for GCC 2.7.* compatibility
|
---|
203 | #endif // QT_H
|
---|
204 |
|
---|
205 | /*
|
---|
206 | Encapsulation of conversion between MIME and Mac flavor.
|
---|
207 | Not need on X11, as the underlying protocol uses the MIME standard
|
---|
208 | directly.
|
---|
209 | */
|
---|
210 |
|
---|
211 | class Q_EXPORT QMacMime {
|
---|
212 | char type;
|
---|
213 | public:
|
---|
214 | enum QMacMimeType { MIME_DND=0x01, MIME_CLIP=0x02, MIME_QT_CONVERTOR=0x04, MIME_ALL=MIME_DND|MIME_CLIP };
|
---|
215 | QMacMime(char);
|
---|
216 | virtual ~QMacMime();
|
---|
217 |
|
---|
218 | static void initialize();
|
---|
219 |
|
---|
220 | static QPtrList<QMacMime> all(QMacMimeType);
|
---|
221 | static QMacMime* convertor(QMacMimeType, const char* mime, int flav);
|
---|
222 | static const char* flavorToMime(QMacMimeType, int flav);
|
---|
223 |
|
---|
224 | virtual const char* convertorName()=0;
|
---|
225 | virtual int countFlavors()=0;
|
---|
226 | virtual int flavor(int index)=0;
|
---|
227 | virtual bool canConvert(const char* mime, int flav)=0;
|
---|
228 | virtual const char* mimeFor(int flav)=0;
|
---|
229 | virtual int flavorFor(const char*)=0;
|
---|
230 | virtual QByteArray convertToMime(QValueList<QByteArray> data, const char* mime, int flav)=0;
|
---|
231 | virtual QValueList<QByteArray> convertFromMime(QByteArray data, const char* mime, int flav)=0;
|
---|
232 | };
|
---|
233 |
|
---|
234 | #endif // Q_WS_MAC
|
---|
235 |
|
---|
236 | #endif // QT_NO_MIME
|
---|
237 |
|
---|
238 | #endif // QMIME_H
|
---|