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_P_H
5#define QQUICKSTACKVIEW_P_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/qquickstackview_p.h>
19#include <QtQuickTemplates2/private/qquickcontrol_p_p.h>
20#if QT_CONFIG(quick_viewtransitions)
21#include <QtQuick/private/qquickitemviewtransition_p.h>
22#endif
23#include <QtQuick/private/qquickitemchangelistener_p.h>
24#include <QtQml/private/qv4value_p.h>
25#include <QtQml/private/qqmlcontextdata_p.h>
26#include <QtCore/qset.h>
27#include <QtCore/qstack.h>
28
29QT_BEGIN_NAMESPACE
30
31class QQuickStackElement;
32struct QQuickStackTransition;
33
34class QQuickStackViewPrivate : public QQuickControlPrivate
35#if QT_CONFIG(quick_viewtransitions)
36 , public QQuickItemViewTransitionChangeListener
37#endif
38{
39 Q_DECLARE_PUBLIC(QQuickStackView)
40
41public:
42 static QQuickStackViewPrivate *get(QQuickStackView *view)
43 {
44 return view->d_func();
45 }
46
47 void warn(const QString &error);
48 void warnOfInterruption(const QString &attemptedOperation);
49
50 void setCurrentItem(QQuickStackElement *element);
51
52 QList<QQuickStackElement *> parseElements(int from, QQmlV4FunctionPtr args, QStringList *errors);
53 QList<QQuickStackElement *> parseElements(const QList<QQuickStackViewArg> &args);
54 QQuickStackElement *findElement(QQuickItem *item) const;
55 QQuickStackElement *findElement(const QV4::Value &value) const;
56 QQuickStackElement *createElement(const QV4::Value &value, const QQmlRefPointer<QQmlContextData> &context, QString *error);
57 bool pushElements(const QList<QQuickStackElement *> &elements);
58 bool pushElement(QQuickStackElement *element);
59 bool popElements(QQuickStackElement *element);
60 bool replaceElements(QQuickStackElement *element, const QList<QQuickStackElement *> &elements);
61
62 enum class CurrentItemPolicy {
63 DoNotPop,
64 Pop
65 };
66 QQuickItem *popToItem(QQuickItem *item, QQuickStackView::Operation operation, CurrentItemPolicy currentItemPolicy);
67
68#if QT_CONFIG(quick_viewtransitions)
69 void ensureTransitioner();
70 void startTransition(const QQuickStackTransition &first, const QQuickStackTransition &second, bool immediate);
71 void completeTransition(QQuickStackElement *element, QQuickTransition *transition, QQuickStackView::Status status);
72
73 void viewItemTransitionFinished(QQuickItemViewTransitionableItem *item) override;
74#endif
75 void setBusy(bool busy);
76 void depthChange(int newDepth, int oldDepth);
77
78 bool busy = false;
79 bool modifyingElements = false;
80 QString operation;
81 QJSValue initialItem;
82 QQuickItem *currentItem = nullptr;
83 QSet<QQuickStackElement*> removing;
84 QList<QQuickStackElement*> removed;
85 QStack<QQuickStackElement *> elements;
86#if QT_CONFIG(quick_viewtransitions)
87 QQuickItemViewTransitioner *transitioner = nullptr;
88#endif
89};
90
91class QQuickStackViewAttachedPrivate : public QObjectPrivate
92//#if QT_CONFIG(quick_viewtransitions)
93 , public QQuickItemChangeListener
94//#endif
95{
96 Q_DECLARE_PUBLIC(QQuickStackViewAttached)
97
98public:
99 static QQuickStackViewAttachedPrivate *get(QQuickStackViewAttached *attached)
100 {
101 return attached->d_func();
102 }
103
104//#if QT_CONFIG(quick_viewtransitions)
105 void itemParentChanged(QQuickItem *item, QQuickItem *parent) override;
106//#endif
107
108 bool explicitVisible = false;
109 QQuickStackElement *element = nullptr;
110};
111
112QT_END_NAMESPACE
113
114#endif // QQUICKSTACKVIEW_P_P_H
115

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