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 QQUICKCONTAINER_P_H
38#define QQUICKCONTAINER_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 <QtQuickTemplates2/private/qquickcontrol_p.h>
52#include <QtQml/qqmllist.h>
53
54QT_BEGIN_NAMESPACE
55
56class QQuickContainerPrivate;
57
58class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickContainer : public QQuickControl
59{
60 Q_OBJECT
61 Q_PROPERTY(int count READ count NOTIFY countChanged FINAL)
62 Q_PROPERTY(QVariant contentModel READ contentModel CONSTANT FINAL)
63 Q_PROPERTY(QQmlListProperty<QObject> contentData READ contentData FINAL)
64 Q_PROPERTY(QQmlListProperty<QQuickItem> contentChildren READ contentChildren NOTIFY contentChildrenChanged FINAL)
65 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged FINAL)
66 Q_PROPERTY(QQuickItem *currentItem READ currentItem NOTIFY currentItemChanged FINAL)
67 // 2.5 (Qt 5.12)
68 Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth RESET resetContentWidth NOTIFY contentWidthChanged FINAL REVISION 5)
69 Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight RESET resetContentHeight NOTIFY contentHeightChanged FINAL REVISION 5)
70 Q_CLASSINFO("DefaultProperty", "contentData")
71
72public:
73 explicit QQuickContainer(QQuickItem *parent = nullptr);
74 ~QQuickContainer();
75
76 int count() const;
77 Q_INVOKABLE QQuickItem *itemAt(int index) const;
78 Q_INVOKABLE void addItem(QQuickItem *item);
79 Q_INVOKABLE void insertItem(int index, QQuickItem *item);
80 Q_INVOKABLE void moveItem(int from, int to);
81 Q_INVOKABLE void removeItem(const QVariant &item); // ### Qt 6: remove
82 void removeItem(QQuickItem *item); // ### Qt 6: Q_INVOKABLE
83 // 2.3 (Qt 5.10)
84 Q_REVISION(3) Q_INVOKABLE QQuickItem *takeItem(int index);
85
86 QVariant contentModel() const;
87 QQmlListProperty<QObject> contentData();
88 QQmlListProperty<QQuickItem> contentChildren();
89
90 int currentIndex() const;
91 QQuickItem *currentItem() const;
92
93 // 2.5 (Qt 5.12)
94 qreal contentWidth() const;
95 void setContentWidth(qreal width);
96 void resetContentWidth();
97
98 qreal contentHeight() const;
99 void setContentHeight(qreal height);
100 void resetContentHeight();
101
102public Q_SLOTS:
103 void setCurrentIndex(int index);
104 // 2.1 (Qt 5.8)
105 Q_REVISION(1) void incrementCurrentIndex();
106 Q_REVISION(1) void decrementCurrentIndex();
107
108Q_SIGNALS:
109 void countChanged();
110 void contentChildrenChanged();
111 void currentIndexChanged();
112 void currentItemChanged();
113 // 2.5 (Qt 5.12)
114 Q_REVISION(5) void contentWidthChanged();
115 Q_REVISION(5) void contentHeightChanged();
116
117protected:
118 QQuickContainer(QQuickContainerPrivate &dd, QQuickItem *parent);
119
120 void componentComplete() override;
121
122 void itemChange(ItemChange change, const ItemChangeData &data) override;
123 void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
124
125 virtual bool isContent(QQuickItem *item) const;
126 virtual void itemAdded(int index, QQuickItem *item);
127 virtual void itemMoved(int index, QQuickItem *item);
128 virtual void itemRemoved(int index, QQuickItem *item);
129
130private:
131 Q_DISABLE_COPY(QQuickContainer)
132 Q_DECLARE_PRIVATE(QQuickContainer)
133 Q_PRIVATE_SLOT(d_func(), void _q_currentIndexChanged())
134};
135
136QT_END_NAMESPACE
137
138QML_DECLARE_TYPE(QQuickContainer)
139
140#endif // QQUICKCONTAINER_P_H
141

source code of qtquickcontrols2/src/quicktemplates2/qquickcontainer_p.h