Qt 4.8
Public Functions | Static Public Functions | List of all members
QXlibMime Class Reference

#include <qxlibmime.h>

Inheritance diagram for QXlibMime:
QInternalMimeData QMimeData QObject QXlibClipboardMime

Public Functions

 QXlibMime ()
 
 ~QXlibMime ()
 
- Public Functions inherited from QInternalMimeData
QStringList formats () const
 Returns a list of formats supported by the object. More...
 
bool hasFormat (const QString &mimeType) const
 Returns true if the object can return data for the MIME type specified by mimeType; otherwise returns false. More...
 
 QInternalMimeData ()
 
 ~QInternalMimeData ()
 
- Public Functions inherited from QMimeData
void clear ()
 Removes all the MIME type and data entries in the object. More...
 
QVariant colorData () const
 Returns a color if the data stored in the object represents a color (MIME type application/x-color); otherwise returns a null variant. More...
 
QByteArray data (const QString &mimetype) const
 Returns the data stored in the object in the format described by the MIME type specified by mimeType. More...
 
bool hasColor () const
 Returns true if the object can return a color (MIME type application/x-color); otherwise returns false. More...
 
bool hasHtml () const
 Returns true if the object can return HTML (MIME type text/html); otherwise returns false. More...
 
bool hasImage () const
 Returns true if the object can return an image; otherwise returns false. More...
 
bool hasText () const
 Returns true if the object can return plain text (MIME type text/plain); otherwise returns false. More...
 
bool hasUrls () const
 Returns true if the object can return a list of urls; otherwise returns false. More...
 
QString html () const
 Returns a string if the data stored in the object is HTML (MIME type text/html); otherwise returns an empty string. More...
 
QVariant imageData () const
 Returns a QVariant storing a QImage if the object can return an image; otherwise returns a null variant. More...
 
 QMimeData ()
 Constructs a new MIME data object with no data in it. More...
 
void removeFormat (const QString &mimetype)
 Removes the data entry for mimeType in the object. More...
 
void setColorData (const QVariant &color)
 Sets the color data in the object to the given color. More...
 
void setData (const QString &mimetype, const QByteArray &data)
 Sets the data associated with the MIME type given by mimeType to the specified data. More...
 
void setHtml (const QString &html)
 Sets html as the HTML (MIME type text/html) used to represent the data. More...
 
void setImageData (const QVariant &image)
 Sets the data in the object to the given image. More...
 
void setText (const QString &text)
 Sets text as the plain text (MIME type text/plain) used to represent the data. More...
 
void setUrls (const QList< QUrl > &urls)
 Sets the URLs stored in the MIME data object to those specified by urls. More...
 
QString text () const
 Returns a plain text (MIME type text/plain) representation of the data. More...
 
QList< QUrlurls () const
 Returns a list of URLs contained within the MIME data object. More...
 
 ~QMimeData ()
 Destroys the MIME data object. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Static Public Functions

static Atom mimeAtomForFormat (Display *display, const QString &format, QVariant::Type requestedType, const QList< Atom > &atoms, QByteArray *requestedEncoding)
 
static QList< Atom > mimeAtomsForFormat (Display *display, const QString &format)
 
static QString mimeAtomToString (Display *display, Atom a)
 
static QVariant mimeConvertToFormat (Display *display, Atom a, const QByteArray &data, const QString &format, QVariant::Type requestedType, const QByteArray &encoding)
 
static bool mimeDataForAtom (Display *display, Atom a, QMimeData *mimeData, QByteArray *data, Atom *atomFormat, int *dataFormat)
 
static QStringList mimeFormatsForAtom (Display *display, Atom a)
 
static Atom mimeStringToAtom (Display *display, const QString &mimeType)
 
- Static Public Functions inherited from QInternalMimeData
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)
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QInternalMimeData
virtual QStringList formats_sys () const =0
 
virtual bool hasFormat_sys (const QString &mimeType) const =0
 
QVariant retrieveData (const QString &mimeType, QVariant::Type type) const
 Returns a variant with the given type containing data for the MIME type specified by mimeType. More...
 
virtual QVariant retrieveData_sys (const QString &mimeType, QVariant::Type type) const =0
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 52 of file qxlibmime.h.

Constructors and Destructors

◆ QXlibMime()

QXlibMime::QXlibMime ( )

Definition at line 51 of file qxlibmime.cpp.

53 { }

◆ ~QXlibMime()

QXlibMime::~QXlibMime ( )

Definition at line 55 of file qxlibmime.cpp.

56 {}

Functions

◆ mimeAtomForFormat()

