2
* Copyright 2012 Canonical Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
import Ubuntu.Components 1.3 as Toolkit
23
\inqmlmodule Ubuntu.Components 1.1
25
\brief The common parent of \l Page, \l MainView, \l PageStack and \l Tabs.
27
It is used to propagate properties such as \l header and \l toolbar from a
28
\l MainView (the root node) to each \l Page (leaf node) in the tree.
35
Used to determine whether an Item is a PageTreeNode
37
property bool __isPageTreeNode: true
40
onParentChanged: internal.updatePageTree()
42
Component.onCompleted: internal.updatePageTree()
46
The toolbar of the node. Propagates down from the root node.
47
This property is DEPRECATED.
49
property Item toolbar: node.__propagated && node.__propagated.hasOwnProperty("toolbar")
50
? node.__propagated.toolbar : null
54
QtObject containing all the properties that are propagated from the
55
root (MainView) of a page tree to its leafs (Pages).
56
This object contains properties such as the header and toolbar that are
57
instantiated by the MainView.
59
This property is internal because the derived classes (MainView and Page)
60
need to access it, but other components using those classes should not have
63
property QtObject __propagated: node.parentNode ? node.parentNode.__propagated : null
66
At any time, there is exactly one path from the root node to a Page leaf node
67
where all nodes are active. All other nodes are not active. This is used by
68
\l Tabs and \l PageStack to determine which of multiple nodes in the Tabs or
69
PageStack is the currently active one.
71
property bool active: node.parentNode ? node.parentNode.active : false
74
The \l PageStack that this Page has been pushed on, or null if it is not
75
part of a PageStack. This value is automatically set for pages that are pushed
76
on a PageStack, and propagates to its child nodes.
78
// Note: pageStack is not included in the propagated property because there may
79
// be multiple PageStacks in a single page tree.
80
property Item pageStack: node.parentNode ? node.parentNode.pageStack : null
83
The parent node of the current node in the page tree.
85
property Item parentNode: null
88
The leaf node that is active.
90
property Item activeLeafNode
93
Whether or not this node is a leaf, that is if it has no descendant that are nodes.
94
Pages are leafs, and they don't have descendants in the PageTree.
96
property bool isLeaf: false
99
activeFocusOnPress: true
102
target: node.parentNode
103
property: "activeLeafNode"
104
value: node.isLeaf ? node : node.activeLeafNode
111
function isPageTreeNode(object) {
112
// FIXME: Use QuickUtils.className() when it becomes available.
113
return (object && object.hasOwnProperty("__isPageTreeNode") && object.__isPageTreeNode);
117
Return the parent node in the page tree, or null if the item is the root node or invalid.
119
function getParentPageTreeNode(item) {
124
if (internal.isPageTreeNode(i)) {
126
// children of a leaf are not part of the tree
129
// current node is part of the tree with i as its parent.
141
Find the parent node.
143
function updatePageTree() {
144
node.parentNode = internal.getParentPageTreeNode(node);