1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2017 The Qt Company Ltd. |
4 | ** Contact: http://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL3$ |
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 The Qt Company. For licensing terms |
14 | ** and conditions see http://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at http://www.qt.io/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 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPLv3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or later as published by the Free |
28 | ** Software Foundation and appearing in the file LICENSE.GPL included in |
29 | ** the packaging of this file. Please review the following information to |
30 | ** ensure the GNU General Public License version 2.0 requirements will be |
31 | ** met: http://www.gnu.org/licenses/gpl-2.0.html. |
32 | ** |
33 | ** $QT_END_LICENSE$ |
34 | ** |
35 | ****************************************************************************/ |
36 | |
37 | #ifndef QQUICKTUMBLER_P_H |
38 | #define QQUICKTUMBLER_P_H |
39 | |
40 | // |
41 | // W A R N I N G |
42 | // ------------- |
43 | // |
44 | // This file is not part of the Qt API. It exists purely as an |
45 | // implementation detail. This header file may change from version to |
46 | // version without notice, or even be removed. |
47 | // |
48 | // We mean it. |
49 | // |
50 | |
51 | #include <QtCore/qvariant.h> |
52 | #include <QtQml/qqmlcomponent.h> |
53 | #include <QtQuickTemplates2/private/qquickcontrol_p.h> |
54 | |
55 | QT_BEGIN_NAMESPACE |
56 | |
57 | class QQuickTumblerAttached; |
58 | class QQuickTumblerPrivate; |
59 | |
60 | class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickTumbler : public QQuickControl |
61 | { |
62 | Q_OBJECT |
63 | Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged FINAL) |
64 | Q_PROPERTY(int count READ count NOTIFY countChanged FINAL) |
65 | Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged FINAL) |
66 | Q_PROPERTY(QQuickItem *currentItem READ currentItem NOTIFY currentItemChanged FINAL) |
67 | Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL) |
68 | Q_PROPERTY(int visibleItemCount READ visibleItemCount WRITE setVisibleItemCount NOTIFY visibleItemCountChanged FINAL) |
69 | // 2.1 (Qt 5.8) |
70 | Q_PROPERTY(bool wrap READ wrap WRITE setWrap RESET resetWrap NOTIFY wrapChanged FINAL REVISION 1) |
71 | // 2.2 (Qt 5.9) |
72 | Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged FINAL REVISION 2) |
73 | |
74 | public: |
75 | explicit QQuickTumbler(QQuickItem *parent = nullptr); |
76 | ~QQuickTumbler(); |
77 | |
78 | QVariant model() const; |
79 | void setModel(const QVariant &model); |
80 | |
81 | int count() const; |
82 | |
83 | int currentIndex() const; |
84 | void setCurrentIndex(int currentIndex); |
85 | QQuickItem *currentItem() const; |
86 | |
87 | QQmlComponent *delegate() const; |
88 | void setDelegate(QQmlComponent *delegate); |
89 | |
90 | int visibleItemCount() const; |
91 | void setVisibleItemCount(int visibleItemCount); |
92 | |
93 | static QQuickTumblerAttached *qmlAttachedProperties(QObject *object); |
94 | |
95 | // 2.1 (Qt 5.8) |
96 | bool wrap() const; |
97 | void setWrap(bool wrap); |
98 | void resetWrap(); |
99 | |
100 | // 2.2 (Qt 5.9) |
101 | bool isMoving() const; |
102 | |
103 | enum PositionMode { |
104 | Beginning, |
105 | Center, |
106 | End, |
107 | Visible, // ListView-only |
108 | Contain, |
109 | SnapPosition |
110 | }; |
111 | Q_ENUM(PositionMode) |
112 | |
113 | // 2.5 (Qt 5.12) |
114 | Q_REVISION(5) Q_INVOKABLE void positionViewAtIndex(int index, PositionMode mode); |
115 | |
116 | Q_SIGNALS: |
117 | void modelChanged(); |
118 | void countChanged(); |
119 | void currentIndexChanged(); |
120 | void currentItemChanged(); |
121 | void delegateChanged(); |
122 | void visibleItemCountChanged(); |
123 | // 2.1 (Qt 5.8) |
124 | Q_REVISION(1) void wrapChanged(); |
125 | // 2.2 (Qt 5.9) |
126 | Q_REVISION(2) void movingChanged(); |
127 | |
128 | protected: |
129 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; |
130 | void componentComplete() override; |
131 | void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override; |
132 | void keyPressEvent(QKeyEvent *event) override; |
133 | void updatePolish() override; |
134 | |
135 | QFont defaultFont() const override; |
136 | QPalette defaultPalette() const override; |
137 | |
138 | private: |
139 | Q_DISABLE_COPY(QQuickTumbler) |
140 | Q_DECLARE_PRIVATE(QQuickTumbler) |
141 | |
142 | Q_PRIVATE_SLOT(d_func(), void _q_updateItemWidths()) |
143 | Q_PRIVATE_SLOT(d_func(), void _q_updateItemHeights()) |
144 | Q_PRIVATE_SLOT(d_func(), void _q_onViewCurrentIndexChanged()) |
145 | Q_PRIVATE_SLOT(d_func(), void _q_onViewCountChanged()) |
146 | Q_PRIVATE_SLOT(d_func(), void _q_onViewOffsetChanged()) |
147 | Q_PRIVATE_SLOT(d_func(), void _q_onViewContentYChanged()) |
148 | }; |
149 | |
150 | class QQuickTumblerAttachedPrivate; |
151 | |
152 | class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickTumblerAttached : public QObject |
153 | { |
154 | Q_OBJECT |
155 | Q_PROPERTY(QQuickTumbler *tumbler READ tumbler CONSTANT FINAL) |
156 | Q_PROPERTY(qreal displacement READ displacement NOTIFY displacementChanged FINAL) |
157 | |
158 | public: |
159 | explicit QQuickTumblerAttached(QObject *parent = nullptr); |
160 | |
161 | QQuickTumbler *tumbler() const; |
162 | qreal displacement() const; |
163 | |
164 | Q_SIGNALS: |
165 | void displacementChanged(); |
166 | |
167 | private: |
168 | Q_DISABLE_COPY(QQuickTumblerAttached) |
169 | Q_DECLARE_PRIVATE(QQuickTumblerAttached) |
170 | }; |
171 | |
172 | QT_END_NAMESPACE |
173 | |
174 | QML_DECLARE_TYPE(QQuickTumbler) |
175 | QML_DECLARE_TYPEINFO(QQuickTumbler, QML_HAS_ATTACHED_PROPERTIES) |
176 | |
177 | #endif // QQUICKTUMBLER_P_H |
178 | |