KDeclarative

MimeDataWrapper.h
1/*
2 SPDX-FileCopyrightText: 2015 Aleix Pol Gonzalez <aleixpol@kde.org>
3
4 SPDX-License-Identifier: MIT
5*/
6
7#ifndef MIMEDATAWRAPPER_H
8#define MIMEDATAWRAPPER_H
9
10#include <QJsonArray>
11#include <QObject>
12#include <QString>
13#include <qqmlregistration.h>
14
15class QMimeData;
16class QObject;
17/**
18 * Exposes a const QMimeData instance
19 *
20 * In contrast to DeclarativeMimeData, doesn't create a copy of the QMimeData instance
21 */
22class MimeDataWrapper : public QObject
23{
25 QML_ELEMENT
26 QML_UNCREATABLE("MimeDataWrapper cannot be created from QML.")
27
28 /**
29 * A plain text (MIME type text/plain) representation of the data.
30 */
31 Q_PROPERTY(QString text READ text CONSTANT)
32
33 /**
34 * A string if the data stored in the object is HTML (MIME type text/html); otherwise returns an empty string.
35 */
36 Q_PROPERTY(QString html READ html CONSTANT)
37
38 /**
39 * Url contained in the mimedata
40 */
41 Q_PROPERTY(QUrl url READ url CONSTANT)
42
43 /**
44 * A list of URLs contained within the MIME data object.
45 * URLs correspond to the MIME type text/uri-list.
46 */
48
49 /**
50 * A color if the data stored in the object represents a color (MIME type application/x-color); otherwise QVariant().
51 */
53
54 /**
55 * The graphical item on the scene that started the drag event. It may be null.
56 */
58
59 /**
60 * Mimetypes provided by the mime data instance
61 *
62 * @sa QMimeData::formats
63 */
65
66 /**
67 * @sa QMimeData::hasUrls
68 */
69 Q_PROPERTY(bool hasUrls READ hasUrls CONSTANT)
70
71 /**
72 * @returns the wrapped object
73 */
75
76public:
77 MimeDataWrapper(const QMimeData *data, QObject *parent);
78
79 QString text() const;
80 QString html() const;
81 QUrl url() const;
82 QJsonArray urls() const;
83 bool hasUrls() const;
84 QVariant color() const;
85 QStringList formats() const;
86 QVariant source() const;
87 QMimeData *mimeData() const;
88
89 Q_INVOKABLE QByteArray getDataAsByteArray(const QString &format);
90
91private:
92 const QMimeData *m_data;
93};
94
95#endif
QMimeData * mimeData
QUrl url
Url contained in the mimedata.
QStringList formats
Mimetypes provided by the mime data instance.
QString html
A string if the data stored in the object is HTML (MIME type text/html); otherwise returns an empty s...
QVariant source
The graphical item on the scene that started the drag event.
QVariant color
A color if the data stored in the object represents a color (MIME type application/x-color); otherwis...
QJsonArray urls
A list of URLs contained within the MIME data object.
QML_ELEMENTQString text
A plain text (MIME type text/plain) representation of the data.
QObject(QObject *parent)
Q_INVOKABLEQ_INVOKABLE
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri May 2 2025 11:58:08 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.