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

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