Atom QXlibMime::mimeAtomForFormat ( Display display,
const QString format,
QVariant::Type  requestedType,
const QList< Atom > &  atoms,
QByteArray requestedEncoding 
)
static

Definition at line 269 of file qxlibmime.cpp.

270 {
271  requestedEncoding->clear();
272 
273  // find matches for string types
274  if (format == QLatin1String("text/plain")) {
281  if (atoms.contains(XA_STRING))
282  return XA_STRING;
283  }
284 
285  // find matches for uri types
286  if (format == QLatin1String("text/uri-list")) {
287  Atom a = mimeStringToAtom(display,format);
288  if (a && atoms.contains(a))
289  return a;
290  a = mimeStringToAtom(display,QLatin1String("text/x-moz-url"));
291  if (a && atoms.contains(a))
292  return a;
293  }
294 
295  // find match for image
296  if (format == QLatin1String("image/ppm")) {
297  if (atoms.contains(XA_PIXMAP))
298  return XA_PIXMAP;
299  }
300 
301  // for string/text requests try to use a format with a well-defined charset
302  // first to avoid encoding problems
303  if (requestedType == QVariant::String
304  && format.startsWith(QLatin1String("text/"))
305  && !format.contains(QLatin1String("charset="))) {
306 
307  QString formatWithCharset = format;
308  formatWithCharset.append(QLatin1String(";charset=utf-8"));
309 
310  Atom a = mimeStringToAtom(display,formatWithCharset);
311  if (a && atoms.contains(a)) {
312  *requestedEncoding = "utf-8";
313  return a;
314  }
315  }
316 
317  Atom a = mimeStringToAtom(display,format);
318  if (a && atoms.contains(a))
319  return a;
320 
321  return 0;
322 }
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
long ASN1_INTEGER_get ASN1_INTEGER * a
The QString class provides a Unicode character string.
Definition: qstring.h:83
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
static Atom atom(X11Atom atom)
static Atom mimeStringToAtom(Display *display, const QString &mimeType)
Definition: qxlibmime.cpp:75
QString & append(QChar c)
Definition: qstring.cpp:1777
void clear()
Clears the contents of the byte array and makes it empty.

◆ mimeAtomsForFormat()

QList< Atom > QXlibMime::mimeAtomsForFormat ( Display display,
const QString format 
)
static

Definition at line 168 of file qxlibmime.cpp.

Referenced by QXlibClipboard::sendTargetsSelection().

