Qt 4.8
Public Functions | List of all members
QMacPasteboardMimePlainText Class Reference
Inheritance diagram for QMacPasteboardMimePlainText:
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...
 
 QMacPasteboardMimePlainText ()
 
- 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 313 of file qmime_mac.cpp.

Constructors and Destructors

◆ QMacPasteboardMimePlainText()

QMacPasteboardMimePlainText::QMacPasteboardMimePlainText ( )
inline

Definition at line 315 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 QMacPasteboardMimePlainText::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 344 of file qmime_mac.cpp.

345 {
346  return flavorFor(mime) == flav;
347 }
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:330

◆ convertFromMime()

QList< QByteArray > QMacPasteboardMimePlainText::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 366 of file qmime_mac.cpp.

367 {
368  QList<QByteArray> ret;
369  QString string = data.toString();
370  if(flavor == QCFString(QLatin1String("com.apple.traditional-mac-plain-text")))
371  ret.append(string.toLatin1());
372  return ret;
373 }
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 QMacPasteboardMimePlainText::convertorName ( )
virtual

Returns a name for the convertor.

All subclasses must reimplement this pure virtual function.

Implements QMacPasteboardMime.

Definition at line 325 of file qmime_mac.cpp.

326 {
327  return QLatin1String("PlainText");
328 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString

◆ convertToMime()

QVariant QMacPasteboardMimePlainText::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 349 of file qmime_mac.cpp.

350 {
351  if(data.count() > 1)
352  qWarning("QMacPasteboardMimePlainText: Cannot handle multiple member data");
353  const QByteArray &firstData = data.first();
354  QVariant ret;
355  if(flavor == QCFString(QLatin1String("com.apple.traditional-mac-plain-text"))) {
356  QCFString str(CFStringCreateWithBytes(kCFAllocatorDefault,
357  reinterpret_cast<const UInt8 *>(firstData.constData()),
358  firstData.size(), CFStringGetSystemEncoding(), false));
359  ret = QString(str);
360  } else {
361  qWarning("QMime::convertToMime: unhandled mimetype: %s", qPrintable(mimetype));
362  }
363  return ret;
364 }
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
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 QMacPasteboardMimePlainText::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 330 of file qmime_mac.cpp.

331 {
332  if (mime == QLatin1String("text/plain"))
333  return QLatin1String("com.apple.traditional-mac-plain-text");
334  return QString();
335 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83

◆ mimeFor()

QString QMacPasteboardMimePlainText::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 337 of file qmime_mac.cpp.

338 {
339  if (flav == QLatin1String("com.apple.traditional-mac-plain-text"))
340  return QLatin1String("text/plain");
341  return QString();
342 }
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: