#include <qdnd_p.h>
Inheritance diagram for QInternalMimeData:


Definition at line 71 of file qdnd_p.h.
Public Member Functions | |
| QInternalMimeData () | |
| ~QInternalMimeData () | |
| bool | hasFormat (const QString &mimeType) const |
| QStringList | formats () const |
Static Public Member Functions | |
| static bool | canReadData (const QString &mimeType) |
| static QStringList | formatsHelper (const QMimeData *data) |
| static bool | hasFormatHelper (const QString &mimeType, const QMimeData *data) |
| static QByteArray | renderDataHelper (const QString &mimeType, const QMimeData *data) |
Protected Member Functions | |
| QVariant | retrieveData (const QString &mimeType, QVariant::Type type) const |
| virtual bool | hasFormat_sys (const QString &mimeType) const=0 |
| virtual QStringList | formats_sys () const=0 |
| virtual QVariant | retrieveData_sys (const QString &mimeType, QVariant::Type type) const =0 |
| QInternalMimeData::QInternalMimeData | ( | ) |
| bool QInternalMimeData::hasFormat | ( | const QString & | mimeType | ) | const [virtual] |
Returns true if the object can return data for the MIME type specified by mimeType; otherwise returns false.
For the most common types of data, you can call the higher-level functions hasText(), hasHtml(), hasUrls(), hasImage(), and hasColor() instead.
Reimplemented from QMimeData.
Definition at line 445 of file qdnd.cpp.
References QList< T >::at(), hasFormat_sys(), i, imageReadMimeFormats(), and QList< T >::size().
00446 { 00447 bool foundFormat = hasFormat_sys(mimeType); 00448 if (!foundFormat && mimeType == QLatin1String("application/x-qt-image")) { 00449 QStringList imageFormats = imageReadMimeFormats(); 00450 for (int i = 0; i < imageFormats.size(); ++i) { 00451 if ((foundFormat = hasFormat_sys(imageFormats.at(i)))) 00452 break; 00453 } 00454 } 00455 return foundFormat; 00456 }
Here is the call graph for this function:

| QStringList QInternalMimeData::formats | ( | ) | const [virtual] |
Returns a list of formats supported by the object. This is a list of MIME types for which the object can return suitable data. The formats in the list are in a priority order.
For the most common types of data, you can call the higher-level functions hasText(), hasHtml(), hasUrls(), hasImage(), and hasColor() instead.
Reimplemented from QMimeData.
Definition at line 458 of file qdnd.cpp.
References QStringList::contains(), formats_sys(), i, and imageReadMimeFormats().
Referenced by QDropData::formats_sys(), QDropData::hasFormat_sys(), QClipboardWatcher::hasFormat_sys(), and QClipboardWatcher::retrieveData_sys().
00459 { 00460 QStringList realFormats = formats_sys(); 00461 if (!realFormats.contains(QLatin1String("application/x-qt-image"))) { 00462 QStringList imageFormats = imageReadMimeFormats(); 00463 for (int i = 0; i < imageFormats.size(); ++i) { 00464 if (realFormats.contains(imageFormats.at(i))) { 00465 realFormats += QLatin1String("application/x-qt-image"); 00466 break; 00467 } 00468 } 00469 } 00470 return realFormats; 00471 }
Here is the call graph for this function:

| bool QInternalMimeData::canReadData | ( | const QString & | mimeType | ) | [static] |
Definition at line 515 of file qdnd.cpp.
References QStringList::contains(), and imageReadMimeFormats().
00516 { 00517 return imageReadMimeFormats().contains(mimeType); 00518 }
Here is the call graph for this function:

