Qt 4.8
qdeclarativepathview_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_H
43 #define QDECLARATIVEPATHVIEW_H
44 
45 #include "qdeclarativeitem.h"
46 #include "private/qdeclarativepath_p.h"
47 
49 
51 
52 QT_MODULE(Declarative)
53 
57 {
58  Q_OBJECT
59 
64 
67 
72 
76 
77  bool moving;
78  bool flicking;
79 
80  int count;
83 
85 
86 public:
88  virtual ~QDeclarativePathView();
89 
90  QVariant model() const;
91  void setModel(const QVariant &);
92 
93  QDeclarativePath *path() const;
94  void setPath(QDeclarativePath *);
95 
96  int currentIndex() const;
97  void setCurrentIndex(int idx);
98 
99  qreal offset() const;
100  void setOffset(qreal offset);
101 
102  QDeclarativeComponent *highlight() const;
103  void setHighlight(QDeclarativeComponent *highlight);
104  QDeclarativeItem *highlightItem();
105 
106  enum HighlightRangeMode { NoHighlightRange, ApplyRange, StrictlyEnforceRange };
107  HighlightRangeMode highlightRangeMode() const;
108  void setHighlightRangeMode(HighlightRangeMode mode);
109 
110  qreal preferredHighlightBegin() const;
111  void setPreferredHighlightBegin(qreal);
112 
113  qreal preferredHighlightEnd() const;
114  void setPreferredHighlightEnd(qreal);
115 
116  int highlightMoveDuration() const;
117  void setHighlightMoveDuration(int);
118 
119  qreal dragMargin() const;
120  void setDragMargin(qreal margin);
121 
122  qreal flickDeceleration() const;
123  void setFlickDeceleration(qreal dec);
124 
125  bool isInteractive() const;
126  void setInteractive(bool);
127 
128  bool isMoving() const;
129  bool isFlicking() const;
130 
131  int count() const;
132 
133  QDeclarativeComponent *delegate() const;
134  void setDelegate(QDeclarativeComponent *);
135 
136  int pathItemCount() const;
137  void setPathItemCount(int);
138 
139  static QDeclarativePathViewAttached *qmlAttachedProperties(QObject *);
140 
141 public Q_SLOTS:
142  void incrementCurrentIndex();
143  void decrementCurrentIndex();
144 
145 Q_SIGNALS:
146  void currentIndexChanged();
147  void offsetChanged();
148  void modelChanged();
149  void countChanged();
150  void pathChanged();
151  void preferredHighlightBeginChanged();
152  void preferredHighlightEndChanged();
153  void highlightRangeModeChanged();
154  void dragMarginChanged();
155  void snapPositionChanged();
156  void delegateChanged();
157  void pathItemCountChanged();
158  void flickDecelerationChanged();
159  void interactiveChanged();
160  void movingChanged();
161  void flickingChanged();
162  void highlightChanged();
163  void highlightItemChanged();
164  void highlightMoveDurationChanged();
165  void movementStarted();
166  void movementEnded();
167  void flickStarted();
168  void flickEnded();
169 
170 protected:
174  bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
176  bool event(QEvent *event);
177  void componentComplete();
178 
179 private Q_SLOTS:
180  void refill();
181  void ticked();
182  void movementEnding();
183  void itemsInserted(int index, int count);
184  void itemsRemoved(int index, int count);
185  void itemsMoved(int,int,int);
186  void modelReset();
187  void createdItem(int index, QDeclarativeItem *item);
188  void destroyingItem(QDeclarativeItem *item);
189  void pathUpdated();
190 
191 private:
195 };
196 
199 {
200  Q_OBJECT
201 
204  bool onPath;
205 
206 public:
209 
210  QDeclarativePathView *view() { return m_view; }
211 
212  bool isCurrentItem() const { return m_isCurrent; }
213  void setIsCurrentItem(bool c) {
214  if (m_isCurrent != c) {
215  m_isCurrent = c;
216  emit currentItemChanged();
217  }
218  }
219 
220  QVariant value(const QByteArray &name) const;
221  void setValue(const QByteArray &name, const QVariant &val);
222 
223  bool isOnPath() const { return m_onPath; }
224  void setOnPath(bool on) {
225  if (on != m_onPath) {
226  m_onPath = on;
227  emit pathChanged();
228  }
229  }
231 
232 Q_SIGNALS:
233  void currentItemChanged();
234  void pathChanged();
235 
236 private:
238  friend class QDeclarativePathView;
241  bool m_onPath : 1;
242  bool m_isCurrent : 1;
243 };
244 
245 
247 
251 
252 #endif // QDECLARATIVEPATHVIEW_H
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
double qreal
Definition: qglobal.h:1193
unsigned char c[8]
Definition: qnumeric_p.h:62
#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
virtual bool event(QEvent *)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
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_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...
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_SIGNALS
Definition: qobjectdefs.h:72
Q_CORE_EXPORT QTextStream & dec(QTextStream &s)
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
#define QML_DECLARE_TYPEINFO(TYPE, FLAGS)
Definition: qdeclarative.h:73
QDeclarativeOpenMetaObject * m_metaobject
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QDeclarativeComponent class encapsulates a QML component definition.
HighlightRangeMode highlightRangeMode
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.
const char * name
#define emit
Definition: qobjectdefs.h:76
QDeclarativeComponent * highlight
#define Q_OBJECT
Definition: qobjectdefs.h:157
#define Q_DECLARE_PRIVATE_D(Dptr, Class)
Definition: qglobal.h:2472
QDeclarativeItem * highlightItem
QDeclarativeComponent * delegate
virtual void componentComplete()
#define Q_AUTOTEST_EXPORT
Definition: qglobal.h:1510
quint16 index
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...