Qt 4.8
Public Functions | Public Variables | List of all members
QMimeDataWrapper Class Reference

#include <qclipboard_p.h>

Inheritance diagram for QMimeDataWrapper:
QMimeSource

Public Functions

QByteArray encodedData (const char *) const
 Returns the encoded data of this object in the specified MIME format. More...
 
const char * format (int n) const
 Returns the (i - 1)-th supported MIME format, or 0. More...
 
 QMimeDataWrapper ()
 
- Public Functions inherited from QMimeSource
virtual bool provides (const char *) const
 Returns true if the object can provide the data in format mimeType; otherwise returns false. More...
 
virtual ~QMimeSource ()
 Destroys the MIME source. More...
 

Public Variables

const QMimeDatadata
 
QList< QByteArrayformats
 

Detailed Description

Definition at line 64 of file qclipboard_p.h.

Constructors and Destructors

◆ QMimeDataWrapper()

QMimeDataWrapper::QMimeDataWrapper ( )
inline

Definition at line 67 of file qclipboard_p.h.

Referenced by QClipboardPrivate::QClipboardPrivate().

67 {}

Functions

◆ encodedData()

QByteArray QMimeDataWrapper::encodedData ( const char *  format) const
virtual

Returns the encoded data of this object in the specified MIME format.

Implements QMimeSource.

Definition at line 670 of file qclipboard.cpp.

Referenced by QMimeDataWrapper().

671 {
672  if (QLatin1String(format) != QLatin1String("application/x-qt-image")){
673  return data->data(QLatin1String(format));
674  } else{
677  QByteArray ba;
678  QBuffer buffer(&ba);
679  buffer.open(QIODevice::WriteOnly);
680  img.save(&buffer, "PNG");
681  return ba;
682  }
683 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
bool save(const QString &fileName, const char *format=0, int quality=-1) const
Saves the image to the file with the given fileName, using the given image file format and quality fa...
Definition: qimage.cpp:5346
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
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
The QBuffer class provides a QIODevice interface for a QByteArray.
Definition: qbuffer.h:57
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
QVariant imageData() const
Returns a QVariant storing a QImage if the object can return an image; otherwise returns a null varia...
Definition: qmimedata.cpp:442
const QMimeData * data
Definition: qclipboard_p.h:73
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
const char * variant

◆ format()

const char * QMimeDataWrapper::format ( int  n) const
virtual

Returns the (i - 1)-th supported MIME format, or 0.

Implements QMimeSource.

Definition at line 658 of file qclipboard.cpp.

Referenced by QMimeDataWrapper().

659 {
660  if (formats.isEmpty()) {
661  QStringList fmts = data->formats();
662  for (int i = 0; i < fmts.size(); ++i)
663  formats.append(fmts.at(i).toLatin1());
664  }
665  if (n < 0 || n >= formats.size())
666  return 0;
667  return formats.at(n).data();
668 }
virtual QStringList formats() const
Returns a list of formats supported by the object.
Definition: qmimedata.cpp:579
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
QList< QByteArray > formats
Definition: qclipboard_p.h:72
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
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
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
const QMimeData * data
Definition: qclipboard_p.h:73

Properties

◆ data

const QMimeData* QMimeDataWrapper::data

Definition at line 73 of file qclipboard_p.h.

◆ formats

QList<QByteArray> QMimeDataWrapper::formats
mutable

Definition at line 72 of file qclipboard_p.h.


The documentation for this class was generated from the following files: