Fix test fails related to QTBUG-22237
[profile/ivi/qtdeclarative.git] / src / declarative / items / qsgdroparea_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QSGDROPAREA_P_H
43 #define QSGDROPAREA_P_H
44
45 #include "qsgitem.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 QT_MODULE(Declarative)
57
58 class QSGDropAreaPrivate;
59 class QSGDropEvent : 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     QSGDropEvent(QSGDropAreaPrivate *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(QDeclarativeV8Function *);
88
89 private:
90     QSGDropAreaPrivate *d;
91     QDropEvent *event;
92 };
93
94 class QSGDropAreaDrag : 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     QSGDropAreaDrag(QSGDropAreaPrivate *d, QObject *parent = 0);
102     ~QSGDropAreaDrag();
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     QSGDropAreaPrivate *d;
114
115     friend class QSGDropArea;
116     friend class QSGDropAreaPrivate;
117 };
118
119 class QSGDropAreaPrivate;
120 class Q_AUTOTEST_EXPORT QSGDropArea : public QSGItem
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(QSGDropAreaDrag *drag READ drag CONSTANT)
126
127 public:
128     QSGDropArea(QSGItem *parent=0);
129     ~QSGDropArea();
130
131     bool containsDrag() const;
132     void setContainsDrag(bool drag);
133
134     QStringList keys() const;
135     void setKeys(const QStringList &keys);
136
137     QSGDropAreaDrag *drag();
138
139 Q_SIGNALS:
140     void containsDragChanged();
141     void keysChanged();
142     void sourceChanged();
143
144     void entered(QSGDropEvent *drag);
145     void exited();
146     void positionChanged(QSGDropEvent *drag);
147     void dropped(QSGDropEvent *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(QSGDropArea)
157     Q_DECLARE_PRIVATE(QSGDropArea)
158 };
159
160 QT_END_NAMESPACE
161
162 QML_DECLARE_TYPE(QSGDropEvent)
163 QML_DECLARE_TYPE(QSGDropArea)
164
165 QT_END_HEADER
166
167 #endif // QSGDRAGTARGET_P_H