6#include "private/qobject_p.h"
85 while ((newLineIndex =
text.
indexOf(
'\n', from)) != -1) {
89 from = newLineIndex + 1;
104 int typeId =
type.id();
109 if (
format ==
"text/plain"_L1 && !
data.isValid()) {
111 if (
data.metaType().id() == QMetaType::QUrl) {
113 }
else if (
data.metaType().id() == QMetaType::QVariantList) {
117 for (
const auto &element :
list) {
118 if (element.metaType().id() == QMetaType::QUrl) {
119 text += element.toUrl().toDisplayString();
136 if ((typeId == QMetaType::QUrl &&
data.metaType().id() == QMetaType::QVariantList)
137 || (typeId == QMetaType::QVariantList &&
data.metaType().id() == QMetaType::QUrl))
141 if ((typeId == QMetaType::QPixmap &&
data.metaType().id() == QMetaType::QImage)
142 || (typeId == QMetaType::QImage &&
data.metaType().id() == QMetaType::QPixmap))
145 if (
data.metaType().id() == QMetaType::QByteArray) {
148 case QMetaType::QString: {
152 if (
format ==
"text/html"_L1) {
161 case QMetaType::QColor: {
166 case QMetaType::QVariantList: {
167 if (
format !=
"text/uri-list"_L1)
171 case QMetaType::QUrl: {
176 if (bav.endsWith(
'\0'))
184 }
else if (typeId == QMetaType::QByteArray) {
187 switch (
data.metaType().id()) {
188 case QMetaType::QByteArray:
189 case QMetaType::QColor:
190 return data.toByteArray();
191 case QMetaType::QString:
192 return data.toString().toUtf8();
193 case QMetaType::QUrl:
194 return data.toUrl().toEncoded();
195 case QMetaType::QVariantList: {
199 for (
const auto &element :
list) {
200 if (element.metaType().id() == QMetaType::QUrl) {
201 result += element.toUrl().toEncoded();
333 if (
data.metaType().id() == QMetaType::QUrl)
335 else if (
data.metaType().id() == QMetaType::QVariantList) {
337 for (
const auto &element :
list) {
338 if (element.metaType().id() == QMetaType::QUrl)
571 if (
mimeType ==
"text/uri-list"_L1) {
612 for (
auto &e :
d->dataList)
661#include "moc_qmimedata.cpp"
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.
QList< T > toList() const noexcept
void push_back(parameter_type t)
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.
const_iterator cend() const noexcept
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
qsizetype indexOf(QLatin1StringView s, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
void chop(qsizetype n)
Removes n characters from the end of the string.
qsizetype size() const noexcept
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...
iterator end()
Returns an \l{STL-style iterators}{STL-style iterator} pointing just after the last character in the ...
QChar * data()
Returns a pointer to the data stored in the QString.
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.
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has userType() \l QMetaType::QByteArray or \l QMet...
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 Q_DECLARE_TYPEINFO(TYPE, FLAGS)