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/qquickpixmapcache_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;
355 d->pixmapLoader.clear();
382 if (
d->keys !=
keys) {
403 return d->externalMimeData;
427 return d->supportedActions;
433 if (
d->supportedActions != actions) {
434 d->supportedActions = actions;
453 return d->proposedAction;
459 if (
d->proposedAction != action) {
460 d->proposedAction = action;
525 emit q->targetChanged();
528 emit q->activeChanged();
545 qmlWarning(
this) <<
"start() cannot be called from within a drag event handler";
552 d->overrideActions =
false;
560 d->overrideActions =
true;
589 qmlWarning(
this) <<
"drop() cannot be called from within a drag event handler";
590 return acceptedAction;
594 d->deliverMoveEvent();
597 return acceptedAction;
603 QPoint scenePos =
d->attachedItem->mapToScene(
d->hotSpot).toPoint();
608 d->deliverEvent(
d->window, &
event);
610 if (
event.isAccepted()) {
611 acceptedAction =
event.dropAction();
612 target =
d->dragGrabber.target();
622 return acceptedAction;
636 qmlWarning(
this) <<
"cancel() cannot be called from within a drag event handler";
643 d->deliverLeaveEvent();
677 switch (
value.typeId()) {
678 case QMetaType::QByteArray:
682 case QMetaType::QString: {
686 }
else if (
mimeType == u
"text/html"_s) {
688 }
else if (
mimeType == u
"text/uri-list"_s) {
694 }
else if (
mimeType.startsWith(u
"text/"_s)) {
695 if (
qsizetype charsetIdx =
mimeType.lastIndexOf(u
";charset="_s); charsetIdx != -1) {
696 charsetIdx +=
sizeof(
";charset=") - 1;
708 <<
" is not a supported text type";
712 case QMetaType::QVariantList:
713 case QMetaType::QStringList:
714 if (
mimeType == u
"text/uri-list"_s) {
726 <<
" is not a valid URI";
733 case QMetaType::QImage:
737 if (imageFormats.isEmpty()) {
753 qmlWarning(
q) <<
"Don't know how to encode variant of type " <<
value.metaType()
775 emit q->dragStarted();
786 emit q->targetChanged();
789 emit q->dragFinished(dropAction);
792 emit q->activeChanged();
812 qmlWarning(
this) <<
"startDrag() cannot be called from within a drag event handler";
817 qmlWarning(
this) <<
"startDrag() drag must be active";
839_xmax(FLT_MAX), _ymin(-FLT_MAX), _ymax(FLT_MAX), _active(
false), _filterChildren(
false),
840 _smoothed(true), _threshold(
QGuiApplication::styleHints()->startDragDistance())
863 if (_target ==
nullptr)
941 if (_smoothed != smooth) {
954 if (_threshold !=
value) {
980 return _filterChildren;
985 if (_filterChildren ==
filter)
998#include "moc_qquickdrag_p.cpp"
\inmodule QtCore \reentrant
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
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 reserve(qsizetype size)
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
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 startDrag(QQmlV4Function *)
\qmlattachedmethod void QtQuick::Drag::startDrag(flags supportedActions)
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)
Qt::DropAction proposedAction
Qt::DropActions supportedActions
void start(QQmlV4Function *)
\qmlattachedmethod void QtQuick::Drag::start(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
void addItemChangeListener(QQuickItemChangeListener *listener, ChangeTypes types)
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.
static QQuickWindowPrivate * get(QQuickWindow *c)
QQuickDeliveryAgentPrivate * deliveryAgentPrivate() const
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\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.
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]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLsizei GLsizei GLchar * source
GLdouble GLdouble GLdouble GLdouble q
QQmlEngine * qmlEngine(const QObject *obj)
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
QQuickItem * qobject_cast< QQuickItem * >(QObject *o)
QUrl url("example.com")
[constructor-url-reference]
bool contains(const AT &t) const noexcept
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent