Qt 4.8
Public Types | Public Functions | Static Public Functions | Properties | Related Functions | List of all members
QMacPasteboardMime Class Referenceabstract

The QMacPasteboardMime class converts between a MIME type and a. More...

#include <qmime.h>

Inheritance diagram for QMacPasteboardMime:
QMacPasteboardMimeAny QMacPasteboardMimeFileUri QMacPasteboardMimeHTMLText QMacPasteboardMimePlainText QMacPasteboardMimeTiff QMacPasteboardMimeTypeName QMacPasteboardMimeUnicodeText QMacPasteboardMimeUrl QMacPasteboardMimeVCard

Public Types

enum  QMacPasteboardMimeType {
  MIME_DND =0x01, MIME_CLIP =0x02, MIME_QT_CONVERTOR =0x04, MIME_QT3_CONVERTOR =0x08,
  MIME_ALL =MIME_DND|MIME_CLIP
}
 

Public Functions

virtual bool canConvert (const QString &mime, QString flav)=0
 Returns true if the convertor can convert (both ways) between mime and flav; otherwise returns false. More...
 
virtual QList< QByteArrayconvertFromMime (const QString &mime, QVariant data, QString flav)=0
 Returns data converted from MIME type mime to Mac UTI flav. More...
 
virtual QString convertorName ()=0
 Returns a name for the convertor. More...
 
virtual QVariant convertToMime (const QString &mime, QList< QByteArray > data, QString flav)=0
 Returns data converted from Mac UTI flav to MIME type mime. More...
 
virtual QString flavorFor (const QString &mime)=0
 Returns the Mac UTI used for MIME type mime, or 0 if this convertor does not support mime. More...
 
virtual QString mimeFor (QString flav)=0
 Returns the MIME UTI used for Mac flavor flav, or 0 if this convertor does not support flav. More...
 
 QMacPasteboardMime (char)
 Constructs a new conversion object of type t, adding it to the globally accessed list of available convertors. More...
 
virtual ~QMacPasteboardMime ()
 Destroys a conversion object, removing it from the global list of available convertors. More...
 

Static Public Functions

static QList< QMacPasteboardMime * > all (uchar)
 Returns a list of all currently defined QMacPasteboardMime objects of type t. More...
 
static QMacPasteboardMimeconvertor (uchar, const QString &mime, QString flav)
 Returns the most-recently created QMacPasteboardMime of type t that can convert between the mime and flav formats. More...
 
static QString flavorToMime (uchar, QString flav)
 Returns a MIME type of type t for flav, or 0 if none exists. More...
 
static void initialize ()
 This is an internal function. More...
 

Properties

char type
 

Related Functions

(Note that these are not member functions.)

void qRegisterDraggedTypes (const QStringList &types)
 Registers the given types as custom pasteboard types. More...
 

Detailed Description

The QMacPasteboardMime class converts between a MIME type and a.

Uniform Type Identifier (UTI) format.

Since
4.2

Qt's drag and drop and clipboard facilities use the MIME standard. On X11, this maps trivially to the Xdnd protocol. On Mac, although some applications use MIME to describe clipboard contents, it is more common to use Apple's UTI format.

QMacPasteboardMime's role is to bridge the gap between MIME and UTI; By subclasses this class, one can extend Qt's drag and drop and clipboard handling to convert to and from unsupported, or proprietary, UTI formats.

A subclass of QMacPasteboardMime will automatically be registered, and active, upon instantiation.

Qt has predefined support for the following UTIs:

When working with MIME data, Qt will interate through all instances of QMacPasteboardMime to find an instance that can convert to, or from, a specific MIME type. It will do this by calling canConvert() on each instance, starting with (and choosing) the last created instance first. The actual conversions will be done by using convertToMime() and convertFromMime().

Note
The API uses the term "flavor" in some cases. This is for backwards compatibility reasons, and should now be understood as UTIs.

Definition at line 141 of file qmime.h.

Enumerations

◆ QMacPasteboardMimeType

Warning
This function is not part of the public interface.
Enumerator
MIME_DND 
MIME_CLIP 
MIME_QT_CONVERTOR 
MIME_QT3_CONVERTOR 
MIME_ALL 

Definition at line 144 of file qmime.h.

Constructors and Destructors

◆ QMacPasteboardMime()

QMacPasteboardMime::QMacPasteboardMime ( char  t)
explicit

Constructs a new conversion object of type t, adding it to the globally accessed list of available convertors.

Definition at line 180 of file qmime_mac.cpp.

Referenced by QMacPasteboardMimeHTMLText::convertFromMime(), and QMacPasteboardMimeVCard::convertFromMime().

180  : type(t)
181 {
182  globalMimeList()->append(this);
183 }

◆ ~QMacPasteboardMime()

QMacPasteboardMime::~QMacPasteboardMime ( )
virtual

Destroys a conversion object, removing it from the global list of available convertors.

Definition at line 189 of file qmime_mac.cpp.

190 {
192  globalMimeList()->removeAll(this);
193 }
static bool closingDown()
Returns true if the application objects are being destroyed; otherwise returns false.

Functions

◆ all()

QList< QMacPasteboardMime * > QMacPasteboardMime::all ( uchar  t)
static

Returns a list of all currently defined QMacPasteboardMime objects of type t.

Definition at line 1244 of file qmime_mac.cpp.

Referenced by QMacPasteboard::retrieveData(), and QMacPasteboard::setMimeData().

1245 {
1246  MimeList ret;
1247  MimeList *mimes = globalMimeList();
1248  for(MimeList::const_iterator it = mimes->constBegin(); it != mimes->constEnd(); ++it) {
1249  if((*it)->type & t)
1250  ret.append((*it));
1251  }
1252  return ret;
1253 }
#define it(className, varName)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
Definition: qlist.h:228
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272

