2 * Copyright (C) 2014,2015 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU 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 General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 import Ubuntu.Components 1.3
19 import "../../Components"
21 /*! \brief Preview widget for expandable widgets.
23 This widget shows a list of widgets defined in widgetData["widgets"]
24 Those widgets can be collapsed or uncollapsed. When uncollapsed
25 all the widgets are shown, when collapsed only the first
26 widgetData["collapsed-widgets"] are shown. It has a title that comes
27 in via widgetData["title"]. This widget expands all child widgets
28 when initialized by specifying widgetData["expanded"] == true.
29 It's in unexpanded mode by default.
34 implicitHeight: childrenRect.height
38 objectName: "titleLabel"
41 right: expandButton.left
44 color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText
47 text: widgetData["title"] || ""
53 objectName: "expandButton"
54 width: titleLabel.height
55 height: titleLabel.height
56 anchors.right: parent.right
58 root.expanded = !root.expanded;
64 name: root.expanded ? "view-collapse" : "view-expand"
65 color: root.scopeStyle ? root.scopeStyle.foreground : theme.palette.normal.baseText
71 top: titleLabel.bottom
72 topMargin: units.gu(1)
79 objectName: "repeater"
80 model: widgetData["widgets"]
81 delegate: PreviewWidgetFactory {
82 height: visible ? implicitHeight : 0
84 widgetId: model.widgetId
85 widgetType: model.type
86 widgetData: model.properties
87 isCurrentPreview: root.isCurrentPreview
88 scopeStyle: root.scopeStyle
93 expanded: root.expanded
94 visible: root.expanded || index < root.widgetData["collapsed-widgets"]
97 root.triggered(widgetId, actionId, data);
100 root.makeSureVisible(item)