Qt 4.8
qdeclarativeflickable_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtDeclarative 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 QDECLARATIVEFLICKABLE_H
43 #define QDECLARATIVEFLICKABLE_H
44 
45 #include "qdeclarativeitem.h"
46 
48 
50 
51 QT_MODULE(Declarative)
52 
56 {
57  Q_OBJECT
58 
64 
67 
71  bool moving;
74  bool flicking;
78 
81 
82  bool atXEnd;
83  bool atYEnd;
86 
88 
91  Q_CLASSINFO("DefaultProperty", "flickableData")
92 
95 
96 public:
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_INVOKABLE Q_REVISION(1) void resizeContent(qreal w, qreal h, QPointF center);
153  Q_INVOKABLE Q_REVISION(1) void returnToBounds();
154 
155 Q_SIGNALS:
156  void contentWidthChanged();
157  void contentHeightChanged();
158  void contentXChanged();
159  void contentYChanged();
160  void movingChanged();
161  void movingHorizontallyChanged();
162  void movingVerticallyChanged();
163  void flickingChanged();
164  void flickingHorizontallyChanged();
165  void flickingVerticallyChanged();
166  void horizontalVelocityChanged();
167  void verticalVelocityChanged();
168  void isAtBoundaryChanged();
169  void flickableDirectionChanged();
170  void interactiveChanged();
171  void boundsBehaviorChanged();
172  void maximumFlickVelocityChanged();
173  void flickDecelerationChanged();
174  void pressDelayChanged();
175  void movementStarted();
176  void movementEnded();
177  void flickStarted();
178  void flickEnded();
179 
180 protected:
181  virtual bool sceneEventFilter(QGraphicsItem *, QEvent *);
186  void timerEvent(QTimerEvent *event);
187 
188  QDeclarativeFlickableVisibleArea *visibleArea();
189 
190 protected Q_SLOTS:
191  virtual void ticked();
192  void movementStarting();
193  void movementEnding();
194 
195 protected:
196  void movementXEnding();
197  void movementYEnding();
198  virtual qreal minXExtent() const;
199  virtual qreal minYExtent() const;
200  virtual qreal maxXExtent() const;
201  virtual qreal maxYExtent() const;
202  qreal vWidth() const;
203  qreal vHeight() const;
204  virtual void viewportMoved();
205  virtual void geometryChanged(const QRectF &newGeometry,
206  const QRectF &oldGeometry);
207  bool sceneEvent(QEvent *event);
208  bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
209 
210  bool xflick() const;
211  bool yflick() const;
212  void cancelFlick();
213 
214 protected:
216 
217 private:
221 };
222 
224 
226 
228 
229 #endif
#define Q_CLASSINFO(name, value)
This macro associates extra information to the class, which is available using QObject::metaObject()...
Definition: qobjectdefs.h:78
double qreal
Definition: qglobal.h:1193
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
EventRef event
#define QT_MODULE(x)
Definition: qglobal.h:2783
QScopedPointer< QGraphicsItemPrivate > d_ptr
#define QML_DECLARE_TYPE(TYPE)
Definition: qdeclarative.h:56
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
QDeclarativeItem * contentItem
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
#define Q_INVOKABLE
Definition: qobjectdefs.h:90
virtual void timerEvent(QTimerEvent *)
This event handler can be reimplemented in a subclass to receive timer events for the object...
Definition: qobject.cpp:1294
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
#define Q_SLOTS
Definition: qobjectdefs.h:71
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse press events for this item...
virtual void wheelEvent(QGraphicsSceneWheelEvent *event)
This event handler, for event event, can be reimplemented to receive wheel events for this item...
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_SIGNALS
Definition: qobjectdefs.h:72
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
FlickableDirection flickableDirection
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
The QDeclarativeItem class provides the most basic of all visual items in QML.
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse move events for this item...
QVariant data(int key) const
Returns this item&#39;s custom data for the key key as a QVariant.
QDeclarativeListProperty< QObject > flickableData
virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
This function is called to handle this item&#39;s changes in geometry from oldGeometry to newGeometry...
#define Q_OBJECT
Definition: qobjectdefs.h:157
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
#define Q_DECLARE_PRIVATE_D(Dptr, Class)
Definition: qglobal.h:2472
The QTimerEvent class contains parameters that describe a timer event.
Definition: qcoreevent.h:341
QDeclarativeListProperty< QGraphicsObject > flickableChildren
#define Q_AUTOTEST_EXPORT
Definition: qglobal.h:1510
virtual bool sceneEvent(QEvent *)
The QGraphicsSceneWheelEvent class provides wheel events in the graphics view framework.
QDeclarativeFlickableVisibleArea * visibleArea
#define class
The QGraphicsObject class provides a base class for all graphics items that require signals...
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
virtual bool sceneEventFilter(QGraphicsItem *watched, QEvent *event)
Filters events for the item watched.
#define QT_END_HEADER
Definition: qglobal.h:137
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse release events for this it...