Change copyrights from Nokia to Digia
[profile/ivi/qtdeclarative.git] / src / quick / items / qquickdroparea_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtQml module of the Qt Toolkit.
7 **
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.
16 **
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.
24 **
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.
28 **
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.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QQUICKDROPAREA_P_H
43 #define QQUICKDROPAREA_P_H
44
45 #include "qquickitem.h"
46
47 #include <private/qqmlguard_p.h>
48 #include <private/qv8engine_p.h>
49
50 #include <QtGui/qevent.h>
51
52 #ifndef QT_NO_DRAGANDDROP
53
54 QT_BEGIN_HEADER
55
56 QT_BEGIN_NAMESPACE
57
58 class QQuickDropAreaPrivate;
59 class QQuickDropEvent : public QObject
60 {
61     Q_OBJECT
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)
69 public:
70     QQuickDropEvent(QQuickDropAreaPrivate *d, QDropEvent *event) : d(d), event(event) {}
71
72     qreal x() const { return event->pos().x(); }
73     qreal y() const { return event->pos().y(); }
74
75     QObject *source();
76
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()); }
81
82     QStringList keys() const;
83
84     bool accepted() const { return event->isAccepted(); }
85     void setAccepted(bool accepted) { event->setAccepted(accepted); }
86
87     Q_INVOKABLE void accept(QQmlV8Function *);
88
89 private:
90     QQuickDropAreaPrivate *d;
91     QDropEvent *event;
92 };
93
94 class QQuickDropAreaDrag : public QObject
95 {
96     Q_OBJECT
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)
100 public:
101     QQuickDropAreaDrag(QQuickDropAreaPrivate *d, QObject *parent = 0);
102     ~QQuickDropAreaDrag();
103
104     qreal x() const;
105     qreal y() const;
106     QObject *source() const;
107
108 Q_SIGNALS:
109     void positionChanged();
110     void sourceChanged();
111
112 private:
113     QQuickDropAreaPrivate *d;
114
115     friend class QQuickDropArea;
116     friend class QQuickDropAreaPrivate;
117 };
118
119 class QQuickDropAreaPrivate;
120 class Q_AUTOTEST_EXPORT QQuickDropArea : public QQuickItem
121 {
122     Q_OBJECT
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)
126
127 public:
128     QQuickDropArea(QQuickItem *parent=0);
129     ~QQuickDropArea();
130
131     bool containsDrag() const;
132     void setContainsDrag(bool drag);
133
134     QStringList keys() const;
135     void setKeys(const QStringList &keys);
136
137     QQuickDropAreaDrag *drag();
138
139 Q_SIGNALS:
140     void containsDragChanged();
141     void keysChanged();
142     void sourceChanged();
143
144     void entered(QQuickDropEvent *drag);
145     void exited();
146     void positionChanged(QQuickDropEvent *drag);
147     void dropped(QQuickDropEvent *drop);
148
149 protected:
150     void dragMoveEvent(QDragMoveEvent *event);
151     void dragEnterEvent(QDragEnterEvent *event);
152     void dragLeaveEvent(QDragLeaveEvent *event);
153     void dropEvent(QDropEvent *event);
154
155 private:
156     Q_DISABLE_COPY(QQuickDropArea)
157     Q_DECLARE_PRIVATE(QQuickDropArea)
158 };
159
160 QT_END_NAMESPACE
161
162 QML_DECLARE_TYPE(QQuickDropEvent)
163 QML_DECLARE_TYPE(QQuickDropArea)
164
165 QT_END_HEADER
166
167 #endif // QT_NO_DRAGANDDROP
168
169 #endif // QQUICKDROPAREA_P_H