1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the QtQml module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
40 ****************************************************************************/
42 #ifndef QQUICKDROPAREA_P_H
43 #define QQUICKDROPAREA_P_H
45 #include "qquickitem.h"
47 #include <private/qqmlguard_p.h>
48 #include <private/qv8engine_p.h>
50 #include <QtGui/qevent.h>
52 #ifndef QT_NO_DRAGANDDROP
58 class QQuickDropAreaPrivate;
59 class QQuickDropEvent : public QObject
62 Q_PROPERTY(qreal x READ x)
63 Q_PROPERTY(qreal y READ y)
64 Q_PROPERTY(QObject *source READ source)
65 Q_PROPERTY(QStringList keys READ keys)
66 Q_PROPERTY(Qt::DropActions supportedActions READ supportedActions)
67 Q_PROPERTY(Qt::DropAction action READ action WRITE setAction RESET resetAction)
68 Q_PROPERTY(bool accepted READ accepted WRITE setAccepted)
70 QQuickDropEvent(QQuickDropAreaPrivate *d, QDropEvent *event) : d(d), event(event) {}
72 qreal x() const { return event->pos().x(); }
73 qreal y() const { return event->pos().y(); }
77 Qt::DropActions supportedActions() const { return event->possibleActions(); }
78 Qt::DropAction action() const { return event->dropAction(); }
79 void setAction(Qt::DropAction action) { event->setDropAction(action); }
80 void resetAction() { event->setDropAction(event->proposedAction()); }
82 QStringList keys() const;
84 bool accepted() const { return event->isAccepted(); }
85 void setAccepted(bool accepted) { event->setAccepted(accepted); }
87 Q_INVOKABLE void accept(QQmlV8Function *);
90 QQuickDropAreaPrivate *d;
94 class QQuickDropAreaDrag : public QObject
97 Q_PROPERTY(qreal x READ x NOTIFY positionChanged)
98 Q_PROPERTY(qreal y READ y NOTIFY positionChanged)
99 Q_PROPERTY(QObject *source READ source NOTIFY sourceChanged)
101 QQuickDropAreaDrag(QQuickDropAreaPrivate *d, QObject *parent = 0);
102 ~QQuickDropAreaDrag();
106 QObject *source() const;
109 void positionChanged();
110 void sourceChanged();
113 QQuickDropAreaPrivate *d;
115 friend class QQuickDropArea;
116 friend class QQuickDropAreaPrivate;
119 class QQuickDropAreaPrivate;
120 class Q_AUTOTEST_EXPORT QQuickDropArea : public QQuickItem
123 Q_PROPERTY(bool containsDrag READ containsDrag NOTIFY containsDragChanged)
124 Q_PROPERTY(QStringList keys READ keys WRITE setKeys NOTIFY keysChanged)
125 Q_PROPERTY(QQuickDropAreaDrag *drag READ drag CONSTANT)
128 QQuickDropArea(QQuickItem *parent=0);
131 bool containsDrag() const;
132 void setContainsDrag(bool drag);
134 QStringList keys() const;
135 void setKeys(const QStringList &keys);
137 QQuickDropAreaDrag *drag();
140 void containsDragChanged();
142 void sourceChanged();
144 void entered(QQuickDropEvent *drag);
146 void positionChanged(QQuickDropEvent *drag);
147 void dropped(QQuickDropEvent *drop);
150 void dragMoveEvent(QDragMoveEvent *event);
151 void dragEnterEvent(QDragEnterEvent *event);
152 void dragLeaveEvent(QDragLeaveEvent *event);
153 void dropEvent(QDropEvent *event);
156 Q_DISABLE_COPY(QQuickDropArea)
157 Q_DECLARE_PRIVATE(QQuickDropArea)
162 QML_DECLARE_TYPE(QQuickDropEvent)
163 QML_DECLARE_TYPE(QQuickDropArea)
167 #endif // QT_NO_DRAGANDDROP
169 #endif // QQUICKDROPAREA_P_H