48 #include <private/qt_mac_p.h> 64 #ifndef QT_NO_CLIPBOARD 76 return qt_mac_pasteboards[0];
78 return qt_mac_pasteboards[1];
82 delete qt_mac_pasteboards[0];
83 delete qt_mac_pasteboards[1];
84 qt_mac_pasteboards[0] = 0;
85 qt_mac_pasteboards[1] = 0;
90 if(!qt_mac_pasteboards[0]) {
162 #endif // QT_NO_CLIPBOARD 170 mac_mime_source =
false;
178 mac_mime_source =
false;
181 OSStatus err = PasteboardCreate(0, &paste);
183 PasteboardSetPromiseKeeper(paste, promiseKeeper,
this);
185 qDebug(
"PasteBoard: Error creating pasteboard: [%d]", (
int)err);
191 mac_mime_source =
false;
194 OSStatus err = PasteboardCreate(name, &paste);
196 PasteboardSetPromiseKeeper(paste, promiseKeeper,
this);
205 for (
int i = 0; i < promises.count(); ++i) {
206 const Promise &promise = promises.at(i);
208 promiseKeeper(paste, (PasteboardItemID)promise.
itemId, flavor,
this);
224 const long promise_id = (long)
id;
229 for (
int i = 0; i < qpaste->
promises.size(); i++){
237 if (!promise.
itemId && flavorAsQString ==
QLatin1String(
"com.trolltech.qt.MimeTypeName")) {
242 PasteboardPutItemFlavor(paste,
id, flavor, data, kPasteboardFlavorNoFlags);
249 qDebug(
"Pasteboard: %d: Request for %ld, %s, but no promise found!", __LINE__, promise_id,
qPrintable(flavorAsQString));
250 return cantGetFlavorErr;
253 #ifdef DEBUG_PASTEBOARD 254 qDebug(
"PasteBoard: Calling in promise for %s[%ld] [%s] (%s) [%d]",
qPrintable(promise.
mime), promise_id,
260 return cantGetFlavorErr;
263 PasteboardPutItemFlavor(paste,
id, flavor, data, kPasteboardFlavorNoFlags);
276 if(PasteboardGetItemCount(paste, &cnt) || !cnt)
279 #ifdef DEBUG_PASTEBOARD 280 qDebug(
"PasteBoard: hasOSType [%c%c%c%c]", (c_flavor>>24)&0xFF, (c_flavor>>16)&0xFF,
281 (c_flavor>>8)&0xFF, (c_flavor>>0)&0xFF);
286 if(PasteboardGetItemIdentifier(paste,
index, &
id) != noErr)
290 if(PasteboardCopyItemFlavors(paste,
id, &types ) != noErr)
293 const int type_count = CFArrayGetCount(types);
294 for(
int i = 0; i < type_count; ++i) {
296 const int os_flavor = UTGetOSTypeFromString(UTTypeCopyPreferredTagWithClass(flavor, kUTTagClassOSType));
297 if(os_flavor == c_flavor) {
298 #ifdef DEBUG_PASTEBOARD 305 #ifdef DEBUG_PASTEBOARD 320 if(PasteboardGetItemCount(paste, &cnt) || !cnt)
323 #ifdef DEBUG_PASTEBOARD 329 if(PasteboardGetItemIdentifier(paste,
index, &
id) != noErr)
332 PasteboardFlavorFlags flags;
333 if(PasteboardGetItemFlavorFlags(paste,
id,
QCFString(c_flavor), &flags) == noErr) {
334 #ifdef DEBUG_PASTEBOARD 340 #ifdef DEBUG_PASTEBOARD 359 mac_mime_source =
true;
380 if (
mime == mime_src || (!mime_src &&
mime && mac_mime_source))
382 mac_mime_source =
false;
391 #ifdef QT_MAC_USE_COCOA 396 if (!formats.
contains(dummyMimeType)) {
399 formats.
append(dummyMimeType);
403 for(
int f = 0; f < formats.
size(); ++f) {
408 if(!flavor.isEmpty()) {
418 for(
int item = 0; item < numItems; ++item) {
419 const int itemID = item+1;
421 PasteboardPutItemFlavor(paste, (PasteboardItemID)itemID,
QCFString(flavor), 0, kPasteboardFlavorNoFlags);
422 #ifdef DEBUG_PASTEBOARD 423 qDebug(
" - adding %d %s [%s] <%s> [%d]",
443 if(PasteboardGetItemCount(paste, &cnt) || !cnt)
446 #ifdef DEBUG_PASTEBOARD 447 qDebug(
"PasteBoard: Formats [%d]", (
int)cnt);
452 if(PasteboardGetItemIdentifier(paste,
index, &
id) != noErr)
456 if(PasteboardCopyItemFlavors(paste,
id, &types ) != noErr)
459 const int type_count = CFArrayGetCount(types);
460 for(
int i = 0; i < type_count; ++i) {
462 #ifdef DEBUG_PASTEBOARD 467 #ifdef DEBUG_PASTEBOARD 486 if(PasteboardGetItemCount(paste, &cnt) || !cnt)
489 #ifdef DEBUG_PASTEBOARD 495 if(PasteboardGetItemIdentifier(paste,
index, &
id) != noErr)
499 if(PasteboardCopyItemFlavors(paste,
id, &types ) != noErr)
502 const int type_count = CFArrayGetCount(types);
503 for(
int i = 0; i < type_count; ++i) {
505 #ifdef DEBUG_PASTEBOARD 509 #ifdef DEBUG_PASTEBOARD 513 if(mimeType == format)
529 if(PasteboardGetItemCount(paste, &cnt) || !cnt)
532 #ifdef DEBUG_PASTEBOARD 541 bool checkForUtf16 = (c_flavor ==
QLatin1String(
"com.apple.traditional-mac-plain-text")
543 if (checkForUtf16 || c_flavor ==
QLatin1String(
"public.utf16-plain-text")) {
551 if (checkForUtf16 && hasFlavor(
QLatin1String(
"public.utf16-plain-text")))
558 if(PasteboardGetItemIdentifier(paste,
index, &
id) != noErr)
562 if(PasteboardCopyItemFlavors(paste,
id, &types ) != noErr)
565 const int type_count = CFArrayGetCount(types);
566 for(
int i = 0; i < type_count; ++i) {
570 if(PasteboardCopyItemFlavorData(paste,
id, flavor, &macBuffer) == noErr) {
571 QByteArray buffer((
const char *)CFDataGetBytePtr(macBuffer), CFDataGetLength(macBuffer));
573 #ifdef DEBUG_PASTEBOARD 582 #ifdef DEBUG_PASTEBOARD 601 PasteboardClear(paste);
608 #ifdef DEBUG_PASTEBOARD 609 qDebug(
"PasteBoard: clear!");
619 const bool fromGlobal = PasteboardSynchronize(paste) & kPasteboardModified;
624 #ifdef DEBUG_PASTEBOARD 626 qDebug(
"Pasteboard: Synchronize!");
The QVariant class acts like a union for the most common Qt data types.
Mode
This enum type is used to control which part of the system clipboard is used by QClipboard::mimeData(...
const struct __CFString * CFStringRef
void clear(Mode mode=Clipboard)
Clear the clipboard contents.
void emitChanged(Mode mode)
Emits the appropriate changed signal for mode.
#define QT_END_NAMESPACE
This macro expands to.
virtual QStringList formats() const
Returns a list of formats supported by the object.
static QList< QMacPasteboardMime * > all(uchar)
Returns a list of all currently defined QMacPasteboardMime objects of type t.
bool event(QEvent *)
Reimplemented Function
void ownerDestroyed()
Internal cleanup for Windows.
#define it(className, varName)
The QByteArray class provides an array of bytes.
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
static QString toQString(CFStringRef cfstr)
QString qt_mac_get_pasteboardString(OSPasteboardRef paste)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool supportsMode(Mode mode) const
Returns true if the clipboard supports the clipboard mode speacified by mode; otherwise returns false...
int count(const T &t) const
Returns the number of occurrences of value in the list.
QByteArray data(const QString &mimetype) const
Returns the data stored in the object in the format described by the MIME type specified by mimeType...
void setMimeData(QMimeData *data, Mode mode=Clipboard)
Sets the clipboard data to src.
The QString class provides a Unicode character string.
bool ownsMode(Mode mode) const
Returns true if the clipboard supports the clipboard data speacified by mode; otherwise returns false...
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
QVariant variantData(const QString &mime)
static QMacPasteboard * qt_mac_pasteboards[2]
OSPasteboardRef pasteBoard() const
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
virtual QVariant retrieveData(const QString &format, QVariant::Type type) const
Returns a variant with the given type containing data for the MIME type specified by mimeType...
Q_CORE_EXPORT void qDebug(const char *,...)
virtual QString flavorFor(const QString &mime)=0
Returns the Mac UTI used for MIME type mime, or 0 if this convertor does not support mime...
virtual QList< QByteArray > convertFromMime(const QString &mime, QVariant data, QString flav)=0
Returns data converted from MIME type mime to Mac UTI flav.
const QMacPasteboard * paste
virtual QStringList formats() const
Returns a list of formats supported by the object.
void append(const T &t)
Inserts value at the end of the list.
const QMimeData * mimeData(Mode mode=Clipboard) const
Returns a reference to a QMimeData representation of the current clipboard data.
#define QT_BEGIN_NAMESPACE
This macro expands to.
QList< Promise > promises
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
const T & at(int i) const
Returns the item at index position i in the list.
The QStringList class provides a list of strings.
QVariant retrieveData(const QString &format, QVariant::Type) const
static const char * data(const QByteArray &arr)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Type
This enum type defines the types of variable that a QVariant can contain.
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
virtual QVariant convertToMime(const QString &mime, QList< QByteArray > data, QString flav)=0
Returns data converted from Mac UTI flav to MIME type mime.
QList< QUrl > urls() const
Returns a list of URLs contained within the MIME data object.
The QMimeData class provides a container for data that records information about its MIME type...
bool hasFormat(const QString &format) const
The QList::iterator class provides an STL-style non-const iterator for QList and QQueue.
~QMacPasteboardMimeSource()
struct OpaquePasteboardRef * PasteboardRef
const char * constData() const
Returns a pointer to the data stored in the byte array.
virtual bool canConvert(const QString &mime, QString flav)=0
Returns true if the convertor can convert (both ways) between mime and flav; otherwise returns false...
QStringList formats() const
static QString flavorToMime(uchar, QString flav)
Returns a MIME type of type t for flav, or 0 if none exists.
QMacPasteboardMime * convertor
int size() const
Returns the number of items in the list.
void setMimeData(QMimeData *mime)
static void qt_mac_cleanupPasteboard()
bool hasFlavor(QString flavor) const
int size() const
Returns the number of bytes in this byte array.
#define QT_USE_NAMESPACE
This macro expands to using QT_NAMESPACE if QT_NAMESPACE is defined and nothing otherwise.
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
static QMacPasteboard * qt_mac_pasteboard(QClipboard::Mode mode)
QMimeData * mimeData() const
The QEvent class is the base class of all event classes.
static bool qt_mac_updateScrap(QClipboard::Mode mode)
#define qPrintable(string)
Type type() const
Returns the event type.
void qAddPostRoutine(QtCleanUpFunction ptr)
Adds a global routine that will be called from the QApplication destructor.
QMacPasteboard(OSPasteboardRef p, uchar mime_type=0)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
The QMacPasteboardMime class converts between a MIME type and a.
static OSStatus promiseKeeper(OSPasteboardRef, PasteboardItemID, CFStringRef, void *)
virtual QString convertorName()=0
Returns a name for the convertor.
void connectNotify(const char *)
Internal optimization for Windows.
QMacPasteboardMimeSource(const QMacPasteboard *p)
bool hasOSType(int c_flavor) const