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_P_H
38#define QQUICKSTACKVIEW_P_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/qquickstackview_p.h>
52#include <QtQuickTemplates2/private/qquickcontrol_p_p.h>
53#include <QtQuick/private/qquickitemviewtransition_p.h>
54#include <QtQuick/private/qquickitemchangelistener_p.h>
55#include <QtQml/private/qv4value_p.h>
56#include <QtCore/qset.h>
57#include <QtCore/qstack.h>
58
59QT_BEGIN_NAMESPACE
60
61class QQmlContextData;
62class QQuickStackElement;
63struct QQuickStackTransition;
64
65class QQuickStackViewPrivate : public QQuickControlPrivate, public QQuickItemViewTransitionChangeListener
66{
67 Q_DECLARE_PUBLIC(QQuickStackView)
68
69public:
70 static QQuickStackViewPrivate *get(QQuickStackView *view)
71 {
72 return view->d_func();
73 }
74
75 void warn(const QString &error);
76 void warnOfInterruption(const QString &attemptedOperation);
77
78 void setCurrentItem(QQuickStackElement *element);
79
80 QList<QQuickStackElement *> parseElements(int from, QQmlV4Function *args, QStringList *errors);
81 QQuickStackElement *findElement(QQuickItem *item) const;
82 QQuickStackElement *findElement(const QV4::Value &value) const;
83 QQuickStackElement *createElement(const QV4::Value &value, QQmlContextData *context, QString *error);
84 bool pushElements(const QList<QQuickStackElement *> &elements);
85 bool pushElement(QQuickStackElement *element);
86 bool popElements(QQuickStackElement *element);
87 bool replaceElements(QQuickStackElement *element, const QList<QQuickStackElement *> &elements);
88
89 void ensureTransitioner();
90 void startTransition(const QQuickStackTransition &first, const QQuickStackTransition &second, bool immediate);
91 void completeTransition(QQuickStackElement *element, QQuickTransition *transition, QQuickStackView::Status status);
92
93 void viewItemTransitionFinished(QQuickItemViewTransitionableItem *item) override;
94 void setBusy(bool busy);
95 void depthChange(int newDepth, int oldDepth);
96
97 bool busy = false;
98 bool modifyingElements = false;
99 QString operation;
100 QJSValue initialItem;
101 QQuickItem *currentItem = nullptr;
102 QSet<QQuickStackElement*> removing;
103 QList<QQuickStackElement*> removed;
104 QStack<QQuickStackElement *> elements;
105 QQuickItemViewTransitioner *transitioner = nullptr;
106};
107
108class QQuickStackViewAttachedPrivate : public QObjectPrivate, public QQuickItemChangeListener
109{
110 Q_DECLARE_PUBLIC(QQuickStackViewAttached)
111
112public:
113 static QQuickStackViewAttachedPrivate *get(QQuickStackViewAttached *attached)
114 {
115 return attached->d_func();
116 }
117
118 void itemParentChanged(QQuickItem *item, QQuickItem *parent) override;
119
120 bool explicitVisible = false;
121 QQuickStackElement *element = nullptr;
122};
123
124QT_END_NAMESPACE
125
126#endif // QQUICKSTACKVIEW_P_P_H
127

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