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

Constructors and Destructors

◆ QMacPasteboardMimeAny()

QMacPasteboardMimeAny::QMacPasteboardMimeAny ( )
inline

Definition at line 199 of file qmime_mac.cpp.

200  }
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

◆ ~QMacPasteboardMimeAny()

QMacPasteboardMimeAny::~QMacPasteboardMimeAny ( )
inline

Definition at line 201 of file qmime_mac.cpp.

201  {
202  }

Functions

◆ canConvert()

bool QMacPasteboardMimeAny::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 234 of file qmime_mac.cpp.

235 {
236  return mimeFor(flav) == mime;
237 }
const char * mime
QString mimeFor(QString flav)
Returns the MIME UTI used for Mac flavor flav, or 0 if this convertor does not support flav...
Definition: qmime_mac.cpp:226

◆ convertFromMime()

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

252 {
253  QList<QByteArray> ret;
254  if (mime == QLatin1String("text/plain"))
255  ret.append(data.toString().toUtf8());
256  else
257  ret.append(data.toByteArray());
258  return ret;
259 }
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
Definition: qstring.cpp:4074
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
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QS...
Definition: qvariant.cpp:2383
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507

◆ convertorName()

QString QMacPasteboardMimeAny::convertorName ( )
virtual

Returns a name for the convertor.

All subclasses must reimplement this pure virtual function.

Implements QMacPasteboardMime.

Definition at line 212 of file qmime_mac.cpp.

213 {
214  return QLatin1String("Any-Mime");
215 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString

◆ convertToMime()

QVariant QMacPasteboardMimeAny::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 239 of file qmime_mac.cpp.

240 {
241  if(data.count() > 1)
242  qWarning("QMacPasteboardMimeAny: Cannot handle multiple member data");
243  QVariant ret;
244  if (mime == QLatin1String("text/plain"))
245  ret = QString::fromUtf8(data.first());
246  else
247  ret = data.first();
248  return ret;
249 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
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
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Definition: qstring.cpp:4302
Q_CORE_EXPORT void qWarning(const char *,...)
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282

◆ flavorFor()

QString QMacPasteboardMimeAny::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 217 of file qmime_mac.cpp.

218 {
219  // do not handle the mime type name in the drag pasteboard
220  if(mime == QLatin1String("application/x-qt-mime-type-name"))
221  return QString();
222  QString ret = QLatin1String("com.trolltech.anymime.") + mime;
223  return ret.replace(QLatin1Char('/'), QLatin1String("--"));
224 }
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
const char * mime
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ mimeFor()

QString QMacPasteboardMimeAny::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 226 of file qmime_mac.cpp.

227 {
228  const QString any_prefix = QLatin1String("com.trolltech.anymime.");
229  if(flav.size() > any_prefix.length() && flav.startsWith(any_prefix))
230  return flav.mid(any_prefix.length()).replace(QLatin1String("--"), QLatin1String("/"));
231  return QString();
232 }
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
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

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