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

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

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