This file is indexed.

/usr/lib/x86_64-linux-gnu/qt5/qml/Ubuntu/Components/1.3/PageStack.qml is in qml-module-ubuntu-components-gles 1.3.1918+16.04.20160404-0ubuntu3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
/*
 * Copyright 2012-2015 Canonical Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; version 3.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import QtQuick 2.4
import "../1.2/stack.js" as Stack
import Ubuntu.Components 1.3
import Ubuntu.Components.Private 1.3

/*!
    \qmltype PageStack
    \inqmlmodule Ubuntu.Components 1.1
    \ingroup ubuntu
    \brief A stack of \l Page items that is used for inter-Page navigation.
        Pages on the stack can be popped, and new Pages can be pushed.
        The page on top of the stack is the visible one.

    PageStack should be used inside a \l MainView in order to automatically add
    a header and toolbar to control the stack. The PageStack will automatically
    set the header title to the title of the \l Page that is currently on top
    of the stack, and the tools of the toolbar to the tools of the \l Page on top
    of the stack. When more than one Pages are on the stack, the toolbar will
    automatically feature a back-button that pop the stack when triggered.

    The anchors of the PageStack are set to fill its parent by default. To use
    left/right/top/bottom anchors, explicitly set anchors.fill of the PageStack to
    undefined:
    \qml
        import QtQuick 2.4
        import Ubuntu.Components 1.3

        MainView {
            width: units.gu(40)
            height: units.gu(71)

            PageStack {
                id: mainStack
                anchors {
                    fill: undefined // unset the default to make the other anchors work
                    left: parent.left
                    right: parent.right
                    top: parent.top
                    bottom: rect.top
                }
            }

            Rectangle {
                id: rect
                color: UbuntuColors.red
                anchors {
                    left: parent.left
                    right: parent.right
                    bottom: parent.bottom
                }
                height: units.gu(10)
            }

            Component.onCompleted: mainStack.push(Qt.resolvedUrl("MyPage.qml"))
        }
    \endqml

    Pages that are defined inside the PageStack must initially set their visibility
    to false to avoid the pages occluding the PageStack before they are pushed.
    When pushing a \l Page, its visibility is automatically updated.

    Example:
    \qml
        import QtQuick 2.4
        import Ubuntu.Components 1.3
        import Ubuntu.Components.ListItems 1.3 as ListItem

        MainView {
            width: units.gu(48)
            height: units.gu(60)

            PageStack {
                id: pageStack
                Component.onCompleted: push(page0)

                Page {
                    id: page0
                    title: i18n.tr("Root page")
                    visible: false

                    Column {
                        anchors.fill: parent
                        ListItem.Standard {
                            text: i18n.tr("Page one")
                            onClicked: pageStack.push(page1, {color: UbuntuColors.orange})
                            progression: true
                        }
                        ListItem.Standard {
                            text: i18n.tr("External page")
                            onClicked: pageStack.push(Qt.resolvedUrl("MyCustomPage.qml"))
                            progression: true
                        }
                    }
                }

                Page {
                    title: "Rectangle"
                    id: page1
                    visible: false
                    property alias color: rectangle.color
                    Rectangle {
                        id: rectangle
                        anchors {
                            fill: parent
                            margins: units.gu(5)
                        }
                    }
                }
            }
        }
    \endqml
    As shown in the example above, the push() function can take an Item, Component or URL as input.
*/

