Debian Codegraph @

src/imports/Lomiri/AddressBook/ContactView/BasicFieldView.qml

raw
1 /*
2 * Copyright (C) 2012-2015 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.4
18 import Lomiri.Components 1.3
19
20 Item {
21 id: root
22
23 property alias typeLabel: typeLabel.text
24 property alias values: valueList.model
25 property double lineHeight: units.gu(2)
26 property QtObject detail: null
27 property variant fields: null
28 property int parentIndex: -1
29
30 activeFocusOnTab: false
31 implicitHeight: typeLabel.height + fieldValues.height + units.gu(2)
32
33 Column {
34 id: fieldValues
35
36 anchors {
37 left: parent.left
38 top: parent.top
39 topMargin: units.gu(1)
40 right: parent.right
41 }
42 height: (valueList.count * root.lineHeight)
43
44 Repeater {
45 id: valueList
46
47 Label {
48 id: label
49 objectName: detail && fields ? "label_" + detailToString(detail.type, fields[index]) + "_" + root.parentIndex + "." + index : ""
50
51 anchors {
52 left: parent ? parent.left : undefined
53 right: parent ? parent.right : undefined
54 }
55 height: root.lineHeight
56 verticalAlignment: Text.AlignVCenter
57 text: modelData ? modelData : ""
58 elide: Text.ElideRight
59
60 // style
61 fontSize: "medium"
62 }
63 }
64 }
65
66 Label {
67 id: typeLabel
68 objectName: detail ? "type_" + detailToString(detail.type, -1) + "_" + root.parentIndex : ""
69
70 elide: Text.ElideRight
71 visible: text != ""
72 anchors {
73 left: parent.left
74 top: fieldValues.bottom
75 //topMargin: units.gu(0.0)
76 right: parent.right
77 }
78 height: visible ? units.gu(2) : 0
79 verticalAlignment: Text.AlignVCenter
80
81 // style
82 fontSize: "small"
83 opacity: 0.8
84 }
85 }