6#include "private/qobject_p.h"
85 while ((newLineIndex =
text.
indexOf(
'\n', from)) != -1) {
90 from = newLineIndex + 1;
100 int typeId =
type.id();
105 if (
format ==
"text/plain"_L1 && !
data.isValid()) {
107 if (
data.metaType().id() == QMetaType::QUrl) {
109 }
else if (
data.metaType().id() == QMetaType::QVariantList) {
114 if (
list.
at(
i).metaType().id() == QMetaType::QUrl) {
115 text +=
list.
at(
i).toUrl().toDisplayString() + u
'\n';
131 if ((typeId == QMetaType::QUrl &&
data.metaType().id() == QMetaType::QVariantList)
132 || (typeId == QMetaType::QVariantList &&
data.metaType().id() == QMetaType::QUrl))
136 if ((typeId == QMetaType::QPixmap &&
data.metaType().id() == QMetaType::QImage)
137 || (typeId == QMetaType::QImage &&
data.metaType().id() == QMetaType::QPixmap))
140 if (
data.metaType().id() == QMetaType::QByteArray) {
143 case QMetaType::QString: {
147 if (
format ==
"text/html"_L1) {
156 case QMetaType::QColor: {
161 case QMetaType::QVariantList: {
162 if (
format !=
"text/uri-list"_L1)
166 case QMetaType::QUrl: {
171 if (bav.endsWith(
'\0'))
179 }
else if (typeId == QMetaType::QByteArray) {
182 switch (
data.metaType().id()) {
183 case QMetaType::QByteArray:
184 case QMetaType::QColor:
185 return data.toByteArray();
186 case QMetaType::QString:
187 return data.toString().toUtf8();
188 case QMetaType::QUrl:
189 return data.toUrl().toEncoded();
190 case QMetaType::QVariantList: {
195 if (
list.
at(
i).metaType().id() == QMetaType::QUrl) {
328 if (
data.metaType().id() == QMetaType::QUrl)
330 else if (
data.metaType().id() == QMetaType::QVariantList) {
333 if (
list.
at(
i).metaType().id() == QMetaType::QUrl)
385 return data.toString();
421 return data.toString();
545 return data.toByteArray();
566 if (
mimeType ==
"text/uri-list"_L1) {
607 for (
auto &
e :
d->dataList)
656#include "moc_qmimedata.cpp"
constexpr bool isEmpty() const noexcept
constexpr void chop(qsizetype n)
QByteArrayView trimmed() const noexcept
bool endsWith(char c) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void chop(qsizetype n)
Removes n bytes from the end of the byte array.
bool isNull() const noexcept
Returns true if this byte array is null; otherwise returns false.
qsizetype size() const noexcept
QList< T > toList() const noexcept
void push_back(parameter_type t)
const_reference at(qsizetype i) const noexcept
void reserve(qsizetype size)
const_iterator cend() const noexcept
void append(parameter_type t)
const_iterator cbegin() const noexcept
std::vector< QMimeDataStruct >::const_iterator find(const QString &format) const noexcept
std::vector< QMimeDataStruct > dataList
QVariant getData(const QString &format) const
QVariant retrieveTypedData(const QString &format, QMetaType type) const
std::vector< QMimeDataStruct >::iterator find(const QString &format) noexcept
void setData(const QString &format, const QVariant &data)
void removeData(const QString &format)
bool hasUrls() const
Returns true if the object can return a list of urls; otherwise returns false.
void setHtml(const QString &html)
Sets html as the HTML (MIME type text/html) used to represent the data.
QVariant colorData() const
Returns a color if the data stored in the object represents a color (MIME type application/x-color); ...
void setData(const QString &mimetype, const QByteArray &data)
Sets the data associated with the MIME type given by mimeType to the specified data.
~QMimeData()
Destroys the MIME data object.
QMimeData()
Constructs a new MIME data object with no data in it.
QVariant imageData() const
Returns a QVariant storing a QImage if the object can return an image; otherwise returns a null varia...
bool hasHtml() const
Returns true if the object can return HTML (MIME type text/html); otherwise returns false.
bool hasImage() const
Returns true if the object can return an image; otherwise returns false.
bool hasText() const
Returns true if the object can return plain text (MIME type text/plain); otherwise returns false.
void setText(const QString &text)
Sets text as the plain text (MIME type text/plain) used to represent the data.
void setImageData(const QVariant &image)
Sets the data in the object to the given image.
virtual bool hasFormat(const QString &mimetype) const
Returns true if the object can return data for the MIME type specified by mimeType; otherwise returns...
void setColorData(const QVariant &color)
Sets the color data in the object to the given color.
virtual QVariant retrieveData(const QString &mimetype, QMetaType preferredType) const
Returns a variant with the given type containing data for the MIME type specified by mimeType.
QString html() const
Returns a string if the data stored in the object is HTML (MIME type text/html); otherwise returns an...
QList< QUrl > urls() const
Returns a list of URLs contained within the MIME data object.
bool hasColor() const
Returns true if the object can return a color (MIME type application/x-color); otherwise returns fals...
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 clear()
Removes all the MIME type and data entries in the object.
virtual QStringList formats() const
Returns a list of formats supported by the object.
void setUrls(const QList< QUrl > &urls)
Sets the URLs stored in the MIME data object to those specified by urls.
void removeFormat(const QString &mimetype)
QString text() const
Returns a plain text (MIME type text/plain) representation of the data.
bool isValid() const noexcept
Returns true if this is a valid string converter that can be used for encoding or decoding text.
static Q_CORE_EXPORT QStringDecoder decoderForHtml(QByteArrayView data)
Tries to determine the encoding of the HTML in data by looking at leading byte order marks or a chars...
\macro QT_RESTRICTED_CAST_FROM_ASCII
void chop(qsizetype n)
Removes n characters from the end of the string.
qsizetype size() const
Returns the number of characters in this string.
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QChar * data()
Returns a pointer to the data stored in the QString.
static QString static QString qsizetype indexOf(QChar c, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
static QUrl fromEncoded(QByteArrayView input, ParsingMode mode=TolerantMode)
Parses input and returns the corresponding QUrl.
bool convert(QMetaType type)
Casts the variant to the requested type, targetType.
QString toString() const
Returns the variant as a QString if the variant has a userType() including, but not limited to:
bool isNull() const
Returns true if this is a null variant, false otherwise.
QSet< QString >::iterator it
Combined button and popup list for selecting options.
static QString textPlainLiteral()
static QList< QVariant > dataToUrls(QByteArrayView text)
static QString textPlainUtf8Literal()
static QString applicationXQtImageLiteral()
static QString textUriListLiteral()
static QString textHtmlLiteral()
static QString applicationXColorLiteral()
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLsizei GLsizei GLenum format
GLdouble GLdouble GLdouble GLdouble q
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
#define QStringLiteral(str)
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)