diff options
Diffstat (limited to 'src/quick/items/qquickdroparea.cpp')
-rw-r--r-- | src/quick/items/qquickdroparea.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/quick/items/qquickdroparea.cpp b/src/quick/items/qquickdroparea.cpp index 217b455d43..e46d546a16 100644 --- a/src/quick/items/qquickdroparea.cpp +++ b/src/quick/items/qquickdroparea.cpp @@ -36,6 +36,7 @@ #include "qquickitem_p.h" #include "qquickwindow.h" +#include <private/qv4arraybuffer_p.h> #include <private/qqmlengine_p.h> #ifndef QT_NO_DRAGANDDROP @@ -496,6 +497,14 @@ void QQuickDropArea::dropEvent(QDropEvent *event) Returns the data for the given \a format converted to a string. \a format should be one contained in the \l formats property. */ +/*! + \qmlmethod string QtQuick::DragEvent::getDataAsArrayBuffer(string format) + \since 5.5 + + Returns the data for the given \a format into an ArrayBuffer, which can + easily be translated into a QByteArray. \a format should be one contained in the \l formats property. +*/ + QObject *QQuickDropEvent::source() { if (const QQuickDragMimeData *dragMime = qobject_cast<const QQuickDragMimeData *>(event->mimeData())) @@ -566,6 +575,17 @@ void QQuickDropEvent::getDataAsString(QQmlV4Function *args) } } +void QQuickDropEvent::getDataAsArrayBuffer(QQmlV4Function *args) +{ + if (args->length() != 0) { + QV4::ExecutionEngine *v4 = args->v4engine(); + QV4::Scope scope(v4); + QV4::ScopedValue v(scope, (*args)[0]); + const QString format = v->toQString(); + args->setReturnValue(v4->newArrayBuffer(event->mimeData()->data(format))->asReturnedValue()); + } +} + void QQuickDropEvent::acceptProposedAction(QQmlV4Function *) { event->acceptProposedAction(); |