169 {
170  QList<Atom> atoms;
171  atoms.append(mimeStringToAtom(display, format));
172 
173  // special cases for strings
174  if (format == QLatin1String("text/plain")) {
176  atoms.append(XA_STRING);
179  }
180 
181  // special cases for uris
182  if (format == QLatin1String("text/uri-list")) {
183  atoms.append(mimeStringToAtom(display,QLatin1String("text/x-moz-url")));
184  }
185 
186  //special cases for images
187  if (format == QLatin1String("image/ppm"))
188  atoms.append(XA_PIXMAP);
189  if (format == QLatin1String("image/pbm"))
190  atoms.append(XA_BITMAP);
191 
192  return atoms;
193 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
static Atom atom(X11Atom atom)
static Atom mimeStringToAtom(Display *display, const QString &mimeType)
Definition: qxlibmime.cpp:75
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ mimeAtomToString()

QString QXlibMime::mimeAtomToString ( Display display,
Atom  a 
)
static

Definition at line 62 of file qxlibmime.cpp.

Referenced by mimeConvertToFormat(), mimeDataForAtom(), mimeFormatsForAtom(), and QXlibClipboard::sendSelection().

63 {
64  if (!a) return 0;
65 
66  if (a == XA_STRING || a == QXlibStatic::atom(QXlibStatic::UTF8_STRING)) {
67  return "text/plain"; // some Xdnd clients are dumb
68  }
69  char *atom = XGetAtomName(display, a);
70  QString result = QString::fromLatin1(atom);
71  XFree(atom);
72  return result;
73 }
long ASN1_INTEGER_get ASN1_INTEGER * a
The QString class provides a Unicode character string.
Definition: qstring.h:83
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
static Atom atom(X11Atom atom)
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188

◆ mimeConvertToFormat()

QVariant QXlibMime::mimeConvertToFormat ( Display display,
Atom  a,
const QByteArray data,
const QString format,
QVariant::Type  requestedType,
const QByteArray encoding 
)
static

Definition at line 195 of file qxlibmime.cpp.

196 {
197  QString atomName = mimeAtomToString(display,a);
198  if (atomName == format)
199  return data;
200 
201  if (!encoding.isEmpty()
202  && atomName == format + QLatin1String(";charset=") + QString::fromLatin1(encoding)) {
203 
204  if (requestedType == QVariant::String) {
206  if (codec)
207  return codec->toUnicode(data);
208  }
209 
210  return data;
211  }
212 
213  // special cases for string types
214  if (format == QLatin1String("text/plain")) {
216  return QString::fromUtf8(data);
217  if (a == XA_STRING)
218  return QString::fromLatin1(data);
221  // #### might be wrong for COMPUND_TEXT
222  return QString::fromLocal8Bit(data, data.size());
223  }
224 
225  // special case for uri types
226  if (format == QLatin1String("text/uri-list")) {
227  if (atomName == QLatin1String("text/x-moz-url")) {
228  // we expect this as utf16 <url><space><title>
229  // the first part is a url that should only contain ascci char
230  // so it should be safe to check that the second char is 0
231  // to verify that it is utf16
232  if (data.size() > 1 && data.at(1) == 0)
233  return QString::fromRawData((const QChar *)data.constData(),
234  data.size() / 2).split(QLatin1Char('\n')).first().toLatin1();
235  }
236  }
237 
238  // special cas for images
239  if (format == QLatin1String("image/ppm")) {
240  if (a == XA_PIXMAP && data.size() == sizeof(Pixmap)) {
241  Pixmap xpm = *((Pixmap*)data.data());
242  if (!xpm)
243  return QByteArray();
244  Window root;
245  int x;
246  int y;
247  uint width;
248  uint height;
249  uint border_width;
250  uint depth;
251 
252  XGetGeometry(display, xpm, &root, &x, &y, &width, &height, &border_width, &depth);
253  XImage *ximg = XGetImage(display,xpm,x,y,width,height,AllPlanes,depth==1 ? XYPixmap : ZPixmap);
255  XDestroyImage(ximg);
256 
257  QImageWriter imageWriter;
258  imageWriter.setFormat("PPMRAW");
259  QBuffer buf;
261  imageWriter.setDevice(&buf);
262  imageWriter.write(qimg);
263  return buf.buffer();
264  }
265  }
266  return QVariant();
267 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
Definition: qstring.cpp:4245
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
static QString mimeAtomToString(Display *display, Atom a)
Definition: qxlibmime.cpp:62
bool open(OpenMode openMode)
Reimplemented Function
Definition: qbuffer.cpp:338
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
long ASN1_INTEGER_get ASN1_INTEGER * a
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 QString class provides a Unicode character string.
Definition: qstring.h:83
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
static QString fromRawData(const QChar *, int size)
Constructs a QString that uses the first size Unicode characters in the array unicode.
Definition: qstring.cpp:7673
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
QByteArray & buffer()
Returns a reference to the QBuffer&#39;s internal buffer.
Definition: qbuffer.cpp:271
The QImageWriter class provides a format independent interface for writing images to files or other d...
Definition: qimagewriter.h:59
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Definition: qstring.cpp:4302
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
unsigned int uint
Definition: qglobal.h:996
static QTextCodec * codec(MYSQL *mysql)
Definition: qsql_mysql.cpp:220
static void split(QT_FT_Vector *b)
static Atom atom(X11Atom atom)
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
QString toUnicode(const QByteArray &) const
Converts a from the encoding of this codec to Unicode, and returns the result in a QString...
void setDevice(QIODevice *device)
Sets QImageWriter&#39;s device to device.
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
static QTextCodec * codecForName(const QByteArray &name)
Searches all installed QTextCodec objects and returns the one which best matches name; the match is c...
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
static QImage qimageFromXImage(XImage *xi)
void setFormat(const QByteArray &format)
Sets the format QImageWriter will use when writing images, to format.
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
The QTextCodec class provides conversions between text encodings.
Definition: qtextcodec.h:62
char at(int i) const
Returns the character at index position i in the byte array.
Definition: qbytearray.h:413
bool write(const QImage &image)
Writes the image image to the assigned device or file name.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ mimeDataForAtom()

bool QXlibMime::mimeDataForAtom ( Display display,
Atom  a,
QMimeData mimeData,
QByteArray data,
Atom *  atomFormat,
int *  dataFormat 
)
static

Definition at line 107 of file qxlibmime.cpp.

Referenced by QXlibClipboard::sendSelection().

108 {
109  bool ret = false;
110  *atomFormat = a;
111  *dataFormat = 8;
112  QString atomName = mimeAtomToString(display, a);
113  if (QInternalMimeData::hasFormatHelper(atomName, mimeData)) {
114  *data = QInternalMimeData::renderDataHelper(atomName, mimeData);
115  if (atomName == QLatin1String("application/x-color"))
116  *dataFormat = 16;
117  ret = true;
118  } else {
120  || a == XA_STRING
123  && QInternalMimeData::hasFormatHelper(QLatin1String("text/plain"), mimeData)) {
125  *data = QInternalMimeData::renderDataHelper(QLatin1String("text/plain"), mimeData);
126  ret = true;
127  } else if (a == XA_STRING) {
129  QLatin1String("text/plain"), mimeData)).toLocal8Bit();
130  ret = true;
131  } else if (a == QXlibStatic::atom(QXlibStatic::TEXT)
133  // the ICCCM states that TEXT and COMPOUND_TEXT are in the
134  // encoding of choice, so we choose the encoding of the locale
136  QLatin1String("text/plain"), mimeData)).toLocal8Bit();
137  char *list[] = { strData.data(), NULL };
138 
139  XICCEncodingStyle style = (a == QXlibStatic::atom(QXlibStatic::COMPOUND_TEXT))
140  ? XCompoundTextStyle : XStdICCTextStyle;
141  XTextProperty textprop;
142  if (list[0] != NULL
143  && XmbTextListToTextProperty(display, list, 1, style,
144  &textprop) == Success) {
145  *atomFormat = textprop.encoding;
146  *dataFormat = textprop.format;
147  *data = QByteArray((const char *) textprop.value, textprop.nitems * textprop.format / 8);
148  ret = true;
149 
150  XFree(textprop.value);
151  }
152  }
153  } else if (atomName == QLatin1String("text/x-moz-url") &&
154  QInternalMimeData::hasFormatHelper(QLatin1String("text/uri-list"), mimeData)) {
156  QLatin1String("text/uri-list"), mimeData).split('\n').first();
157  QString mozUri = QString::fromLatin1(uri, uri.size());
158  mozUri += QLatin1Char('\n');
159  *data = QByteArray(reinterpret_cast<const char *>(mozUri.utf16()), mozUri.length() * 2);
160  ret = true;
161  } else if ((a == XA_PIXMAP || a == XA_BITMAP) && mimeData->hasImage()) {
162  ret = true;
163  }
164  }
165  return ret && data != 0;
166 }
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
static QString mimeAtomToString(Display *display, Atom a)
Definition: qxlibmime.cpp:62
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
long ASN1_INTEGER_get ASN1_INTEGER * a
The QString class provides a Unicode character string.
Definition: qstring.h:83
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Definition: qstring.cpp:4302
static bool hasFormatHelper(const QString &mimeType, const QMimeData *data)
Definition: qdnd.cpp:428
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
static QByteArray renderDataHelper(const QString &mimeType, const QMimeData *data)
Definition: qdnd.cpp:447
static Atom atom(X11Atom atom)
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
bool hasImage() const
Returns true if the object can return an image; otherwise returns false.
Definition: qmimedata.cpp:471
QList< QByteArray > split(char sep) const
Splits the byte array into subarrays wherever sep occurs, and returns the list of those arrays...
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ mimeFormatsForAtom()

