Merge lp:~renatofilho/address-book-app/dynamic-backend into lp:address-book-app
- dynamic-backend
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Francis Ginther |
Approved revision: | 110 |
Merged at revision: | 108 |
Proposed branch: | lp:~renatofilho/address-book-app/dynamic-backend |
Merge into: | lp:address-book-app |
Diff against target: |
387 lines (+109/-39) 14 files modified
CMakeLists.txt (+12/-12) src/app/addressbookapp.cpp (+9/-0) src/imports/Common/ContactDetailGroupBase.qml (+21/-2) src/imports/ContactEdit/ContactDetailWithTypeEditor.qml (+4/-2) src/imports/ContactList/ContactListPage.qml (+1/-0) src/imports/ContactView/CMakeLists.txt (+0/-1) src/imports/ContactView/ContactDetailGroupWithTypeView.qml (+1/-0) src/imports/ContactView/ContactView.qml (+2/-1) src/imports/Ubuntu/Contacts/CMakeLists.txt (+1/-0) src/imports/Ubuntu/Contacts/ContactFetch.qml (+32/-5) src/imports/Ubuntu/Contacts/ContactListView.qml (+1/-0) src/imports/Ubuntu/Contacts/ContactSearchListView.qml (+7/-0) src/imports/Ubuntu/Contacts/ContactSimpleListView.qml (+17/-16) src/imports/Ubuntu/Contacts/qmldir (+1/-0) |
To merge this branch: | bzr merge lp:~renatofilho/address-book-app/dynamic-backend |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Gustavo Pichorim Boiko (community) | Approve | ||
Review via email: mp+192326@code.launchpad.net |
Commit message
Allow change the application QtContact backend, using env variable (QTCONTACTS_
Description of the change
Gustavo Pichorim Boiko (boiko) wrote : | # |
Renato Araujo Oliveira Filho (renatofilho) wrote : | # |
> 57 + // use galare as default QtContacts Manager
> 58 + if (qEnvironmentVa
> 59 + defaultManager = qgetenv(
> 60 + }
>
> Wouldn't it be a good idea to check if the value set from command line
> actually exists in the list of available managers?
If the manager does not exists it will use the default one.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:109
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:110
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Gustavo Pichorim Boiko (boiko) wrote : | # |
Looks good and works as expected!
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Francis Ginther (fginther) wrote : | # |
jenkins failed due to a bad armhf build node. Re-approving.
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2013-10-08 18:42:21 +0000 |
3 | +++ CMakeLists.txt 2013-10-23 13:28:45 +0000 |
4 | @@ -27,18 +27,6 @@ |
5 | # Tests |
6 | enable_testing() |
7 | |
8 | -# uninstall target |
9 | -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" |
10 | - "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" |
11 | - IMMEDIATE @ONLY) |
12 | -add_custom_target(uninstall "${CMAKE_COMMAND}" |
13 | - -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") |
14 | - |
15 | -# config file |
16 | -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.in" |
17 | - "${CMAKE_CURRENT_BINARY_DIR}/config.h" |
18 | - IMMEDIATE @ONLY) |
19 | - |
20 | # components PATH |
21 | execute_process( |
22 | COMMAND qmake -query QT_INSTALL_QML |
23 | @@ -51,3 +39,15 @@ |
24 | add_subdirectory(src) |
25 | add_subdirectory(po) |
26 | add_subdirectory(tests) |
27 | + |
28 | +# uninstall target |
29 | +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" |
30 | + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" |
31 | + IMMEDIATE @ONLY) |
32 | +add_custom_target(uninstall "${CMAKE_COMMAND}" |
33 | + -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") |
34 | + |
35 | +# config file |
36 | +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.in" |
37 | + "${CMAKE_CURRENT_BINARY_DIR}/config.h" |
38 | + IMMEDIATE @ONLY) |
39 | |
40 | === modified file 'src/app/addressbookapp.cpp' |
41 | --- src/app/addressbookapp.cpp 2013-10-15 14:34:03 +0000 |
42 | +++ src/app/addressbookapp.cpp 2013-10-23 13:28:45 +0000 |
43 | @@ -18,6 +18,7 @@ |
44 | #include "addressbookapp.h" |
45 | #include "imagescalethread.h" |
46 | |
47 | + |
48 | #include <QDir> |
49 | #include <QUrl> |
50 | #include <QUrlQuery> |
51 | @@ -90,6 +91,13 @@ |
52 | |
53 | QString contactKey; |
54 | QStringList arguments = this->arguments(); |
55 | + QByteArray defaultManager("galera"); |
56 | + |
57 | + // use galare as default QtContacts Manager |
58 | + if (qEnvironmentVariableIsSet("QTCONTACTS_MANAGER_OVERRIDE")) { |
59 | + defaultManager = qgetenv("QTCONTACTS_MANAGER_OVERRIDE"); |
60 | + } |
61 | + qDebug() << "Using contact manager:" << defaultManager; |
62 | |
63 | if (arguments.contains("--help")) { |
64 | printUsage(arguments); |
65 | @@ -147,6 +155,7 @@ |
66 | m_view->setResizeMode(QQuickView::SizeRootObjectToView); |
67 | m_view->setTitle("AddressBook"); |
68 | m_view->engine()->addImportPath(importPath("/imports/")); |
69 | + m_view->rootContext()->setContextProperty("DEFAULT_CONTACT_MANAGER", defaultManager); |
70 | m_view->rootContext()->setContextProperty("application", this); |
71 | m_view->rootContext()->setContextProperty("contactKey", contactKey); |
72 | |
73 | |
74 | === modified file 'src/imports/Common/ContactDetailGroupBase.qml' |
75 | --- src/imports/Common/ContactDetailGroupBase.qml 2013-10-03 22:48:16 +0000 |
76 | +++ src/imports/Common/ContactDetailGroupBase.qml 2013-10-23 13:28:45 +0000 |
77 | @@ -33,10 +33,11 @@ |
78 | property Component detailDelegate |
79 | property int minimumHeight: 0 |
80 | property bool loaded: false |
81 | + property bool showEmpty: true |
82 | |
83 | signal newFieldAdded(var index) |
84 | |
85 | - implicitHeight: root.details.length > 0 ? contents.implicitHeight : minimumHeight |
86 | + implicitHeight: detailsModel.values.length > 0 ? contents.implicitHeight : minimumHeight |
87 | visible: implicitHeight > 0 |
88 | |
89 | // This model is used to avoid rebuild the repeater every time that the details change |
90 | @@ -44,7 +45,25 @@ |
91 | ListModel { |
92 | id: detailsModel |
93 | |
94 | - property var values: root.details |
95 | + property var values: root.showEmpty ? root.details : filterDetails(root.details) |
96 | + |
97 | + function filterDetails(details) { |
98 | + var result = [] |
99 | + for(var d in details) { |
100 | + var isEmpty = true |
101 | + for(var f in root.fields) { |
102 | + var fieldValue = details[d].value(root.fields[f]) |
103 | + if (fieldValue && (String(fieldValue) !== "")) { |
104 | + isEmpty = false |
105 | + break; |
106 | + } |
107 | + } |
108 | + if (!isEmpty) { |
109 | + result.push(details[d]) |
110 | + } |
111 | + } |
112 | + return result |
113 | + } |
114 | |
115 | onValuesChanged: { |
116 | if (!values) { |
117 | |
118 | === modified file 'src/imports/ContactEdit/ContactDetailWithTypeEditor.qml' |
119 | --- src/imports/ContactEdit/ContactDetailWithTypeEditor.qml 2013-10-03 22:48:16 +0000 |
120 | +++ src/imports/ContactEdit/ContactDetailWithTypeEditor.qml 2013-10-23 13:28:45 +0000 |
121 | @@ -45,10 +45,12 @@ |
122 | var input = fieldValues.children[i] |
123 | if (input.detail && (input.field >= 0)) { |
124 | var originalValue = input.detail.value(input.field) |
125 | - if (input.text != "") { |
126 | + originalValue = originalValue ? String(originalValue) : "" |
127 | + if (input.text !== "") { |
128 | isEmpty = false |
129 | } |
130 | - if (originalValue != input.text) { |
131 | + |
132 | + if (originalValue !== input.text) { |
133 | input.detail.setValue(input.field, input.text) |
134 | detailchanged = true |
135 | } |
136 | |
137 | === modified file 'src/imports/ContactList/ContactListPage.qml' |
138 | --- src/imports/ContactList/ContactListPage.qml 2013-10-10 15:15:15 +0000 |
139 | +++ src/imports/ContactList/ContactListPage.qml 2013-10-23 13:28:45 +0000 |
140 | @@ -65,6 +65,7 @@ |
141 | ContactsUI.ContactListView { |
142 | id: contactList |
143 | |
144 | + manager: DEFAULT_CONTACT_MANAGER |
145 | showFavoritePhoneLabel: false |
146 | multiSelectionEnabled: true |
147 | anchors { |
148 | |
149 | === modified file 'src/imports/ContactView/CMakeLists.txt' |
150 | --- src/imports/ContactView/CMakeLists.txt 2013-09-17 01:31:27 +0000 |
151 | +++ src/imports/ContactView/CMakeLists.txt 2013-10-23 13:28:45 +0000 |
152 | @@ -12,7 +12,6 @@ |
153 | ContactDetailPhoneNumbersView.qml |
154 | ContactDetailPhoneNumberView.qml |
155 | ContactDetailWithTypeView.qml |
156 | - ContactFetch.qml |
157 | ContactHeaderView.qml |
158 | ContactView.qml |
159 | ) |
160 | |
161 | === modified file 'src/imports/ContactView/ContactDetailGroupWithTypeView.qml' |
162 | --- src/imports/ContactView/ContactDetailGroupWithTypeView.qml 2013-07-25 20:00:03 +0000 |
163 | +++ src/imports/ContactView/ContactDetailGroupWithTypeView.qml 2013-10-23 13:28:45 +0000 |
164 | @@ -27,6 +27,7 @@ |
165 | property Action defaultAction |
166 | signal actionTrigerred(string action, QtObject detail) |
167 | |
168 | + showEmpty: false |
169 | headerDelegate: ListItem.Empty { |
170 | highlightWhenPressed: false |
171 | |
172 | |
173 | === modified file 'src/imports/ContactView/ContactView.qml' |
174 | --- src/imports/ContactView/ContactView.qml 2013-09-19 12:37:39 +0000 |
175 | +++ src/imports/ContactView/ContactView.qml 2013-10-23 13:28:45 +0000 |
176 | @@ -18,6 +18,7 @@ |
177 | import QtContacts 5.0 |
178 | import Ubuntu.Components 0.1 |
179 | import Ubuntu.Components.ListItems 0.1 as ListItem |
180 | +import Ubuntu.Contacts 0.1 as ContactsUI |
181 | |
182 | Page { |
183 | id: root |
184 | @@ -137,7 +138,7 @@ |
185 | anchors.centerIn: parent |
186 | } |
187 | |
188 | - ContactFetch { |
189 | + ContactsUI.ContactFetch { |
190 | id: contactFetch |
191 | |
192 | onContactRemoved: pageStack.pop() |
193 | |
194 | === modified file 'src/imports/Ubuntu/Contacts/CMakeLists.txt' |
195 | --- src/imports/Ubuntu/Contacts/CMakeLists.txt 2013-10-08 20:53:44 +0000 |
196 | +++ src/imports/Ubuntu/Contacts/CMakeLists.txt 2013-10-23 13:28:45 +0000 |
197 | @@ -5,6 +5,7 @@ |
198 | ContactDetailPhoneNumberTypeModel.qml |
199 | ContactDetailPickerDelegate.qml |
200 | ContactDetailPickerPhoneNumberDelegate.qml |
201 | + ContactFetch.qml |
202 | ContactListView.qml |
203 | Contacts.js |
204 | ContactSearchListView.qml |
205 | |
206 | === renamed file 'src/imports/ContactView/ContactFetch.qml' => 'src/imports/Ubuntu/Contacts/ContactFetch.qml' |
207 | --- src/imports/ContactView/ContactFetch.qml 2013-09-11 22:39:52 +0000 |
208 | +++ src/imports/Ubuntu/Contacts/ContactFetch.qml 2013-10-23 13:28:45 +0000 |
209 | @@ -24,17 +24,35 @@ |
210 | property QtObject contact: null |
211 | property bool contactIsDirty: false |
212 | |
213 | + property string _pendingId: "" |
214 | + property bool _ready: false |
215 | + |
216 | signal contactFetched(QtObject contact) |
217 | signal contactRemoved() |
218 | |
219 | function fetchContact(contactId) { |
220 | + if (root._ready) { |
221 | + root._fetchContact(contactId) |
222 | + } else { |
223 | + root._pendingId = contactId |
224 | + } |
225 | + } |
226 | + |
227 | + function _fetchContact(contactId) { |
228 | if (contact && !contactIsDirty) { |
229 | contactFetched(contact) |
230 | } else { |
231 | running = true |
232 | - connections.currentQueryId = model.fetchContacts([contactId]) |
233 | - if (connections.currentQueryId === -1) { |
234 | - running = false |
235 | + if (model.manager === "memory") { |
236 | + // memory backend emit contact fetched before return from "fetchContacts" we will use operation = "-2" |
237 | + // to say that we are wainting for a operation from memory manager |
238 | + connections.currentQueryId = -2 |
239 | + model.fetchContacts([contactId]) |
240 | + } else { |
241 | + connections.currentQueryId = model.fetchContacts([contactId]) |
242 | + if (connections.currentQueryId === -1) { |
243 | + running = false |
244 | + } |
245 | } |
246 | } |
247 | } |
248 | @@ -62,13 +80,22 @@ |
249 | property int currentQueryId: -1 |
250 | |
251 | onContactsFetched: { |
252 | - if (requestId == currentQueryId) { |
253 | + // currentQueryId == -2 is used during a fetch using "memory" manager |
254 | + if ((currentQueryId == -2) || (requestId == currentQueryId)) { |
255 | root.contactIsDirty = false |
256 | root.running = false |
257 | currentQueryId = -1 |
258 | + root.contact = fetchedContacts[0] |
259 | root.contactFetched(fetchedContacts[0]) |
260 | - root.contact = fetchedContacts[0] |
261 | } |
262 | } |
263 | } |
264 | + |
265 | + Component.onCompleted: { |
266 | + root._ready = true |
267 | + if (root._pendingId != "") { |
268 | + root._fetchContact(root._pendingId) |
269 | + root._pendingId = "" |
270 | + } |
271 | + } |
272 | } |
273 | |
274 | === modified file 'src/imports/Ubuntu/Contacts/ContactListView.qml' |
275 | --- src/imports/Ubuntu/Contacts/ContactListView.qml 2013-10-10 15:15:15 +0000 |
276 | +++ src/imports/Ubuntu/Contacts/ContactListView.qml 2013-10-23 13:28:45 +0000 |
277 | @@ -56,6 +56,7 @@ |
278 | ContactSimpleListView { |
279 | id: favouritesList |
280 | |
281 | + manager: root.manager |
282 | header: ListItem.Header { |
283 | height: units.gu(5) |
284 | text: i18n.tr("Favourites") |
285 | |
286 | === modified file 'src/imports/Ubuntu/Contacts/ContactSearchListView.qml' |
287 | --- src/imports/Ubuntu/Contacts/ContactSearchListView.qml 2013-09-26 14:39:08 +0000 |
288 | +++ src/imports/Ubuntu/Contacts/ContactSearchListView.qml 2013-10-23 13:28:45 +0000 |
289 | @@ -111,6 +111,13 @@ |
290 | */ |
291 | property variant detailFieldsToDisplay: [ PhoneNumber.Number ] |
292 | /*! |
293 | + \qmlproperty string manager |
294 | + |
295 | + This property holds the manager uri of the contact backend engine. |
296 | + By default this is set to "galera" |
297 | + */ |
298 | + property alias manager: contactsModel.manager |
299 | + /*! |
300 | \internal \qmlproperty variant ___selectedDetail |
301 | */ |
302 | property variant ___selectedDetail: null |
303 | |
304 | === modified file 'src/imports/Ubuntu/Contacts/ContactSimpleListView.qml' |
305 | --- src/imports/Ubuntu/Contacts/ContactSimpleListView.qml 2013-10-15 18:34:42 +0000 |
306 | +++ src/imports/Ubuntu/Contacts/ContactSimpleListView.qml 2013-10-23 13:28:45 +0000 |
307 | @@ -149,6 +149,15 @@ |
308 | By default this is set to true |
309 | */ |
310 | property bool showSections: true |
311 | + |
312 | + /*! |
313 | + \qmlproperty string manager |
314 | + |
315 | + This property holds the manager uri of the contact backend engine. |
316 | + By default this is set to "galera" |
317 | + */ |
318 | + property alias manager: contactsModel.manager |
319 | + |
320 | /*! |
321 | This handler is called when any error occurs in the contact model |
322 | */ |
323 | @@ -200,11 +209,8 @@ |
324 | */ |
325 | function _fetchContact(index, contact) |
326 | { |
327 | - if (priv.currentOperation !== -1) { |
328 | - return |
329 | - } |
330 | contactListView.currentIndex = index |
331 | - priv.currentOperation = contactsModel.fetchContacts(contact.contactId) |
332 | + contactFetch.fetchContact(contact.contactId) |
333 | } |
334 | |
335 | clip: true |
336 | @@ -259,7 +265,7 @@ |
337 | width: parent.width |
338 | visible: loaderDelegate.status == Loader.Ready |
339 | state: contactListView.expanded ? "" : "collapsed" |
340 | - |
341 | + |
342 | Behavior on height { |
343 | enabled: currentContactExpanded == index || detailsShown |
344 | UbuntuNumberAnimation {} |
345 | @@ -349,6 +355,7 @@ |
346 | return |
347 | } |
348 | |
349 | + console.debug("Will fetch" + contact) |
350 | contactListView._fetchContact(index, contact) |
351 | } |
352 | onPressAndHold: { |
353 | @@ -463,17 +470,11 @@ |
354 | onTriggered: priv.scrollList() |
355 | } |
356 | |
357 | - Connections { |
358 | - target: listModel |
359 | - onContactsFetched: { |
360 | - if (requestId == priv.currentOperation) { |
361 | - priv.currentOperation = -1 |
362 | - // this fetch request can only return one contact |
363 | - if(fetchedContacts.length !== 1) |
364 | - return |
365 | - contactListView.contactClicked(fetchedContacts[0]) |
366 | - } |
367 | - } |
368 | + ContactFetch { |
369 | + id: contactFetch |
370 | + |
371 | + model: contactsModel |
372 | + onContactFetched: contactListView.contactClicked(contact) |
373 | } |
374 | |
375 | // This is a workaround to make sure the spinner will disappear if the model is empty |
376 | |
377 | === modified file 'src/imports/Ubuntu/Contacts/qmldir' |
378 | --- src/imports/Ubuntu/Contacts/qmldir 2013-10-04 19:16:48 +0000 |
379 | +++ src/imports/Ubuntu/Contacts/qmldir 2013-10-23 13:28:45 +0000 |
380 | @@ -2,6 +2,7 @@ |
381 | |
382 | ContactDetailOnlineAccountTypeModel 0.1 ContactDetailOnlineAccountTypeModel.qml |
383 | ContactDetailPhoneNumberTypeModel 0.1 ContactDetailPhoneNumberTypeModel.qml |
384 | +ContactFetch 0.1 ContactFetch.qml |
385 | ContactListView 0.1 ContactListView.qml |
386 | ContactSearchListView 0.1 ContactSearchListView.qml |
387 | ContactSimpleListView 0.1 ContactSimpleListView.qml |
57 + // use galare as default QtContacts Manager riableIsSet( "QTCONTACTS_ MANAGER_ OVERRIDE" )) { "QTCONTACTS_ MANAGER_ OVERRIDE" );
58 + if (qEnvironmentVa
59 + defaultManager = qgetenv(
60 + }
Wouldn't it be a good idea to check if the value set from command line actually exists in the list of available managers?