Qt 4.8
qclipboard_mac.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qclipboard.h"
43 #include "qapplication.h"
44 #include "qbitmap.h"
45 #include "qdatetime.h"
46 #include "qdebug.h"
47 #include "qapplication_p.h"
48 #include <private/qt_mac_p.h>
49 #include "qevent.h"
50 #include "qurl.h"
51 #include <stdlib.h>
52 #include <string.h>
53 #include "qt_cocoa_helpers_mac_p.h"
54 
56 
58 
59 /*****************************************************************************
60  QClipboard debug facilities
61  *****************************************************************************/
62 //#define DEBUG_PASTEBOARD
63 
64 #ifndef QT_NO_CLIPBOARD
65 
66 /*****************************************************************************
67  QClipboard member functions for mac.
68  *****************************************************************************/
69 
70 static QMacPasteboard *qt_mac_pasteboards[2] = {0, 0};
71 
73 {
75  if (mode == QClipboard::Clipboard)
76  return qt_mac_pasteboards[0];
77  else
78  return qt_mac_pasteboards[1];
79 }
80 
81 static void qt_mac_cleanupPasteboard() {
82  delete qt_mac_pasteboards[0];
83  delete qt_mac_pasteboards[1];
84  qt_mac_pasteboards[0] = 0;
85  qt_mac_pasteboards[1] = 0;
86 }
87 
89 {
90  if(!qt_mac_pasteboards[0]) {
91  qt_mac_pasteboards[0] = new QMacPasteboard(kPasteboardClipboard, QMacPasteboardMime::MIME_CLIP);
92  qt_mac_pasteboards[1] = new QMacPasteboard(kPasteboardFind, QMacPasteboardMime::MIME_CLIP);
94  return true;
95  }
96  return qt_mac_pasteboard(mode)->sync();
97 }
98 
100 {
101  if (!supportsMode(mode))
102  return;
103  qt_mac_updateScrap(mode);
104  qt_mac_pasteboard(mode)->clear();
105  setMimeData(0, mode);
106 }
107 
109 {
110 }
111 
112 
113 void QClipboard::connectNotify(const char *signal)
114 {
115  Q_UNUSED(signal);
116 }
117 
119 {
120  if(e->type() != QEvent::Clipboard)
121  return QObject::event(e);
122 
125  }
126 
129  }
130 
131  return QObject::event(e);
132 }
133 
135 {
136  if (!supportsMode(mode))
137  return 0;
138  qt_mac_updateScrap(mode);
139  return qt_mac_pasteboard(mode)->mimeData();
140 }
141 
143 {
144  if (!supportsMode(mode))
145  return;
146  qt_mac_updateScrap(mode);
147  qt_mac_pasteboard(mode)->setMimeData(src);
148  emitChanged(mode);
149 }
150 
152 {
153  return (mode == Clipboard || mode == FindBuffer);
154 }
155 
156 bool QClipboard::ownsMode(Mode mode) const
157 {
158  Q_UNUSED(mode);
159  return false;
160 }
161 
162 #endif // QT_NO_CLIPBOARD
163 
164 /*****************************************************************************
165  QMacPasteboard code
166 *****************************************************************************/
167 
169 {
170  mac_mime_source = false;
171  mime_type = mt ? mt : uchar(QMacPasteboardMime::MIME_ALL);
172  paste = p;
173  CFRetain(paste);
174 }
175 
177 {
178  mac_mime_source = false;
179  mime_type = mt ? mt : uchar(QMacPasteboardMime::MIME_ALL);
180  paste = 0;
181  OSStatus err = PasteboardCreate(0, &paste);
182  if(err == noErr) {
183  PasteboardSetPromiseKeeper(paste, promiseKeeper, this);
184  } else {
185  qDebug("PasteBoard: Error creating pasteboard: [%d]", (int)err);
186  }
187 }
188 
190 {
191  mac_mime_source = false;
192  mime_type = mt ? mt : uchar(QMacPasteboardMime::MIME_ALL);
193  paste = 0;
194  OSStatus err = PasteboardCreate(name, &paste);
195  if(err == noErr) {
196  PasteboardSetPromiseKeeper(paste, promiseKeeper, this);
197  } else {
198  qDebug("PasteBoard: Error creating pasteboard: %s [%d]", QCFString::toQString(name).toLatin1().constData(), (int)err);
199  }
200 }
201 
203 {
204  // commit all promises for paste after exit close
205  for (int i = 0; i < promises.count(); ++i) {
206  const Promise &promise = promises.at(i);
207  QCFString flavor = QCFString(promise.convertor->flavorFor(promise.mime));
208  promiseKeeper(paste, (PasteboardItemID)promise.itemId, flavor, this);
209  }
210 
211  if(paste)
212  CFRelease(paste);
213 }
214 
217 {
218  return paste;
219 }
220 
221 OSStatus QMacPasteboard::promiseKeeper(PasteboardRef paste, PasteboardItemID id, CFStringRef flavor, void *_qpaste)
222 {
223  QMacPasteboard *qpaste = (QMacPasteboard*)_qpaste;
224  const long promise_id = (long)id;
225 
226  // Find the kept promise
227  const QString flavorAsQString = QCFString::toQString(flavor);
228  QMacPasteboard::Promise promise;
229  for (int i = 0; i < qpaste->promises.size(); i++){
230  QMacPasteboard::Promise tmp = qpaste->promises[i];
231  if (tmp.itemId == promise_id && tmp.convertor->canConvert(tmp.mime, flavorAsQString)){
232  promise = tmp;
233  break;
234  }
235  }
236 
237  if (!promise.itemId && flavorAsQString == QLatin1String("com.trolltech.qt.MimeTypeName")) {
238  // we have promised this data, but wont be able to convert, so return null data.
239  // This helps in making the application/x-qt-mime-type-name hidden from normal use.
240  QByteArray ba;
241  QCFType<CFDataRef> data = CFDataCreate(0, (UInt8*)ba.constData(), ba.size());
242  PasteboardPutItemFlavor(paste, id, flavor, data, kPasteboardFlavorNoFlags);
243  return noErr;
244  }
245 
246  if (!promise.itemId) {
247  // There was no promise that could deliver data for the
248  // given id and flavor. This should not happend.
249  qDebug("Pasteboard: %d: Request for %ld, %s, but no promise found!", __LINE__, promise_id, qPrintable(flavorAsQString));
250  return cantGetFlavorErr;
251  }
252 
253 #ifdef DEBUG_PASTEBOARD
254  qDebug("PasteBoard: Calling in promise for %s[%ld] [%s] (%s) [%d]", qPrintable(promise.mime), promise_id,
255  qPrintable(flavorAsQString), qPrintable(promise.convertor->convertorName()), promise.offset);
256 #endif
257 
258  QList<QByteArray> md = promise.convertor->convertFromMime(promise.mime, promise.data, flavorAsQString);
259  if (md.size() <= promise.offset)
260  return cantGetFlavorErr;
261  const QByteArray &ba = md[promise.offset];
262  QCFType<CFDataRef> data = CFDataCreate(0, (UInt8*)ba.constData(), ba.size());
263  PasteboardPutItemFlavor(paste, id, flavor, data, kPasteboardFlavorNoFlags);
264  return noErr;
265 }
266 
267 bool
268 QMacPasteboard::hasOSType(int c_flavor) const
269 {
270  if (!paste)
271  return false;
272 
273  sync();
274 
275  ItemCount cnt = 0;
276  if(PasteboardGetItemCount(paste, &cnt) || !cnt)
277  return false;
278 
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);
282 #endif
283  for(uint index = 1; index <= cnt; ++index) {
284 
285  PasteboardItemID id;
286  if(PasteboardGetItemIdentifier(paste, index, &id) != noErr)
287  return false;
288 
290  if(PasteboardCopyItemFlavors(paste, id, &types ) != noErr)
291  return false;
292 
293  const int type_count = CFArrayGetCount(types);
294  for(int i = 0; i < type_count; ++i) {
295  CFStringRef flavor = (CFStringRef)CFArrayGetValueAtIndex(types, i);
296  const int os_flavor = UTGetOSTypeFromString(UTTypeCopyPreferredTagWithClass(flavor, kUTTagClassOSType));
297  if(os_flavor == c_flavor) {
298 #ifdef DEBUG_PASTEBOARD
299  qDebug(" - Found!");
300 #endif
301  return true;
302  }
303  }
304  }
305 #ifdef DEBUG_PASTEBOARD
306  qDebug(" - NotFound!");
307 #endif
308  return false;
309 }
310 
311 bool
313 {
314  if (!paste)
315  return false;
316 
317  sync();
318 
319  ItemCount cnt = 0;
320  if(PasteboardGetItemCount(paste, &cnt) || !cnt)
321  return false;
322 
323 #ifdef DEBUG_PASTEBOARD
324  qDebug("PasteBoard: hasFlavor [%s]", qPrintable(c_flavor));
325 #endif
326  for(uint index = 1; index <= cnt; ++index) {
327 
328  PasteboardItemID id;
329  if(PasteboardGetItemIdentifier(paste, index, &id) != noErr)
330  return false;
331 
332  PasteboardFlavorFlags flags;
333  if(PasteboardGetItemFlavorFlags(paste, id, QCFString(c_flavor), &flags) == noErr) {
334 #ifdef DEBUG_PASTEBOARD
335  qDebug(" - Found!");
336 #endif
337  return true;
338  }
339  }
340 #ifdef DEBUG_PASTEBOARD
341  qDebug(" - NotFound!");
342 #endif
343  return false;
344 }
345 
348 public:
351  virtual QStringList formats() const { return paste->formats(); }
352  virtual QVariant retrieveData(const QString &format, QVariant::Type type) const { return paste->retrieveData(format, type); }
353 };
354 
355 QMimeData
357 {
358  if(!mime) {
359  mac_mime_source = true;
360  mime = new QMacPasteboardMimeSource(this);
361 
362  }
363  return mime;
364 }
365 
366 class QMacMimeData : public QMimeData
367 {
368 public:
369  QVariant variantData(const QString &mime) { return retrieveData(mime, QVariant::Invalid); }
370 private:
371  QMacMimeData();
372 };
373 
374 void
376 {
377  if (!paste)
378  return;
379 
380  if (mime == mime_src || (!mime_src && mime && mac_mime_source))
381  return;
382  mac_mime_source = false;
383  delete mime;
384  mime = mime_src;
385 
386  QList<QMacPasteboardMime*> availableConverters = QMacPasteboardMime::all(mime_type);
387  if (mime != 0) {
388  clear_helper();
389  QStringList formats = mime_src->formats();
390 
391 #ifdef QT_MAC_USE_COCOA
392  // QMimeData sub classes reimplementing the formats() might not expose the
393  // temporary "application/x-qt-mime-type-name" mimetype. So check the existence
394  // of this mime type while doing drag and drop.
395  QString dummyMimeType(QLatin1String("application/x-qt-mime-type-name"));
396  if (!formats.contains(dummyMimeType)) {
397  QByteArray dummyType = mime_src->data(dummyMimeType);
398  if (!dummyType.isEmpty()) {
399  formats.append(dummyMimeType);
400  }
401  }
402 #endif
403  for(int f = 0; f < formats.size(); ++f) {
404  QString mimeType = formats.at(f);
405  for (QList<QMacPasteboardMime *>::Iterator it = availableConverters.begin(); it != availableConverters.end(); ++it) {
406  QMacPasteboardMime *c = (*it);
407  QString flavor(c->flavorFor(mimeType));
408  if(!flavor.isEmpty()) {
409  QVariant mimeData = static_cast<QMacMimeData*>(mime_src)->variantData(mimeType);
410 #if 0
411  //### Grrr, why didn't I put in a virtual int QMacPasteboardMime::count()? --Sam
412  const int numItems = c->convertFromMime(mimeType, mimeData, flavor).size();
413 #else
414  int numItems = 1; //this is a hack but it is much faster than allowing conversion above
415  if(c->convertorName() == QLatin1String("FileURL"))
416  numItems = mime_src->urls().count();
417 #endif
418  for(int item = 0; item < numItems; ++item) {
419  const int itemID = item+1; //id starts at 1
420  promises.append(QMacPasteboard::Promise(itemID, c, mimeType, mimeData, item));
421  PasteboardPutItemFlavor(paste, (PasteboardItemID)itemID, QCFString(flavor), 0, kPasteboardFlavorNoFlags);
422 #ifdef DEBUG_PASTEBOARD
423  qDebug(" - adding %d %s [%s] <%s> [%d]",
424  itemID, qPrintable(mimeType), qPrintable(flavor), qPrintable(c->convertorName()), item);
425 #endif
426  }
427  }
428  }
429  }
430  }
431 }
432 
435 {
436  if (!paste)
437  return QStringList();
438 
439  sync();
440 
441  QStringList ret;
442  ItemCount cnt = 0;
443  if(PasteboardGetItemCount(paste, &cnt) || !cnt)
444  return ret;
445 
446 #ifdef DEBUG_PASTEBOARD
447  qDebug("PasteBoard: Formats [%d]", (int)cnt);
448 #endif
449  for(uint index = 1; index <= cnt; ++index) {
450 
451  PasteboardItemID id;
452  if(PasteboardGetItemIdentifier(paste, index, &id) != noErr)
453  continue;
454 
456  if(PasteboardCopyItemFlavors(paste, id, &types ) != noErr)
457  continue;
458 
459  const int type_count = CFArrayGetCount(types);
460  for(int i = 0; i < type_count; ++i) {
461  const QString flavor = QCFString::toQString((CFStringRef)CFArrayGetValueAtIndex(types, i));
462 #ifdef DEBUG_PASTEBOARD
463  qDebug(" -%s", qPrintable(QString(flavor)));
464 #endif
465  QString mimeType = QMacPasteboardMime::flavorToMime(mime_type, flavor);
466  if(!mimeType.isEmpty() && !ret.contains(mimeType)) {
467 #ifdef DEBUG_PASTEBOARD
468  qDebug(" -<%d> %s [%s]", ret.size(), qPrintable(mimeType), qPrintable(QString(flavor)));
469 #endif
470  ret << mimeType;
471  }
472  }
473  }
474  return ret;
475 }
476 
477 bool
479 {
480  if (!paste)
481  return false;
482 
483  sync();
484 
485  ItemCount cnt = 0;
486  if(PasteboardGetItemCount(paste, &cnt) || !cnt)
487  return false;
488 
489 #ifdef DEBUG_PASTEBOARD
490  qDebug("PasteBoard: hasFormat [%s]", qPrintable(format));
491 #endif
492  for(uint index = 1; index <= cnt; ++index) {
493 
494  PasteboardItemID id;
495  if(PasteboardGetItemIdentifier(paste, index, &id) != noErr)
496  continue;
497 
499  if(PasteboardCopyItemFlavors(paste, id, &types ) != noErr)
500  continue;
501 
502  const int type_count = CFArrayGetCount(types);
503  for(int i = 0; i < type_count; ++i) {
504  const QString flavor = QCFString::toQString((CFStringRef)CFArrayGetValueAtIndex(types, i));
505 #ifdef DEBUG_PASTEBOARD
506  qDebug(" -%s [0x%x]", qPrintable(QString(flavor)), mime_type);
507 #endif
508  QString mimeType = QMacPasteboardMime::flavorToMime(mime_type, flavor);
509 #ifdef DEBUG_PASTEBOARD
510  if(!mimeType.isEmpty())
511  qDebug(" - %s", qPrintable(mimeType));
512 #endif
513  if(mimeType == format)
514  return true;
515  }
516  }
517  return false;
518 }
519 
520 QVariant
522 {
523  if (!paste)
524  return QVariant();
525 
526  sync();
527 
528  ItemCount cnt = 0;
529  if(PasteboardGetItemCount(paste, &cnt) || !cnt)
530  return QByteArray();
531 
532 #ifdef DEBUG_PASTEBOARD
533  qDebug("Pasteboard: retrieveData [%s]", qPrintable(format));
534 #endif
535  const QList<QMacPasteboardMime *> mimes = QMacPasteboardMime::all(mime_type);
536  for(int mime = 0; mime < mimes.size(); ++mime) {
537  QMacPasteboardMime *c = mimes.at(mime);
538  QString c_flavor = c->flavorFor(format);
539  if(!c_flavor.isEmpty()) {
540  // Handle text/plain a little differently. Try handling Unicode first.
541  bool checkForUtf16 = (c_flavor == QLatin1String("com.apple.traditional-mac-plain-text")
542  || c_flavor == QLatin1String("public.utf8-plain-text"));
543  if (checkForUtf16 || c_flavor == QLatin1String("public.utf16-plain-text")) {
544  // Try to get the NSStringPboardType from NSPasteboard, newlines are mapped
545  // correctly (as '\n') in this data. The 'public.utf16-plain-text' type
546  // usually maps newlines to '\r' instead.
548  if (!str.isEmpty())
549  return str;
550  }
551  if (checkForUtf16 && hasFlavor(QLatin1String("public.utf16-plain-text")))
552  c_flavor = QLatin1String("public.utf16-plain-text");
553 
554  QVariant ret;
555  QList<QByteArray> retList;
556  for(uint index = 1; index <= cnt; ++index) {
557  PasteboardItemID id;
558  if(PasteboardGetItemIdentifier(paste, index, &id) != noErr)
559  continue;
560 
562  if(PasteboardCopyItemFlavors(paste, id, &types ) != noErr)
563  continue;
564 
565  const int type_count = CFArrayGetCount(types);
566  for(int i = 0; i < type_count; ++i) {
567  CFStringRef flavor = static_cast<CFStringRef>(CFArrayGetValueAtIndex(types, i));
568  if(c_flavor == QCFString::toQString(flavor)) {
569  QCFType<CFDataRef> macBuffer;
570  if(PasteboardCopyItemFlavorData(paste, id, flavor, &macBuffer) == noErr) {
571  QByteArray buffer((const char *)CFDataGetBytePtr(macBuffer), CFDataGetLength(macBuffer));
572  if(!buffer.isEmpty()) {
573 #ifdef DEBUG_PASTEBOARD
574  qDebug(" - %s [%s] (%s)", qPrintable(format), qPrintable(QCFString::toQString(flavor)), qPrintable(c->convertorName()));
575 #endif
576  buffer.detach(); //detach since we release the macBuffer
577  retList.append(buffer);
578  break; //skip to next element
579  }
580  }
581  } else {
582 #ifdef DEBUG_PASTEBOARD
583  qDebug(" - NoMatch %s [%s] (%s)", qPrintable(c_flavor), qPrintable(QCFString::toQString(flavor)), qPrintable(c->convertorName()));
584 #endif
585  }
586  }
587  }
588 
589  if (!retList.isEmpty()) {
590  ret = c->convertToMime(format, retList, c_flavor);
591  return ret;
592  }
593  }
594  }
595  return QVariant();
596 }
597 
599 {
600  if (paste)
601  PasteboardClear(paste);
602  promises.clear();
603 }
604 
605 void
607 {
608 #ifdef DEBUG_PASTEBOARD
609  qDebug("PasteBoard: clear!");
610 #endif
611  clear_helper();
612 }
613 
614 bool
616 {
617  if (!paste)
618  return false;
619  const bool fromGlobal = PasteboardSynchronize(paste) & kPasteboardModified;
620 
621  if (fromGlobal)
622  const_cast<QMacPasteboard *>(this)->setMimeData(0);
623 
624 #ifdef DEBUG_PASTEBOARD
625  if(fromGlobal)
626  qDebug("Pasteboard: Synchronize!");
627 #endif
628  return fromGlobal;
629 }
630 
631 
632 
633 
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
Mode
This enum type is used to control which part of the system clipboard is used by QClipboard::mimeData(...
Definition: qclipboard.h:71
const struct __CFString * CFStringRef
void clear(Mode mode=Clipboard)
Clear the clipboard contents.
void emitChanged(Mode mode)
Emits the appropriate changed signal for mode.
Definition: qclipboard.cpp:640
int type
Definition: qmetatype.cpp:239
unsigned char c[8]
Definition: qnumeric_p.h:62
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
virtual QStringList formats() const
Returns a list of formats supported by the object.
Definition: qmimedata.cpp:579
static QList< QMacPasteboardMime * > all(uchar)
Returns a list of all currently defined QMacPasteboardMime objects of type t.
Definition: qmime_mac.cpp:1244
bool event(QEvent *)
Reimplemented Function
void ownerDestroyed()
Internal cleanup for Windows.
#define it(className, varName)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
static QString toQString(CFStringRef cfstr)
Definition: qcore_mac.cpp:47
const char * mime
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.
Definition: qlist.h:891
QByteArray data(const QString &mimetype) const
Returns the data stored in the object in the format described by the MIME type specified by mimeType...
Definition: qmimedata.cpp:524
void setMimeData(QMimeData *data, Mode mode=Clipboard)
Sets the clipboard data to src.
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool ownsMode(Mode mode) const
Returns true if the clipboard supports the clipboard data speacified by mode; otherwise returns false...
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
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.
Definition: qlist.h:152
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.
unsigned char uchar
Definition: qglobal.h:994
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.
Definition: qlist.h:507
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.
Definition: qglobal.h:89
QList< Promise > promises
Definition: qt_mac_p.h:221
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
const char * name
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QVariant retrieveData(const QString &format, QVariant::Type) const
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
Type
This enum type defines the types of variable that a QVariant can contain.
Definition: qvariant.h:95
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
Definition: qstringlist.h:172
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.
Definition: qmimedata.cpp:310
signed long OSStatus
The QMimeData class provides a container for data that records information about its MIME type...
Definition: qmimedata.h:57
bool hasFormat(const QString &format) const
The QList::iterator class provides an STL-style non-const iterator for QList and QQueue.
Definition: qlist.h:181
struct OpaquePasteboardRef * PasteboardRef
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
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 const struct @32 types[]
static QString flavorToMime(uchar, QString flav)
Returns a MIME type of type t for flav, or 0 if none exists.
Definition: qmime_mac.cpp:1221
QMacPasteboardMime * convertor
Definition: qt_mac_p.h:217
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
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.
Definition: qbytearray.h:402
#define QT_USE_NAMESPACE
This macro expands to using QT_NAMESPACE if QT_NAMESPACE is defined and nothing otherwise.
Definition: qglobal.h:88
quint16 index
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
static QMacPasteboard * qt_mac_pasteboard(QClipboard::Mode mode)
bool sync() const
QMimeData * mimeData() const
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
static bool qt_mac_updateScrap(QClipboard::Mode mode)
#define qPrintable(string)
Definition: qglobal.h:1750
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
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...
Definition: qglobal.h:1729
The QMacPasteboardMime class converts between a MIME type and a.
Definition: qmime.h:141
static OSStatus promiseKeeper(OSPasteboardRef, PasteboardItemID, CFStringRef, void *)
void detach()
Definition: qbytearray.h:435
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