PageTreeNode {
    id: pageStack
    anchors.fill: parent

    /*!
      \internal
      Please do not use this property any more. \l MainView now has a header
      property that controls when the header is shown/hidden.
     */
    property bool __showHeader: true
    QtObject {
        property alias showHeader: pageStack.__showHeader
        onShowHeaderChanged: print("__showHeader is deprecated. Do not use it.")
    }

    /*!
      The current size of the stack
     */
    //FIXME: would prefer this be readonly, but readonly properties are only bound at
    //initialisation. Trying to update it in push or pop fails. Not sure how to fix.
    property int depth: 0

    /*!
      The currently active page
     */
    property Item currentPage: null

    /*!
      Push a page to the stack, and apply the given (optional) properties to the page.
      The pushed page may be an Item, Component or URL.
      The function returns the Item that was pushed, or the Item that was created from
      the Component or URL. Depending on the animation of the header, the returned
      Page may or may not be active and on top of the PageStack yet.
     */
    function push(page, properties) {
        internal.finishPreviousAction();
        internal.pageWrapper = internal.createWrapper(page, properties);
        var pageObject = internal.pageWrapper.object;

        if (internal.animateHeader && internal.stack.size() > 0) {
            internal.headStyle.animateOutFinished.connect(internal.pushWrapperObject);
            internal.headStyle.animateOut();
        } else {
            internal.pushWrapperObject();
        }
        // set the back action for Page.header:
        if (pageObject && pageObject.hasOwnProperty("header") && pageObject.header &&
                pageObject.header.hasOwnProperty("navigationActions")) {
            // Page.header is an instance of PageHeader.
            pageObject.header.navigationActions = [ backAction ];
        }

        return pageObject;
    }

    /*!
      Pop the top item from the stack if the stack size is at least 1.
      Do not do anything if 0 or 1 items are on the stack.
     */
    function pop() {
        internal.finishPreviousAction();
        if (internal.stack.size() < 1) {
            print("WARNING: Trying to pop an empty PageStack. Ignoring.");
            return;
        }
        // do not animate if there is no page to animate back in after popping
        if (internal.animateHeader && internal.stack.size() > 1) {
            internal.headStyle.animateOutFinished.connect(internal.popAndDestroy);
            internal.headStyle.animateOut();
        } else {
            internal.popAndDestroy();
        }
    }

    /*!
      Deactivate the active page and clear the stack.
     */
    function clear() {
        internal.finishPreviousAction();
        while (internal.stack.size() > 0) {
            internal.stack.top().active = false;
            if (internal.stack.top().canDestroy) internal.stack.top().destroyObject();
            internal.stack.pop();
        }
        internal.stackUpdated();
    }

    Action {
        // used when the Page has a Page.header property set.
        id: backAction
        visible: pageStack.depth > 0
        iconName: "back"
        text: "Back"
        onTriggered: pageStack.pop()
        objectName: "pagestack_back_action"
    }


    Component {
        id: pageWrapperComponent
        PageWrapper{
        }
    }

    QtObject {
        id: internal
        property Item headStyle: (pageStack.__propagated
                                      && pageStack.__propagated.header
                                      && pageStack.__propagated.header.__styleInstance)
                                    ? pageStack.__propagated.header.__styleInstance
                                    : null

        property bool animateHeader: pageStack.__propagated &&
                                     pageStack.__propagated.hasOwnProperty("animateHeader") &&
                                     pageStack.__propagated.animateHeader

        // Call this function before pushing or popping to ensure correct order
        // of pushes/pops on the stack. This terminates any currently running
        // header transition.
        function finishPreviousAction() {
            // no action required when animating IN because the PageStack was
            // already updated before that transition started.
            if (internal.animateHeader && internal.headStyle.state == "OUT") {
                // force instant update of the PageStack without waiting for
                // the OUT animation to finish:
                internal.headStyle.animateOutFinished();
            }
        }

        // The PageWrapper to be pushed on the stack by pushWrapperObject().
        property var pageWrapper: null

        // Called when the header animate OUT transition finishes for push() or instantly
        // when header animations are disabled.
        function pushWrapperObject() {
            if (internal.animateHeader) {
                headStyle.animateOutFinished.disconnect(internal.pushWrapperObject);
            }
            if (internal.stack.size() > 0) internal.stack.top().active = false;
            internal.stack.push(internal.pageWrapper);
            internal.pageWrapper = null;
            internal.stackUpdated();
        }

        // Called when header animate OUT transition finishes for pop() or instantly
        // when header animations are disabled.
        function popAndDestroy() {
            if (internal.animateHeader) {
                headStyle.animateOutFinished.disconnect(internal.popAndDestroy);
            }
            internal.stack.top().active = false;
            if (internal.stack.top().canDestroy) internal.stack.top().destroyObject();
            internal.stack.pop();
            internal.stackUpdated();
        }

        /*!
          The instance of the stack from javascript
         */
        property var stack: new Stack.Stack()

        function createWrapper(page, properties) {
            var wrapperObject = pageWrapperComponent.createObject(pageStack);
            wrapperObject.pageStack = pageStack;
            wrapperObject.properties = properties;
            // set reference last because it will trigger creation of the object
            //  with specified properties.
            wrapperObject.reference = page;
            return wrapperObject;
        }

        // Update depth and makes the Item on top of the stack active, and
        // then animates IN the new header contents if header animations are enabled.
        function stackUpdated() {
            pageStack.depth = stack.size();
            if (pageStack.depth > 0) {
                internal.stack.top().active = true;
                currentPage = stack.top().object;

                if (internal.animateHeader) {
                    headStyle.animateIn();
                }
            } else {
                currentPage = null;
            }
        }
    }

    /*!
      \qmlproperty list<Object> data
      Children of PageStack are placed in a separate item such that they are
      not active by default until they are pushed on the PageStack.
     */
    default property alias data: inactiveNode.data
    PageTreeNode {
        anchors.fill: parent
        id: inactiveNode
        active: false
    }
}