1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
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.
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.
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.
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.
40 ****************************************************************************/
42 #ifndef QSGDROPAREA_P_H
43 #define QSGDROPAREA_P_H
47 #include <private/qdeclarativeguard_p.h>
48 #include <private/qv8engine_p.h>
50 #include <QtGui/qevent.h>
56 QT_MODULE(Declarative)
58 class QSGDropAreaPrivate;
59 class QSGDropEvent : 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 QSGDropEvent(QSGDropAreaPrivate *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(QDeclarativeV8Function *);
90 QSGDropAreaPrivate *d;
94 class QSGDropAreaDrag : 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 QSGDropAreaDrag(QSGDropAreaPrivate *d, QObject *parent = 0);
106 QObject *source() const;
109 void positionChanged();
110 void sourceChanged();
113 QSGDropAreaPrivate *d;
115 friend class QSGDropArea;
116 friend class QSGDropAreaPrivate;
119 class QSGDropAreaPrivate;
120 class Q_AUTOTEST_EXPORT QSGDropArea : public QSGItem
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)
128 QSGDropArea(QSGItem *parent=0);
131 bool containsDrag() const;
132 void setContainsDrag(bool drag);
134 QStringList keys() const;
135 void setKeys(const QStringList &keys);
137 QSGDropAreaDrag *drag();
140 void containsDragChanged();
142 void sourceChanged();
144 void entered(QSGDropEvent *drag);
146 void positionChanged(QSGDropEvent *drag);
147 void dropped(QSGDropEvent *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(QSGDropArea)
157 Q_DECLARE_PRIVATE(QSGDropArea)
162 QML_DECLARE_TYPE(QSGDropEvent)
163 QML_DECLARE_TYPE(QSGDropArea)
167 #endif // QSGDRAGTARGET_P_H