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 QQUICKREPEATER_P_H |
5 | #define QQUICKREPEATER_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 "qquickitem.h" |
19 | |
20 | #include <private/qtquickglobal_p.h> |
21 | |
22 | QT_REQUIRE_CONFIG(quick_repeater); |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | class QQmlChangeSet; |
27 | |
28 | class QQuickRepeaterPrivate; |
29 | class Q_QUICK_PRIVATE_EXPORT QQuickRepeater : public QQuickItem |
30 | { |
31 | Q_OBJECT |
32 | |
33 | Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged FINAL) |
34 | Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL) |
35 | Q_PROPERTY(int count READ count NOTIFY countChanged FINAL) |
36 | Q_CLASSINFO("DefaultProperty", "delegate") |
37 | QML_NAMED_ELEMENT(Repeater) |
38 | QML_ADDED_IN_VERSION(2, 0) |
39 | |
40 | public: |
41 | QQuickRepeater(QQuickItem *parent=nullptr); |
42 | virtual ~QQuickRepeater(); |
43 | |
44 | QVariant model() const; |
45 | void setModel(const QVariant &); |
46 | |
47 | QQmlComponent *delegate() const; |
48 | void setDelegate(QQmlComponent *); |
49 | |
50 | int count() const; |
51 | |
52 | Q_INVOKABLE QQuickItem *itemAt(int index) const; |
53 | |
54 | Q_SIGNALS: |
55 | void modelChanged(); |
56 | void delegateChanged(); |
57 | void countChanged(); |
58 | |
59 | void itemAdded(int index, QQuickItem *item); |
60 | void itemRemoved(int index, QQuickItem *item); |
61 | |
62 | private: |
63 | void clear(); |
64 | void regenerate(); |
65 | |
66 | protected: |
67 | void componentComplete() override; |
68 | void itemChange(ItemChange change, const ItemChangeData &value) override; |
69 | |
70 | private Q_SLOTS: |
71 | void createdItem(int index, QObject *item); |
72 | void initItem(int, QObject *item); |
73 | void modelUpdated(const QQmlChangeSet &changeSet, bool reset); |
74 | |
75 | private: |
76 | Q_DISABLE_COPY(QQuickRepeater) |
77 | Q_DECLARE_PRIVATE(QQuickRepeater) |
78 | }; |
79 | |
80 | QT_END_NAMESPACE |
81 | |
82 | QML_DECLARE_TYPE(QQuickRepeater) |
83 | |
84 | #endif // QQUICKREPEATER_P_H |
85 |