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, QQmlV4Function *args, QStringList *errors);
53 QQuickStackElement *findElement(QQuickItem *item) const;
54 QQuickStackElement *findElement(const QV4::Value &value) const;
55 QQuickStackElement *createElement(const QV4::Value &value, const QQmlRefPointer<QQmlContextData> &context, QString *error);
56 bool pushElements(const QList<QQuickStackElement *> &elements);
57 bool pushElement(QQuickStackElement *element);
58 bool popElements(QQuickStackElement *element);
59 bool replaceElements(QQuickStackElement *element, const QList<QQuickStackElement *> &elements);
60
61#if QT_CONFIG(quick_viewtransitions)
62 void ensureTransitioner();
63 void startTransition(const QQuickStackTransition &first, const QQuickStackTransition &second, bool immediate);
64 void completeTransition(QQuickStackElement *element, QQuickTransition *transition, QQuickStackView::Status status);
65
66 void viewItemTransitionFinished(QQuickItemViewTransitionableItem *item) override;
67#endif
68 void setBusy(bool busy);
69 void depthChange(int newDepth, int oldDepth);
70
71 bool busy = false;
72 bool modifyingElements = false;
73 QString operation;
74 QJSValue initialItem;
75 QQuickItem *currentItem = nullptr;
76 QSet<QQuickStackElement*> removing;
77 QList<QQuickStackElement*> removed;
78 QStack<QQuickStackElement *> elements;
79#if QT_CONFIG(quick_viewtransitions)
80 QQuickItemViewTransitioner *transitioner = nullptr;
81#endif
82};
83
84class QQuickStackViewAttachedPrivate : public QObjectPrivate
85//#if QT_CONFIG(quick_viewtransitions)
86 , public QQuickItemChangeListener
87//#endif
88{
89 Q_DECLARE_PUBLIC(QQuickStackViewAttached)
90
91public:
92 static QQuickStackViewAttachedPrivate *get(QQuickStackViewAttached *attached)
93 {
94 return attached->d_func();
95 }
96
97//#if QT_CONFIG(quick_viewtransitions)
98 void itemParentChanged(QQuickItem *item, QQuickItem *parent) override;
99//#endif
100
101 bool explicitVisible = false;
102 QQuickStackElement *element = nullptr;
103};
104
105QT_END_NAMESPACE
106
107#endif // QQUICKSTACKVIEW_P_P_H
108

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