QStringList QXlibMime::mimeFormatsForAtom ( Display display,
Atom  a 
)
static

Definition at line 82 of file qxlibmime.cpp.

Referenced by QXlibClipboardMime::formats_sys().

83 {
85  if (a) {
86  QString atomName = mimeAtomToString(display, a);
87  formats.append(atomName);
88 
89  // special cases for string type
91  || a == XA_STRING
94  formats.append(QLatin1String("text/plain"));
95 
96  // special cases for uris
97  if (atomName == QLatin1String("text/x-moz-url"))
98  formats.append(QLatin1String("text/uri-list"));
99 
100  // special case for images
101  if (a == XA_PIXMAP)
102  formats.append(QLatin1String("image/ppm"));
103  }
104  return formats;
105 }
static QString mimeAtomToString(Display *display, Atom a)
Definition: qxlibmime.cpp:62
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
long ASN1_INTEGER_get ASN1_INTEGER * a
The QString class provides a Unicode character string.
Definition: qstring.h:83
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QStringList formats() const
Returns a list of formats supported by the object.
Definition: qdnd.cpp:351
static Atom atom(X11Atom atom)

◆ mimeStringToAtom()

Atom QXlibMime::mimeStringToAtom ( Display display,
const QString mimeType 
)
static

Definition at line 75 of file qxlibmime.cpp.

Referenced by mimeAtomForFormat(), and mimeAtomsForFormat().

76 {
77  if (mimeType.isEmpty())
78  return 0;
79  return XInternAtom(display, mimeType.toLatin1().constData(), False);
80 }
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433

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