Debian Codegraph @

src/imports/Lomiri/Contacts/ContactDetailPickerPhoneNumberDelegate.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 import QtContacts 5.0 as QtContacts
20
21 Item {
22 id: root
23
24 signal detailClicked(QtObject detail, string action)
25 signal addDetailClicked(int detailType)
26
27 function containsPointer(item, point)
28 {
29 return ((point.x >= item.x) && (point.x <= item.x + item.width) &&
30 (point.y >= item.y) && (point.y <= item.y + item.height));
31 }
32
33 function updateDetails(contact)
34 {
35 if (contact) {
36 phoneNumberEntries.model = contact.details(QtContacts.ContactDetail.PhoneNumber)
37 }
38 }
39
40 height: detailItems.height + units.gu(2)
41 Column {
42 id: detailItems
43
44 anchors {
45 top: parent.top
46 topMargin: units.gu(1)
47 left: parent.left
48 right: parent.right
49 }
50 height: childrenRect.height
51 width: parent.width
52
53 Item {
54 id: noNumberMessage
55
56 anchors {
57 left: parent.left
58 right: parent.right
59 }
60
61 height: visible ? units.gu(8) : 0
62 Rectangle {
63 anchors {
64 fill: parent
65 leftMargin: units.gu(-2)
66 rightMargin: units.gu(-2)
67 }
68 color: Theme.palette.selected.background
69 opacity: noNumberMessageArea.pressed ? 1.0 : 0.0
70 Behavior on opacity {
71 LomiriNumberAnimation {}
72 }
73 }
74 Label {
75 anchors {
76 verticalCenter: parent.verticalCenter
77 left: parent.left
78 leftMargin: units.gu(8)
79 right: parent.right
80 }
81
82 text: i18n.dtr("lomiri-addressbook-app", "Add number...")
83 }
84 visible: phoneNumberEntries.count == 0
85 MouseArea {
86 id: noNumberMessageArea
87
88 anchors.fill: parent
89 enabled: parent.visible
90 onClicked: root.addDetailClicked(QtContacts.ContactDetail.PhoneNumber)
91 }
92 }
93
94 Repeater {
95 id: phoneNumberEntries
96
97 SubtitledWithColors {
98 anchors {
99 left: parent.left
100 leftMargin: units.gu(6)
101 right: parent.right
102 }
103 text: modelData.number
104 subText: phoneTypeModel.get(phoneTypeModel.getTypeIndex(modelData)).label
105 onClicked: root.detailClicked(modelData, "call")
106
107 MouseArea {
108 anchors {
109 top: parent.top
110 bottom: parent.bottom
111 right: parent.right
112 rightMargin: units.gu(1)
113 }
114 width: units.gu(4)
115
116 z: 100
117 onClicked: root.detailClicked(modelData, "message")
118 Icon {
119 id: messageIcon
120
121 name: "message"
122 height: units.gu(3)
123 width: height
124 anchors.verticalCenter: parent.verticalCenter
125 asynchronous: true
126 }
127 }
128 }
129 }
130 }
131
132 ContactDetailPhoneNumberTypeModel {
133 id: phoneTypeModel
134 }
135 }