- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qmime.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtGui module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    00039 **
    00040 ****************************************************************************/
    00041
    00042 #ifndef QMIME_H
    00043 #define QMIME_H
    00044
    00045 #include <QtCore/qmimedata.h>
    00046
    00047 QT_BEGIN_HEADER
    00048
    00049 QT_BEGIN_NAMESPACE
    00050
    00051 QT_MODULE(Gui)
    00052
    00053 class Q_GUI_EXPORT QMimeSource
    00054 {
    00055 public:
    00056     virtual ~QMimeSource();
    00057     virtual const char* format(int n = 0) const = 0;
    00058     virtual bool provides(const char*) const;
    00059     virtual QByteArray encodedData(const char*) const = 0;
    00060 };
    00061
    00062
    00063 #if defined(Q_WS_WIN)
    00064
    00065 QT_BEGIN_INCLUDE_NAMESPACE
    00066 typedef struct tagFORMATETC FORMATETC;
    00067 typedef struct tagSTGMEDIUM STGMEDIUM;
    00068 struct IDataObject;
    00069
    00070 #include <QtCore/qvariant.h>
    00071 QT_END_INCLUDE_NAMESPACE
    00072
    00073 /*
    00074   Encapsulation of conversion between MIME and Windows CLIPFORMAT.
    00075   Not need on X11, as the underlying protocol uses the MIME standard
    00076   directly.
    00077 */
    00078
    00079 class Q_GUI_EXPORT QWindowsMime
    00080 {
    00081 public:
    00082     QWindowsMime();
    00083     virtual ~QWindowsMime();
    00084
    00085     // for converting from Qt
    00086     virtual bool canConvertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const = 0;
    00087     virtual bool convertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData, STGMEDIUM * pmedium) const = 0;
    00088     virtual QVector<FORMATETC> formatsForMime(const QString &mimeType, const QMimeData *mimeData) const = 0;
    00089
    00090     // for converting to Qt
    00091     virtual bool canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const = 0;
    00092     virtual QVariant convertToMime(const QString &mimeType, IDataObject *pDataObj, QVariant::Type preferredType) const = 0;
    00093     virtual QString mimeForFormat(const FORMATETC &formatetc) const = 0;
    00094
    00095     static int registerMimeType(const QString &mime);
    00096
    00097 private:
    00098     friend class QClipboardWatcher;
    00099     friend class QDragManager;
    00100     friend class QDropData;
    00101     friend class QOleDataObject;
    00102
    00103     static QWindowsMime *converterToMime(const QString &mimeType, IDataObject *pDataObj);
    00104     static QStringList allMimesForFormats(IDataObject *pDataObj);
    00105     static QWindowsMime *converterFromMime(const FORMATETC &formatetc, const QMimeData *mimeData);
    00106     static QVector<FORMATETC> allFormatsForMime(const QMimeData *mimeData);
    00107 };
    00108
    00109 #endif
    00110 #if defined(Q_WS_MAC)
    00111
    00112 /*
    00113   Encapsulation of conversion between MIME and Mac flavor.
    00114   Not needed on X11, as the underlying protocol uses the MIME standard
    00115   directly.
    00116 */
    00117
    00118 class Q_GUI_EXPORT QMacMime { //Obsolete
    00119     char type;
    00120 public:
    00121     enum QMacMimeType { MIME_DND=0x01, MIME_CLIP=0x02, MIME_QT_CONVERTOR=0x04, MIME_ALL=MIME_DND|MIME_CLIP };
    00122     explicit QMacMime(char) { }
    00123     virtual ~QMacMime() { }
    00124
    00125     static void initialize() { }
    00126
    00127     static QList<QMacMime*> all(QMacMimeType) { return QList<QMacMime*>(); }
    00128     static QMacMime *convertor(QMacMimeType, const QString &, int) { return 0; }
    00129     static QString flavorToMime(QMacMimeType, int) { return QString(); }
    00130
    00131     virtual QString convertorName()=0;
    00132     virtual int countFlavors()=0;
    00133     virtual int flavor(int index)=0;
    00134     virtual bool canConvert(const QString &mime, int flav)=0;
    00135     virtual QString mimeFor(int flav)=0;
    00136     virtual int flavorFor(const QString &mime)=0;
    00137     virtual QVariant convertToMime(const QString &mime, QList<QByteArray> data, int flav)=0;
    00138     virtual QList<QByteArray> convertFromMime(const QString &mime, QVariant data, int flav)=0;
    00139 };
    00140
    00141 class Q_GUI_EXPORT QMacPasteboardMime {
    00142     char type;
    00143 public:
    00144     enum QMacPasteboardMimeType { MIME_DND=0x01,
    00145                                   MIME_CLIP=0x02,
    00146                                   MIME_QT_CONVERTOR=0x04,
    00147                                   MIME_QT3_CONVERTOR=0x08,
    00148                                   MIME_ALL=MIME_DND|MIME_CLIP
    00149     };
    00150     explicit QMacPasteboardMime(char);
    00151     virtual ~QMacPasteboardMime();
    00152
    00153     static void initialize();
    00154
    00155     static QList<QMacPasteboardMime*> all(uchar);
    00156     static QMacPasteboardMime *convertor(uchar, const QString &mime, QString flav);
    00157     static QString flavorToMime(uchar, QString flav);
    00158
    00159     virtual QString convertorName() = 0;
    00160
    00161     virtual bool canConvert(const QString &mime, QString flav) = 0;
    00162     virtual QString mimeFor(QString flav) = 0;
    00163     virtual QString flavorFor(const QString &mime) = 0;
    00164     virtual QVariant convertToMime(const QString &mime, QList<QByteArray> data, QString flav) = 0;
    00165     virtual QList<QByteArray> convertFromMime(const QString &mime, QVariant data, QString flav) = 0;
    00166 };
    00167
    00168 // ### Qt 5: Add const QStringList& QMacPasteboardMime::supportedFlavours()
    00169 Q_GUI_EXPORT void qRegisterDraggedTypes(const QStringList &types);
    00170 #endif // Q_WS_MAC
    00171
    00172 QT_END_NAMESPACE
    00173
    00174 QT_END_HEADER
    00175
    00176 #endif // QMIME_H