Qt 4.8
qdeclarativepathview_p_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 QDECLARATIVEPATHVIEW_P_H
43 #define QDECLARATIVEPATHVIEW_P_H
44 
45 //
46 // W A R N I N G
47 // -------------
48 //
49 // This file is not part of the Qt API. It exists purely as an
50 // implementation detail. This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55 
56 #include "private/qdeclarativepathview_p.h"
57 
58 #include "private/qdeclarativeitem_p.h"
59 #include "private/qdeclarativevisualitemmodel_p.h"
60 
61 #include <qdeclarative.h>
63 #include <qdeclarativeguard_p.h>
64 
65 #include <qdatetime.h>
66 
68 
72 {
74 
75 public:
77  : path(0), currentIndex(0), currentItemOffset(0.0), startPc(0), lastDist(0)
78  , lastElapsed(0), offset(0.0), offsetAdj(0.0), mappedRange(1.0)
79  , stealMouse(false), ownModel(false), interactive(true), haveHighlightRange(true)
80  , autoHighlight(true), highlightUp(false), layoutScheduled(false)
81  , moving(false), flicking(false)
82  , dragMargin(0), deceleration(100)
84  , firstIndex(-1), pathItems(-1), requestedIndex(-1)
89  , highlightRangeMode(QDeclarativePathView::StrictlyEnforceRange)
91  {
92  }
93 
94  void init();
95 
96  void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) {
97  if ((newGeometry.size() != oldGeometry.size())
98  && (!highlightItem || item != highlightItem)) {
99  if (QDeclarativePathViewAttached *att = attached(item))
100  att->m_percent = -1;
101  scheduleLayout();
102  }
103  }
104 
105  void scheduleLayout() {
107  if (!layoutScheduled) {
108  layoutScheduled = true;
110  }
111  }
112 
113  QDeclarativeItem *getItem(int modelIndex);
114  void releaseItem(QDeclarativeItem *item);
116  void clear();
117  void updateMappedRange();
119  void createHighlight();
120  void updateHighlight();
122  bool isValid() const {
123  return model && model->count() > 0 && model->isValid() && path;
124  }
125 
129 
130  int calcCurrentIndex();
131  void updateCurrent();
132  static void fixOffsetCallback(void*);
133  void fixOffset();
134  void setOffset(qreal offset);
135  void setAdjustedOffset(qreal offset);
136  void regenerate();
138  void snapToCurrent();
139  QPointF pointNear(const QPointF &point, qreal *nearPercent=0) const;
140 
152  bool stealMouse : 1;
153  bool ownModel : 1;
154  bool interactive : 1;
156  bool autoHighlight : 1;
157  bool highlightUp : 1;
158  bool layoutScheduled : 1;
159  bool moving : 1;
160  bool flicking : 1;
188 };
189 
191 
192 #endif
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
virtual bool isValid() const =0
void handleMouseMoveEvent(QGraphicsSceneMouseEvent *event)
double qreal
Definition: qglobal.h:1193
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
EventRef event
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
QDeclarativeGuard< QDeclarativeVisualModel > model
void updateItem(QDeclarativeItem *, qreal)
void releaseItem(QDeclarativeItem *item)
The QElapsedTimer class provides a fast way to calculate elapsed times.
Definition: qelapsedtimer.h:53
void handleMouseReleaseEvent(QGraphicsSceneMouseEvent *)
QDeclarativeTimeLineValueProxy< QDeclarativePathViewPrivate > moveOffset
QList< QDeclarativeItem * > itemCache
#define Q_Q(Class)
Definition: qglobal.h:2483
QPointF pointNear(const QPointF &point, qreal *nearPercent=0) const
QDeclarativePathView::HighlightRangeMode highlightRangeMode
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
The QDeclarativeComponent class encapsulates a QML component definition.
void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry)
The QDeclarativeItem class provides the most basic of all visual items in QML.
QDeclarativeGuard< QDeclarativeItem > currentItem
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
QDeclarativeComponent * highlightComponent
The QDeclarativeTimeLine class provides a timeline for controlling animations.
QDeclarativePathViewAttached * attached(QDeclarativeItem *item)
void handleMousePressEvent(QGraphicsSceneMouseEvent *event)
QSizeF size() const
Returns the size of the rectangle.
Definition: qrect.h:713
QDeclarativeItem * getItem(int modelIndex)
QList< QDeclarativeItem * > items
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
QDeclarativeOpenMetaObjectType * attType
QDeclarativeTimeLineValueProxy< QDeclarativePathViewPrivate > moveHighlight
qreal positionOfIndex(qreal index) const
The QList class is a template class that provides lists.
Definition: qdatastream.h:62