home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / include / qmime.h < prev    next >
C/C++ Source or Header  |  2001-10-11  |  5KB  |  162 lines

  1. /****************************************************************************
  2. ** $Id:  qt/qmime.h   3.0.0   edited Jun 22 12:24 $
  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. #ifdef 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. #endif // QT_NO_MIME
  160.  
  161. #endif // QMIME_H
  162.