2
* Copyright (C) 2014 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.1
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"]
32
implicitHeight: childrenRect.height
38
objectName: "titleLabel"
41
right: expandButton.left
44
color: root.scopeStyle ? root.scopeStyle.foreground : "grey"
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"
70
top: titleLabel.bottom
71
topMargin: units.gu(1)
78
objectName: "repeater"
79
model: widgetData["widgets"]
80
delegate: PreviewWidgetFactory {
81
height: visible ? implicitHeight : 0
83
widgetId: modelData.widgetId
84
widgetType: modelData.type
85
widgetData: modelData.properties
86
isCurrentPreview: root.isCurrentPreview
87
scopeStyle: root.scopeStyle
92
expanded: root.expanded
93
visible: root.expanded || index < root.widgetData["collapsed-widgets"]
96
root.triggered(widgetId, actionId, data);