| QStringList QInternalMimeData::formatsHelper | ( | const QMimeData * | data | ) | [static] |
Definition at line 521 of file qdnd.cpp.
References QList< T >::append(), QStringList::contains(), QMimeData::data(), i, and imageWriteMimeFormats().
Referenced by QDragManager::move(), and send_targets_selection().
00522 { 00523 QStringList realFormats = data->formats(); 00524 if (realFormats.contains(QLatin1String("application/x-qt-image"))) { 00525 // add all supported image formats 00526 QStringList imageFormats = imageWriteMimeFormats(); 00527 for (int i = 0; i < imageFormats.size(); ++i) { 00528 if (!realFormats.contains(imageFormats.at(i))) 00529 realFormats.append(imageFormats.at(i)); 00530 } 00531 } 00532 return realFormats; 00533 }
Here is the call graph for this function:

| bool QInternalMimeData::hasFormatHelper | ( | const QString & | mimeType, | |
| const QMimeData * | data | |||
| ) | [static] |
Definition at line 535 of file qdnd.cpp.
References QList< T >::at(), QStringList::contains(), QMimeData::data(), i, imageWriteMimeFormats(), QList< T >::size(), and QString::startsWith().
Referenced by QX11Data::xdndMimeDataForAtom().
00536 { 00537 00538 bool foundFormat = data->hasFormat(mimeType); 00539 if (!foundFormat) { 00540 if (mimeType == QLatin1String("application/x-qt-image")) { 00541 // check all supported image formats 00542 QStringList imageFormats = imageWriteMimeFormats(); 00543 for (int i = 0; i < imageFormats.size(); ++i) { 00544 if ((foundFormat = data->hasFormat(imageFormats.at(i)))) 00545 break; 00546 } 00547 } else if (mimeType.startsWith(QLatin1String("image/"))) { 00548 return data->hasImage() && imageWriteMimeFormats().contains(mimeType); 00549 } 00550 } 00551 return foundFormat; 00552 }
Here is the call graph for this function:

| QByteArray QInternalMimeData::renderDataHelper | ( | const QString & | mimeType, | |
| const QMimeData * | data | |||
| ) | [static] |
Definition at line 554 of file qdnd.cpp.
References buf, c, QMimeData::data(), QByteArray::data(), image, QString::indexOf(), QByteArray::isEmpty(), QString::mid(), QByteArray::resize(), QString::startsWith(), QString::toUpper(), and QIODevice::WriteOnly.
Referenced by QX11Data::xdndMimeDataForAtom().
00555 { 00556 QByteArray ba; 00557 if (mimeType == QLatin1String("application/x-color")) { 00558 /* QMimeData can only provide colors as QColor or the name 00559 of a color as a QByteArray or a QString. So we need to do 00560 the conversion to application/x-color here. 00561 The application/x-color format is : 00562 type: application/x-color 00563 format: 16 00564 data[0]: red 00565 data[1]: green 00566 data[2]: blue 00567 data[3]: opacity 00568 */ 00569 ba.resize(8); 00570 ushort * colBuf = (ushort *)ba.data(); 00571 QColor c = qvariant_cast<QColor>(data->colorData()); 00572 colBuf[0] = ushort(c.redF() * 0xFFFF); 00573 colBuf[1] = ushort(c.greenF() * 0xFFFF); 00574 colBuf[2] = ushort(c.blueF() * 0xFFFF); 00575 colBuf[3] = ushort(c.alphaF() * 0xFFFF); 00576 } else { 00577 ba = data->data(mimeType); 00578 if (ba.isEmpty()) { 00579 if (mimeType == QLatin1String("application/x-qt-image") && data->hasImage()) { 00580 QImage image = qvariant_cast<QImage>(data->imageData()); 00581 QBuffer buf(&ba); 00582 buf.open(QBuffer::WriteOnly); 00583 // would there not be PNG ?? 00584 image.save(&buf, "PNG"); 00585 } else if (mimeType.startsWith(QLatin1String("image/")) && data->hasImage()) { 00586 QImage image = qvariant_cast<QImage>(data->imageData()); 00587 QBuffer buf(&ba); 00588 buf.open(QBuffer::WriteOnly); 00589 image.save(&buf, mimeType.mid(mimeType.indexOf(QLatin1Char('/')) + 1).toLatin1().toUpper()); 00590 } 00591 } 00592 } 00593 return ba; 00594 }
Here is the call graph for this function:

| QVariant QInternalMimeData::retrieveData | ( | const QString & | mimeType, | |
| QVariant::Type | type | |||
| ) | const [protected, virtual] |
Returns a variant with the given type containing data for the MIME type specified by mimeType. If the object does not support the MIME type or variant type given, a null variant is returned instead.
This function is called by the general data() getter and by the convenience getters (text(), html(), urls(), imageData(), and colorData()). You can reimplement it if you want to store your data using a custom data structure (instead of a QByteArray, which is what setData() provides). You would then also need to reimplement hasFormat() and formats().
Reimplemented from QMimeData.
Definition at line 473 of file qdnd.cpp.
References QList< T >::at(), QVariant::Bitmap, QVariant::ByteArray, c, QMimeData::data(), QByteArray::data(), QImage::fromData(), i, QVariant::Image, imageReadMimeFormats(), QByteArray::isEmpty(), QByteArray::isNull(), QVariant::Pixmap, qWarning(), QMimeData::retrieveData(), retrieveData_sys(), QByteArray::size(), and QList< T >::size().
00474 { 00475 QVariant data = retrieveData_sys(mimeType, type); 00476 if (mimeType == QLatin1String("application/x-qt-image")) { 00477 if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty())) { 00478 // try to find an image 00479 QStringList imageFormats = imageReadMimeFormats(); 00480 for (int i = 0; i < imageFormats.size(); ++i) { 00481 data = retrieveData_sys(imageFormats.at(i), type); 00482 if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty())) 00483 continue; 00484 break; 00485 } 00486 } 00487 // we wanted some image type, but all we got was a byte array. Convert it to an image. 00488 if (data.type() == QVariant::ByteArray 00489 && (type == QVariant::Image || type == QVariant::Pixmap || type == QVariant::Bitmap)) 00490 data = QImage::fromData(data.toByteArray()); 00491 00492 } else if (mimeType == QLatin1String("application/x-color") && data.type() == QVariant::ByteArray) { 00493 QColor c; 00494 QByteArray ba = data.toByteArray(); 00495 if (ba.size() == 8) { 00496 ushort * colBuf = (ushort *)ba.data(); 00497 c.setRgbF(qreal(colBuf[0]) / qreal(0xFFFF), 00498 qreal(colBuf[1]) / qreal(0xFFFF), 00499 qreal(colBuf[2]) / qreal(0xFFFF), 00500 qreal(colBuf[3]) / qreal(0xFFFF)); 00501 data = c; 00502 } else { 00503 qWarning("Qt: Invalid color format"); 00504 } 00505 } else if (data.type() != type && data.type() == QVariant::ByteArray) { 00506 // try to use mime data's internal conversion stuf. 00507 QInternalMimeData *that = const_cast<QInternalMimeData *>(this); 00508 that->setData(mimeType, data.toByteArray()); 00509 data = QMimeData::retrieveData(mimeType, type); 00510 that->clear(); 00511 } 00512 return data; 00513 }
Here is the call graph for this function:

| virtual bool QInternalMimeData::hasFormat_sys | ( | const QString & | mimeType | ) | const [protected, pure virtual] |
Referenced by hasFormat().
| virtual QStringList QInternalMimeData::formats_sys | ( | ) | const [protected, pure virtual] |
Referenced by formats().
| virtual QVariant QInternalMimeData::retrieveData_sys | ( | const QString & | mimeType, | |
| QVariant::Type | type | |||
| ) | const [protected, pure virtual] |
Referenced by retrieveData().
1.5.1