![]() |
Qt 6.x
The Qt SDK
|
The QUtiMimeConverter class converts between a MIME type and a \l{https://developer.apple.com/documentation/uniformtypeidentifiers} {Uniform Type Identifier (UTI)} format. More...
#include <qutimimeconverter.h>
Public Types | |
enum class | HandlerScopeFlag : uint8_t { DnD = 0x01 , Clipboard = 0x02 , Qt_compatible = 0x04 , Qt3_compatible = 0x08 , All = DnD|Clipboard , AllCompatible = All|Qt_compatible } |
Public Member Functions | |
QUtiMimeConverter () | |
Constructs a new conversion object and adds it to the globally accessed list of available converters. | |
virtual | ~QUtiMimeConverter () |
Destroys a conversion object, removing it from the global list of available converters. | |
HandlerScope | scope () const |
bool | canConvert (const QString &mime, const QString &uti) const |
Returns true if the converter can convert (both ways) between mime and uti; otherwise returns false . | |
virtual QList< QByteArray > | convertFromMime (const QString &mime, const QVariant &data, const QString &uti) const =0 |
Returns data converted from MIME type mime to Mac UTI uti. | |
virtual QString | utiForMime (const QString &mime) const =0 |
Returns the Mac UTI used for MIME type mime, or an empty string if this converter does not support converting from mime. | |
virtual QString | mimeForUti (const QString &uti) const =0 |
Returns the MIME type used for Mac UTI uti, or an empty string if this converter does not support converting from uti. | |
virtual QVariant | convertToMime (const QString &mime, const QList< QByteArray > &data, const QString &uti) const =0 |
Returns data converted from Mac UTI uti to MIME type mime. | |
virtual int | count (const QMimeData *mimeData) const |
Returns the item count for the given mimeData. | |
Friends | |
class | QMacMimeTypeName |
class | QMacMimeAny |
Related Symbols | |
(Note that these are not member symbols.) | |
void | qRegisterDraggedTypes (const QStringList &types) |
Registers the given types as custom pasteboard types. | |
The QUtiMimeConverter class converts between a MIME type and a \l{https://developer.apple.com/documentation/uniformtypeidentifiers} {Uniform Type Identifier (UTI)} format.
\inmodule QtGui
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.
QUtiMimeConverter'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 QUtiMimeConverter will automatically be registered, and active, upon instantiation.
Qt has predefined support for the following UTIs: \list
When working with MIME data, Qt will iterate through all instances of QUtiMimeConverter to find find an instance that can convert to, or from, a specific MIME type. It will do this by calling mimeForUti() or utiForMime() on each instance, starting with (and choosing) the last created instance first. The actual conversions will be done by using convertToMime() and convertFromMime().
Definition at line 18 of file qutimimeconverter.h.
|
strong |
Enumerator | |
---|---|
DnD | |
Clipboard | |
Qt_compatible | |
Qt3_compatible | |
All | |
AllCompatible |
Definition at line 22 of file qutimimeconverter.h.
QUtiMimeConverter::QUtiMimeConverter | ( | ) |
Constructs a new conversion object and adds it to the globally accessed list of available converters.
Definition at line 98 of file qutimimeconverter.mm.
|
virtual |
Destroys a conversion object, removing it from the global list of available converters.
Definition at line 107 of file qutimimeconverter.mm.
References QMacMimeRegistry::unregisterMimeConverter().
Returns true
if the converter can convert (both ways) between mime and uti; otherwise returns false
.
Definition at line 37 of file qutimimeconverter.h.
References mime.
Referenced by QMacMimeHTMLText::convertFromMime(), QMacMimeRtfText::convertFromMime(), QMacMimeFileUri::convertFromMime(), QMacMimeUrl::convertFromMime(), QMacMimeVCard::convertFromMime(), QMacMimeTiff::convertFromMime(), QMacMimeHTMLText::convertToMime(), QMacMimeRtfText::convertToMime(), QMacMimeFileUri::convertToMime(), QMacMimeUrl::convertToMime(), QMacMimeVCard::convertToMime(), and QMacMimeTiff::convertToMime().
|
pure virtual |
Returns data converted from MIME type mime to Mac UTI uti.
Note that Mac UTIs must all be self-terminating. The return value may contain trailing data.
All subclasses must reimplement this pure virtual function.
Implemented in QMacMimeAny, QMacMimeTypeName, QMacMimePlainTextFallback, QMacMimeUnicodeText, QMacMimeHTMLText, QMacMimeRtfText, QMacMimeFileUri, QMacMimeUrl, QMacMimeVCard, QMacMimeTiff, and QMacMimeTraditionalMacPlainText.
|
pure virtual |
Returns data converted from Mac UTI uti to MIME type mime.
Note that Mac UTIs must all be self-terminating. The input data may contain trailing data.
All subclasses must reimplement this pure virtual function.
Implemented in QMacMimeAny, QMacMimeTypeName, QMacMimePlainTextFallback, QMacMimeUnicodeText, QMacMimeHTMLText, QMacMimeRtfText, QMacMimeFileUri, QMacMimeUrl, QMacMimeVCard, QMacMimeTiff, and QMacMimeTraditionalMacPlainText.
|
virtual |
Returns the item count for the given mimeData.
Reimplemented in QMacMimeFileUri.
Definition at line 115 of file qutimimeconverter.mm.
Returns the MIME type used for Mac UTI uti, or an empty string if this converter does not support converting from uti.
All subclasses must reimplement this pure virtual function.
Implemented in QMacMimeAny, QMacMimeTypeName, QMacMimePlainTextFallback, QMacMimeUnicodeText, QMacMimeHTMLText, QMacMimeRtfText, QMacMimeFileUri, QMacMimeUrl, QMacMimeVCard, QMacMimeTiff, and QMacMimeTraditionalMacPlainText.
|
inline |
Definition at line 36 of file qutimimeconverter.h.
Returns the Mac UTI used for MIME type mime, or an empty string if this converter does not support converting from mime.
All subclasses must reimplement this pure virtual function.
Implemented in QMacMimeAny, QMacMimeTypeName, QMacMimePlainTextFallback, QMacMimeUnicodeText, QMacMimeHTMLText, QMacMimeRtfText, QMacMimeFileUri, QMacMimeUrl, QMacMimeVCard, QMacMimeTiff, and QMacMimeTraditionalMacPlainText.
|
friend |
Definition at line 50 of file qutimimeconverter.h.
|
friend |
Definition at line 49 of file qutimimeconverter.h.
|
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 QUtiMimeConverter subclass implementation. By default drag and drop is enabled for all standard pasteboard types.