1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the QtDeclarative module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QDECLARATIVEFLICKABLE_H
|
---|
43 | #define QDECLARATIVEFLICKABLE_H
|
---|
44 |
|
---|
45 | #include "qdeclarativeitem.h"
|
---|
46 |
|
---|
47 | QT_BEGIN_HEADER
|
---|
48 |
|
---|
49 | QT_BEGIN_NAMESPACE
|
---|
50 |
|
---|
51 | QT_MODULE(Declarative)
|
---|
52 |
|
---|
53 | class QDeclarativeFlickablePrivate;
|
---|
54 | class QDeclarativeFlickableVisibleArea;
|
---|
55 | class Q_AUTOTEST_EXPORT QDeclarativeFlickable : public QDeclarativeItem
|
---|
56 | {
|
---|
57 | Q_OBJECT
|
---|
58 |
|
---|
59 | Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged)
|
---|
60 | Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged)
|
---|
61 | Q_PROPERTY(qreal contentX READ contentX WRITE setContentX NOTIFY contentXChanged)
|
---|
62 | Q_PROPERTY(qreal contentY READ contentY WRITE setContentY NOTIFY contentYChanged)
|
---|
63 | Q_PROPERTY(QDeclarativeItem *contentItem READ contentItem CONSTANT)
|
---|
64 |
|
---|
65 | Q_PROPERTY(qreal horizontalVelocity READ horizontalVelocity NOTIFY horizontalVelocityChanged)
|
---|
66 | Q_PROPERTY(qreal verticalVelocity READ verticalVelocity NOTIFY verticalVelocityChanged)
|
---|
67 |
|
---|
68 | Q_PROPERTY(BoundsBehavior boundsBehavior READ boundsBehavior WRITE setBoundsBehavior NOTIFY boundsBehaviorChanged)
|
---|
69 | Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity NOTIFY maximumFlickVelocityChanged)
|
---|
70 | Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
|
---|
71 | Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged)
|
---|
72 | Q_PROPERTY(bool movingHorizontally READ isMovingHorizontally NOTIFY movingHorizontallyChanged)
|
---|
73 | Q_PROPERTY(bool movingVertically READ isMovingVertically NOTIFY movingVerticallyChanged)
|
---|
74 | Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged)
|
---|
75 | Q_PROPERTY(bool flickingHorizontally READ isFlickingHorizontally NOTIFY flickingHorizontallyChanged)
|
---|
76 | Q_PROPERTY(bool flickingVertically READ isFlickingVertically NOTIFY flickingVerticallyChanged)
|
---|
77 | Q_PROPERTY(FlickableDirection flickableDirection READ flickableDirection WRITE setFlickableDirection NOTIFY flickableDirectionChanged)
|
---|
78 |
|
---|
79 | Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged)
|
---|
80 | Q_PROPERTY(int pressDelay READ pressDelay WRITE setPressDelay NOTIFY pressDelayChanged)
|
---|
81 |
|
---|
82 | Q_PROPERTY(bool atXEnd READ isAtXEnd NOTIFY isAtBoundaryChanged)
|
---|
83 | Q_PROPERTY(bool atYEnd READ isAtYEnd NOTIFY isAtBoundaryChanged)
|
---|
84 | Q_PROPERTY(bool atXBeginning READ isAtXBeginning NOTIFY isAtBoundaryChanged)
|
---|
85 | Q_PROPERTY(bool atYBeginning READ isAtYBeginning NOTIFY isAtBoundaryChanged)
|
---|
86 |
|
---|
87 | Q_PROPERTY(QDeclarativeFlickableVisibleArea *visibleArea READ visibleArea CONSTANT)
|
---|
88 |
|
---|
89 | Q_PROPERTY(QDeclarativeListProperty<QObject> flickableData READ flickableData)
|
---|
90 | Q_PROPERTY(QDeclarativeListProperty<QGraphicsObject> flickableChildren READ flickableChildren)
|
---|
91 | Q_CLASSINFO("DefaultProperty", "flickableData")
|
---|
92 |
|
---|
93 | Q_ENUMS(FlickableDirection)
|
---|
94 | Q_ENUMS(BoundsBehavior)
|
---|
95 |
|
---|
96 | public:
|
---|
97 | QDeclarativeFlickable(QDeclarativeItem *parent=0);
|
---|
98 | ~QDeclarativeFlickable();
|
---|
99 |
|
---|
100 | QDeclarativeListProperty<QObject> flickableData();
|
---|
101 | QDeclarativeListProperty<QGraphicsObject> flickableChildren();
|
---|
102 |
|
---|
103 | enum BoundsBehavior { StopAtBounds, DragOverBounds, DragAndOvershootBounds };
|
---|
104 | BoundsBehavior boundsBehavior() const;
|
---|
105 | void setBoundsBehavior(BoundsBehavior);
|
---|
106 |
|
---|
107 | qreal contentWidth() const;
|
---|
108 | void setContentWidth(qreal);
|
---|
109 |
|
---|
110 | qreal contentHeight() const;
|
---|
111 | void setContentHeight(qreal);
|
---|
112 |
|
---|
113 | qreal contentX() const;
|
---|
114 | virtual void setContentX(qreal pos);
|
---|
115 |
|
---|
116 | qreal contentY() const;
|
---|
117 | virtual void setContentY(qreal pos);
|
---|
118 |
|
---|
119 | bool isMoving() const;
|
---|
120 | bool isMovingHorizontally() const;
|
---|
121 | bool isMovingVertically() const;
|
---|
122 | bool isFlicking() const;
|
---|
123 | bool isFlickingHorizontally() const;
|
---|
124 | bool isFlickingVertically() const;
|
---|
125 |
|
---|
126 | int pressDelay() const;
|
---|
127 | void setPressDelay(int delay);
|
---|
128 |
|
---|
129 | qreal maximumFlickVelocity() const;
|
---|
130 | void setMaximumFlickVelocity(qreal);
|
---|
131 |
|
---|
132 | qreal flickDeceleration() const;
|
---|
133 | void setFlickDeceleration(qreal);
|
---|
134 |
|
---|
135 | bool isInteractive() const;
|
---|
136 | void setInteractive(bool);
|
---|
137 |
|
---|
138 | qreal horizontalVelocity() const;
|
---|
139 | qreal verticalVelocity() const;
|
---|
140 |
|
---|
141 | bool isAtXEnd() const;
|
---|
142 | bool isAtXBeginning() const;
|
---|
143 | bool isAtYEnd() const;
|
---|
144 | bool isAtYBeginning() const;
|
---|
145 |
|
---|
146 | QDeclarativeItem *contentItem();
|
---|
147 |
|
---|
148 | enum FlickableDirection { AutoFlickDirection=0x00, HorizontalFlick=0x01, VerticalFlick=0x02, HorizontalAndVerticalFlick=0x03 };
|
---|
149 | FlickableDirection flickableDirection() const;
|
---|
150 | void setFlickableDirection(FlickableDirection);
|
---|
151 |
|
---|
152 | Q_SIGNALS:
|
---|
153 | void contentWidthChanged();
|
---|
154 | void contentHeightChanged();
|
---|
155 | void contentXChanged();
|
---|
156 | void contentYChanged();
|
---|
157 | void movingChanged();
|
---|
158 | void movingHorizontallyChanged();
|
---|
159 | void movingVerticallyChanged();
|
---|
160 | void flickingChanged();
|
---|
161 | void flickingHorizontallyChanged();
|
---|
162 | void flickingVerticallyChanged();
|
---|
163 | void horizontalVelocityChanged();
|
---|
164 | void verticalVelocityChanged();
|
---|
165 | void isAtBoundaryChanged();
|
---|
166 | void flickableDirectionChanged();
|
---|
167 | void interactiveChanged();
|
---|
168 | void boundsBehaviorChanged();
|
---|
169 | void maximumFlickVelocityChanged();
|
---|
170 | void flickDecelerationChanged();
|
---|
171 | void pressDelayChanged();
|
---|
172 | void movementStarted();
|
---|
173 | void movementEnded();
|
---|
174 | void flickStarted();
|
---|
175 | void flickEnded();
|
---|
176 |
|
---|
177 | protected:
|
---|
178 | virtual bool sceneEventFilter(QGraphicsItem *, QEvent *);
|
---|
179 | void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
---|
180 | void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
---|
181 | void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
---|
182 | void wheelEvent(QGraphicsSceneWheelEvent *event);
|
---|
183 | void timerEvent(QTimerEvent *event);
|
---|
184 |
|
---|
185 | QDeclarativeFlickableVisibleArea *visibleArea();
|
---|
186 |
|
---|
187 | protected Q_SLOTS:
|
---|
188 | virtual void ticked();
|
---|
189 | void movementStarting();
|
---|
190 | void movementEnding();
|
---|
191 |
|
---|
192 | protected:
|
---|
193 | void movementXEnding();
|
---|
194 | void movementYEnding();
|
---|
195 | virtual qreal minXExtent() const;
|
---|
196 | virtual qreal minYExtent() const;
|
---|
197 | virtual qreal maxXExtent() const;
|
---|
198 | virtual qreal maxYExtent() const;
|
---|
199 | qreal vWidth() const;
|
---|
200 | qreal vHeight() const;
|
---|
201 | virtual void viewportMoved();
|
---|
202 | virtual void geometryChanged(const QRectF &newGeometry,
|
---|
203 | const QRectF &oldGeometry);
|
---|
204 | bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
|
---|
205 |
|
---|
206 | bool xflick() const;
|
---|
207 | bool yflick() const;
|
---|
208 | void cancelFlick();
|
---|
209 |
|
---|
210 | protected:
|
---|
211 | QDeclarativeFlickable(QDeclarativeFlickablePrivate &dd, QDeclarativeItem *parent);
|
---|
212 |
|
---|
213 | private:
|
---|
214 | Q_DISABLE_COPY(QDeclarativeFlickable)
|
---|
215 | Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeFlickable)
|
---|
216 | friend class QDeclarativeFlickableVisibleArea;
|
---|
217 | };
|
---|
218 |
|
---|
219 | QT_END_NAMESPACE
|
---|
220 |
|
---|
221 | QML_DECLARE_TYPE(QDeclarativeFlickable)
|
---|
222 |
|
---|
223 | QT_END_HEADER
|
---|
224 |
|
---|
225 | #endif
|
---|