Debian Codegraph @

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

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