The QMacPasteboardMime class converts between a MIME type and a UTI (统一类型标识符) 格式。 更多...
头: | #include <QMacPasteboardMime> |
qmake: | QT += macextras |
Since: | Qt 5.2 |
QMacPasteboardMime ( char ) | |
virtual | ~QMacPasteboardMime () |
virtual bool | canConvert (const QString & mime , QString flav ) = 0 |
virtual QList<QByteArray> | convertFromMime (const QString & mime , QVariant data , QString flav ) = 0 |
virtual QVariant | convertToMime (const QString & mime , QList<QByteArray> data , QString flav ) = 0 |
virtual QString | convertorName () = 0 |
virtual int | count (QMimeData * mimeData ) |
virtual QString | flavorFor (const QString & mime ) = 0 |
virtual QString | mimeFor (QString flav ) = 0 |
void | qRegisterDraggedTypes (const QStringList & 类型 ) |
The QMacPasteboardMime class converts between a MIME type and a UTI (统一类型标识符) 格式。
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:
UTI | 转换成 |
---|---|
public.utf8-plain-text
|
text/plain
|
public.utf16-plain-text
|
text/plain
|
public.html
|
text/html
|
public.url
|
text/uri-list
|
public.file-url
|
text/uri-list
|
public.tiff
|
application/x-qt-image
|
public.vcard
|
text/plain
|
com.apple.traditional-mac-plain-text
|
text/plain
|
com.apple.pict
|
application/x-qt-image
|
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 () 和 convertFromMime ().
注意: The API uses the term "flavor" in some cases. This is for backwards compatibility reasons, and should now be understood as UTIs.
Default constructs an instance of QMacPasteboardMime.
[虚拟]
QMacPasteboardMime::
~QMacPasteboardMime
()
Destroys the instance of QMacPasteboardMime. The destructor is virtual.
[pure virtual]
bool
QMacPasteboardMime::
canConvert
(const
QString
&
mime
,
QString
flav
)
Returns true if the converter can convert (both ways) between mime and flav ;否则返回 false。
All subclasses must reimplement this pure virtual function.
[pure virtual]
QList
<
QByteArray
> QMacPasteboardMime::
convertFromMime
(const
QString
&
mime
,
QVariant
data
,
QString
flav
)
返回 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.
[pure virtual]
QVariant
QMacPasteboardMime::
convertToMime
(const
QString
&
mime
,
QList
<
QByteArray
>
data
,
QString
flav
)
返回 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.
[pure virtual]
QString
QMacPasteboardMime::
convertorName
()
Returns a name for the converter.
All subclasses must reimplement this pure virtual function.
[虚拟]
int
QMacPasteboardMime::
count
(
QMimeData
*
mimeData
)
[pure virtual]
QString
QMacPasteboardMime::
flavorFor
(const
QString
&
mime
)
Returns the Mac UTI used for MIME type mime , or 0 if this converter does not support mime .
All subclasses must reimplement this pure virtual function.
[pure virtual]
QString
QMacPasteboardMime::
mimeFor
(
QString
flav
)
Returns the MIME UTI used for Mac flavor flav , or 0 if this converter does not support flav .
All subclasses must reimplement this pure virtual function.
注册给定 类型 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.
另请参阅 QMacPasteboardMime .