KDeclarative

DeclarativeMimeData.h
1/*
2 SPDX-FileCopyrightText: 2010 BetterInbox <contact@betterinbox.com>
3 SPDX-FileContributor: Gregory Schlomoff <greg@betterinbox.com>
4
5 SPDX-License-Identifier: MIT
6*/
7
8#ifndef DECLARATIVEMIMEDATA_H
9#define DECLARATIVEMIMEDATA_H
10
11#include <QColor>
12#include <QJsonArray>
13#include <QMimeData>
14#include <QQuickItem>
15#include <QUrl>
16
17struct MimeDataForign {
18 Q_GADGET
19 QML_ANONYMOUS
20 QML_FOREIGN(QMimeData)
21};
22
24{
26 QML_NAMED_ELEMENT(MimeData)
27 QML_UNCREATABLE("MimeData cannot be created from QML.")
28
29 /**
30 * A plain text (MIME type text/plain) representation of the data.
31 */
32 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
33
34 /**
35 * A string if the data stored in the object is HTML (MIME type text/html); otherwise returns an empty string.
36 */
37 Q_PROPERTY(QString html READ html WRITE setHtml NOTIFY htmlChanged)
38
39 /**
40 * Url contained in the mimedata
41 */
42 Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
43
44 /**
45 * A list of URLs contained within the MIME data object.
46 * URLs correspond to the MIME type text/uri-list.
47 */
48 Q_PROPERTY(QJsonArray urls READ urls WRITE setUrls NOTIFY urlsChanged)
49
50 /**
51 * A color if the data stored in the object represents a color (MIME type application/x-color); otherwise QColor().
52 */
53 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
54
55 /**
56 * The graphical item on the scene that started the drag event. It may be null.
57 */
58 Q_PROPERTY(QQuickItem *source READ source WRITE setSource NOTIFY sourceChanged)
59
60 /** @see QMimeData::hasUrls */
61 Q_PROPERTY(bool hasUrls READ hasUrls NOTIFY urlsChanged)
62 // TODO: Image property
63
64 /**
65 * @sa QMimeData::formats
66 */
68public:
70 DeclarativeMimeData(const QMimeData *copy);
71
72 QUrl url() const;
73 void setUrl(const QUrl &url);
74
75 QJsonArray urls() const;
76 void setUrls(const QJsonArray &urls);
77
78 QColor color() const;
79 void setColor(const QColor &color);
80 Q_INVOKABLE bool hasColor() const;
81
82 Q_INVOKABLE void setData(const QString &mimeType, const QVariant &data);
83
84 QQuickItem *source() const;
85 void setSource(QQuickItem *source);
86
87 Q_INVOKABLE QByteArray getDataAsByteArray(const QString &format);
88
89 /*
90 QString text() const; //TODO: Reimplement this to issue the onChanged signals
91 void setText(const QString &text);
92 QString html() const;
93 void setHtml(const QString &html);
94 */
95
97 void textChanged(); // FIXME not being used
98 void htmlChanged(); // FIXME not being used
99 void urlChanged();
100 void urlsChanged();
101 void colorChanged();
102 void sourceChanged();
103
104private:
105 QQuickItem *m_source;
106};
107
108#endif // DECLARATIVEMIMEDATA_H
QString html
A string if the data stored in the object is HTML (MIME type text/html); otherwise returns an empty s...
QJsonArray urls
A list of URLs contained within the MIME data object.
QString text
A plain text (MIME type text/plain) representation of the data.
QUrl url
Url contained in the mimedata.
QColor color
A color if the data stored in the object represents a color (MIME type application/x-color); otherwis...
QQuickItem * source
The graphical item on the scene that started the drag event.
QByteArray data(const QString &mimeType) const const
void setHtml(const QString &html)
void setText(const QString &text)
Q_INVOKABLEQ_INVOKABLE
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
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.