Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / quick / items / qquickdroparea_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
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/qdeclarativeguard_p.h>
48 #include <private/qv8engine_p.h>
49
50 #include <QtGui/qevent.h>
51
52 QT_BEGIN_HEADER
53
54 QT_BEGIN_NAMESPACE
55
56 class QQuickDropAreaPrivate;
57 class QQuickDropEvent : public QObject
58 {
59     Q_OBJECT
60     Q_PROPERTY(qreal x READ x)
61     Q_PROPERTY(qreal y READ y)
62     Q_PROPERTY(QObject *source READ source)
63     Q_PROPERTY(QStringList keys READ keys)
64     Q_PROPERTY(Qt::DropActions supportedActions READ supportedActions)
65     Q_PROPERTY(Qt::DropAction action READ action WRITE setAction RESET resetAction)
66     Q_PROPERTY(bool accepted READ accepted WRITE setAccepted)
67 public:
68     QQuickDropEvent(QQuickDropAreaPrivate *d, QDropEvent *event) : d(d), event(event) {}
69
70     qreal x() const { return event->pos().x(); }
71     qreal y() const { return event->pos().y(); }
72
73     QObject *source();
74
75     Qt::DropActions supportedActions() const { return event->possibleActions(); }
76     Qt::DropAction action() const { return event->dropAction(); }
77     void setAction(Qt::DropAction action) { event->setDropAction(action); }
78     void resetAction() { event->setDropAction(event->proposedAction()); }
79
80     QStringList keys() const;
81
82     bool accepted() const { return event->isAccepted(); }
83     void setAccepted(bool accepted) { event->setAccepted(accepted); }
84
85     Q_INVOKABLE void accept(QDeclarativeV8Function *);
86
87 private:
88     QQuickDropAreaPrivate *d;
89     QDropEvent *event;
90 };
91
92 class QQuickDropAreaDrag : public QObject
93 {
94     Q_OBJECT
95     Q_PROPERTY(qreal x READ x NOTIFY positionChanged)
96     Q_PROPERTY(qreal y READ y NOTIFY positionChanged)
97     Q_PROPERTY(QObject *source READ source NOTIFY sourceChanged)
98 public:
99     QQuickDropAreaDrag(QQuickDropAreaPrivate *d, QObject *parent = 0);
100     ~QQuickDropAreaDrag();
101
102     qreal x() const;
103     qreal y() const;
104     QObject *source() const;
105
106 Q_SIGNALS:
107     void positionChanged();
108     void sourceChanged();
109
110 private:
111     QQuickDropAreaPrivate *d;
112
113     friend class QQuickDropArea;
114     friend class QQuickDropAreaPrivate;
115 };
116
117 class QQuickDropAreaPrivate;
118 class Q_AUTOTEST_EXPORT QQuickDropArea : public QQuickItem
119 {
120     Q_OBJECT
121     Q_PROPERTY(bool containsDrag READ containsDrag NOTIFY containsDragChanged)
122     Q_PROPERTY(QStringList keys READ keys WRITE setKeys NOTIFY keysChanged)
123     Q_PROPERTY(QQuickDropAreaDrag *drag READ drag CONSTANT)
124
125 public:
126     QQuickDropArea(QQuickItem *parent=0);
127     ~QQuickDropArea();
128
129     bool containsDrag() const;
130     void setContainsDrag(bool drag);
131
132     QStringList keys() const;
133     void setKeys(const QStringList &keys);
134
135     QQuickDropAreaDrag *drag();
136
137 Q_SIGNALS:
138     void containsDragChanged();
139     void keysChanged();
140     void sourceChanged();
141
142     void entered(QQuickDropEvent *drag);
143     void exited();
144     void positionChanged(QQuickDropEvent *drag);
145     void dropped(QQuickDropEvent *drop);
146
147 protected:
148     void dragMoveEvent(QDragMoveEvent *event);
149     void dragEnterEvent(QDragEnterEvent *event);
150     void dragLeaveEvent(QDragLeaveEvent *event);
151     void dropEvent(QDropEvent *event);
152
153 private:
154     Q_DISABLE_COPY(QQuickDropArea)
155     Q_DECLARE_PRIVATE(QQuickDropArea)
156 };
157
158 QT_END_NAMESPACE
159
160 QML_DECLARE_TYPE(QQuickDropEvent)
161 QML_DECLARE_TYPE(QQuickDropArea)
162
163 QT_END_HEADER
164
165 #endif // QQUICKDROPAREA_P_H