7#include <private/qguiapplication_p.h>
8#include <qpa/qplatformintegration.h>
9#include <private/qquickitem_p.h>
10#include <QtQuick/private/qquickevents_p_p.h>
11#include <private/qquickitemchangelistener_p.h>
12#include <private/qquickpixmap_p.h>
13#include <private/qv4scopedvalue_p.h>
14#include <QtCore/qbuffer.h>
15#include <QtCore/qmimedata.h>
16#include <QtCore/qstringconverter.h>
17#include <QtQml/qqmlinfo.h>
18#include <QtGui/qevent.h>
19#include <QtGui/qstylehints.h>
20#include <QtGui/qguiapplication.h>
21#include <QtGui/qimagewriter.h>
23#include <qpa/qplatformdrag.h>
24#include <QtGui/qdrag.h>
134 emit q->targetChanged();
142 QDragLeaveEvent
event;
161 d->eventQueued =
false;
162 if (
d->dragRestarted) {
163 d->deliverLeaveEvent();
166 d->deliverEnterEvent();
168 if (
d->target !=
d->dragGrabber.target()) {
169 d->target =
d->dragGrabber.target();
172 }
else if (
d->itemMoved) {
173 d->deliverMoveEvent();
186 d->source =
d->attachedItem;
222 qmlWarning(
this) <<
"active cannot be changed from within a drag event handler";
225 d->start(
d->supportedActions);
232 d->startDrag(
d->supportedActions);
261 if (
d->source !=
item) {
272 if (
d->source !=
d->attachedItem) {
273 d->source =
d->attachedItem;
345 return d->imageSource;
351 if (
d->imageSource !=
url) {
352 d->imageSource =
url;
387 int width =
d->imageSourceSize.width();
388 int height =
d->imageSourceSize.height();
396 if (
d->imageSourceSize !=
size) {
397 d->imageSourceSize =
size;
399 if (!
d->imageSource.isEmpty())
424 if (
d->keys !=
keys) {
445 return d->externalMimeData;
469 return d->supportedActions;
475 if (
d->supportedActions != actions) {
476 d->supportedActions = actions;
495 return d->proposedAction;
501 if (
d->proposedAction != action) {
502 d->proposedAction = action;
567 emit q->targetChanged();
570 emit q->activeChanged();
587 qmlWarning(
this) <<
"start() cannot be called from within a drag event handler";
594 d->overrideActions =
false;
602 d->overrideActions =
true;
631 qmlWarning(
this) <<
"drop() cannot be called from within a drag event handler";
632 return acceptedAction;
636 d->deliverMoveEvent();
639 return acceptedAction;
645 QPoint scenePos =
d->attachedItem->mapToScene(
d->hotSpot).toPoint();
650 d->deliverEvent(
d->window, &
event);
652 if (
event.isAccepted()) {
653 acceptedAction =
event.dropAction();
654 target =
d->dragGrabber.target();
664 return acceptedAction;
678 qmlWarning(
this) <<
"cancel() cannot be called from within a drag event handler";
685 d->deliverLeaveEvent();
719 switch (
value.typeId()) {
720 case QMetaType::QByteArray:
724 case QMetaType::QString: {
728 }
else if (
mimeType == u
"text/html"_s) {
730 }
else if (
mimeType == u
"text/uri-list"_s) {
736 }
else if (
mimeType.startsWith(u
"text/"_s)) {
737 if (
qsizetype charsetIdx =
mimeType.lastIndexOf(u
";charset="_s); charsetIdx != -1) {
738 charsetIdx +=
sizeof(
";charset=") - 1;
753 case QMetaType::QVariantList:
754 case QMetaType::QStringList:
755 if (
mimeType == u
"text/uri-list"_s) {
758 urls.reserve(
values.size());
767 <<
" is not a valid URI";
774 case QMetaType::QImage:
778 if (imageFormats.isEmpty()) {
794 qmlWarning(
q) <<
"Don't know how to encode variant of type " <<
value.metaType()
827 emit q->dragStarted();
838 emit q->targetChanged();
841 emit q->dragFinished(dropAction);
844 emit q->activeChanged();
864 qmlWarning(
this) <<
"startDrag() cannot be called from within a drag event handler";
869 qmlWarning(
this) <<
"startDrag() drag must be active";
890:
QObject(parent), _target(
nullptr), _axis(XAndYAxis), _xmin(-FLT_MAX),
891_xmax(FLT_MAX), _ymin(-FLT_MAX), _ymax(FLT_MAX), _active(
false), _filterChildren(
false),
892 _smoothed(true), _threshold(
QGuiApplication::styleHints()->startDragDistance())
915 if (_target ==
nullptr)
993 if (_smoothed != smooth) {
1006 if (_threshold !=
value) {
1024 if (_active == drag)
1032 return _filterChildren;
1037 if (_filterChildren ==
filter)
1039 _filterChildren =
filter;
1050#include "moc_qquickdrag_p.cpp"
\inmodule QtCore \reentrant
static void postEvent(QObject *receiver, QEvent *event, int priority=Qt::NormalEventPriority)
void setHotSpot(const QPoint &hotspot)
Sets the position of the hot spot relative to the top-left corner of the pixmap used to the point spe...
Qt::DropAction exec(Qt::DropActions supportedActions=Qt::MoveAction)
void setMimeData(QMimeData *data)
Sets the data to be sent to the given MIME data.
void setPixmap(const QPixmap &)
Sets pixmap as the pixmap used to represent the data in a drag and drop operation.
static QPlatformIntegration * platformIntegration()
static QStyleHints * styleHints()
Returns the application's style hints.
The QImageWriter class provides a format independent interface for writing images to files or other d...
bool write(const QImage &image)
Writes the image image to the assigned device or file name.
static QList< QByteArray > supportedMimeTypes()
Returns the list of MIME types supported by QImageWriter.
static QList< QByteArray > imageFormatsForMimeType(const QByteArray &mimeType)
QList< T > toList() const noexcept
qsizetype length() const noexcept
void setHtml(const QString &html)
Sets html as the HTML (MIME type text/html) used to represent the data.
void setData(const QString &mimetype, const QByteArray &data)
Sets the data associated with the MIME type given by mimeType to the specified data.
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.
void setUrls(const QList< QUrl > &urls)
Sets the URLs stored in the MIME data object to those specified by urls.
QObject * parent() const
Returns a pointer to the parent object.
virtual bool event(QEvent *event)
This virtual function receives events to an object and should return true if the event e was recogniz...
void deleteLater()
\threadsafe
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
\inmodule QtCore\reentrant
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
\inmodule QtCore\reentrant
The QQmlContext class defines a context within a QML engine.
Qt::DropAction proposedAction
QQuickDragMimeData * mimeData
QMimeData * createMimeData() const
\qmlattachedsignal QtQuick::Drag::dragStarted()
QQuickPixmap pixmapLoader
void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) override
\qmltype Drag \instantiates QQuickDrag \inqmlmodule QtQuick
Qt::DropAction startDrag(Qt::DropActions supportedActions)
QQuickDragGrabber dragGrabber
QPointer< QObject > source
void itemParentChanged(QQuickItem *, QQuickItem *parent) override
Qt::DropActions supportedActions
void start(Qt::DropActions supportedActions)
QQuickItem * attachedItem
void deliverEvent(QQuickWindow *window, QEvent *event)
QVariantMap externalMimeData
QPointer< QQuickWindow > window
void imageSourceSizeChanged()
void setSupportedActions(Qt::DropActions actions)
void setImageSource(const QUrl &url)
QQuickDrag::DragType dragType
void setSource(QObject *item)
void cancel()
\qmlattachedmethod void QtQuick::Drag::cancel()
void setMimeData(const QVariantMap &mimeData)
void setDragType(QQuickDrag::DragType dragType)
void setImageSourceSize(const QSize &size)
void start(QQmlV4FunctionPtr)
\qmlattachedmethod void QtQuick::Drag::start(flags supportedActions)
Qt::DropAction proposedAction
Qt::DropActions supportedActions
void startDrag(QQmlV4FunctionPtr)
\qmlattachedmethod void QtQuick::Drag::startDrag(flags supportedActions)
void setActive(bool active)
bool event(QEvent *event) override
This virtual function receives events to an object and should return true if the event e was recogniz...
QQuickDragAttached(QObject *parent)
void proposedActionChanged()
void imageSourceChanged()
void setKeys(const QStringList &keys)
void setProposedAction(Qt::DropAction action)
Q_INVOKABLE int drop()
\qmlattachedmethod enumeration QtQuick::Drag::drop()
bool isActive() const
\qmlattachedproperty bool QtQuick::Drag::active
void setHotSpot(const QPointF &hotSpot)
void supportedActionsChanged()
void setSmoothed(bool smooth)
void setFilterChildren(bool)
void setTarget(QQuickItem *target)
void filterChildrenChanged()
QQuickDrag(QObject *parent=nullptr)
static QQuickDragAttached * qmlAttachedProperties(QObject *obj)
void setProposedAction(Qt::DropAction action)
bool positionChange() const
static QQuickItemPrivate * get(QQuickItem *item)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
QPointF mapToScene(const QPointF &point) const
Maps the given point in this item's coordinate system to the equivalent point within the scene's coor...
QQuickWindow * window() const
Returns the window in which this item is rendered.
void load(QQmlEngine *, const QUrl &)
static QQuickWindowPrivate * get(QQuickWindow *c)
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
bool isValid() const noexcept
Returns true if this is a valid string converter that can be used for encoding or decoding text.
Q_WEAK_OVERLOAD DecodedData< const QString & > encode(const QString &str)
\macro QT_RESTRICTED_CAST_FROM_ASCII
QByteArray toUtf8() const &
bool isValid() const
Returns true if the URL is non-empty and valid; otherwise returns false.
bool isEmpty() const
Returns true if the URL has no data; otherwise returns false.
void clear()
Resets the content of the QUrl.
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLenum GLsizei GLsizei GLint * values
[15]
GLsizei const GLfloat * v
[13]
GLint GLsizei GLsizei height
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLsizei GLsizei GLchar * source
GLdouble GLdouble GLdouble GLdouble q
QQmlContext * qmlContext(const QObject *obj)
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
QQuickItem * qobject_cast< QQuickItem * >(QObject *o)
QUrl url("example.com")
[constructor-url-reference]