1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Default info provider plugin for CntListModel. It can provide |
|
15 * the phone number and the image url of a contact (text and |
|
16 * icon1 field respectively). |
|
17 * |
|
18 */ |
|
19 |
|
20 #include <qtcontacts.h> |
|
21 #include "cntdefaultinfoprovider.h" |
|
22 #include <hbglobal.h> |
|
23 |
|
24 /*! |
|
25 /return the info fields supported by this provider |
|
26 */ |
|
27 ContactInfoFields CntDefaultInfoProvider::supportedFields() const |
|
28 { |
|
29 // this provider does not have any info for the icon2 field |
|
30 return ContactInfoIcon1Field | ContactInfoTextField; |
|
31 } |
|
32 |
|
33 /*! |
|
34 The contact contains all the info this provider needs, so signals with the requested info |
|
35 fields are emitted immediately. |
|
36 |
|
37 /param contact the contact for which info is requested |
|
38 /param requestedInfo one or more of the flags in ContactInfoFields |
|
39 */ |
|
40 void CntDefaultInfoProvider::requestInfo(const QContact& contact, ContactInfoFields requestedInfo) |
|
41 { |
|
42 if (requestedInfo & ContactInfoTextField) { |
|
43 QContactDetail detail = contact.preferredDetail("call"); |
|
44 QString number; |
|
45 |
|
46 if (!detail.isEmpty()) |
|
47 { |
|
48 number = static_cast<QContactPhoneNumber>(detail).number(); |
|
49 } |
|
50 else |
|
51 { |
|
52 QList<QContactPhoneNumber> numbers = contact.details<QContactPhoneNumber>(); |
|
53 if (numbers.count() > 1) |
|
54 number = hbTrId("txt_phob_dblist_val_ln_numbers", numbers.count()); |
|
55 else if (numbers.count() == 1) |
|
56 number = numbers.at(0).number(); |
|
57 } |
|
58 |
|
59 emit infoFieldReady(this, contact.localId(), ContactInfoTextField, number); |
|
60 } |
|
61 |
|
62 if (requestedInfo & ContactInfoIcon1Field) { |
|
63 QString imageUrl = contact.detail<QContactAvatar>().imageUrl().toString(); |
|
64 emit infoFieldReady(this, contact.localId(), ContactInfoIcon1Field, imageUrl); |
|
65 } |
|
66 } |
|