Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickitemview_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQUICKITEMVIEW_P_H
5#define QQUICKITEMVIEW_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuick/private/qtquickglobal_p.h>
19
20QT_REQUIRE_CONFIG(quick_itemview);
21
22#include "qquickflickable_p.h"
23#include <qpointer.h>
24#include <QtCore/QLoggingCategory>
25
27
28Q_DECLARE_LOGGING_CATEGORY(lcItemViewDelegateLifecycle)
29
30class QQmlChangeSet;
31
33
34class Q_QUICK_EXPORT QQuickItemView : public QQuickFlickable
35{
37
38 Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
39 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
40 Q_PROPERTY(int count READ count NOTIFY countChanged)
41
42 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
43 Q_PROPERTY(QQuickItem *currentItem READ currentItem NOTIFY currentItemChanged)
44
45 Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled NOTIFY keyNavigationWrapsChanged)
46 Q_PROPERTY(bool keyNavigationEnabled READ isKeyNavigationEnabled WRITE setKeyNavigationEnabled NOTIFY keyNavigationEnabledChanged REVISION(2, 7))
47 Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer NOTIFY cacheBufferChanged)
48 Q_PROPERTY(int displayMarginBeginning READ displayMarginBeginning WRITE setDisplayMarginBeginning NOTIFY displayMarginBeginningChanged REVISION(2, 3))
49 Q_PROPERTY(int displayMarginEnd READ displayMarginEnd WRITE setDisplayMarginEnd NOTIFY displayMarginEndChanged REVISION(2, 3))
50
51 Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged)
52 Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged)
53 Q_PROPERTY(VerticalLayoutDirection verticalLayoutDirection READ verticalLayoutDirection WRITE setVerticalLayoutDirection NOTIFY verticalLayoutDirectionChanged)
54
55 Q_PROPERTY(QQmlComponent *header READ header WRITE setHeader NOTIFY headerChanged)
56 Q_PROPERTY(QQuickItem *headerItem READ headerItem NOTIFY headerItemChanged)
57 Q_PROPERTY(QQmlComponent *footer READ footer WRITE setFooter NOTIFY footerChanged)
58 Q_PROPERTY(QQuickItem *footerItem READ footerItem NOTIFY footerItemChanged)
59
60#if QT_CONFIG(quick_viewtransitions)
61 Q_PROPERTY(QQuickTransition *populate READ populateTransition WRITE setPopulateTransition NOTIFY populateTransitionChanged)
62 Q_PROPERTY(QQuickTransition *add READ addTransition WRITE setAddTransition NOTIFY addTransitionChanged)
63 Q_PROPERTY(QQuickTransition *addDisplaced READ addDisplacedTransition WRITE setAddDisplacedTransition NOTIFY addDisplacedTransitionChanged)
64 Q_PROPERTY(QQuickTransition *move READ moveTransition WRITE setMoveTransition NOTIFY moveTransitionChanged)
65 Q_PROPERTY(QQuickTransition *moveDisplaced READ moveDisplacedTransition WRITE setMoveDisplacedTransition NOTIFY moveDisplacedTransitionChanged)
66 Q_PROPERTY(QQuickTransition *remove READ removeTransition WRITE setRemoveTransition NOTIFY removeTransitionChanged)
67 Q_PROPERTY(QQuickTransition *removeDisplaced READ removeDisplacedTransition WRITE setRemoveDisplacedTransition NOTIFY removeDisplacedTransitionChanged)
68 Q_PROPERTY(QQuickTransition *displaced READ displacedTransition WRITE setDisplacedTransition NOTIFY displacedTransitionChanged)
69#endif
70
71 Q_PROPERTY(QQmlComponent *highlight READ highlight WRITE setHighlight NOTIFY highlightChanged)
72 Q_PROPERTY(QQuickItem *highlightItem READ highlightItem NOTIFY highlightItemChanged)
73 Q_PROPERTY(bool highlightFollowsCurrentItem READ highlightFollowsCurrentItem WRITE setHighlightFollowsCurrentItem NOTIFY highlightFollowsCurrentItemChanged)
74 Q_PROPERTY(HighlightRangeMode highlightRangeMode READ highlightRangeMode WRITE setHighlightRangeMode NOTIFY highlightRangeModeChanged)
75 Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin NOTIFY preferredHighlightBeginChanged RESET resetPreferredHighlightBegin)
76 Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd NOTIFY preferredHighlightEndChanged RESET resetPreferredHighlightEnd)
77 Q_PROPERTY(int highlightMoveDuration READ highlightMoveDuration WRITE setHighlightMoveDuration NOTIFY highlightMoveDurationChanged)
78
79 Q_PROPERTY(bool reuseItems READ reuseItems WRITE setReuseItems NOTIFY reuseItemsChanged REVISION(2, 15))
80
81 QML_NAMED_ELEMENT(ItemView)
82 QML_UNCREATABLE("ItemView is an abstract base class.")
84
85public:
86 // this holds all layout enum values so they can be referred to by other enums
87 // to ensure consistent values - e.g. QML references to GridView.TopToBottom flow
88 // and GridView.TopToBottom vertical layout direction should have same value
90 LeftToRight = Qt::LeftToRight,
91 RightToLeft = Qt::RightToLeft,
93 VerticalBottomToTop
94 };
95 Q_ENUM(LayoutDirection)
96
98 TopToBottom = VerticalTopToBottom,
99 BottomToTop = VerticalBottomToTop
100 };
101 Q_ENUM(VerticalLayoutDirection)
102
103 QQuickItemView(QQuickFlickablePrivate &dd, QQuickItem *parent = nullptr);
105
106 QVariant model() const;
107 void setModel(const QVariant &);
108
109 QQmlComponent *delegate() const;
110 void setDelegate(QQmlComponent *);
111
112 int count() const;
113
114 int currentIndex() const;
115 void setCurrentIndex(int idx);
116
117 QQuickItem *currentItem() const;
118
119 bool isWrapEnabled() const;
120 void setWrapEnabled(bool);
121
122 bool isKeyNavigationEnabled() const;
123 void setKeyNavigationEnabled(bool);
124
125 int cacheBuffer() const;
126 void setCacheBuffer(int);
127
128 int displayMarginBeginning() const;
129 void setDisplayMarginBeginning(int);
130
131 int displayMarginEnd() const;
132 void setDisplayMarginEnd(int);
133
134 Qt::LayoutDirection layoutDirection() const;
135 void setLayoutDirection(Qt::LayoutDirection);
136 Qt::LayoutDirection effectiveLayoutDirection() const;
137
138 VerticalLayoutDirection verticalLayoutDirection() const;
139 void setVerticalLayoutDirection(VerticalLayoutDirection layoutDirection);
140
141 QQmlComponent *footer() const;
142 void setFooter(QQmlComponent *);
143 QQuickItem *footerItem() const;
144
145 QQmlComponent *header() const;
146 void setHeader(QQmlComponent *);
147 QQuickItem *headerItem() const;
148
149#if QT_CONFIG(quick_viewtransitions)
150 QQuickTransition *populateTransition() const;
151 void setPopulateTransition(QQuickTransition *transition);
152
153 QQuickTransition *addTransition() const;
154 void setAddTransition(QQuickTransition *transition);
155
156 QQuickTransition *addDisplacedTransition() const;
157 void setAddDisplacedTransition(QQuickTransition *transition);
158
159 QQuickTransition *moveTransition() const;
160 void setMoveTransition(QQuickTransition *transition);
161
162 QQuickTransition *moveDisplacedTransition() const;
163 void setMoveDisplacedTransition(QQuickTransition *transition);
164
165 QQuickTransition *removeTransition() const;
166 void setRemoveTransition(QQuickTransition *transition);
167
168 QQuickTransition *removeDisplacedTransition() const;
169 void setRemoveDisplacedTransition(QQuickTransition *transition);
170
171 QQuickTransition *displacedTransition() const;
172 void setDisplacedTransition(QQuickTransition *transition);
173#endif
174
175 QQmlComponent *highlight() const;
176 void setHighlight(QQmlComponent *);
177
178 QQuickItem *highlightItem() const;
179
180 bool highlightFollowsCurrentItem() const;
181 virtual void setHighlightFollowsCurrentItem(bool);
182
183 enum HighlightRangeMode { NoHighlightRange, ApplyRange, StrictlyEnforceRange };
184 Q_ENUM(HighlightRangeMode)
185 HighlightRangeMode highlightRangeMode() const;
186 void setHighlightRangeMode(HighlightRangeMode mode);
187
188 qreal preferredHighlightBegin() const;
189 void setPreferredHighlightBegin(qreal);
190 void resetPreferredHighlightBegin();
191
192 qreal preferredHighlightEnd() const;
193 void setPreferredHighlightEnd(qreal);
194 void resetPreferredHighlightEnd();
195
196 int highlightMoveDuration() const;
197 virtual void setHighlightMoveDuration(int);
198
199 bool reuseItems() const;
200 void setReuseItems(bool reuse);
201
202 enum PositionMode { Beginning, Center, End, Visible, Contain, SnapPosition };
203 Q_ENUM(PositionMode)
204
205 Q_INVOKABLE void positionViewAtIndex(int index, int mode);
206 Q_INVOKABLE int indexAt(qreal x, qreal y) const;
207 Q_INVOKABLE QQuickItem *itemAt(qreal x, qreal y) const;
208 Q_REVISION(2, 13) Q_INVOKABLE QQuickItem *itemAtIndex(int index) const;
209 Q_INVOKABLE void positionViewAtBeginning();
210 Q_INVOKABLE void positionViewAtEnd();
211 Q_REVISION(2, 1) Q_INVOKABLE void forceLayout();
212
213 void setContentX(qreal pos) override;
214 void setContentY(qreal pos) override;
215 qreal originX() const override;
216 qreal originY() const override;
217
219 void modelChanged();
220 void delegateChanged();
221 void countChanged();
222 void currentIndexChanged();
223 void currentItemChanged();
224
225 void keyNavigationWrapsChanged();
226 Q_REVISION(2, 7) void keyNavigationEnabledChanged();
227 void cacheBufferChanged();
228 void displayMarginBeginningChanged();
229 void displayMarginEndChanged();
230
231 void layoutDirectionChanged();
232 void effectiveLayoutDirectionChanged();
233 void verticalLayoutDirectionChanged();
234
235 void headerChanged();
236 void footerChanged();
237 void headerItemChanged();
238 void footerItemChanged();
239
240#if QT_CONFIG(quick_viewtransitions)
241 void populateTransitionChanged();
242 void addTransitionChanged();
243 void addDisplacedTransitionChanged();
244 void moveTransitionChanged();
245 void moveDisplacedTransitionChanged();
246 void removeTransitionChanged();
247 void removeDisplacedTransitionChanged();
248 void displacedTransitionChanged();
249#endif
250
258
259 Q_REVISION(2, 15) void reuseItemsChanged();
260
261protected:
262 void updatePolish() override;
263 void componentComplete() override;
264 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
265 qreal minYExtent() const override;
266 qreal maxYExtent() const override;
267 qreal minXExtent() const override;
268 qreal maxXExtent() const override;
269
270protected Q_SLOTS:
271 void destroyRemoved();
272 void createdItem(int index, QObject *item);
273 virtual void initItem(int index, QObject *item);
274 void modelUpdated(const QQmlChangeSet &changeSet, bool reset);
275 void destroyingItem(QObject *item);
276 Q_REVISION(2, 15) void onItemPooled(int modelIndex, QObject *object);
277 Q_REVISION(2, 15) void onItemReused(int modelIndex, QObject *object);
278 void animStopped();
279 void trackedPositionChanged();
280
281private:
282 Q_DECLARE_PRIVATE(QQuickItemView)
283};
284
285
286class Q_QUICK_EXPORT QQuickItemViewAttached : public QObject
287{
289
290 Q_PROPERTY(QQuickItemView *view READ view NOTIFY viewChanged FINAL)
291 Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged FINAL)
292 Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged FINAL)
293
294 Q_PROPERTY(QString section READ section NOTIFY sectionChanged FINAL)
295 Q_PROPERTY(QString previousSection READ prevSection NOTIFY prevSectionChanged FINAL)
296 Q_PROPERTY(QString nextSection READ nextSection NOTIFY nextSectionChanged FINAL)
297
298public:
300 : QObject(parent), m_isCurrent(false), m_delayRemove(false) {}
302
303 QQuickItemView *view() const { return m_view; }
305 if (view != m_view) {
306 m_view = view;
307 Q_EMIT viewChanged();
308 }
309 }
310
311 bool isCurrentItem() const { return m_isCurrent; }
312 void setIsCurrentItem(bool c) {
313 if (m_isCurrent != c) {
314 m_isCurrent = c;
315 Q_EMIT currentItemChanged();
316 }
317 }
318
319 bool delayRemove() const { return m_delayRemove; }
320 void setDelayRemove(bool delay) {
321 if (m_delayRemove != delay) {
322 m_delayRemove = delay;
323 Q_EMIT delayRemoveChanged();
324 }
325 }
326
327 QString section() const { return m_section; }
328 void setSection(const QString &sect) {
329 if (m_section != sect) {
330 m_section = sect;
331 Q_EMIT sectionChanged();
332 }
333 }
334
335 QString prevSection() const { return m_prevSection; }
336 void setPrevSection(const QString &sect) {
337 if (m_prevSection != sect) {
338 m_prevSection = sect;
339 Q_EMIT prevSectionChanged();
340 }
341 }
342
343 QString nextSection() const { return m_nextSection; }
344 void setNextSection(const QString &sect) {
345 if (m_nextSection != sect) {
346 m_nextSection = sect;
347 Q_EMIT nextSectionChanged();
348 }
349 }
350
351 void setSections(const QString &prev, const QString &sect, const QString &next) {
352 bool prevChanged = prev != m_prevSection;
353 bool sectChanged = sect != m_section;
354 bool nextChanged = next != m_nextSection;
355 m_prevSection = prev;
356 m_section = sect;
357 m_nextSection = next;
358 if (prevChanged)
359 Q_EMIT prevSectionChanged();
360 if (sectChanged)
361 Q_EMIT sectionChanged();
362 if (nextChanged)
363 Q_EMIT nextSectionChanged();
364 }
365
366 void emitAdd() { Q_EMIT add(); }
368
373
374 void add();
375 void remove();
376
380
381 void pooled();
382 void reused();
383
384public:
385 QPointer<QQuickItemView> m_view;
386 bool m_isCurrent : 1;
388
389 // current only used by list view
393};
394
395
397
398#endif // QQUICKITEMVIEW_P_H
399
\inmodule QtCore
Definition qobject.h:103
The QQmlChangeSet class stores an ordered list of notifications about changes to a linear data set.
The QQmlComponent class encapsulates a QML component definition.
void setSections(const QString &prev, const QString &sect, const QString &next)
QString nextSection() const
void setView(QQuickItemView *view)
QPointer< QQuickItemView > m_view
void setDelayRemove(bool delay)
void setSection(const QString &sect)
QQuickItemView * view() const
void setPrevSection(const QString &sect)
void setNextSection(const QString &sect)
QString prevSection() const
Q_REVISION(2, 15) void reuseItemsChanged()
void highlightMoveDurationChanged()
Q_REVISION(2, 13) Q_INVOKABLE QQuickItem *itemAtIndex(int index) const
void preferredHighlightBeginChanged()
void highlightItemChanged()
void highlightChanged()
void highlightFollowsCurrentItemChanged()
void preferredHighlightEndChanged()
void highlightRangeModeChanged()
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
\inmodule QtCore\reentrant
Definition qrect.h:484
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qvariant.h:65
short next
Definition keywords.cpp:445
Combined button and popup list for selecting options.
Definition qcompare.h:63
LayoutDirection
@ LeftToRight
@ RightToLeft
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
static QString header(const QString &name)
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLint GLint GLint GLint GLint x
[0]
GLenum mode
GLuint index
[2]
GLenum GLenum GLsizei count
GLint y
GLboolean reset
const GLubyte * c
static void add(QPainterPath &path, const QWingedEdge &list, int edge, QPathEdge::Traversal traversal)
#define QML_UNCREATABLE(REASON)
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
#define QT_REQUIRE_CONFIG(feature)
#define Q_ENUM(x)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_REVISION(...)
#define Q_EMIT
#define Q_INVOKABLE
#define Q_SLOTS
#define Q_SIGNALS
double qreal
Definition qtypes.h:187
static const uint base
Definition qurlidna.cpp:20
view setModel(model)
[17] //! [18]
QSqlQueryModel * model
[16]
settings remove("monkey")
QGraphicsItem * item
textPart setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"text\""))
QQuickView * view
[0]