Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquicklistview_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// Qt-Security score:significant reason:default
4
5#ifndef QQUICKLISTVIEW_P_H
6#define QQUICKLISTVIEW_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <private/qtquickglobal_p.h>
20
22
24
25#include <private/qtquickglobal_p.h>
26
27#include <QtCore/qpointer.h>
28
30
31class QQuickListView;
33class Q_QUICK_EXPORT QQuickViewSection : public QObject
34{
35 Q_OBJECT
36 Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged)
37 Q_PROPERTY(SectionCriteria criteria READ criteria WRITE setCriteria NOTIFY criteriaChanged)
38 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
39 Q_PROPERTY(int labelPositioning READ labelPositioning WRITE setLabelPositioning NOTIFY labelPositioningChanged)
40 QML_NAMED_ELEMENT(ViewSection)
41 QML_ADDED_IN_VERSION(2, 0)
42public:
43 QQuickViewSection(QQuickListView *parent=nullptr);
44
45 QString property() const { return m_property; }
46 void setProperty(const QString &);
47
48 enum SectionCriteria { FullString, FirstCharacter };
49 Q_ENUM(SectionCriteria)
50 SectionCriteria criteria() const { return m_criteria; }
51 void setCriteria(SectionCriteria);
52
53 QQmlComponent *delegate() const { return m_delegate; }
54 void setDelegate(QQmlComponent *delegate);
55
56 QString sectionString(const QString &value);
57
58 enum LabelPositioning { InlineLabels = 0x01, CurrentLabelAtStart = 0x02, NextLabelAtEnd = 0x04 };
59 Q_ENUM(LabelPositioning)
60 int labelPositioning() const { return m_labelPositioning; }
61 void setLabelPositioning(int pos);
62
63Q_SIGNALS:
64 void sectionsChanged();
65 void propertyChanged();
66 void criteriaChanged();
67 void delegateChanged();
68 void labelPositioningChanged();
69
70private:
71 QString m_property;
72 SectionCriteria m_criteria;
73 QQmlComponent *m_delegate;
74 int m_labelPositioning;
75 QQuickListViewPrivate *m_view;
76};
77
78
79class QQmlInstanceModel;
80class QQuickListViewAttached;
81class Q_QUICK_EXPORT QQuickListView : public QQuickItemView
82{
83 Q_OBJECT
84 Q_DECLARE_PRIVATE(QQuickListView)
85
86 Q_PROPERTY(qreal highlightMoveVelocity READ highlightMoveVelocity WRITE setHighlightMoveVelocity NOTIFY highlightMoveVelocityChanged)
87 Q_PROPERTY(qreal highlightResizeVelocity READ highlightResizeVelocity WRITE setHighlightResizeVelocity NOTIFY highlightResizeVelocityChanged)
88 Q_PROPERTY(int highlightResizeDuration READ highlightResizeDuration WRITE setHighlightResizeDuration NOTIFY highlightResizeDurationChanged)
89
90 Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
91 Q_PROPERTY(Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
92
93 Q_PROPERTY(QQuickViewSection *section READ sectionCriteria CONSTANT)
94 Q_PROPERTY(QString currentSection READ currentSection NOTIFY currentSectionChanged)
95
96 Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged)
97
98 Q_PROPERTY(HeaderPositioning headerPositioning READ headerPositioning WRITE setHeaderPositioning NOTIFY headerPositioningChanged REVISION(2, 4))
99 Q_PROPERTY(FooterPositioning footerPositioning READ footerPositioning WRITE setFooterPositioning NOTIFY footerPositioningChanged REVISION(2, 4))
100
101 Q_CLASSINFO("DefaultProperty", "data")
102 QML_NAMED_ELEMENT(ListView)
103 QML_ADDED_IN_VERSION(2, 0)
104 QML_ATTACHED(QQuickListViewAttached)
105
106public:
107 QQuickListView(QQuickItem *parent=nullptr);
108 ~QQuickListView();
109
110 qreal spacing() const;
111 void setSpacing(qreal spacing);
112
113 enum Orientation { Horizontal = Qt::Horizontal, Vertical = Qt::Vertical };
114 Q_ENUM(Orientation)
115 Orientation orientation() const;
116 void setOrientation(Orientation);
117
118 QQuickViewSection *sectionCriteria();
119 QString currentSection() const;
120
121 void setHighlightFollowsCurrentItem(bool) override;
122
123 qreal highlightMoveVelocity() const;
124 void setHighlightMoveVelocity(qreal);
125
126 qreal highlightResizeVelocity() const;
127 void setHighlightResizeVelocity(qreal);
128
129 int highlightResizeDuration() const;
130 void setHighlightResizeDuration(int);
131
132 void setHighlightMoveDuration(int) override;
133
134 enum SnapMode { NoSnap, SnapToItem, SnapOneItem };
135 Q_ENUM(SnapMode)
136 SnapMode snapMode() const;
137 void setSnapMode(SnapMode mode);
138
139 enum HeaderPositioning { InlineHeader, OverlayHeader, PullBackHeader };
140 Q_ENUM(HeaderPositioning)
141 HeaderPositioning headerPositioning() const;
142 void setHeaderPositioning(HeaderPositioning positioning);
143
144 enum FooterPositioning { InlineFooter, OverlayFooter, PullBackFooter };
145 Q_ENUM(FooterPositioning)
146 FooterPositioning footerPositioning() const;
147 void setFooterPositioning(FooterPositioning positioning);
148
149 static QQuickListViewAttached *qmlAttachedProperties(QObject *);
150
151public Q_SLOTS:
152 void incrementCurrentIndex();
153 void decrementCurrentIndex();
154
155Q_SIGNALS:
156 void spacingChanged();
157 void orientationChanged();
158 void currentSectionChanged();
159 void highlightMoveVelocityChanged();
160 void highlightResizeVelocityChanged();
161 void highlightResizeDurationChanged();
162 void snapModeChanged();
163 Q_REVISION(2, 4) void headerPositioningChanged();
164 Q_REVISION(2, 4) void footerPositioningChanged();
165
166protected:
167 void viewportMoved(Qt::Orientations orient) override;
168 void keyPressEvent(QKeyEvent *) override;
169 void geometryChange(const QRectF &newGeometry,const QRectF &oldGeometry) override;
170 void initItem(int index, QObject *item) override;
171 qreal maxYExtent() const override;
172 qreal maxXExtent() const override;
173};
174
175class Q_QUICK_EXPORT QQuickListViewAttached : public QQuickItemViewAttached
176{
177 Q_OBJECT
178 Q_PROPERTY(QQuickListView *view READ view NOTIFY viewChanged FINAL)
179public:
180 QQuickListViewAttached(QObject *parent)
181 : QQuickItemViewAttached(parent), m_sectionItem(nullptr) {}
182 ~QQuickListViewAttached() {}
183 QQuickListView *view() const { return m_view; }
184 void setView(QQuickListView *view) {
185 if (view != m_view) {
186 m_view = view;
187 Q_EMIT viewChanged();
188 }
189 }
190
191public:
192 QPointer<QQuickItem> m_sectionItem;
193private:
194 QPointer<QQuickListView> m_view;
195};
196
197
198QT_END_NAMESPACE
199
200#endif // QQUICKLISTVIEW_P_H
bool contains(qreal x, qreal y) const override
FxListItemSG(QQuickItem *i, QQuickListView *v, bool own)
qreal itemPosition() const
QQuickItem * section() const
qreal position() const override
qreal endPosition() const override
void setSize(qreal size)
qreal size() const override
qreal sectionSize() const override
void setSection(QQuickItem *s)
void setPosition(qreal pos, bool immediate=false, bool resetInactiveAxis=true)
qreal itemSize() const
QQuickListView * view
MutableModelIterator(QQmlInstanceModel *model, int iBegin, int iEnd)
void releaseSectionItem(QQuickItem *item)
QQuickItem * sectionCache[sectionCacheSize]
void createHighlight(bool onDestruction=false) override
void visibleItemsChanged() override
bool hasStickyHeader() const override
std::unique_ptr< QSmoothedAnimation > highlightWidthAnimator
static void setSectionHelper(QQmlContext *context, QQuickItem *sectionItem, const QString &section)
FxViewItem * snapItemAt(qreal pos)
QQuickListView::Orientation orient
void updateInlineSection(FxListItemSG *)
void updateSections() override
qreal originPosition() const override
QQuickListView::FooterPositioning footerPositioning
void fixupPosition() override
QString sectionAt(int modelIndex)
void updateSectionCriteria() override
qreal snapPosAt(qreal pos)
void initializeComponentItem(QQuickItem *item) const override
void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &oldGeometry) override
void updateHeader() override
void layoutVisibleItems(int fromModelIndex=0) override
QQuickItem * currentSectionItem
qreal endPositionAt(int index) const override
void updateHighlight() override
void setPosition(qreal pos) override
qreal lastPosition() const override
std::unique_ptr< QSmoothedAnimation > highlightHeightAnimator
bool addVisibleItems(qreal fillFrom, qreal fillTo, qreal bufferFrom, qreal bufferTo, bool doBuffer) override
void adjustFirstItem(qreal forwards, qreal backwards, int) override
void repositionPackageItemAt(QQuickItem *item, int index) override
void fixup(AxisData &data, qreal minExtent, qreal maxExtent) override
bool applyInsertionChange(const QQmlChangeSet::Change &insert, ChangeResult *changeResult, QList< FxViewItem * > *addedItems, QList< MovedItem > *movingIntoView) override
void changedVisibleIndex(int newIndex) override
bool releaseItem(FxViewItem *item, QQmlInstanceModel::ReusableFlag reusableFlag) override
QQuickViewSection * sectionCriteria
bool showFooterForIndex(int index) const override
FxViewItem * newViewItem(int index, QQuickItem *item) override
void resetHighlightPosition() override
qreal footerSize() const override
bool wantsPointerEvent(const QPointerEvent *event) override
void repositionItemAt(FxViewItem *item, int index, qreal sizeBuffer) override
bool showHeaderForIndex(int index) const override
void initializeCurrentItem() override
QQuickListView::HeaderPositioning headerPositioning
void updateSizeChangesBeforeVisiblePos(FxViewItem *item, ChangeResult *removeResult) override
void initializeViewItem(FxViewItem *item) override
bool hasStickyFooter() const override
qreal positionAt(int index) const override
bool flick(QQuickItemViewPrivate::AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, QQuickTimeLineCallback::Callback fixupCallback, QEvent::Type eventType, qreal velocity) override
void updateFooter() override
FxViewItem * itemBefore(int modelIndex) const
static const int sectionCacheSize
QQuickItemViewAttached * getAttachedObject(const QObject *object) const override
bool movingFromHighlight() override
void resetFirstItemPosition(qreal pos=0.0) override
bool removeNonVisibleItems(qreal bufferFrom, qreal bufferTo) override
std::unique_ptr< QSmoothedAnimation > highlightPosAnimator
QQuickItem * getSectionItem(const QString &section)
void removeItem(FxViewItem *item)
bool isContentFlowReversed() const override
QQuickListView::SnapMode snapMode
qreal headerSize() const override
void clear(bool onDestruction) override
Q_STATIC_LOGGING_CATEGORY(lcAccessibilityCore, "qt.accessibility.core")
#define QML_FLICK_SNAPONETHRESHOLD
QT_REQUIRE_CONFIG(quick_listview)