Qt 4.8
Public Functions | List of all members
QMacPasteboardMimeUnicodeText Class Reference
Inheritance diagram for QMacPasteboardMimeUnicodeText:
QMacPasteboardMime

Public Functions

bool canConvert (const QString &mime, QString flav)
 Returns true if the convertor can convert (both ways) between mime and flav; otherwise returns false. More...
 
QList< QByteArrayconvertFromMime (const QString &mime, QVariant data, QString flav)
 Returns data converted from MIME type mime to Mac UTI flav. More...
 
QString convertorName ()
 Returns a name for the convertor. More...
 
QVariant convertToMime (const QString &mime, QList< QByteArray > data, QString flav)
 Returns data converted from Mac UTI flav to MIME type mime. More...
 
QString flavorFor (const QString &mime)
 Returns the Mac UTI used for MIME type mime, or 0 if this convertor does not support mime. More...
 
QString mimeFor (QString flav)
 Returns the MIME UTI used for Mac flavor flav, or 0 if this convertor does not support flav. More...
 
 QMacPasteboardMimeUnicodeText ()
 
- Public Functions inherited from QMacPasteboardMime
 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...
 

Additional Inherited Members

- Public Types inherited from QMacPasteboardMime
enum  QMacPasteboardMimeType {
  MIME_DND =0x01, MIME_CLIP =0x02, MIME_QT_CONVERTOR =0x04, MIME_QT3_CONVERTOR =0x08,
  MIME_ALL =MIME_DND|MIME_CLIP
}
 
- Static Public Functions inherited from QMacPasteboardMime
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...
 

Detailed Description

Definition at line 375 of file qmime_mac.cpp.

Constructors and Destructors

◆ QMacPasteboardMimeUnicodeText()

QMacPasteboardMimeUnicodeText::QMacPasteboardMimeUnicodeText ( )
inline

Definition at line 377 of file qmime_mac.cpp.

QMacPasteboardMime(char)
Constructs a new conversion object of type t, adding it to the globally accessed list of available co...
Definition: qmime_mac.cpp:180

Functions

◆ canConvert()

bool QMacPasteboardMimeUnicodeText::canConvert ( const QString mime,
QString  flav 
)
virtual

Returns true if the convertor can convert (both ways) between mime and flav; otherwise returns false.

All subclasses must reimplement this pure virtual function.

Implements QMacPasteboardMime.

Definition at line 418 of file qmime_mac.cpp.

419 {
420  return flavorFor(mime) == flav;
421 }
QString flavorFor(const QString &mime)
Returns the Mac UTI used for MIME type mime, or 0 if this convertor does not support mime...
Definition: qmime_mac.cpp:392

◆ convertFromMime()

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

Returns data converted from MIME type mime to Mac UTI flav.

Note that Mac flavors must all be self-terminating. The return value may contain trailing data.

All subclasses must reimplement this pure virtual function.

Implements QMacPasteboardMime.

Definition at line 444 of file qmime_mac.cpp.

445 {
446  QList<QByteArray> ret;
447  QString string = data.toString();
448  if(flavor == QLatin1String("public.utf8-plain-text"))
449  ret.append(string.toUtf8());
450  else if (flavor == QLatin1String("public.utf16-plain-text"))
451  ret.append(QByteArray((char*)string.utf16(), string.length()*2));
452  return ret;
453 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507

◆ convertorName()

QString QMacPasteboardMimeUnicodeText::convertorName ( )
virtual

Returns a name for the convertor.

All subclasses must reimplement this pure virtual function.

Implements QMacPasteboardMime.

Definition at line 387 of file qmime_mac.cpp.

388 {
389  return QLatin1String("UnicodeText");
390 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString

◆ convertToMime()

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

Returns data converted from Mac UTI flav to MIME type mime.

Note that Mac flavors must all be self-terminating. The input data may contain trailing data.

All subclasses must reimplement this pure virtual function.

Implements QMacPasteboardMime.

Definition at line 423 of file qmime_mac.cpp.

424 {
425  if(data.count() > 1)
426  qWarning("QMacPasteboardMimeUnicodeText: Cannot handle multiple member data");
427  const QByteArray &firstData = data.first();
428  // I can only handle two types (system and unicode) so deal with them that way
429  QVariant ret;
430  if(flavor == QLatin1String("public.utf8-plain-text")) {
431  QCFString str(CFStringCreateWithBytes(kCFAllocatorDefault,
432  reinterpret_cast<const UInt8 *>(firstData.constData()),
433  firstData.size(), CFStringGetSystemEncoding(), false));
434  ret = QString(str);
435  } else if (flavor == QLatin1String("public.utf16-plain-text")) {
436  ret = QString(reinterpret_cast<const QChar *>(firstData.constData()),
437  firstData.size() / sizeof(QChar));
438  } else {
439  qWarning("QMime::convertToMime: unhandled mimetype: %s", qPrintable(mimetype));
440  }
441  return ret;
442 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
Q_CORE_EXPORT void qWarning(const char *,...)
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
#define qPrintable(string)
Definition: qglobal.h:1750

◆ flavorFor()

QString QMacPasteboardMimeUnicodeText::flavorFor ( const QString mime)
virtual

Returns the Mac UTI used for MIME type mime, or 0 if this convertor does not support mime.

All subclasses must reimplement this pure virtual function.

Implements QMacPasteboardMime.

Definition at line 392 of file qmime_mac.cpp.

393 {
394  if (mime == QLatin1String("text/plain"))
395  return QLatin1String("public.utf16-plain-text");
396  int i = mime.indexOf(QLatin1String("charset="));
397  if (i >= 0) {
398  QString cs(mime.mid(i+8).toLower());
399  i = cs.indexOf(QLatin1Char(';'));
400  if (i>=0)
401  cs = cs.left(i);
402  if (cs == QLatin1String("system"))
403  return QLatin1String("public.utf8-plain-text");
404  else if (cs == QLatin1String("iso-10646-ucs-2")
405  || cs == QLatin1String("utf16"))
406  return QLatin1String("public.utf16-plain-text");
407  }
408  return QString();
409 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
Definition: qstring.cpp:5389
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ mimeFor()

QString QMacPasteboardMimeUnicodeText::mimeFor ( QString  flav)
virtual

Returns the MIME UTI used for Mac flavor flav, or 0 if this convertor does not support flav.

All subclasses must reimplement this pure virtual function.

Implements QMacPasteboardMime.

Definition at line 411 of file qmime_mac.cpp.

412 {
413  if (flav == QLatin1String("public.utf16-plain-text") || flav == QLatin1String("public.utf8-plain-text"))
414  return QLatin1String("text/plain");
415  return QString();
416 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83

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