Debian Codegraph @

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

raw ◀ ▶
Source reconstructed at patch state 0 of 4 — not the installed (fully patched) source.
4 Debian patches touch this file
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 QtContacts 5.0
19
20 import Lomiri.Components 1.3
21 import Lomiri.Components.Popups 1.3
22 import Lomiri.Contacts 0.1
23
24 Page {
25 id: root
26
27 property QtObject contact: null
28 property string contactId
29 property alias extensions: extensionsContents.children
30 property alias model: contactFetch.model
31 property alias editable: contactDetailAvatar.editable
32 property alias headerActions: trailingBar.actions
33
34 signal contactFetched(QtObject contact)
35 signal contactRemoved()
36 signal actionTrigerred(string action, QtObject contact, QtObject detail)
37
38 function fetchContact(contactId)
39 {
40 if (contactId !== "") {
41 contactFetch.fetchContact(contactId)
42 }
43 }
44
45 header: PageHeader {
46 id: pageHeader
47
48 flickable: flickable
49 title: contact ? ContactsJS.formatToDisplay(contact, i18n.dtr("lomiri-addressbook-app", "No name")) : ""
50 trailingActionBar {
51 id: trailingBar
52 }
53 }
54
55 Connections {
56 target: contact
57 function onContactChanged() {
58 pageHeader.title = ContactsJS.formatToDisplay(contact, i18n.dtr("lomiri-addressbook-app", "No name"))
59 }
60 }
61
62 // Pop page if the contact get removed
63 onContactChanged: {
64 if (!contact) {
65 root.contactRemoved()
66 }
67 }
68
69 onActiveChanged: {
70 if (active) {
71 //WORKAROUND: to correct scroll back the page
72 flickable.returnToBounds()
73 }
74 }
75
76 ActivityIndicator {
77 id: busyIndicator
78
79 parent: root
80 running: (root.contact === null) && contactFetch.running
81 visible: running
82 anchors.centerIn: parent
83 }
84
85 ContactFetch {
86 id: contactFetch
87
88 onContactRemoved: root.contactRemoved()
89 onContactNotFound: PopupUtils.open(Qt.resolvedUrl("ContactFetchError.qml"), root)
90 onContactFetched: {
91 root.contact = contact
92 root.contactFetched(root.contact)
93 }
94 }
95
96
97 Flickable {
98 id: flickable
99
100 flickableDirection: Flickable.VerticalFlick
101 anchors.fill: parent
102 clip: true
103 //WORKAROUND: There is a bug on SDK page that causes the page to appear flicked with small contents
104 // see bug #1223050
105 contentHeight: Math.max(contents.height, parent.height) + units.gu(2)
106 contentWidth: parent.width
107
108 Column {
109 id: contents
110
111 height: childrenRect.height
112 anchors {
113 top: parent.top
114 left: parent.left
115 right: parent.right
116 }
117
118 ContactDetailAvatarView {
119 id: contactDetailAvatar
120 objectName: "avatar"
121
122 contact: root.contact
123 anchors.left: parent.left
124 height: implicitHeight
125 width: implicitWidth
126 }
127
128 ContactDetailPhoneNumbersView {
129 objectName: "phones"
130
131 contact: root.contact
132 anchors {
133 left: parent.left
134 right: parent.right
135 }
136 height: implicitHeight
137 onActionTrigerred: root.actionTrigerred(actionName, root.contact, detail)
138 }
139
140 ContactDetailEmailsView {
141 objectName: "emails"
142
143 contact: root.contact
144 anchors {
145 left: parent.left
146 right: parent.right
147 }
148 height: implicitHeight
149 onActionTrigerred: root.actionTrigerred(actionName, root.contact, detail)
150 }
151
152 ContactDetailUrlView {
153 objectName: "emails"
154
155 contact: root.contact
156 anchors {
157 left: parent.left
158 right: parent.right
159 }
160 height: implicitHeight
161 }
162
163 ContactDetailOnlineAccountsView {
164 contact: root.contact
165 anchors {
166 left: parent.left
167 right: parent.right
168 }
169 height: implicitHeight
170 onActionTrigerred: root.actionTrigerred(actionName, root.contact, detail)
171 }
172
173 ContactDetailAddressesView {
174 objectName: "addresses"
175
176 contact: root.contact
177 anchors {
178 left: parent.left
179 right: parent.right
180 }
181 height: implicitHeight
182 onActionTrigerred: root.actionTrigerred(actionName, root.contact, detail)
183 }
184
185 ContactDetailBirthdayView {
186 objectName: "birthday"
187
188 contact: root.contact
189 anchors {
190 left: parent.left
191 right: parent.right
192 }
193 height: implicitHeight
194 }
195
196 ContactDetailOrganizationsView {
197 objectName: "organizations"
198
199 contact: root.contact
200 anchors {
201 left: parent.left
202 right: parent.right
203 }
204 height: implicitHeight
205 onActionTrigerred: root.actionTrigerred(actionName, root.contact, detail)
206 }
207
208 ContactDetailNoteView {
209 objectName: "note"
210
211 contact: root.contact
212 anchors {
213 left: parent.left
214 right: parent.right
215 }
216 height: implicitHeight
217 }
218
219 ContactDetailRingtoneView {
220 objectName: "ringtone"
221
222 contact: root.contact
223 anchors {
224 left: parent.left
225 right: parent.right
226 }
227 height: implicitHeight
228 }
229
230 Item {
231 id: extensionsContents
232
233 anchors {
234 left: parent.left
235 right: parent.right
236 }
237 height: childrenRect.height
238 }
239 }
240 }
241
242 Component.onCompleted: {
243 if (contact == null) {
244 fetchContact(root.contactId)
245 }
246 }
247 onContactIdChanged: {
248 if (contact == null) {
249 fetchContact(root.contactId)
250 }
251 }
252 onModelChanged: {
253 if (contact == null) {
254 fetchContact(root.contactId)
255 }
256 }
257 }