**
****************************************************************************/
-#include "qsgdrag_p.h"
+#include "qquickdrag_p.h"
-#include <private/qsgitem_p.h>
-#include <private/qsgevents_p_p.h>
-#include <private/qsgitemchangelistener_p.h>
+#include <private/qquickitem_p.h>
+#include <private/qquickevents_p_p.h>
+#include <private/qquickitemchangelistener_p.h>
#include <private/qv8engine_p.h>
#include <QtGui/qevent.h>
QT_BEGIN_NAMESPACE
-class QSGDragAttachedPrivate : public QObjectPrivate, public QSGItemChangeListener
+class QQuickDragAttachedPrivate : public QObjectPrivate, public QQuickItemChangeListener
{
- Q_DECLARE_PUBLIC(QSGDragAttached)
+ Q_DECLARE_PUBLIC(QQuickDragAttached)
public:
- static QSGDragAttachedPrivate *get(QSGDragAttached *attached) {
- return static_cast<QSGDragAttachedPrivate *>(QObjectPrivate::get(attached)); }
+ static QQuickDragAttachedPrivate *get(QQuickDragAttached *attached) {
+ return static_cast<QQuickDragAttachedPrivate *>(QObjectPrivate::get(attached)); }
- QSGDragAttachedPrivate()
+ QQuickDragAttachedPrivate()
: attachedItem(0)
, mimeData(0)
, proposedAction(Qt::MoveAction)
{
}
- void itemGeometryChanged(QSGItem *, const QRectF &, const QRectF &);
+ void itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &);
void start() { start(supportedActions); }
void start(Qt::DropActions supportedActions);
- void setTarget(QSGItem *item);
+ void setTarget(QQuickItem *item);
- QSGDragGrabber dragGrabber;
+ QQuickDragGrabber dragGrabber;
QDeclarativeGuard<QObject> source;
QDeclarativeGuard<QObject> target;
- QSGItem *attachedItem;
- QSGDragMimeData *mimeData;
+ QQuickItem *attachedItem;
+ QQuickDragMimeData *mimeData;
Qt::DropAction proposedAction;
Qt::DropActions supportedActions;
bool active : 1;
};
/*!
- \qmlclass Drag QSGDrag
+ \qmlclass Drag QQuickDrag
\inqmlmodule QtQuick 2
\brief The Drag attached property provides drag and drop events for moved Items.
*/
-void QSGDragAttachedPrivate::itemGeometryChanged(QSGItem *, const QRectF &newGeometry, const QRectF &oldGeometry)
+void QQuickDragAttachedPrivate::itemGeometryChanged(QQuickItem *, const QRectF &newGeometry, const QRectF &oldGeometry)
{
- Q_Q(QSGDragAttached);
+ Q_Q(QQuickDragAttached);
if (newGeometry.topLeft() == oldGeometry.topLeft() || !active)
return;
- if (QSGCanvas *canvas = attachedItem->canvas()) {
+ if (QQuickCanvas *canvas = attachedItem->canvas()) {
QPoint scenePos = attachedItem->mapToScene(hotSpot).toPoint();
QDragMoveEvent event(scenePos, mimeData->m_supportedActions, mimeData, Qt::NoButton, Qt::NoModifier);
- QSGDropEventEx::setProposedAction(&event, proposedAction);
- QSGCanvasPrivate::get(canvas)->deliverDragEvent(&dragGrabber, &event);
+ QQuickDropEventEx::setProposedAction(&event, proposedAction);
+ QQuickCanvasPrivate::get(canvas)->deliverDragEvent(&dragGrabber, &event);
if (target != dragGrabber.target()) {
target = dragGrabber.target();
emit q->targetChanged();
}
}
-QSGDragAttached::QSGDragAttached(QObject *parent)
- : QObject(*new QSGDragAttachedPrivate, parent)
+QQuickDragAttached::QQuickDragAttached(QObject *parent)
+ : QObject(*new QQuickDragAttachedPrivate, parent)
{
- Q_D(QSGDragAttached);
- d->attachedItem = qobject_cast<QSGItem *>(parent);
+ Q_D(QQuickDragAttached);
+ d->attachedItem = qobject_cast<QQuickItem *>(parent);
d->source = d->attachedItem;
}
-QSGDragAttached::~QSGDragAttached()
+QQuickDragAttached::~QQuickDragAttached()
{
- Q_D(QSGDragAttached);
+ Q_D(QQuickDragAttached);
delete d->mimeData;
}
event with item's new position to the scene.
*/
-bool QSGDragAttached::isActive() const
+bool QQuickDragAttached::isActive() const
{
- Q_D(const QSGDragAttached);
+ Q_D(const QQuickDragAttached);
return d->active;
}
-void QSGDragAttached::setActive(bool active)
+void QQuickDragAttached::setActive(bool active)
{
- Q_D(QSGDragAttached);
+ Q_D(QQuickDragAttached);
if (d->active != active) {
if (active)
d->start(d->supportedActions);
Changes to source while a Drag is active don't take effect until a new drag is started.
*/
-QObject *QSGDragAttached::source() const
+QObject *QQuickDragAttached::source() const
{
- Q_D(const QSGDragAttached);
+ Q_D(const QQuickDragAttached);
return d->source;
}
-void QSGDragAttached::setSource(QObject *item)
+void QQuickDragAttached::setSource(QObject *item)
{
- Q_D(QSGDragAttached);
+ Q_D(QQuickDragAttached);
if (d->source != item) {
d->source = item;
emit sourceChanged();
}
}
-void QSGDragAttached::resetSource()
+void QQuickDragAttached::resetSource()
{
- Q_D(QSGDragAttached);
+ Q_D(QQuickDragAttached);
if (d->source != d->attachedItem) {
d->source = d->attachedItem;
emit sourceChanged();
the drag was cancelled the target will then be null.
*/
-QObject *QSGDragAttached::target() const
+QObject *QQuickDragAttached::target() const
{
- Q_D(const QSGDragAttached);
+ Q_D(const QQuickDragAttached);
return d->target;
}
Changes to hotSpot will take effect when the next event is sent.
*/
-QPointF QSGDragAttached::hotSpot() const
+QPointF QQuickDragAttached::hotSpot() const
{
- Q_D(const QSGDragAttached);
+ Q_D(const QQuickDragAttached);
return d->hotSpot;
}
-void QSGDragAttached::setHotSpot(const QPointF &hotSpot)
+void QQuickDragAttached::setHotSpot(const QPointF &hotSpot)
{
- Q_D(QSGDragAttached);
+ Q_D(QQuickDragAttached);
if (d->hotSpot != hotSpot) {
d->hotSpot = hotSpot;
emit hotSpotChanged();
Changes to keys while a Drag is active don't take effect until a new drag is started.
*/
-QStringList QSGDragAttached::keys() const
+QStringList QQuickDragAttached::keys() const
{
- Q_D(const QSGDragAttached);
+ Q_D(const QQuickDragAttached);
return d->keys;
}
-void QSGDragAttached::setKeys(const QStringList &keys)
+void QQuickDragAttached::setKeys(const QStringList &keys)
{
- Q_D(QSGDragAttached);
+ Q_D(QQuickDragAttached);
if (d->keys != keys) {
d->keys = keys;
emit keysChanged();
until a new drag is started.
*/
-Qt::DropActions QSGDragAttached::supportedActions() const
+Qt::DropActions QQuickDragAttached::supportedActions() const
{
- Q_D(const QSGDragAttached);
+ Q_D(const QQuickDragAttached);
return d->supportedActions;
}
-void QSGDragAttached::setSupportedActions(Qt::DropActions actions)
+void QQuickDragAttached::setSupportedActions(Qt::DropActions actions)
{
- Q_D(QSGDragAttached);
+ Q_D(QQuickDragAttached);
if (d->supportedActions != actions) {
d->supportedActions = actions;
emit supportedActionsChanged();
Changes to proposedAction will take effect when the next event is sent.
*/
-Qt::DropAction QSGDragAttached::proposedAction() const
+Qt::DropAction QQuickDragAttached::proposedAction() const
{
- Q_D(const QSGDragAttached);
+ Q_D(const QQuickDragAttached);
return d->proposedAction;
}
-void QSGDragAttached::setProposedAction(Qt::DropAction action)
+void QQuickDragAttached::setProposedAction(Qt::DropAction action)
{
- Q_D(QSGDragAttached);
+ Q_D(QQuickDragAttached);
if (d->proposedAction != action) {
d->proposedAction = action;
emit proposedActionChanged();
}
}
-void QSGDragAttachedPrivate::start(Qt::DropActions supportedActions)
+void QQuickDragAttachedPrivate::start(Qt::DropActions supportedActions)
{
- Q_Q(QSGDragAttached);
+ Q_Q(QQuickDragAttached);
Q_ASSERT(!active);
- if (QSGCanvas *canvas = attachedItem ? attachedItem->canvas() : 0) {
+ if (QQuickCanvas *canvas = attachedItem ? attachedItem->canvas() : 0) {
if (!mimeData)
- mimeData = new QSGDragMimeData;
+ mimeData = new QQuickDragMimeData;
if (!listening) {
- QSGItemPrivate::get(attachedItem)->addItemChangeListener(this, QSGItemPrivate::Geometry);
+ QQuickItemPrivate::get(attachedItem)->addItemChangeListener(this, QQuickItemPrivate::Geometry);
listening = true;
}
QPoint scenePos = attachedItem->mapToScene(hotSpot).toPoint();
QDragEnterEvent event(scenePos, supportedActions, mimeData, Qt::NoButton, Qt::NoModifier);
- QSGDropEventEx::setProposedAction(&event, proposedAction);
- QSGCanvasPrivate::get(canvas)->deliverDragEvent(&dragGrabber, &event);
+ QQuickDropEventEx::setProposedAction(&event, proposedAction);
+ QQuickCanvasPrivate::get(canvas)->deliverDragEvent(&dragGrabber, &event);
emit q->activeChanged();
if (target != dragGrabber.target()) {
property for the started sequence.
*/
-void QSGDragAttached::start(QDeclarativeV8Function *args)
+void QQuickDragAttached::start(QDeclarativeV8Function *args)
{
- Q_D(QSGDragAttached);
+ Q_D(QQuickDragAttached);
if (d->active)
cancel();
*/
-int QSGDragAttached::drop()
+int QQuickDragAttached::drop()
{
- Q_D(QSGDragAttached);
+ Q_D(QQuickDragAttached);
Qt::DropAction acceptedAction = Qt::IgnoreAction;
if (!d->active)
QObject *target = 0;
- if (QSGCanvas *canvas = d->attachedItem->canvas()) {
+ if (QQuickCanvas *canvas = d->attachedItem->canvas()) {
QPoint scenePos = d->attachedItem->mapToScene(d->hotSpot).toPoint();
QDropEvent event(
scenePos, d->mimeData->m_supportedActions, d->mimeData, Qt::NoButton, Qt::NoModifier);
- QSGDropEventEx::setProposedAction(&event, d->proposedAction);
- QSGCanvasPrivate::get(canvas)->deliverDragEvent(&d->dragGrabber, &event);
+ QQuickDropEventEx::setProposedAction(&event, d->proposedAction);
+ QQuickCanvasPrivate::get(canvas)->deliverDragEvent(&d->dragGrabber, &event);
if (event.isAccepted()) {
acceptedAction = event.dropAction();
Ends a drag sequence.
*/
-void QSGDragAttached::cancel()
+void QQuickDragAttached::cancel()
{
- Q_D(QSGDragAttached);
+ Q_D(QQuickDragAttached);
if (!d->active)
return;
- if (QSGCanvas *canvas = d->attachedItem->canvas()) {
+ if (QQuickCanvas *canvas = d->attachedItem->canvas()) {
QDragLeaveEvent event;
- QSGCanvasPrivate::get(canvas)->deliverDragEvent(&d->dragGrabber, &event);
+ QQuickCanvasPrivate::get(canvas)->deliverDragEvent(&d->dragGrabber, &event);
}
d->active = false;