◆ canConvert()

bool QMacPasteboardMime::canConvert ( const QString mime,
QString  flav 
)
pure virtual

◆ convertFromMime()

QList< QByteArray > QMacPasteboardMime::convertFromMime ( const QString mime,
QVariant  data,
QString  flav 
)
pure virtual

◆ convertor()

QMacPasteboardMime * QMacPasteboardMime::convertor ( uchar  t,
const QString mime,
QString  flav 
)
static

Returns the most-recently created QMacPasteboardMime of type t that can convert between the mime and flav formats.

Returns 0 if no such convertor exists.

Definition at line 1196 of file qmime_mac.cpp.

1197 {
1198  MimeList *mimes = globalMimeList();
1199  for(MimeList::const_iterator it = mimes->constBegin(); it != mimes->constEnd(); ++it) {
1200 #ifdef DEBUG_MIME_MAPS
1201  qDebug("QMacPasteboardMime::convertor: seeing if %s (%d) can convert %s to %d[%c%c%c%c] [%d]",
1202  (*it)->convertorName().toLatin1().constData(),
1203  (*it)->type & t, mime.toLatin1().constData(),
1204  flav, (flav >> 24) & 0xFF, (flav >> 16) & 0xFF, (flav >> 8) & 0xFF, (flav) & 0xFF,
1205  (*it)->canConvert(mime,flav));
1206  for(int i = 0; i < (*it)->countFlavors(); ++i) {
1207  int f = (*it)->flavor(i);
1208  qDebug(" %d) %d[%c%c%c%c] [%s]", i, f,
1209  (f >> 24) & 0xFF, (f >> 16) & 0xFF, (f >> 8) & 0xFF, (f) & 0xFF,
1210  (*it)->convertorName().toLatin1().constData());
1211  }
1212 #endif
1213  if(((*it)->type & t) && (*it)->canConvert(mime, flav))
1214  return (*it);
1215  }
1216  return 0;
1217 }
#define it(className, varName)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
Definition: qlist.h:228
Q_CORE_EXPORT void qDebug(const char *,...)
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272

◆ convertorName()

QString QMacPasteboardMime::convertorName ( )
pure virtual

◆ convertToMime()

QVariant QMacPasteboardMime::convertToMime ( const QString mime,
QList< QByteArray data,
QString  flav 
)
pure virtual

◆ flavorFor()

QString QMacPasteboardMime::flavorFor ( const QString mime)
pure virtual

◆ flavorToMime()

QString QMacPasteboardMime::flavorToMime ( uchar  t,
QString  flav 
)
static

Returns a MIME type of type t for flav, or 0 if none exists.

Definition at line 1221 of file qmime_mac.cpp.

Referenced by QMacPasteboard::formats(), and QMacPasteboard::hasFormat().

1222 {
1223  MimeList *mimes = globalMimeList();
1224  for(MimeList::const_iterator it = mimes->constBegin(); it != mimes->constEnd(); ++it) {
1225 #ifdef DEBUG_MIME_MAPS
1226  qDebug("QMacMIme::flavorToMime: attempting %s (%d) for flavor %d[%c%c%c%c] [%s]",
1227  (*it)->convertorName().toLatin1().constData(),
1228  (*it)->type & t, flav, (flav >> 24) & 0xFF, (flav >> 16) & 0xFF, (flav >> 8) & 0xFF, (flav) & 0xFF,
1229  (*it)->mimeFor(flav).toLatin1().constData());
1230 
1231 #endif
1232  if((*it)->type & t) {
1233  QString mimeType = (*it)->mimeFor(flav);
1234  if(!mimeType.isNull())
1235  return mimeType;
1236  }
1237  }
1238  return QString();
1239 }
#define it(className, varName)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
Definition: qlist.h:228
The QString class provides a Unicode character string.
Definition: qstring.h:83
Q_CORE_EXPORT void qDebug(const char *,...)
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272

◆ initialize()

void QMacPasteboardMime::initialize ( )
static

This is an internal function.

Warning
This function is not part of the public interface.

Definition at line 1162 of file qmime_mac.cpp.

Referenced by qt_init().

1163 {
1164  if(globalMimeList()->isEmpty()) {
1166 
1167  //standard types that we wrap
1169 #ifdef Q_WS_MAC32
1170  // 10.6 does automatic synthesis to and from PICT to standard image types (like TIFF),
1171  // so don't bother doing it ourselves, especially since it's not available in 64-bit.
1173  new QMacPasteboardMimePict;
1174 #endif
1182  //make sure our "non-standard" types are always last! --Sam
1184 #ifdef QT3_SUPPORT
1185  new QMacPasteboardMimeQt3Any;
1186 #endif
1187  }
1188 }
static void cleanup_mimes()
Definition: qmime_mac.cpp:84
void qAddPostRoutine(QtCleanUpFunction p)
static bool isEmpty(const char *str)
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
Definition: qglobal.h:1646

◆ mimeFor()

QString QMacPasteboardMime::mimeFor ( QString  flav)
pure virtual

Friends and Related Functions

◆ qRegisterDraggedTypes()

void qRegisterDraggedTypes ( const QStringList types)
related

Registers the given types as custom pasteboard types.

This function should be called to enable the Drag and Drop events for custom pasteboard types on Cocoa implementations. This is required in addition to a QMacPasteboardMime subclass implementation. By default drag and drop is enabled for all standard pasteboard types.

See also
QMacPasteboardMime

Properties

◆ type

char QMacPasteboardMime::type
private

Definition at line 142 of file qmime.h.


The documentation for this class was generated from the following files: