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
qquickpathview_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 QQUICKPATHVIEW_P_H
6#define QQUICKPATHVIEW_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
23#include "qquickitem.h"
24
25#include <private/qtquickglobal_p.h>
26#include <private/qquickpath_p.h>
27
29
30class QQmlChangeSet;
31class QQmlComponent;
32
35class Q_QUICK_EXPORT QQuickPathView : public QQuickItem
36{
37 Q_OBJECT
38
39 Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
40 Q_PROPERTY(QQuickPath *path READ path WRITE setPath NOTIFY pathChanged)
41 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
42 Q_PROPERTY(QQuickItem *currentItem READ currentItem NOTIFY currentItemChanged)
43 Q_PROPERTY(qreal offset READ offset WRITE setOffset NOTIFY offsetChanged)
44
45 Q_PROPERTY(QQmlComponent *highlight READ highlight WRITE setHighlight NOTIFY highlightChanged)
46 Q_PROPERTY(QQuickItem *highlightItem READ highlightItem NOTIFY highlightItemChanged)
47
48 Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin NOTIFY preferredHighlightBeginChanged)
49 Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd NOTIFY preferredHighlightEndChanged)
50 Q_PROPERTY(HighlightRangeMode highlightRangeMode READ highlightRangeMode WRITE setHighlightRangeMode NOTIFY highlightRangeModeChanged)
51 Q_PROPERTY(int highlightMoveDuration READ highlightMoveDuration WRITE setHighlightMoveDuration NOTIFY highlightMoveDurationChanged)
52
53 Q_PROPERTY(qreal dragMargin READ dragMargin WRITE setDragMargin NOTIFY dragMarginChanged)
54 Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity NOTIFY maximumFlickVelocityChanged)
55 Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
56 Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged)
57
58 Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged)
59 Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged)
60 Q_PROPERTY(bool dragging READ isDragging NOTIFY draggingChanged)
61
62 Q_PROPERTY(int count READ count NOTIFY countChanged)
63 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
64 Q_PROPERTY(int pathItemCount READ pathItemCount WRITE setPathItemCount RESET resetPathItemCount NOTIFY pathItemCountChanged)
65 Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged)
66 Q_PROPERTY(MovementDirection movementDirection READ movementDirection WRITE setMovementDirection NOTIFY movementDirectionChanged REVISION(2, 7))
67
68 Q_PROPERTY(int cacheItemCount READ cacheItemCount WRITE setCacheItemCount NOTIFY cacheItemCountChanged)
69 QML_NAMED_ELEMENT(PathView)
70 QML_ADDED_IN_VERSION(2, 0)
71 QML_ATTACHED(QQuickPathViewAttached)
72
73public:
74 QQuickPathView(QQuickItem *parent = nullptr);
75 virtual ~QQuickPathView();
76
77 QVariant model() const;
78 void setModel(const QVariant &);
79
80 QQuickPath *path() const;
81 void setPath(QQuickPath *);
82
83 int currentIndex() const;
84 void setCurrentIndex(int idx);
85
86 QQuickItem *currentItem() const;
87
88 qreal offset() const;
89 void setOffset(qreal offset);
90
91 QQmlComponent *highlight() const;
92 void setHighlight(QQmlComponent *highlight);
93 QQuickItem *highlightItem() const;
94
95 enum HighlightRangeMode { NoHighlightRange, ApplyRange, StrictlyEnforceRange };
96 Q_ENUM(HighlightRangeMode)
97 HighlightRangeMode highlightRangeMode() const;
98 void setHighlightRangeMode(HighlightRangeMode mode);
99
100 qreal preferredHighlightBegin() const;
101 void setPreferredHighlightBegin(qreal);
102
103 qreal preferredHighlightEnd() const;
104 void setPreferredHighlightEnd(qreal);
105
106 int highlightMoveDuration() const;
107 void setHighlightMoveDuration(int);
108
109 qreal dragMargin() const;
110 void setDragMargin(qreal margin);
111
112 qreal flickDeceleration() const;
113 void setFlickDeceleration(qreal dec);
114
115 qreal maximumFlickVelocity() const;
116 void setMaximumFlickVelocity(qreal);
117
118 bool isInteractive() const;
119 void setInteractive(bool);
120
121 bool isMoving() const;
122 bool isFlicking() const;
123 bool isDragging() const;
124
125 int count() const;
126
127 QQmlComponent *delegate() const;
128 void setDelegate(QQmlComponent *);
129
130 int pathItemCount() const;
131 void setPathItemCount(int);
132 void resetPathItemCount();
133
134 int cacheItemCount() const;
135 void setCacheItemCount(int);
136
137 enum SnapMode { NoSnap, SnapToItem, SnapOneItem };
138 Q_ENUM(SnapMode)
139 SnapMode snapMode() const;
140 void setSnapMode(SnapMode mode);
141
142 enum MovementDirection { Shortest, Negative, Positive };
143 Q_ENUM(MovementDirection)
144 MovementDirection movementDirection() const;
145 void setMovementDirection(MovementDirection dir);
146
147 enum PositionMode { Beginning, Center, End, Contain=4, SnapPosition }; // 3 == Visible in other views
148 Q_ENUM(PositionMode)
149 Q_INVOKABLE void positionViewAtIndex(int index, int mode);
150 Q_INVOKABLE int indexAt(qreal x, qreal y) const;
151 Q_INVOKABLE QQuickItem *itemAt(qreal x, qreal y) const;
152 Q_REVISION(2, 13) Q_INVOKABLE QQuickItem *itemAtIndex(int index) const;
153
154 static QQuickPathViewAttached *qmlAttachedProperties(QObject *);
155
156public Q_SLOTS:
157 void incrementCurrentIndex();
158 void decrementCurrentIndex();
159
160Q_SIGNALS:
161 void currentIndexChanged();
162 void currentItemChanged();
163 void offsetChanged();
164 void modelChanged();
165 void countChanged();
166 void pathChanged();
167 void preferredHighlightBeginChanged();
168 void preferredHighlightEndChanged();
169 void highlightRangeModeChanged();
170 void dragMarginChanged();
171 void snapPositionChanged();
172 void delegateChanged();
173 void pathItemCountChanged();
174 void maximumFlickVelocityChanged();
175 void flickDecelerationChanged();
176 void interactiveChanged();
177 void movingChanged();
178 void flickingChanged();
179 void draggingChanged();
180 void highlightChanged();
181 void highlightItemChanged();
182 void highlightMoveDurationChanged();
183 void movementStarted();
184 void movementEnded();
185 Q_REVISION(2, 7) void movementDirectionChanged();
186 void flickStarted();
187 void flickEnded();
188 void dragStarted();
189 void dragEnded();
190 void snapModeChanged();
191 void cacheItemCountChanged();
192
193protected:
194 void updatePolish() override;
195 void mousePressEvent(QMouseEvent *event) override;
196 void mouseMoveEvent(QMouseEvent *event) override;
197 void mouseReleaseEvent(QMouseEvent *) override;
198 bool childMouseEventFilter(QQuickItem *, QEvent *) override;
199 void mouseUngrabEvent() override;
200 void componentComplete() override;
201
202private Q_SLOTS:
203 void refill();
204 void ticked();
205 void movementEnding();
206 void modelUpdated(const QQmlChangeSet &changeSet, bool reset);
207 void createdItem(int index, QObject *item);
208 void initItem(int index, QObject *item);
209 void destroyingItem(QObject *item);
210 void pathUpdated();
211
212private:
213 friend class QQuickPathViewAttached;
214 Q_DISABLE_COPY(QQuickPathView)
215 Q_DECLARE_PRIVATE(QQuickPathView)
216};
217
218class QQmlOpenMetaObject;
220{
221 Q_OBJECT
222
223 Q_PROPERTY(QQuickPathView *view READ view CONSTANT FINAL)
226
227public:
230
231 QQuickPathView *view() const { return m_view; }
232
233 bool isCurrentItem() const { return m_isCurrent; }
234 void setIsCurrentItem(bool c) {
235 if (m_isCurrent != c) {
236 m_isCurrent = c;
237 Q_EMIT currentItemChanged();
238 }
239 }
240
241 QVariant value(const QByteArray &name) const;
242 void setValue(const QByteArray &name, const QVariant &val);
243
244 bool isOnPath() const { return m_onPath; }
245 void setOnPath(bool on) {
246 if (on != m_onPath) {
247 m_onPath = on;
248 Q_EMIT pathChanged();
249 }
250 }
252
256
257private:
259 friend class QQuickPathView;
260 QQuickPathView *m_view;
261 QQmlOpenMetaObject *m_metaobject;
262 bool m_onPath : 1;
263 bool m_isCurrent : 1;
264};
265
266
267QT_END_NAMESPACE
268
269#endif // QQUICKPATHVIEW_P_H
void setValue(const QByteArray &name, const QVariant &val)
QQuickPathView * view() const
QVariant value(const QByteArray &name) const
void releaseItem(QQuickItem *item)
qint64 computeCurrentTime(QInputEvent *event) const
void updateItem(QQuickItem *, qreal)
void snapToIndex(int index, MovementReason reason)
void handleMousePressEvent(QMouseEvent *event)
QQmlOpenMetaObjectType * attType
void handleMouseReleaseEvent(QMouseEvent *)
QQmlComponent * highlightComponent
void setAdjustedOffset(qreal offset)
void setHighlightPosition(qreal pos)
void handleMouseMoveEvent(QMouseEvent *event)
QPointF pointNear(const QPointF &point, qreal *nearPercent=0) const
void setOffset(qreal offset)
QQmlOpenMetaObjectType * attachedType()
qreal positionOfIndex(qreal index) const
QQuickItem * getItem(int modelIndex, qreal z=0, bool async=false)
void addVelocitySample(qreal v)
QQuickPathViewAttached * attached(QQuickItem *item)
bool isInBound(qreal position, qreal lower, qreal upper, bool emptyRangeCheck=true) const
static void fixOffsetCallback(void *)
Q_STATIC_LOGGING_CATEGORY(lcAccessibilityCore, "qt.accessibility.core")
#define QML_FLICK_SAMPLEBUFFER
#define QML_FLICK_DISCARDSAMPLES
#define QML_FLICK_VELOCITY_DECAY_TIME
static QT_BEGIN_NAMESPACE QQmlOpenMetaObjectType * qPathViewAttachedType
static int currentIndexRemainder(int currentIndex, int modelCount) noexcept
QT_REQUIRE_CONFIG(quick_pathview)