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 QQUICKSTACKVIEW_P_H
5#define QQUICKSTACKVIEW_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
20QT_BEGIN_NAMESPACE
21
22class QQmlV4Function;
23class QQuickTransition;
24class QQuickStackElement;
25class QQuickStackViewPrivate;
26class QQuickStackViewAttached;
27class QQuickStackViewAttachedPrivate;
28
29class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickStackView : public QQuickControl
30{
31 Q_OBJECT
32 Q_PROPERTY(bool busy READ isBusy NOTIFY busyChanged FINAL)
33 Q_PROPERTY(int depth READ depth NOTIFY depthChanged FINAL)
34 Q_PROPERTY(QQuickItem *currentItem READ currentItem NOTIFY currentItemChanged FINAL)
35 Q_PROPERTY(QJSValue initialItem READ initialItem WRITE setInitialItem FINAL)
36#if QT_CONFIG(quick_viewtransitions)
37 Q_PROPERTY(QQuickTransition *popEnter READ popEnter WRITE setPopEnter NOTIFY popEnterChanged FINAL)
38 Q_PROPERTY(QQuickTransition *popExit READ popExit WRITE setPopExit NOTIFY popExitChanged FINAL)
39 Q_PROPERTY(QQuickTransition *pushEnter READ pushEnter WRITE setPushEnter NOTIFY pushEnterChanged FINAL)
40 Q_PROPERTY(QQuickTransition *pushExit READ pushExit WRITE setPushExit NOTIFY pushExitChanged FINAL)
41 Q_PROPERTY(QQuickTransition *replaceEnter READ replaceEnter WRITE setReplaceEnter NOTIFY replaceEnterChanged FINAL)
42 Q_PROPERTY(QQuickTransition *replaceExit READ replaceExit WRITE setReplaceExit NOTIFY replaceExitChanged FINAL)
43#endif
44 // 2.3 (Qt 5.10)
45 Q_PROPERTY(bool empty READ isEmpty NOTIFY emptyChanged FINAL REVISION(2, 3))
46 QML_NAMED_ELEMENT(StackView)
47 QML_ATTACHED(QQuickStackViewAttached)
48 QML_ADDED_IN_VERSION(2, 0)
49
50public:
51 explicit QQuickStackView(QQuickItem *parent = nullptr);
52 ~QQuickStackView();
53
54 static QQuickStackViewAttached *qmlAttachedProperties(QObject *object);
55
56 bool isBusy() const;
57 int depth() const;
58 QQuickItem *currentItem() const;
59
60 enum Status {
61 Inactive = 0,
62 Deactivating = 1,
63 Activating = 2,
64 Active = 3
65 };
66 Q_ENUM(Status)
67
68 QJSValue initialItem() const;
69 void setInitialItem(const QJSValue &item);
70
71#if QT_CONFIG(quick_viewtransitions)
72 QQuickTransition *popEnter() const;
73 void setPopEnter(QQuickTransition *enter);
74
75 QQuickTransition *popExit() const;
76 void setPopExit(QQuickTransition *exit);
77
78 QQuickTransition *pushEnter() const;
79 void setPushEnter(QQuickTransition *enter);
80
81 QQuickTransition *pushExit() const;
82 void setPushExit(QQuickTransition *exit);
83
84 QQuickTransition *replaceEnter() const;
85 void setReplaceEnter(QQuickTransition *enter);
86
87 QQuickTransition *replaceExit() const;
88 void setReplaceExit(QQuickTransition *exit);
89#endif
90
91 enum LoadBehavior {
92 DontLoad,
93 ForceLoad
94 };
95 Q_ENUM(LoadBehavior)
96
97 Q_INVOKABLE QQuickItem *get(int index, QQuickStackView::LoadBehavior behavior = DontLoad);
98 Q_INVOKABLE QQuickItem *find(const QJSValue &callback, QQuickStackView::LoadBehavior behavior = DontLoad);
99
100 enum Operation {
101 Transition = -1, // ### Deprecated in Qt 6; remove in Qt 7.
102 Immediate = 0,
103 PushTransition = 1,
104 ReplaceTransition = 2,
105 PopTransition = 3,
106 };
107 Q_ENUM(Operation)
108
109 Q_INVOKABLE void push(QQmlV4Function *args);
110 Q_INVOKABLE void pop(QQmlV4Function *args);
111 Q_INVOKABLE void replace(QQmlV4Function *args);
112
113 // 2.3 (Qt 5.10)
114 bool isEmpty() const;
115
116public Q_SLOTS:
117 void clear(Operation operation = Immediate);
118
119Q_SIGNALS:
120 void busyChanged();
121 void depthChanged();
122 void currentItemChanged();
123#if QT_CONFIG(quick_viewtransitions)
124 void popEnterChanged();
125 void popExitChanged();
126 void pushEnterChanged();
127 void pushExitChanged();
128 void replaceEnterChanged();
129 void replaceExitChanged();
130#endif
131 // 2.3 (Qt 5.10)
132 Q_REVISION(2, 3) void emptyChanged();
133
134protected:
135 void componentComplete() override;
136 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
137 bool childMouseEventFilter(QQuickItem *, QEvent *) override;
138
139#if QT_CONFIG(quicktemplates2_multitouch)
140 void touchEvent(QTouchEvent *event) override;
141#endif
142
143#if QT_CONFIG(accessibility)
144 QAccessible::Role accessibleRole() const override;
145#endif
146
147private:
148 Q_DISABLE_COPY(QQuickStackView)
149 Q_DECLARE_PRIVATE(QQuickStackView)
150};
151
152class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickStackViewAttached : public QObject
153{
154 Q_OBJECT
155 Q_PROPERTY(int index READ index NOTIFY indexChanged FINAL)
156 Q_PROPERTY(QQuickStackView *view READ view NOTIFY viewChanged FINAL)
157 Q_PROPERTY(QQuickStackView::Status status READ status NOTIFY statusChanged FINAL)
158 // 2.2 (Qt 5.9)
159 Q_PROPERTY(bool visible READ isVisible WRITE setVisible RESET resetVisible NOTIFY visibleChanged FINAL) // REVISION(2, 2)
160
161public:
162 explicit QQuickStackViewAttached(QObject *parent = nullptr);
163 ~QQuickStackViewAttached();
164
165 int index() const;
166 QQuickStackView *view() const;
167 QQuickStackView::Status status() const;
168
169 // 2.2 (Qt 5.9)
170 bool isVisible() const;
171 void setVisible(bool visible);
172 void resetVisible();
173
174Q_SIGNALS:
175 void indexChanged();
176 void viewChanged();
177 void statusChanged();
178 // 2.1 (Qt 5.8)
179 /*Q_REVISION(2, 1)*/ void activated();
180 /*Q_REVISION(2, 1)*/ void activating();
181 /*Q_REVISION(2, 1)*/ void deactivated();
182 /*Q_REVISION(2, 1)*/ void deactivating();
183 /*Q_REVISION(2, 1)*/ void removed();
184 // 2.2 (Qt 5.9)
185 /*Q_REVISION(2, 2)*/ void visibleChanged();
186
187private:
188 Q_DISABLE_COPY(QQuickStackViewAttached)
189 Q_DECLARE_PRIVATE(QQuickStackViewAttached)
190};
191
192QT_END_NAMESPACE
193
194QML_DECLARE_TYPE(QQuickStackView)
195
196#endif // QQUICKSTACKVIEW_P_H
197

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