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
qquicktumbler_p.h
Go to the documentation of this file.
1// Copyright (C) 2017 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 QQUICKTUMBLER_P_H
6#define QQUICKTUMBLER_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 <QtCore/qvariant.h>
20#include <QtQml/qqmlcomponent.h>
21#include <QtQuickTemplates2/private/qquickcontrol_p.h>
22
23QT_BEGIN_NAMESPACE
24
25class QQuickTumblerAttached;
26class QQuickTumblerPrivate;
27
28class Q_QUICKTEMPLATES2_EXPORT QQuickTumbler : public QQuickControl
29{
30 Q_OBJECT
31 Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged FINAL)
32 Q_PROPERTY(int count READ count NOTIFY countChanged FINAL)
33 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged FINAL)
34 Q_PROPERTY(QQuickItem *currentItem READ currentItem NOTIFY currentItemChanged FINAL)
35 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
36 Q_PROPERTY(int visibleItemCount READ visibleItemCount WRITE setVisibleItemCount NOTIFY visibleItemCountChanged FINAL)
37 // 2.1 (Qt 5.8)
38 Q_PROPERTY(bool wrap READ wrap WRITE setWrap RESET resetWrap NOTIFY wrapChanged FINAL REVISION(2, 1))
39 // 2.2 (Qt 5.9)
40 Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged FINAL REVISION(2, 2))
41 Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration RESET resetFlickDeceleration NOTIFY flickDecelerationChanged FINAL REVISION(6, 9))
42 QML_NAMED_ELEMENT(Tumbler)
43 QML_ATTACHED(QQuickTumblerAttached)
44 QML_ADDED_IN_VERSION(2, 0)
45
46public:
47 explicit QQuickTumbler(QQuickItem *parent = nullptr);
48 ~QQuickTumbler();
49
50 QVariant model() const;
51 void setModel(const QVariant &model);
52
53 int count() const;
54
55 int currentIndex() const;
56 void setCurrentIndex(int currentIndex);
57 QQuickItem *currentItem() const;
58
59 QQmlComponent *delegate() const;
60 void setDelegate(QQmlComponent *delegate);
61
62 int visibleItemCount() const;
63 void setVisibleItemCount(int visibleItemCount);
64
65 static QQuickTumblerAttached *qmlAttachedProperties(QObject *object);
66
67 // 2.1 (Qt 5.8)
68 bool wrap() const;
69 void setWrap(bool wrap);
70 void resetWrap();
71
72 // 2.2 (Qt 5.9)
73 bool isMoving() const;
74
75 enum PositionMode {
76 Beginning,
77 Center,
78 End,
79 Visible, // ListView-only
80 Contain,
81 SnapPosition
82 };
83 Q_ENUM(PositionMode)
84
85 // 2.5 (Qt 5.12)
86 Q_REVISION(2, 5) Q_INVOKABLE void positionViewAtIndex(int index, PositionMode mode);
87
88 qreal flickDeceleration() const;
89 void setFlickDeceleration(qreal newFlickDeceleration);
90 void resetFlickDeceleration();
91
92Q_SIGNALS:
93 void modelChanged();
94 void countChanged();
95 void currentIndexChanged();
96 void currentItemChanged();
97 void delegateChanged();
98 void visibleItemCountChanged();
99 // 2.1 (Qt 5.8)
100 Q_REVISION(2, 1) void wrapChanged();
101 // 2.2 (Qt 5.9)
102 Q_REVISION(2, 2) void movingChanged();
103 Q_REVISION(6, 9) void flickDecelerationChanged();
104
105protected:
106 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
107 void componentComplete() override;
108 void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
109 void keyPressEvent(QKeyEvent *event) override;
110 void updatePolish() override;
111
112 QFont defaultFont() const override;
113
114private:
115 Q_DISABLE_COPY(QQuickTumbler)
116 Q_DECLARE_PRIVATE(QQuickTumbler)
117
118 Q_PRIVATE_SLOT(d_func(), void _q_updateItemWidths())
119 Q_PRIVATE_SLOT(d_func(), void _q_updateItemHeights())
120 Q_PRIVATE_SLOT(d_func(), void _q_onViewCurrentIndexChanged())
121 Q_PRIVATE_SLOT(d_func(), void _q_onViewCountChanged())
122 Q_PRIVATE_SLOT(d_func(), void _q_onViewOffsetChanged())
123 Q_PRIVATE_SLOT(d_func(), void _q_onViewContentYChanged())
124};
125
127
128class Q_QUICKTEMPLATES2_EXPORT QQuickTumblerAttached : public QObject
129{
130 Q_OBJECT
131 Q_PROPERTY(QQuickTumbler *tumbler READ tumbler CONSTANT FINAL)
132 Q_PROPERTY(qreal displacement READ displacement NOTIFY displacementChanged FINAL)
133
134public:
135 explicit QQuickTumblerAttached(QObject *parent = nullptr);
136
137 QQuickTumbler *tumbler() const;
138 qreal displacement() const;
139
140Q_SIGNALS:
141 void displacementChanged();
142
143private:
144 Q_DISABLE_COPY(QQuickTumblerAttached)
145 Q_DECLARE_PRIVATE(QQuickTumblerAttached)
146};
147
148QT_END_NAMESPACE
149
150#endif // QQUICKTUMBLER_P_H
static qreal defaultFlickDeceleration(bool wrap)
static qreal delegateHeight(const QQuickTumbler *tumbler)