1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Quick Controls module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
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 https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#include "qquickstack_p.h"
41
42QT_BEGIN_NAMESPACE
43
44/*!
45 \qmltype Stack
46 \instantiates QQuickStack1
47 \inqmlmodule QtQuick.Controls
48 \ingroup controls
49 \brief Provides attached properties for items pushed onto a StackView.
50
51 The Stack type provides attached properties for items pushed onto a \l StackView.
52 It gives specific information about the item, such as its \l status and
53 \l index in the stack \l view the item is in.
54
55 \sa StackView
56*/
57
58QQuickStack1::QQuickStack1(QObject *object)
59 : QObject(object),
60 m_index(-1),
61 m_status(Inactive),
62 m_view(0)
63{
64}
65
66QQuickStack1 *QQuickStack1::qmlAttachedProperties(QObject *object)
67{
68 return new QQuickStack1(object);
69}
70
71/*!
72 \readonly
73 \qmlattachedproperty int Stack::index
74
75 This property holds the index of the item inside \l{view}{StackView},
76 so that \l{StackView::get()}{StackView.get(index)} will return the item itself.
77 If \l{Stack::view}{view} is \c null, \a index will be \c -1.
78*/
79int QQuickStack1::index() const
80{
81 return m_index;
82}
83
84void QQuickStack1::setIndex(int index)
85{
86 if (m_index != index) {
87 m_index = index;
88 emit indexChanged();
89 }
90}
91
92/*!
93 \readonly
94 \qmlattachedproperty enumeration Stack::status
95
96 This property holds the status of the item. It can have one of the following values:
97 \list
98 \li \c Stack.Inactive: the item is not visible
99 \li \c Stack.Activating: the item is transitioning into becoming an active item on the stack
100 \li \c Stack.Active: the item is on top of the stack
101 \li \c Stack.Deactivating: the item is transitioning into becoming inactive
102 \endlist
103*/
104QQuickStack1::Status QQuickStack1::status() const
105{
106 return m_status;
107}
108
109void QQuickStack1::setStatus(Status status)
110{
111 if (m_status != status) {
112 m_status = status;
113 emit statusChanged();
114 }
115}
116
117/*!
118 \readonly
119 \qmlattachedproperty StackView Stack::view
120
121 This property holds the StackView the item is in. If the item is not inside
122 a StackView, \a view will be \c null.
123*/
124QQuickItem *QQuickStack1::view() const
125{
126 return m_view;
127}
128
129void QQuickStack1::setView(QQuickItem *view)
130{
131 if (m_view != view) {
132 m_view = view;
133 emit viewChanged();
134 }
135}
136
137QT_END_NAMESPACE
138

source code of qtquickcontrols/src/controls/qquickstack.cpp