Qt 4.8
qdeclarativelistview_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 QDECLARATIVELISTVIEW_H
43 #define QDECLARATIVELISTVIEW_H
44 
45 #include "private/qdeclarativeflickable_p.h"
46 #include "private/qdeclarativeguard_p.h"
47 
49 
51 
52 QT_MODULE(Declarative)
53 
55 {
56  Q_OBJECT
61 public:
62  QDeclarativeViewSection(QObject *parent=0) : QObject(parent), m_criteria(FullString), m_delegate(0) {}
63 
64  QString property() const { return m_property; }
65  void setProperty(const QString &);
66 
67  enum SectionCriteria { FullString, FirstCharacter };
68  SectionCriteria criteria() const { return m_criteria; }
69  void setCriteria(SectionCriteria);
70 
71  QDeclarativeComponent *delegate() const { return m_delegate; }
72  void setDelegate(QDeclarativeComponent *delegate);
73 
74  QString sectionString(const QString &value);
75 
76 Q_SIGNALS:
77  void propertyChanged();
78  void criteriaChanged();
79  void delegateChanged();
80 
81 private:
85 };
86 
87 
92 {
93  Q_OBJECT
95 
96  QVariant model;
98  int currentIndex;
99  QDeclarativeItem *currentItem;
100  int count;
101 
103  QDeclarativeItem *highlightItem;
104  bool highlightFollowsCurrentItem;
105  qreal highlightMoveSpeed;
106  int highlightMoveDuration;
107  qreal highlightResizeSpeed;
108  int highlightResizeDuration;
109 
110  qreal preferredHighlightBegin;
111  qreal preferredHighlightEnd;
112  HighlightRangeMode highlightRangeMode;
113 
114  qreal spacing;
115  Orientation orientation;
116  Qt::LayoutDirection layoutDirection;
117  bool keyNavigationWraps;
118  int cacheBuffer;
120  QString currentSection;
121 
122  SnapMode snapMode;
123 
126 
131  Q_CLASSINFO("DefaultProperty", "data")
132 
133 public:
136 
137  QVariant model() const;
138  void setModel(const QVariant &);
139 
140  QDeclarativeComponent *delegate() const;
141  void setDelegate(QDeclarativeComponent *);
142 
143  int currentIndex() const;
144  void setCurrentIndex(int idx);
145 
146  QDeclarativeItem *currentItem();
147  QDeclarativeItem *highlightItem();
148  int count() const;
149 
150  QDeclarativeComponent *highlight() const;
151  void setHighlight(QDeclarativeComponent *highlight);
152 
153  bool highlightFollowsCurrentItem() const;
154  void setHighlightFollowsCurrentItem(bool);
155 
156  enum HighlightRangeMode { NoHighlightRange, ApplyRange, StrictlyEnforceRange };
157  HighlightRangeMode highlightRangeMode() const;
158  void setHighlightRangeMode(HighlightRangeMode mode);
159 
160  qreal preferredHighlightBegin() const;
161  void setPreferredHighlightBegin(qreal);
162  void resetPreferredHighlightBegin();
163 
164  qreal preferredHighlightEnd() const;
165  void setPreferredHighlightEnd(qreal);
166  void resetPreferredHighlightEnd();
167 
168  qreal spacing() const;
169  void setSpacing(qreal spacing);
170 
172  Orientation orientation() const;
173  void setOrientation(Orientation);
174 
175  Qt::LayoutDirection layoutDirection() const;
176  void setLayoutDirection(Qt::LayoutDirection);
177  Qt::LayoutDirection effectiveLayoutDirection() const;
178 
179  bool isWrapEnabled() const;
180  void setWrapEnabled(bool);
181 
182  int cacheBuffer() const;
183  void setCacheBuffer(int);
184 
185  QDeclarativeViewSection *sectionCriteria();
186  QString currentSection() const;
187 
188  qreal highlightMoveSpeed() const;
189  void setHighlightMoveSpeed(qreal);
190 
191  int highlightMoveDuration() const;
192  void setHighlightMoveDuration(int);
193 
194  qreal highlightResizeSpeed() const;
195  void setHighlightResizeSpeed(qreal);
196 
197  int highlightResizeDuration() const;
198  void setHighlightResizeDuration(int);
199 
200  enum SnapMode { NoSnap, SnapToItem, SnapOneItem };
201  SnapMode snapMode() const;
202  void setSnapMode(SnapMode mode);
203 
204  QDeclarativeComponent *footer() const;
205  void setFooter(QDeclarativeComponent *);
206 
207  QDeclarativeComponent *header() const;
208  void setHeader(QDeclarativeComponent *);
209 
210  virtual void setContentX(qreal pos);
211  virtual void setContentY(qreal pos);
212 
213  static QDeclarativeListViewAttached *qmlAttachedProperties(QObject *);
214 
215  enum PositionMode { Beginning, Center, End, Visible, Contain };
216 
217  Q_INVOKABLE void positionViewAtIndex(int index, int mode);
218  Q_INVOKABLE int indexAt(qreal x, qreal y) const;
219  Q_INVOKABLE Q_REVISION(1) void positionViewAtBeginning();
220  Q_INVOKABLE Q_REVISION(1) void positionViewAtEnd();
221 
222 public Q_SLOTS:
223  void incrementCurrentIndex();
224  void decrementCurrentIndex();
225 
226 Q_SIGNALS:
227  void countChanged();
228  void spacingChanged();
229  void orientationChanged();
230  Q_REVISION(1) void layoutDirectionChanged();
231  void currentIndexChanged();
232  void currentSectionChanged();
233  void highlightMoveSpeedChanged();
234  void highlightMoveDurationChanged();
235  void highlightResizeSpeedChanged();
236  void highlightResizeDurationChanged();
237  void highlightChanged();
238  void highlightItemChanged();
239  void modelChanged();
240  void delegateChanged();
241  void highlightFollowsCurrentItemChanged();
242  void preferredHighlightBeginChanged();
243  void preferredHighlightEndChanged();
244  void highlightRangeModeChanged();
245  void keyNavigationWrapsChanged();
246  void cacheBufferChanged();
247  void snapModeChanged();
248  void headerChanged();
249  void footerChanged();
250 
251 protected:
252  virtual bool event(QEvent *event);
253  virtual void viewportMoved();
254  virtual qreal minYExtent() const;
255  virtual qreal maxYExtent() const;
256  virtual qreal minXExtent() const;
257  virtual qreal maxXExtent() const;
258  virtual void keyPressEvent(QKeyEvent *);
259  virtual void geometryChanged(const QRectF &newGeometry,const QRectF &oldGeometry);
260  virtual void componentComplete();
261 
262 private Q_SLOTS:
263  void updateSections();
264  void refill();
265  void trackedPositionChanged();
266  void itemsInserted(int index, int count);
267  void itemsRemoved(int index, int count);
268  void itemsMoved(int from, int to, int count);
269  void itemsChanged(int index, int count);
270  void modelReset();
271  void destroyRemoved();
272  void createdItem(int index, QDeclarativeItem *item);
273  void destroyingItem(QDeclarativeItem *item);
274  void animStopped();
275 };
276 
278 {
279  Q_OBJECT
280 public:
282  : QObject(parent), m_view(0), m_isCurrent(false), m_delayRemove(false) {}
284 
286  QDeclarativeListView *view() { return m_view; }
288  if (view != m_view) {
289  m_view = view;
290  emit viewChanged();
291  }
292  }
293 
295  bool isCurrentItem() const { return m_isCurrent; }
296  void setIsCurrentItem(bool c) {
297  if (m_isCurrent != c) {
298  m_isCurrent = c;
299  emit currentItemChanged();
300  }
301  }
302 
304  QString prevSection() const { return m_prevSection; }
305  void setPrevSection(const QString &sect) {
306  if (m_prevSection != sect) {
307  m_prevSection = sect;
308  emit prevSectionChanged();
309  }
310  }
311 
313  QString nextSection() const { return m_nextSection; }
314  void setNextSection(const QString &sect) {
315  if (m_nextSection != sect) {
316  m_nextSection = sect;
317  emit nextSectionChanged();
318  }
319  }
320 
322  QString section() const { return m_section; }
323  void setSection(const QString &sect) {
324  if (m_section != sect) {
325  m_section = sect;
326  emit sectionChanged();
327  }
328  }
329 
331  bool delayRemove() const { return m_delayRemove; }
332  void setDelayRemove(bool delay) {
333  if (m_delayRemove != delay) {
334  m_delayRemove = delay;
335  emit delayRemoveChanged();
336  }
337  }
338 
339  void emitAdd() { emit add(); }
340  void emitRemove() { emit remove(); }
341 
342 Q_SIGNALS:
343  void currentItemChanged();
344  void sectionChanged();
345  void prevSectionChanged();
346  void nextSectionChanged();
347  void delayRemoveChanged();
348  void add();
349  void remove();
350  void viewChanged();
351 
352 public:
357  bool m_isCurrent : 1;
358  bool m_delayRemove : 1;
359 };
360 
361 
363 
367 
369 
370 #endif
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QDeclarativeComponent * delegate
The QKeyEvent class describes a key event.
Definition: qevent.h:224
#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
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
virtual qreal maxYExtent() const
QScopedPointer< QGraphicsItemPrivate > d_ptr
#define add(aName)
#define QML_DECLARE_TYPE(TYPE)
Definition: qdeclarative.h:56
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
virtual bool event(QEvent *)
#define Q_INVOKABLE
Definition: qobjectdefs.h:90
virtual void keyPressEvent(QKeyEvent *event)
#define Q_SLOTS
Definition: qobjectdefs.h:71
The QString class provides a Unicode character string.
Definition: qstring.h:83
void setView(QDeclarativeListView *view)
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QDeclarativeGuard< QDeclarativeListView > m_view
#define Q_SIGNALS
Definition: qobjectdefs.h:72
virtual qreal minYExtent() const
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
#define QML_DECLARE_TYPEINFO(TYPE, FLAGS)
Definition: qdeclarative.h:73
void setNextSection(const QString &sect)
SectionCriteria criteria() const
#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.
QDeclarativeComponent * m_delegate
The QDeclarativeItem class provides the most basic of all visual items in QML.
QVariant data(int key) const
Returns this item&#39;s custom data for the key key as a QVariant.
#define emit
Definition: qobjectdefs.h:76
LayoutDirection
Definition: qnamespace.h:1580
static const char * data(const QByteArray &arr)
void setPrevSection(const QString &sect)
virtual qreal minXExtent() const
#define Q_OBJECT
Definition: qobjectdefs.h:157
#define Q_DECLARE_PRIVATE_D(Dptr, Class)
Definition: qglobal.h:2472
QDeclarativeComponent * delegate() const
virtual void componentComplete()
QDeclarativeViewSection(QObject *parent=0)
Definition: qnamespace.h:54
#define Q_AUTOTEST_EXPORT
Definition: qglobal.h:1510
quint16 index
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...
virtual void setContentX(qreal pos)
#define class
virtual qreal maxXExtent() const
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
#define QT_END_HEADER
Definition: qglobal.h:137
virtual IFMETHOD End(void)=0
void setSection(const QString &sect)
virtual void setContentY(qreal pos)