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
4#ifndef QQUICKCONTAINER_P_H
5#define QQUICKCONTAINER_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 <QtQuickTemplates2/private/qquickcontrol_p.h>
19#include <QtQml/qqmllist.h>
20
21QT_BEGIN_NAMESPACE
22
23class QQuickContainerPrivate;
24
25class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickContainer : public QQuickControl
26{
27 Q_OBJECT
28 Q_PROPERTY(int count READ count NOTIFY countChanged FINAL)
29 Q_PROPERTY(QVariant contentModel READ contentModel CONSTANT FINAL)
30 Q_PROPERTY(QQmlListProperty<QObject> contentData READ contentData)
31 Q_PROPERTY(QQmlListProperty<QQuickItem> contentChildren READ contentChildren NOTIFY contentChildrenChanged FINAL)
32 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged FINAL)
33 Q_PROPERTY(QQuickItem *currentItem READ currentItem NOTIFY currentItemChanged FINAL)
34 // 2.5 (Qt 5.12)
35 Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth RESET resetContentWidth NOTIFY contentWidthChanged FINAL REVISION(2, 5))
36 Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight RESET resetContentHeight NOTIFY contentHeightChanged FINAL REVISION(2, 5))
37 Q_CLASSINFO("DefaultProperty", "contentData")
38 QML_NAMED_ELEMENT(Container)
39 QML_ADDED_IN_VERSION(2, 0)
40
41public:
42 explicit QQuickContainer(QQuickItem *parent = nullptr);
43 ~QQuickContainer();
44
45 int count() const;
46 Q_INVOKABLE QQuickItem *itemAt(int index) const;
47 Q_INVOKABLE void addItem(QQuickItem *item);
48 Q_INVOKABLE void insertItem(int index, QQuickItem *item);
49 Q_INVOKABLE void moveItem(int from, int to);
50 Q_INVOKABLE void removeItem(QQuickItem *item);
51 // 2.3 (Qt 5.10)
52 Q_REVISION(2, 3) Q_INVOKABLE QQuickItem *takeItem(int index);
53
54 QVariant contentModel() const;
55 QQmlListProperty<QObject> contentData();
56 QQmlListProperty<QQuickItem> contentChildren();
57
58 int currentIndex() const;
59 QQuickItem *currentItem() const;
60
61 // 2.5 (Qt 5.12)
62 qreal contentWidth() const;
63 void setContentWidth(qreal width);
64 void resetContentWidth();
65
66 qreal contentHeight() const;
67 void setContentHeight(qreal height);
68 void resetContentHeight();
69
70public Q_SLOTS:
71 void setCurrentIndex(int index);
72 // 2.1 (Qt 5.8)
73 Q_REVISION(2, 1) void incrementCurrentIndex();
74 Q_REVISION(2, 1) void decrementCurrentIndex();
75
76Q_SIGNALS:
77 void countChanged();
78 void contentChildrenChanged();
79 void currentIndexChanged();
80 void currentItemChanged();
81 // 2.5 (Qt 5.12)
82 Q_REVISION(2, 5) void contentWidthChanged();
83 Q_REVISION(2, 5) void contentHeightChanged();
84
85protected:
86 QQuickContainer(QQuickContainerPrivate &dd, QQuickItem *parent);
87
88 void componentComplete() override;
89
90 void itemChange(ItemChange change, const ItemChangeData &data) override;
91 void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
92
93 virtual bool isContent(QQuickItem *item) const;
94 virtual void itemAdded(int index, QQuickItem *item);
95 virtual void itemMoved(int index, QQuickItem *item);
96 virtual void itemRemoved(int index, QQuickItem *item);
97
98private:
99 Q_DISABLE_COPY(QQuickContainer)
100 Q_DECLARE_PRIVATE(QQuickContainer)
101 Q_PRIVATE_SLOT(d_func(), void _q_currentIndexChanged())
102};
103
104QT_END_NAMESPACE
105
106QML_DECLARE_TYPE(QQuickContainer)
107
108#endif // QQUICKCONTAINER_P_H
109

source code of qtdeclarative/src/quicktemplates/qquickcontainer_p.h