[2] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
| 4 | ** Contact: Qt Software Information ([email protected])
|
---|
| 5 | **
|
---|
| 6 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
| 7 | **
|
---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 9 | ** Commercial Usage
|
---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 13 | ** a written agreement between you and Nokia.
|
---|
| 14 | **
|
---|
| 15 | ** GNU Lesser General Public License Usage
|
---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
| 17 | ** General Public License version 2.1 as published by the Free Software
|
---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
| 19 | ** packaging of this file. Please review the following information to
|
---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
| 22 | **
|
---|
| 23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
| 26 | ** package.
|
---|
| 27 | **
|
---|
| 28 | ** GNU General Public License Usage
|
---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 32 | ** packaging of this file. Please review the following information to
|
---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
| 35 | **
|
---|
| 36 | ** If you are unsure which license is appropriate for your use, please
|
---|
| 37 | ** contact the sales department at [email protected].
|
---|
| 38 | ** $QT_END_LICENSE$
|
---|
| 39 | **
|
---|
| 40 | ****************************************************************************/
|
---|
| 41 |
|
---|
| 42 | #ifndef QMIME_H
|
---|
| 43 | #define QMIME_H
|
---|
| 44 |
|
---|
| 45 | #include <QtCore/qmimedata.h>
|
---|
| 46 |
|
---|
| 47 | QT_BEGIN_HEADER
|
---|
| 48 |
|
---|
| 49 | QT_BEGIN_NAMESPACE
|
---|
| 50 |
|
---|
| 51 | QT_MODULE(Gui)
|
---|
| 52 |
|
---|
| 53 | class Q_GUI_EXPORT QMimeSource
|
---|
| 54 | {
|
---|
| 55 | public:
|
---|
| 56 | virtual ~QMimeSource();
|
---|
| 57 | virtual const char* format(int n = 0) const = 0;
|
---|
| 58 | virtual bool provides(const char*) const;
|
---|
| 59 | virtual QByteArray encodedData(const char*) const = 0;
|
---|
| 60 | };
|
---|
| 61 |
|
---|
| 62 |
|
---|
| 63 | #if defined(Q_WS_WIN)
|
---|
| 64 |
|
---|
| 65 | QT_BEGIN_INCLUDE_NAMESPACE
|
---|
| 66 | typedef struct tagFORMATETC FORMATETC;
|
---|
| 67 | typedef struct tagSTGMEDIUM STGMEDIUM;
|
---|
| 68 | struct IDataObject;
|
---|
| 69 |
|
---|
| 70 | #include <QtCore/qvariant.h>
|
---|
| 71 | QT_END_INCLUDE_NAMESPACE
|
---|
| 72 |
|
---|
| 73 | /*
|
---|
| 74 | Encapsulation of conversion between MIME and Windows CLIPFORMAT.
|
---|
| 75 | Not need on X11, as the underlying protocol uses the MIME standard
|
---|
| 76 | directly.
|
---|
| 77 | */
|
---|
| 78 |
|
---|
| 79 | class Q_GUI_EXPORT QWindowsMime
|
---|
| 80 | {
|
---|
| 81 | public:
|
---|
| 82 | QWindowsMime();
|
---|
| 83 | virtual ~QWindowsMime();
|
---|
| 84 |
|
---|
| 85 | // for converting from Qt
|
---|
| 86 | virtual bool canConvertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const = 0;
|
---|
| 87 | virtual bool convertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData, STGMEDIUM * pmedium) const = 0;
|
---|
| 88 | virtual QVector<FORMATETC> formatsForMime(const QString &mimeType, const QMimeData *mimeData) const = 0;
|
---|
| 89 |
|
---|
| 90 | // for converting to Qt
|
---|
| 91 | virtual bool canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const = 0;
|
---|
| 92 | virtual QVariant convertToMime(const QString &mimeType, IDataObject *pDataObj, QVariant::Type preferredType) const = 0;
|
---|
| 93 | virtual QString mimeForFormat(const FORMATETC &formatetc) const = 0;
|
---|
| 94 |
|
---|
| 95 | static int registerMimeType(const QString &mime);
|
---|
| 96 |
|
---|
| 97 | private:
|
---|
| 98 | friend class QClipboardWatcher;
|
---|
| 99 | friend class QDragManager;
|
---|
| 100 | friend class QDropData;
|
---|
| 101 | friend class QOleDataObject;
|
---|
| 102 |
|
---|
| 103 | static QWindowsMime *converterToMime(const QString &mimeType, IDataObject *pDataObj);
|
---|
| 104 | static QStringList allMimesForFormats(IDataObject *pDataObj);
|
---|
| 105 | static QWindowsMime *converterFromMime(const FORMATETC &formatetc, const QMimeData *mimeData);
|
---|
| 106 | static QVector<FORMATETC> allFormatsForMime(const QMimeData *mimeData);
|
---|
| 107 | };
|
---|
| 108 |
|
---|
| 109 | #endif
|
---|
[321] | 110 | #if defined(Q_WS_PM)
|
---|
| 111 |
|
---|
| 112 | /*
|
---|
| 113 | Encapsulation of conversion between MIME and OS/2 PM clipboard.
|
---|
| 114 | */
|
---|
| 115 |
|
---|
[323] | 116 | typedef unsigned long ULONG;
|
---|
| 117 |
|
---|
[321] | 118 | class Q_GUI_EXPORT QPMMime
|
---|
| 119 | {
|
---|
| 120 | public:
|
---|
| 121 | QPMMime();
|
---|
| 122 | virtual ~QPMMime();
|
---|
[323] | 123 |
|
---|
[338] | 124 | struct MimeCFPair
|
---|
| 125 | {
|
---|
| 126 | MimeCFPair(const QString &m, ULONG f) : mime(m), format(f) {}
|
---|
| 127 | QString mime;
|
---|
| 128 | ULONG format;
|
---|
| 129 | };
|
---|
| 130 |
|
---|
[323] | 131 | // for converting from Qt
|
---|
[338] | 132 | virtual QList<MimeCFPair> formatsForMimeData(const QMimeData *mimeData) const = 0;
|
---|
[324] | 133 | virtual bool convertFromMimeData(const QMimeData *mimeData, ULONG format,
|
---|
| 134 | ULONG &flags, ULONG *data) const = 0;
|
---|
[323] | 135 | // for converting to Qt
|
---|
[334] | 136 | virtual QList<MimeCFPair> mimesForFormats(const QList<ULONG> &formats) const = 0;
|
---|
[324] | 137 | virtual QVariant convertFromFormat(ULONG format, ULONG flags, ULONG data,
|
---|
| 138 | const QString &mimeType,
|
---|
| 139 | QVariant::Type preferredType) const = 0;
|
---|
[323] | 140 |
|
---|
[337] | 141 | protected:
|
---|
| 142 |
|
---|
[323] | 143 | static ULONG registerMimeType(const QString &mime);
|
---|
[347] | 144 | static void unregisterMimeType(ULONG mimeId);
|
---|
[323] | 145 |
|
---|
[332] | 146 | static ULONG allocateMemory(size_t size);
|
---|
| 147 | static void freeMemory(ULONG addr);
|
---|
| 148 |
|
---|
[337] | 149 | static QString formatName(ULONG format);
|
---|
| 150 |
|
---|
[323] | 151 | private:
|
---|
| 152 | friend class QClipboardWatcher;
|
---|
[326] | 153 | friend class QClipboardData;
|
---|
[324] | 154 | friend class QClipboard;
|
---|
[323] | 155 |
|
---|
[324] | 156 | struct Match
|
---|
| 157 | {
|
---|
[334] | 158 | Match(QPMMime *c, const QString f, ULONG cf, int p) :
|
---|
| 159 | converter(c), mime(f), format(cf), priority(p) {}
|
---|
[324] | 160 |
|
---|
| 161 | QPMMime *converter;
|
---|
[338] | 162 | QString mime;
|
---|
| 163 | ULONG format;
|
---|
[324] | 164 | int priority;
|
---|
| 165 | };
|
---|
| 166 |
|
---|
| 167 | static QList<Match> allConvertersFromFormats(const QList<ULONG> &formats);
|
---|
| 168 | static QList<Match> allConvertersFromMimeData(const QMimeData *mimeData);
|
---|
[321] | 169 | };
|
---|
| 170 |
|
---|
| 171 | #endif
|
---|
[2] | 172 | #if defined(Q_WS_MAC)
|
---|
| 173 |
|
---|
| 174 | /*
|
---|
| 175 | Encapsulation of conversion between MIME and Mac flavor.
|
---|
| 176 | Not needed on X11, as the underlying protocol uses the MIME standard
|
---|
| 177 | directly.
|
---|
| 178 | */
|
---|
| 179 |
|
---|
| 180 | class Q_GUI_EXPORT QMacMime { //Obsolete
|
---|
| 181 | char type;
|
---|
| 182 | public:
|
---|
| 183 | enum QMacMimeType { MIME_DND=0x01, MIME_CLIP=0x02, MIME_QT_CONVERTOR=0x04, MIME_ALL=MIME_DND|MIME_CLIP };
|
---|
| 184 | explicit QMacMime(char) { }
|
---|
| 185 | virtual ~QMacMime() { }
|
---|
| 186 |
|
---|
| 187 | static void initialize() { }
|
---|
| 188 |
|
---|
| 189 | static QList<QMacMime*> all(QMacMimeType) { return QList<QMacMime*>(); }
|
---|
| 190 | static QMacMime *convertor(QMacMimeType, const QString &, int) { return 0; }
|
---|
| 191 | static QString flavorToMime(QMacMimeType, int) { return QString(); }
|
---|
| 192 |
|
---|
| 193 | virtual QString convertorName()=0;
|
---|
| 194 | virtual int countFlavors()=0;
|
---|
| 195 | virtual int flavor(int index)=0;
|
---|
| 196 | virtual bool canConvert(const QString &mime, int flav)=0;
|
---|
| 197 | virtual QString mimeFor(int flav)=0;
|
---|
| 198 | virtual int flavorFor(const QString &mime)=0;
|
---|
| 199 | virtual QVariant convertToMime(const QString &mime, QList<QByteArray> data, int flav)=0;
|
---|
| 200 | virtual QList<QByteArray> convertFromMime(const QString &mime, QVariant data, int flav)=0;
|
---|
| 201 | };
|
---|
| 202 |
|
---|
| 203 | class Q_GUI_EXPORT QMacPasteboardMime {
|
---|
| 204 | char type;
|
---|
| 205 | public:
|
---|
| 206 | enum QMacPasteboardMimeType { MIME_DND=0x01,
|
---|
| 207 | MIME_CLIP=0x02,
|
---|
| 208 | MIME_QT_CONVERTOR=0x04,
|
---|
| 209 | MIME_QT3_CONVERTOR=0x08,
|
---|
| 210 | MIME_ALL=MIME_DND|MIME_CLIP
|
---|
| 211 | };
|
---|
| 212 | explicit QMacPasteboardMime(char);
|
---|
| 213 | virtual ~QMacPasteboardMime();
|
---|
| 214 |
|
---|
| 215 | static void initialize();
|
---|
| 216 |
|
---|
| 217 | static QList<QMacPasteboardMime*> all(uchar);
|
---|
| 218 | static QMacPasteboardMime *convertor(uchar, const QString &mime, QString flav);
|
---|
| 219 | static QString flavorToMime(uchar, QString flav);
|
---|
| 220 |
|
---|
| 221 | virtual QString convertorName() = 0;
|
---|
| 222 |
|
---|
| 223 | virtual bool canConvert(const QString &mime, QString flav) = 0;
|
---|
| 224 | virtual QString mimeFor(QString flav) = 0;
|
---|
| 225 | virtual QString flavorFor(const QString &mime) = 0;
|
---|
| 226 | virtual QVariant convertToMime(const QString &mime, QList<QByteArray> data, QString flav) = 0;
|
---|
| 227 | virtual QList<QByteArray> convertFromMime(const QString &mime, QVariant data, QString flav) = 0;
|
---|
| 228 | };
|
---|
| 229 |
|
---|
| 230 | // ### Qt 5: Add const QStringList& QMacPasteboardMime::supportedFlavours()
|
---|
| 231 | Q_GUI_EXPORT void qRegisterDraggedTypes(const QStringList &types);
|
---|
| 232 | #endif // Q_WS_MAC
|
---|
| 233 |
|
---|
| 234 | QT_END_NAMESPACE
|
---|
| 235 |
|
---|
| 236 | QT_END_HEADER
|
---|
| 237 |
|
---|
| 238 | #endif // QMIME_H
|
---|