Merge lp:~renatofilho/address-book-app/no-most-called into lp:address-book-app
- no-most-called
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Gustavo Pichorim Boiko |
Approved revision: | 667 |
Merged at revision: | 666 |
Proposed branch: | lp:~renatofilho/address-book-app/no-most-called |
Merge into: | lp:address-book-app |
Diff against target: |
822 lines (+1/-727) 9 files modified
debian/control (+1/-3) src/imports/Ubuntu/Contacts/CMakeLists.txt (+0/-4) src/imports/Ubuntu/Contacts/ContactListView.qml (+0/-13) src/imports/Ubuntu/Contacts/MostCalledList.qml (+0/-115) src/imports/Ubuntu/Contacts/MostCalledModel.qml (+0/-102) src/imports/Ubuntu/Contacts/mostcalledproxymodel.cpp (+0/-374) src/imports/Ubuntu/Contacts/mostcalledproxymodel.h (+0/-112) src/imports/Ubuntu/Contacts/plugin.cpp (+0/-2) src/imports/Ubuntu/Contacts/qmldir (+0/-2) |
To merge this branch: | bzr merge lp:~renatofilho/address-book-app/no-most-called |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gustavo Pichorim Boiko (community) | Approve | ||
system-apps-ci-bot | continuous-integration | Approve | |
Review via email: mp+313059@code.launchpad.net |
Commit message
Remove MostCalledList.
It will be moved to dialer-app.
Description of the change
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
- 667. By Renato Araujo Oliveira Filho
-
Remove 'qtdeclarative5
-ubuntu- content1' as dep for 's390x' arch.
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:667
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Gustavo Pichorim Boiko (boiko) wrote : | # |
Looks good!
Preview Diff
1 | === modified file 'debian/control' |
2 | --- debian/control 2016-11-24 18:54:55 +0000 |
3 | +++ debian/control 2016-12-14 13:04:55 +0000 |
4 | @@ -23,8 +23,7 @@ |
5 | qtdeclarative5-gsettings1.0 [amd64 armhf i386], |
6 | qml-module-ofono [amd64 armhf i386], |
7 | qtdeclarative5-qtcontacts-plugin [amd64 armhf i386], |
8 | - qtdeclarative5-ubuntu-content1 [amd64 armhf i386 s390x], |
9 | - qtdeclarative5-ubuntu-history0.1 [amd64 armhf i386], |
10 | + qtdeclarative5-ubuntu-content1 [amd64 armhf i386], |
11 | qtdeclarative5-ubuntu-keyboard-extensions0.1 [amd64 armhf i386], |
12 | qtdeclarative5-buteo-syncfw0.1 [amd64 armhf i386], |
13 | qtdeclarative5-ubuntu-telephony-phonenumber0.1 [amd64 armhf i386], |
14 | @@ -59,7 +58,6 @@ |
15 | qtdeclarative5-qtquick2-plugin, |
16 | qml-module-ofono, |
17 | qtdeclarative5-ubuntu-addressbook0.1 (= ${binary:Version}), |
18 | - qtdeclarative5-ubuntu-history0.1, |
19 | qtdeclarative5-ubuntu-keyboard-extensions0.1, |
20 | qtdeclarative5-ubuntu-telephony-phonenumber0.1 (>= 0.1+14.10.20140715.1), |
21 | ${misc:Depends}, |
22 | |
23 | === modified file 'src/imports/Ubuntu/Contacts/CMakeLists.txt' |
24 | --- src/imports/Ubuntu/Contacts/CMakeLists.txt 2016-01-22 14:51:39 +0000 |
25 | +++ src/imports/Ubuntu/Contacts/CMakeLists.txt 2016-12-14 13:04:55 +0000 |
26 | @@ -18,8 +18,6 @@ |
27 | FastScroll.qml |
28 | ListItemWithActionsCheckBox.qml |
29 | ListItemWithActions.qml |
30 | - MostCalledList.qml |
31 | - MostCalledModel.qml |
32 | MultipleSelectionListView.qml |
33 | MultipleSelectionVisualModel.qml |
34 | Ofono.qml |
35 | @@ -40,8 +38,6 @@ |
36 | contacts.cpp |
37 | imagescalethread.h |
38 | imagescalethread.cpp |
39 | - mostcalledproxymodel.h |
40 | - mostcalledproxymodel.cpp |
41 | plugin.h |
42 | plugin.cpp |
43 | simcardcontacts.h |
44 | |
45 | === modified file 'src/imports/Ubuntu/Contacts/ContactListView.qml' |
46 | --- src/imports/Ubuntu/Contacts/ContactListView.qml 2016-09-19 20:47:48 +0000 |
47 | +++ src/imports/Ubuntu/Contacts/ContactListView.qml 2016-12-14 13:04:55 +0000 |
48 | @@ -570,19 +570,6 @@ |
49 | } |
50 | } |
51 | } |
52 | - |
53 | - MostCalledList { |
54 | - id: mostCalledView |
55 | - |
56 | - anchors { |
57 | - left: parent.left |
58 | - right: parent.right |
59 | - margins: units.gu(1) |
60 | - } |
61 | - parentView: view |
62 | - visible: view.favouritesIsSelected |
63 | - height: visible && (count > 0) ? childrenRect.height : 0 |
64 | - } |
65 | } |
66 | onError: root.error(message) |
67 | onContactClicked: root.contactClicked(contact) |
68 | |
69 | === removed file 'src/imports/Ubuntu/Contacts/MostCalledList.qml' |
70 | --- src/imports/Ubuntu/Contacts/MostCalledList.qml 2016-05-05 15:55:23 +0000 |
71 | +++ src/imports/Ubuntu/Contacts/MostCalledList.qml 1970-01-01 00:00:00 +0000 |
72 | @@ -1,115 +0,0 @@ |
73 | -/* |
74 | - * Copyright (C) 2012-2014 Canonical, Ltd. |
75 | - * |
76 | - * This program is free software; you can redistribute it and/or modify |
77 | - * it under the terms of the GNU General Public License as published by |
78 | - * the Free Software Foundation; version 3. |
79 | - * |
80 | - * This program is distributed in the hope that it will be useful, |
81 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
82 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
83 | - * GNU General Public License for more details. |
84 | - * |
85 | - * You should have received a copy of the GNU General Public License |
86 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
87 | - */ |
88 | - |
89 | -import QtQuick 2.4 |
90 | - |
91 | -Column { |
92 | - id: root |
93 | - |
94 | - property alias parentView: scrollAnimation.target |
95 | - readonly property alias count: callerRepeat.count |
96 | - |
97 | - /* internal */ |
98 | - property int _nextCurrentIndex: -1 |
99 | - |
100 | - |
101 | - function makeItemVisible(item) |
102 | - { |
103 | - if (!item) { |
104 | - return |
105 | - } |
106 | - |
107 | - var itemY = parent.y + root.y + item.y |
108 | - var areaY = parentView.contentY |
109 | - if (itemY < areaY) { |
110 | - // move foward |
111 | - scrollAnimation.to = itemY |
112 | - } else if ((areaY + parentView.height) < (itemY + item.height)) { |
113 | - // move backward |
114 | - scrollAnimation.to = itemY + item.height |
115 | - } else { |
116 | - return |
117 | - } |
118 | - scrollAnimation.restart() |
119 | - } |
120 | - |
121 | - SmoothedAnimation { |
122 | - id: scrollAnimation |
123 | - |
124 | - property: "contentY" |
125 | - velocity: parentView.highlightMoveVelocity |
126 | - duration: parentView.highlightMoveDuration |
127 | - } |
128 | - |
129 | - SectionDelegate { |
130 | - anchors { |
131 | - left: parent.left |
132 | - right: parent.right |
133 | - margins: units.gu(2) |
134 | - } |
135 | - text: i18n.dtr("address-book-app", "Frequently called") |
136 | - visible: (root.count > 0) |
137 | - } |
138 | - |
139 | - Repeater { |
140 | - id: callerRepeat |
141 | - |
142 | - model: MostCalledModel { |
143 | - id: calledModel |
144 | - |
145 | - onContactClicked: parentView.contactClicked(contact) |
146 | - onAddContactClicked: parentView.addContactClicked(label) |
147 | - onCurrentIndexChanged: { |
148 | - if (currentIndex !== -1) { |
149 | - parentView.currentIndex = -1 |
150 | - root._nextCurrentIndex = currentIndex |
151 | - } |
152 | - } |
153 | - } |
154 | - } |
155 | - |
156 | - Connections { |
157 | - target: parentView |
158 | - onCurrentIndexChanged: { |
159 | - if (parentView.currentIndex !== -1) { |
160 | - calledModel.currentIndex = -1 |
161 | - } |
162 | - } |
163 | - } |
164 | - |
165 | - onHeightChanged: { |
166 | - if (root._nextCurrentIndex != -1) { |
167 | - heightChangedTimeout.restart() |
168 | - } |
169 | - } |
170 | - |
171 | - Timer { |
172 | - id: heightChangedTimeout |
173 | - interval: 100 |
174 | - onTriggered: { |
175 | - makeItemVisible(callerRepeat.itemAt(root._nextCurrentIndex)) |
176 | - root._nextCurrentIndex = -1 |
177 | - } |
178 | - } |
179 | - |
180 | - onVisibleChanged: { |
181 | - // update the model every time that it became visible |
182 | - // in fact calling update only reloads the model data if it has changed |
183 | - if (visible) { |
184 | - calledModel.model.update() |
185 | - } |
186 | - } |
187 | -} |
188 | |
189 | === removed file 'src/imports/Ubuntu/Contacts/MostCalledModel.qml' |
190 | --- src/imports/Ubuntu/Contacts/MostCalledModel.qml 2015-10-26 13:18:11 +0000 |
191 | +++ src/imports/Ubuntu/Contacts/MostCalledModel.qml 1970-01-01 00:00:00 +0000 |
192 | @@ -1,102 +0,0 @@ |
193 | -/* |
194 | - * Copyright (C) 2012-2015 Canonical, Ltd. |
195 | - * |
196 | - * This program is free software; you can redistribute it and/or modify |
197 | - * it under the terms of the GNU General Public License as published by |
198 | - * the Free Software Foundation; version 3. |
199 | - * |
200 | - * This program is distributed in the hope that it will be useful, |
201 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
202 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
203 | - * GNU General Public License for more details. |
204 | - * |
205 | - * You should have received a copy of the GNU General Public License |
206 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
207 | - */ |
208 | - |
209 | - |
210 | -import QtQuick 2.4 |
211 | -import QtContacts 5.0 |
212 | - |
213 | -import Ubuntu.History 0.1 |
214 | -import Ubuntu.Contacts 0.1 as ContactUI |
215 | - |
216 | -VisualDataModel { |
217 | - id: root |
218 | - |
219 | - property var contactModel: null |
220 | - property int currentIndex: -1 |
221 | - property alias callAverage: mostCalledModel.callAverage |
222 | - |
223 | - signal contactClicked(int index, QtObject contact) |
224 | - signal addContactClicked(string label) |
225 | - signal loaded() |
226 | - |
227 | - property var baseModel: HistoryEventModel { |
228 | - id: historyEventModel |
229 | - |
230 | - type: HistoryThreadModel.EventTypeVoice |
231 | - sort: HistorySort { |
232 | - sortField: "timestamp" |
233 | - sortOrder: HistorySort.DescendingOrder |
234 | - } |
235 | - filter: HistoryFilter { |
236 | - filterProperty: "senderId" |
237 | - filterValue: "self" |
238 | - matchFlags: HistoryFilter.MatchCaseSensitive |
239 | - } |
240 | - onCanFetchMoreChanged: { |
241 | - if (count === 0) { |
242 | - mostCalledModel.update() |
243 | - } |
244 | - } |
245 | - } |
246 | - |
247 | - model: ContactUI.MostCalledContactsModel { |
248 | - id: mostCalledModel |
249 | - |
250 | - startInterval: new Date((new Date().getTime() - 2592000000)) // one month ago |
251 | - maxCount: 5 |
252 | - onLoaded: root.loaded() |
253 | - sourceModel: historyEventModel |
254 | - } |
255 | - |
256 | - delegate: ContactDelegate { |
257 | - id: contactDelegate |
258 | - |
259 | - readonly property alias contact: contactFetch.contact |
260 | - property var contents |
261 | - |
262 | - defaultAvatarUrl: "image://theme/contacts" |
263 | - width: parent ? parent.width : 0 |
264 | - isCurrentItem: root.currentIndex === index |
265 | - locked: true |
266 | - |
267 | - // collapse the item before remove it, to avoid crash |
268 | - ListView.onRemove: SequentialAnimation { |
269 | - ScriptAction { |
270 | - script: { |
271 | - if (contactDelegate.state !== "") { |
272 | - historyModel.currentIndex = -1 |
273 | - } |
274 | - } |
275 | - } |
276 | - } |
277 | - |
278 | - onClicked: { |
279 | - if (contact) { |
280 | - root.contactClicked(index, contact) |
281 | - } else { |
282 | - root.addContactClicked(name.text) |
283 | - } |
284 | - } |
285 | - |
286 | - // delegate does not support more than one child |
287 | - contents: ContactFetch { |
288 | - id: contactFetch |
289 | - model: contactsModel |
290 | - } |
291 | - |
292 | - Component.onCompleted: contactFetch.fetchContact(contactId) |
293 | - } |
294 | -} |
295 | |
296 | === removed file 'src/imports/Ubuntu/Contacts/mostcalledproxymodel.cpp' |
297 | --- src/imports/Ubuntu/Contacts/mostcalledproxymodel.cpp 2016-05-05 15:56:00 +0000 |
298 | +++ src/imports/Ubuntu/Contacts/mostcalledproxymodel.cpp 1970-01-01 00:00:00 +0000 |
299 | @@ -1,374 +0,0 @@ |
300 | -/* |
301 | - * Copyright (C) 2012-2015 Canonical, Ltd. |
302 | - * |
303 | - * This program is free software; you can redistribute it and/or modify |
304 | - * it under the terms of the GNU General Public License as published by |
305 | - * the Free Software Foundation; version 3. |
306 | - * |
307 | - * This program is distributed in the hope that it will be useful, |
308 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
309 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
310 | - * GNU General Public License for more details. |
311 | - * |
312 | - * You should have received a copy of the GNU General Public License |
313 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
314 | - */ |
315 | - |
316 | -#include "mostcalledproxymodel.h" |
317 | - |
318 | -#include <QtContacts/QContactManager> |
319 | -#include <QtContacts/QContactFilter> |
320 | -#include <QtContacts/QContactPhoneNumber> |
321 | -#include <QtContacts/QContactFetchRequest> |
322 | - |
323 | -#include <QDebug> |
324 | - |
325 | -using namespace QtContacts; |
326 | - |
327 | -bool mostCalledContactsModelDataGreaterThan(const MostCalledContactsModelData &d1, const MostCalledContactsModelData &d2) |
328 | -{ |
329 | - return d1.callCount > d2.callCount; |
330 | -} |
331 | - |
332 | -MostCalledContactsModel::MostCalledContactsModel(QObject *parent) |
333 | - : QAbstractListModel(parent), |
334 | - m_sourceModel(0), |
335 | - m_currentFetch(0), |
336 | - m_manager(new QContactManager("galera")), |
337 | - m_maxCount(20), |
338 | - m_average(0), |
339 | - m_outdated(true), |
340 | - m_reloadingModel(false), |
341 | - m_aboutToQuit(false) |
342 | -{ |
343 | - connect(this, SIGNAL(sourceModelChanged(QAbstractItemModel*)), SLOT(markAsOutdated())); |
344 | - connect(this, SIGNAL(maxCountChanged(uint)), SLOT(markAsOutdated())); |
345 | - connect(this, SIGNAL(startIntervalChanged(QDateTime)), SLOT(markAsOutdated())); |
346 | -} |
347 | - |
348 | -MostCalledContactsModel::~MostCalledContactsModel() |
349 | -{ |
350 | - m_aboutToQuit = true; |
351 | - m_phones.clear(); |
352 | - |
353 | - if (m_currentFetch) { |
354 | - m_currentFetch->cancel(); |
355 | - } |
356 | -} |
357 | - |
358 | -QVariant MostCalledContactsModel::data(const QModelIndex &index, int role) const |
359 | -{ |
360 | - if (!index.isValid()) { |
361 | - return QVariant(); |
362 | - } |
363 | - |
364 | - int row = index.row(); |
365 | - if ((row >= 0) && (row < m_data.size())) { |
366 | - switch (role) |
367 | - { |
368 | - case MostCalledContactsModel::ContactIdRole: |
369 | - return m_data[row].contactId; |
370 | - case MostCalledContactsModel::PhoneNumberRole: |
371 | - return m_data[row].phoneNumber; |
372 | - case MostCalledContactsModel::CallCountRole: |
373 | - return m_data[row].callCount; |
374 | - default: |
375 | - return QVariant(); |
376 | - } |
377 | - } |
378 | - return QVariant(); |
379 | -} |
380 | - |
381 | -QHash<int, QByteArray> MostCalledContactsModel::roleNames() const |
382 | -{ |
383 | - static QHash<int, QByteArray> roles; |
384 | - if (roles.isEmpty()) { |
385 | - roles.insert(MostCalledContactsModel::ContactIdRole, "contactId"); |
386 | - roles.insert(MostCalledContactsModel::PhoneNumberRole, "phoneNumber"); |
387 | - roles.insert(MostCalledContactsModel::CallCountRole, "callCount"); |
388 | - } |
389 | - return roles; |
390 | -} |
391 | - |
392 | -int MostCalledContactsModel::rowCount(const QModelIndex &) const |
393 | -{ |
394 | - return m_data.size(); |
395 | -} |
396 | - |
397 | -QAbstractItemModel *MostCalledContactsModel::sourceModel() const |
398 | -{ |
399 | - return m_sourceModel; |
400 | -} |
401 | - |
402 | -void MostCalledContactsModel::setSourceModel(QAbstractItemModel *model) |
403 | -{ |
404 | - if (m_sourceModel != model) { |
405 | - if (m_sourceModel) { |
406 | - disconnect(m_sourceModel); |
407 | - } |
408 | - |
409 | - m_sourceModel = model; |
410 | - connect(m_sourceModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), SLOT(markAsOutdated())); |
411 | - connect(m_sourceModel, SIGNAL(rowsInserted(QModelIndex,int,int)), SLOT(markAsOutdated())); |
412 | - connect(m_sourceModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(markAsOutdated())); |
413 | - connect(m_sourceModel, SIGNAL(modelReset()), SLOT(markAsOutdated())); |
414 | - |
415 | - Q_EMIT sourceModelChanged(m_sourceModel); |
416 | - } |
417 | -} |
418 | - |
419 | - |
420 | -uint MostCalledContactsModel::maxCount() const |
421 | -{ |
422 | - return m_maxCount; |
423 | -} |
424 | - |
425 | -void MostCalledContactsModel::setMaxCount(uint value) |
426 | -{ |
427 | - if (m_maxCount != value) { |
428 | - m_maxCount = value; |
429 | - Q_EMIT maxCountChanged(m_maxCount); |
430 | - } |
431 | -} |
432 | - |
433 | -int MostCalledContactsModel::callAverage() const |
434 | -{ |
435 | - return m_average; |
436 | -} |
437 | - |
438 | -QDateTime MostCalledContactsModel::startInterval() const |
439 | -{ |
440 | - return m_startInterval; |
441 | -} |
442 | - |
443 | -void MostCalledContactsModel::setStartInterval(const QDateTime &value) |
444 | -{ |
445 | - if (m_startInterval != value) { |
446 | - m_startInterval = value; |
447 | - Q_EMIT startIntervalChanged(m_startInterval); |
448 | - } |
449 | -} |
450 | - |
451 | -QVariant MostCalledContactsModel::getSourceData(int row, int role) |
452 | -{ |
453 | - QAbstractItemModel *source = sourceModel(); |
454 | - if (!source) { |
455 | - return QVariant(); |
456 | - } |
457 | - |
458 | - while ((source->rowCount() <= row) && (source->canFetchMore(QModelIndex()))) { |
459 | - source->fetchMore(QModelIndex()); |
460 | - } |
461 | - |
462 | - if (source->rowCount() < row) { |
463 | - return QVariant(); |
464 | - } |
465 | - |
466 | - QModelIndex sourceIndex = source->index(row, 0); |
467 | - return source->data(sourceIndex, role); |
468 | -} |
469 | - |
470 | -void MostCalledContactsModel::update() |
471 | -{ |
472 | - // skip update if not necessary |
473 | - if (!m_outdated || m_reloadingModel) { |
474 | - return; |
475 | - } |
476 | - |
477 | - if (m_maxCount <= 0) { |
478 | - qWarning() << "update model requested with invalid maxCount"; |
479 | - m_outdated = false; |
480 | - return; |
481 | - } |
482 | - |
483 | - if (!m_startInterval.isValid()) { |
484 | - qWarning() << "Update model requested with invalid startInterval"; |
485 | - m_outdated = false; |
486 | - return; |
487 | - } |
488 | - |
489 | - QAbstractItemModel *source = sourceModel(); |
490 | - if (!source) { |
491 | - qWarning() << "Update model requested with null source model"; |
492 | - m_outdated = false; |
493 | - return; |
494 | - } |
495 | - |
496 | - m_totalCalls = 0; |
497 | - m_phones.clear(); |
498 | - m_phoneToContactCache.clear(); |
499 | - m_contactsData.clear(); |
500 | - queryContacts(); |
501 | -} |
502 | - |
503 | -void MostCalledContactsModel::queryContacts() |
504 | -{ |
505 | - // get all phone in the date inteval |
506 | - QHash<int, QByteArray> roles = sourceModel()->roleNames(); |
507 | - int participantsRole = roles.key("participants", -1); |
508 | - int timestampRole = roles.key("timestamp", -1); |
509 | - int row = 0; |
510 | - |
511 | - Q_ASSERT(participantsRole != -1); |
512 | - Q_ASSERT(timestampRole != -1); |
513 | - |
514 | - while(true) { |
515 | - QVariant date = getSourceData(row, timestampRole); |
516 | - |
517 | - // end of source model |
518 | - if (date.isNull()) { |
519 | - break; |
520 | - } |
521 | - |
522 | - // exit if date is out of interval |
523 | - if (date.toDateTime() < m_startInterval) { |
524 | - break; |
525 | - } |
526 | - |
527 | - QVariant data = getSourceData(row, participantsRole); |
528 | - if (data.isValid()) { |
529 | - const QVariantList participants = data.toList(); |
530 | - Q_FOREACH(const QVariant &map, participants) { |
531 | - const QString phone = map.toMap().value("identifier").toString(); |
532 | - if (!phone.isEmpty()) |
533 | - m_phones << phone; |
534 | - } |
535 | - } |
536 | - |
537 | - // next row |
538 | - row++; |
539 | - } |
540 | - |
541 | - // query for all phones |
542 | - nextContact(); |
543 | -} |
544 | - |
545 | -void MostCalledContactsModel::nextContact() |
546 | -{ |
547 | - if (m_phones.isEmpty()) { |
548 | - parseResult(); |
549 | - return; |
550 | - } |
551 | - |
552 | - QString nextPhone = m_phones.takeFirst(); |
553 | - |
554 | - if (m_phoneToContactCache.contains(nextPhone)) { |
555 | - registerCall(nextPhone, m_phoneToContactCache.value(nextPhone)); |
556 | - nextContact(); |
557 | - return; |
558 | - } else { |
559 | - QContactFilter filter(QContactPhoneNumber::match(nextPhone)); |
560 | - QContactFetchHint hint; |
561 | - hint.setDetailTypesHint(QList<QContactDetail::DetailType>() << QContactDetail::TypeGuid); |
562 | - |
563 | - m_currentFetch = new QContactFetchRequest; |
564 | - m_currentFetch->setProperty("PHONE", nextPhone); |
565 | - m_currentFetch->setFilter(filter); |
566 | - m_currentFetch->setFetchHint(hint); |
567 | - m_currentFetch->setManager(m_manager.data()); |
568 | - |
569 | - connect(m_currentFetch, |
570 | - SIGNAL(stateChanged(QContactAbstractRequest::State)), |
571 | - SLOT(fetchContactIdDone())); |
572 | - |
573 | - m_currentFetch->start(); |
574 | - } |
575 | -} |
576 | - |
577 | -void MostCalledContactsModel::fetchContactIdDone() |
578 | -{ |
579 | - Q_ASSERT(m_currentFetch); |
580 | - |
581 | - if (m_aboutToQuit) { |
582 | - m_currentFetch->deleteLater(); |
583 | - m_currentFetch = 0; |
584 | - return; |
585 | - } |
586 | - |
587 | - if (m_currentFetch->state() == QContactAbstractRequest::ActiveState) { |
588 | - return; |
589 | - } |
590 | - |
591 | - if (!m_currentFetch->contacts().isEmpty()) { |
592 | - QString id = m_currentFetch->contacts().at(0).id().toString(); |
593 | - registerCall(m_currentFetch->property("PHONE").toString(), id); |
594 | - } |
595 | - m_currentFetch->deleteLater(); |
596 | - m_currentFetch = 0; |
597 | - nextContact(); |
598 | -} |
599 | - |
600 | -void MostCalledContactsModel::registerCall(const QString &phone, const QString &contactId) |
601 | -{ |
602 | - // update cache |
603 | - m_phoneToContactCache.insert(phone, contactId); |
604 | - |
605 | - if (m_contactsData.contains(contactId)) { |
606 | - MostCalledContactsModelData &data = m_contactsData[contactId]; |
607 | - data.callCount++; |
608 | - } else { |
609 | - MostCalledContactsModelData data; |
610 | - data.contactId = contactId; |
611 | - data.phoneNumber = phone; |
612 | - data.callCount = 1; |
613 | - m_contactsData.insert(contactId, data); |
614 | - } |
615 | - m_totalCalls++; |
616 | -} |
617 | - |
618 | -void MostCalledContactsModel::parseResult() |
619 | -{ |
620 | - if (m_aboutToQuit) { |
621 | - return; |
622 | - } |
623 | - |
624 | - Q_EMIT beginResetModel(); |
625 | - |
626 | - m_reloadingModel = true; |
627 | - m_outdated = false; |
628 | - m_data.clear(); |
629 | - m_average = 0; |
630 | - |
631 | - if (!m_contactsData.isEmpty()) { |
632 | - // sort by callCount |
633 | - QList<MostCalledContactsModelData> data = m_contactsData.values(); |
634 | - qSort(data.begin(), data.end(), mostCalledContactsModelDataGreaterThan); |
635 | - |
636 | - // average |
637 | - m_average = qRound(((qreal) (m_totalCalls)) / m_contactsData.size()); |
638 | - Q_FOREACH(const MostCalledContactsModelData &d, data) { |
639 | - if (d.callCount >= m_average) { |
640 | - m_data << d; |
641 | - } |
642 | - if ((uint) m_data.size() >= m_maxCount) { |
643 | - break; |
644 | - } |
645 | - } |
646 | - } |
647 | - |
648 | - m_totalCalls = 0; |
649 | - m_phones.clear(); |
650 | - m_phoneToContactCache.clear(); |
651 | - m_contactsData.clear(); |
652 | - |
653 | - Q_EMIT endResetModel(); |
654 | - m_reloadingModel = false; |
655 | - Q_EMIT callAverageChanged(m_average); |
656 | - Q_EMIT loaded(); |
657 | -} |
658 | - |
659 | - |
660 | -void MostCalledContactsModel::markAsOutdated() |
661 | -{ |
662 | - // skip if model is being reloaded |
663 | - if (m_reloadingModel) { |
664 | - return; |
665 | - } |
666 | - |
667 | - if (!m_outdated) { |
668 | - m_outdated = true; |
669 | - Q_EMIT outdatedChange(m_outdated); |
670 | - } |
671 | -} |
672 | - |
673 | - |
674 | |
675 | === removed file 'src/imports/Ubuntu/Contacts/mostcalledproxymodel.h' |
676 | --- src/imports/Ubuntu/Contacts/mostcalledproxymodel.h 2015-05-07 17:27:16 +0000 |
677 | +++ src/imports/Ubuntu/Contacts/mostcalledproxymodel.h 1970-01-01 00:00:00 +0000 |
678 | @@ -1,112 +0,0 @@ |
679 | -/* |
680 | - * Copyright (C) 2012-2015 Canonical, Ltd. |
681 | - * |
682 | - * This program is free software; you can redistribute it and/or modify |
683 | - * it under the terms of the GNU General Public License as published by |
684 | - * the Free Software Foundation; version 3. |
685 | - * |
686 | - * This program is distributed in the hope that it will be useful, |
687 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
688 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
689 | - * GNU General Public License for more details. |
690 | - * |
691 | - * You should have received a copy of the GNU General Public License |
692 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
693 | - */ |
694 | - |
695 | -#ifndef __MOSTCALLEDCONTACTSMODEL_H__ |
696 | -#define __MOSTCALLEDCONTACTSMODEL_H__ |
697 | - |
698 | - |
699 | -#include <QtCore/QAbstractListModel> |
700 | -#include <QtCore/QScopedPointer> |
701 | -#include <QtCore/QDateTime> |
702 | -#include <QtCore/QMap> |
703 | - |
704 | -#include <QtContacts/QContactManager> |
705 | -#include <QtContacts/QContactFetchRequest> |
706 | - |
707 | -struct MostCalledContactsModelData |
708 | -{ |
709 | - QString contactId; |
710 | - QString phoneNumber; |
711 | - int callCount; |
712 | -}; |
713 | - |
714 | -class MostCalledContactsModel : public QAbstractListModel |
715 | -{ |
716 | - Q_OBJECT |
717 | - Q_PROPERTY(QAbstractItemModel* sourceModel READ sourceModel WRITE setSourceModel NOTIFY sourceModelChanged) |
718 | - Q_PROPERTY(uint maxCount READ maxCount WRITE setMaxCount NOTIFY maxCountChanged) |
719 | - Q_PROPERTY(int callAverage READ callAverage NOTIFY callAverageChanged) |
720 | - Q_PROPERTY(QDateTime startInterval READ startInterval WRITE setStartInterval NOTIFY startIntervalChanged) |
721 | - Q_PROPERTY(bool outdated READ outdated NOTIFY outdatedChange) |
722 | - |
723 | -public: |
724 | - enum Role { |
725 | - ContactIdRole = 0, |
726 | - PhoneNumberRole, |
727 | - CallCountRole |
728 | - }; |
729 | - |
730 | - MostCalledContactsModel(QObject *parent=0); |
731 | - ~MostCalledContactsModel(); |
732 | - |
733 | - QVariant data(const QModelIndex &index, int role) const; |
734 | - QHash<int, QByteArray> roleNames() const; |
735 | - int rowCount(const QModelIndex&) const; |
736 | - |
737 | - QAbstractItemModel *sourceModel() const; |
738 | - void setSourceModel(QAbstractItemModel *model); |
739 | - |
740 | - uint maxCount() const; |
741 | - void setMaxCount(uint value); |
742 | - |
743 | - int callAverage() const; |
744 | - bool outdated() const; |
745 | - |
746 | - QDateTime startInterval() const; |
747 | - void setStartInterval(const QDateTime &value); |
748 | - |
749 | - Q_INVOKABLE void update(); |
750 | - |
751 | -Q_SIGNALS: |
752 | - void maxCountChanged(uint value); |
753 | - void callAverageChanged(int value); |
754 | - void startIntervalChanged(const QDateTime &value); |
755 | - void sourceModelChanged(QAbstractItemModel *value); |
756 | - void outdatedChange(bool value); |
757 | - void loaded(); |
758 | - |
759 | -private Q_SLOTS: |
760 | - void markAsOutdated(); |
761 | - void fetchContactIdDone(); |
762 | - |
763 | -private: |
764 | - QAbstractItemModel *m_sourceModel; |
765 | - QtContacts::QContactFetchRequest *m_currentFetch; |
766 | - |
767 | - QScopedPointer<QtContacts::QContactManager> m_manager; |
768 | - QList<MostCalledContactsModelData> m_data; |
769 | - uint m_maxCount; |
770 | - int m_average; |
771 | - QDateTime m_startInterval; |
772 | - bool m_outdated; |
773 | - bool m_reloadingModel; |
774 | - bool m_aboutToQuit; |
775 | - |
776 | - QStringList m_phones; |
777 | - QMap<QString, QString> m_phoneToContactCache; |
778 | - QMap<QString, MostCalledContactsModelData > m_contactsData; |
779 | - int m_totalCalls; |
780 | - |
781 | - void fetchContactId(const QString &phoneNumber); |
782 | - QVariant getSourceData(int row, int role); |
783 | - void queryContacts(); |
784 | - void nextContact(); |
785 | - void registerCall(const QString &phone, const QString &contactId); |
786 | - void parseResult(); |
787 | -}; |
788 | - |
789 | - |
790 | -#endif |
791 | |
792 | === modified file 'src/imports/Ubuntu/Contacts/plugin.cpp' |
793 | --- src/imports/Ubuntu/Contacts/plugin.cpp 2015-05-07 17:27:16 +0000 |
794 | +++ src/imports/Ubuntu/Contacts/plugin.cpp 2016-12-14 13:04:55 +0000 |
795 | @@ -15,7 +15,6 @@ |
796 | */ |
797 | |
798 | #include "plugin.h" |
799 | -#include "mostcalledproxymodel.h" |
800 | #include "contacts.h" |
801 | #include "simcardcontacts.h" |
802 | |
803 | @@ -39,6 +38,5 @@ |
804 | { |
805 | // @uri Ubuntu.Contacts |
806 | qmlRegisterSingletonType<UbuntuContacts>(uri, 0, 1, "Contacts", contactsProvider); |
807 | - qmlRegisterType<MostCalledContactsModel>(uri, 0, 1, "MostCalledContactsModel"); |
808 | qmlRegisterType<SimCardContacts>(uri, 0, 1, "SimCardContacts"); |
809 | } |
810 | |
811 | === modified file 'src/imports/Ubuntu/Contacts/qmldir' |
812 | --- src/imports/Ubuntu/Contacts/qmldir 2015-10-23 11:03:31 +0000 |
813 | +++ src/imports/Ubuntu/Contacts/qmldir 2016-12-14 13:04:55 +0000 |
814 | @@ -28,8 +28,6 @@ |
815 | internal FastScrollJs FastScroll.js |
816 | internal FastScroll FastScroll.qml |
817 | internal ListItemWithActionsCheckBox ListItemWithActionsCheckBox.qml |
818 | -internal MostCalledList MostCalledList.qml |
819 | -internal MostCalledModel MostCalledModel.qml |
820 | internal Ofono Ofono.qml |
821 | internal SectionDelegate SectionDelegate.qml |
822 | internal SubtitledWithColors SubtitledWithColors.qml |
PASSED: Continuous integration, rev:666 /jenkins. canonical. com/system- apps/job/ lp-address- book-app- ci/52/ /jenkins. canonical. com/system- apps/job/ build/2180 /jenkins. canonical. com/system- apps/job/ test-0- autopkgtest/ label=phone- armhf,release= vivid+overlay, testname= default/ 562 /jenkins. canonical. com/system- apps/job/ build-0- fetch/2183 /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=amd64, release= vivid+overlay/ 2010 /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=amd64, release= vivid+overlay/ 2010/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 2010 /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 2010/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=amd64, release= zesty/2010 /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=amd64, release= zesty/2010/ artifact/ output/ *zip*/output. zip /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=armhf, release= vivid+overlay/ 2010 /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=armhf, release= vivid+overlay/ 2010/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 2010 /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 2010/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=armhf, release= zesty/2010 /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=armhf, release= zesty/2010/ artifact/ output/ *zip*/output. zip /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=i386, release= vivid+overlay/ 2010 /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=i386, release= vivid+overlay/ 2010/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 2010 /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 2010/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=i386, release= zesty/2010 /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=i386, release= zesty/2010/ artifact/ output/ *zip*/output. zip
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/system- apps/job/ lp-address- book-app- ci/52/rebuild
https:/