Unity 8
 All Classes Functions
PreviewTable.qml
1 /*
2  * Copyright (C) 2014 Canonical, Ltd.
3  *
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.
7  *
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.
12  *
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/>.
15  */
16 
17 import QtQuick 2.0
18 import QtQuick.Layouts 1.1
19 import Ubuntu.Components 0.1
20 import "../../Components"
21 
22 /*! \brief Preview widget for table.
23 
24  This widget shows two columns contained in widgetData["values"]
25  as arrays of label,value along with a title that comes from widgetData["title"].
26 
27  In case the widget is collapsed it only shows 3 lines of values.
28  */
29 
30 PreviewWidget {
31  id: root
32  implicitHeight: column.implicitHeight
33 
34  readonly property int maximumCollapsedRowCount: 3
35 
36  Column {
37  id: column
38  objectName: "column"
39  spacing: units.gu(1)
40 
41  Label {
42  id: titleLabel
43  objectName: "titleLabel"
44  anchors {
45  left: parent.left
46  right: parent.right
47  }
48  height: visible ? implicitHeight : 0
49  fontSize: "large"
50  color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText
51  visible: text !== ""
52  opacity: .8
53  text: widgetData["title"] || ""
54  }
55 
56  GridLayout {
57  objectName: "gridLayout"
58  columns: 2
59  columnSpacing: units.gu(2)
60  Repeater {
61  id: rowsRepeater
62  model: widgetData["values"]
63 
64  delegate: Repeater {
65  id: perRowRepeater
66  readonly property int rowIndex: index
67  model: widgetData["values"][index]
68  delegate: Label {
69  objectName: "label"+rowIndex+index
70  fontSize: "small"
71  text: perRowRepeater.model[index]
72  visible: root.expanded || rowIndex < maximumCollapsedRowCount
73  color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText
74  font.bold: index == 0
75  }
76  }
77  }
78  }
79  }
80 }