author | John Kern <johnk@symbian.org> |
Fri, 13 Aug 2010 13:03:12 -0700 | |
changeset 29 | a9f1d0e21384 |
parent 25 | adbe71832e2b |
child 31 | 7140311376c0 |
permissions | -rwxr-xr-x |
19
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
1 |
#include <QContact> |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
2 |
#include <QContactAddress> |
23 | 3 |
#include <QContactName> |
19
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
4 |
#include <QContactOrganization> |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
5 |
#include <QContactPhoneNumber> |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
6 |
|
25
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
7 |
|
19
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
8 |
#include "contactsengine.h" |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
9 |
|
23 | 10 |
#include <QDebug> |
11 |
||
19
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
12 |
using namespace QtMobility; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
13 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
14 |
ContactsEngine::ContactsEngine(QObject *parent) : |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
15 |
QAbstractListModel(parent) |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
16 |
{ |
25
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
17 |
this->m_manager = 0; |
19
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
18 |
} |
23 | 19 |
|
19
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
20 |
ContactsEngine::~ContactsEngine() |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
21 |
{ |
23 | 22 |
|
19
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
23 |
} |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
24 |
|
25
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
25 |
//void ContactsEngine::createManager() |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
26 |
//{ |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
27 |
// // this->m_manager = new QContactManager("symbian"); |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
28 |
// // let's try the default. |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
29 |
// this->m_manager = new QContactManager(); |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
30 |
//} |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
31 |
|
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
32 |
void ContactsEngine::createManager() |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
33 |
{ |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
34 |
// adapted from http://wiki.forum.nokia.com/index.php/Finding_contact_manager_in_Qt |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
35 |
|
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
36 |
// Get list of different contact back-ends |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
37 |
QStringList availableManagers = QContactManager::availableManagers(); |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
38 |
|
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
39 |
QList<QContactLocalId> contactIds; |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
40 |
// Try to find contacts from some back-end |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
41 |
while (!availableManagers.isEmpty()) { |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
42 |
// Get some manager |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
43 |
m_manager = new QContactManager(availableManagers.first()); |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
44 |
availableManagers.removeFirst(); |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
45 |
|
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
46 |
// Contacts exists? |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
47 |
contactIds = m_manager->contactIds(); |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
48 |
if (!contactIds.isEmpty()) { |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
49 |
// Contact found |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
50 |
availableManagers.clear(); |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
51 |
break; |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
52 |
} |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
53 |
else { |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
54 |
// Not found, try the next manager |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
55 |
delete m_manager; |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
56 |
m_manager = 0; |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
57 |
} |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
58 |
} |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
59 |
|
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
60 |
// Use default if no contact found from any back-end |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
61 |
if (!m_manager) { |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
62 |
m_manager = new QContactManager(); |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
63 |
} |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
64 |
|
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
65 |
// Show message to the user |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
66 |
QString msg = QString("Manager %1 created, that has %2 contacts") |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
67 |
.arg(m_manager->managerName()).arg(contactIds.count()); |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
68 |
|
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
69 |
// emit errorOccurred(msg); |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
70 |
} |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
71 |
|
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
72 |
|
23 | 73 |
void ContactsEngine::setManager(const QString & aMgrName) |
19
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
74 |
{ |
25
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
75 |
// noop |
19
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
76 |
} |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
77 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
78 |
void ContactsEngine::populateAddresses() |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
79 |
{ |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
80 |
QContact *contact; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
81 |
QContactOrganization *dept; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
82 |
QStringList departmentName; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
83 |
QContactPhoneNumber *number; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
84 |
QContactAddress *address; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
85 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
86 |
// this source is open source. Do not put private numbers in here. |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
87 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
88 |
// emergency numbers |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
89 |
// fire Foster City |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
90 |
contact = new QContact(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
91 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
92 |
dept = new QContactOrganization(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
93 |
departmentName << "Foster City Fire department"; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
94 |
dept->setDepartment(departmentName); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
95 |
contact->saveDetail(dept); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
96 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
97 |
number = new QContactPhoneNumber(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
98 |
number->setContexts(QContactDetail::ContextWork); |
29 | 99 |
number->setNumber("+1-650-286-3350"); |
19
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
100 |
contact->saveDetail(number); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
101 |
//fire.setPreferredDetail("DialAction",number); //doesn't compile. Has it been depreciated? |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
102 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
103 |
// create address detail |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
104 |
address = new QContactAddress(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
105 |
address->setCountry("USA"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
106 |
address->setRegion("CA"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
107 |
address->setLocality("Foster City"); // RFC 2426 - defines the difference locality and region. |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
108 |
address->setStreet("1040 East Hillsdale Boulevard"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
109 |
address->setPostcode("94404"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
110 |
contact->saveDetail(address); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
111 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
112 |
this->m_manager->saveContact(contact); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
113 |
// Note that the caller retains ownership of the detail. |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
114 |
delete dept; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
115 |
while (!departmentName.isEmpty()) |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
116 |
departmentName.takeFirst(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
117 |
delete number; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
118 |
delete address; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
119 |
delete contact; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
120 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
121 |
// police - foster city |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
122 |
contact = new QContact(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
123 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
124 |
dept = new QContactOrganization(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
125 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
126 |
departmentName << "Foster City Police department"; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
127 |
dept->setDepartment(departmentName); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
128 |
contact->saveDetail(dept); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
129 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
130 |
number = new QContactPhoneNumber(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
131 |
number->setContexts(QContactDetail::ContextWork); |
29 | 132 |
number->setNumber("+1(650)286-3300"); |
19
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
133 |
contact->saveDetail(number); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
134 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
135 |
// create address detail |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
136 |
address = new QContactAddress(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
137 |
address->setCountry("USA"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
138 |
address->setRegion("CA"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
139 |
address->setLocality("Foster City"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
140 |
address->setStreet("1030 East Hillsdale Boulevard"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
141 |
address->setPostcode("94404"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
142 |
contact->saveDetail(address); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
143 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
144 |
this->m_manager->saveContact(contact); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
145 |
delete dept; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
146 |
while (!departmentName.isEmpty()) |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
147 |
departmentName.takeFirst(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
148 |
delete number; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
149 |
delete address; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
150 |
delete contact; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
151 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
152 |
// taxi - Foster City |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
153 |
contact = new QContact(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
154 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
155 |
dept = new QContactOrganization(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
156 |
departmentName << "Foster City Yellow Cab"; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
157 |
dept->setDepartment(departmentName); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
158 |
contact->saveDetail(dept); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
159 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
160 |
number = new QContactPhoneNumber(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
161 |
number->setContexts(QContactDetail::ContextWork); |
29 | 162 |
number->setNumber("+1(650)367-9999"); |
19
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
163 |
contact->saveDetail(number); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
164 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
165 |
// create address detail |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
166 |
address = new QContactAddress(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
167 |
address->setCountry("USA"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
168 |
address->setRegion("CA"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
169 |
address->setLocality("Foster City"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
170 |
address->setStreet("1055 foster city blvd"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
171 |
address->setPostcode("94404"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
172 |
contact->saveDetail(address); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
173 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
174 |
this->m_manager->saveContact(contact); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
175 |
delete dept; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
176 |
while (!departmentName.isEmpty()) |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
177 |
departmentName.takeFirst(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
178 |
delete number; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
179 |
delete address; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
180 |
delete contact; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
181 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
182 |
// fire - Menlo Park |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
183 |
contact = new QContact(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
184 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
185 |
dept = new QContactOrganization(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
186 |
departmentName << "Menlo Park fire department"; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
187 |
dept->setDepartment(departmentName); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
188 |
contact->saveDetail(dept); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
189 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
190 |
number = new QContactPhoneNumber(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
191 |
number->setContexts(QContactDetail::ContextWork); |
29 | 192 |
number->setNumber("+1(650)688-8400"); |
19
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
193 |
contact->saveDetail(number); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
194 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
195 |
// create address detail |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
196 |
address = new QContactAddress(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
197 |
address->setCountry("USA"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
198 |
address->setRegion("CA"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
199 |
address->setLocality("Menlo Park"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
200 |
address->setStreet("170 Middlefield Road"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
201 |
address->setPostcode("94025"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
202 |
contact->saveDetail(address); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
203 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
204 |
this->m_manager->saveContact(contact); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
205 |
delete dept; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
206 |
while (!departmentName.isEmpty()) |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
207 |
departmentName.takeFirst(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
208 |
delete number; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
209 |
delete address; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
210 |
delete contact; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
211 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
212 |
//701 Laurel Street, Menlo Park, CA? - |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
213 |
// police - Menlo Park |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
214 |
contact = new QContact(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
215 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
216 |
dept = new QContactOrganization(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
217 |
departmentName << "Menlo Park police department"; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
218 |
dept->setDepartment(departmentName); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
219 |
contact->saveDetail(dept); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
220 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
221 |
number = new QContactPhoneNumber(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
222 |
number->setContexts(QContactDetail::ContextWork); |
29 | 223 |
number->setNumber("+1(650)858-3328"); |
19
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
224 |
contact->saveDetail(number); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
225 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
226 |
// create address detail |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
227 |
address = new QContactAddress(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
228 |
address->setCountry("USA"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
229 |
address->setRegion("CA"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
230 |
address->setLocality("Menlo Park"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
231 |
address->setStreet("701 Laurel Street"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
232 |
address->setPostcode("94025"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
233 |
contact->saveDetail(address); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
234 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
235 |
this->m_manager->saveContact(contact); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
236 |
delete dept; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
237 |
while (!departmentName.isEmpty()) |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
238 |
departmentName.takeFirst(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
239 |
delete number; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
240 |
delete address; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
241 |
delete contact; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
242 |
} |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
243 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
244 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
245 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
246 |
QStringList ContactsEngine::dataSources() |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
247 |
{ |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
248 |
QStringList availableManagers = QContactManager::availableManagers(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
249 |
availableManagers.removeAll("invalid"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
250 |
foreach(QString managerName, availableManagers) { |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
251 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
252 |
QMap<QString, QString> params; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
253 |
QString managerUri = QContactManager::buildUri(managerName, params); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
254 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
255 |
// Add some parameters to SIM backend so that we can use |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
256 |
// all the stores. |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
257 |
if (managerName == "symbiansim") { |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
258 |
availableManagers.removeAll("symbiansim"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
259 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
260 |
availableManagers.append("symbiansim:adn"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
261 |
params.insert("store", "ADN"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
262 |
managerUri = QContactManager::buildUri(managerName, params); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
263 |
m_availableManagers.insert(availableManagers.last(), managerUri); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
264 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
265 |
availableManagers.append("symbiansim:fdn"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
266 |
params.clear(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
267 |
params.insert("store", "FDN"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
268 |
managerUri = QContactManager::buildUri(managerName, params); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
269 |
m_availableManagers.insert(availableManagers.last(), managerUri); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
270 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
271 |
availableManagers.append("symbiansim:sdn"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
272 |
params.clear(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
273 |
params.insert("store", "SDN"); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
274 |
managerUri = QContactManager::buildUri(managerName, params); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
275 |
m_availableManagers.insert(availableManagers.last(), managerUri); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
276 |
} |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
277 |
else { |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
278 |
m_availableManagers.insert(managerName, managerUri); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
279 |
} |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
280 |
} |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
281 |
return (availableManagers); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
282 |
} |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
283 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
284 |
int ContactsEngine::rowCount(const QModelIndex &parent) const |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
285 |
{ |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
286 |
QList<QContact> allContacts; |
23 | 287 |
int rc = 0; |
288 |
if (this->m_manager) |
|
289 |
{ |
|
290 |
allContacts = this->m_manager->contacts(); |
|
291 |
// return stringList.count(); |
|
292 |
if (!allContacts.isEmpty()) |
|
293 |
rc = allContacts.count(); |
|
294 |
} |
|
295 |
return rc; |
|
19
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
296 |
} |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
297 |
|
23 | 298 |
void ContactsEngine::enumerateMgrs() |
299 |
{ |
|
300 |
QStringList mgrs = QContactManager::availableManagers(); |
|
301 |
qDebug() << "Enumerate available Contact Managers:" << endl; |
|
302 |
foreach(QString m, mgrs) |
|
25
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
303 |
{ |
23 | 304 |
qDebug() << "\tmgr: " << m << endl; |
25
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
305 |
this->dumpContactMgr(); |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
306 |
} |
23 | 307 |
qDebug() << endl; |
308 |
} |
|
309 |
||
310 |
// dump the current contact manager. |
|
311 |
void ContactsEngine::dumpContactMgr() |
|
312 |
{ |
|
313 |
qDebug() << "Dump Contact Manager:" << endl; |
|
25
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
314 |
if (this->m_manager) { |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
315 |
qDebug() << "\tname: " << this->m_manager->managerName() << endl; |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
316 |
qDebug() << "\tURI: " << this->m_manager->managerUri() << endl; |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
317 |
qDebug() << "\tVersion: " << this->m_manager->managerVersion() << endl; |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
318 |
qDebug() << "\tCount:" << this->m_manager->contacts().count() << endl; |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
319 |
} else { |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
320 |
qDebug() << "\t Contact Manager set to zero." << endl; |
adbe71832e2b
runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents:
23
diff
changeset
|
321 |
} |
23 | 322 |
qDebug() << endl; |
323 |
} |
|
324 |
||
19
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
325 |
QVariant ContactsEngine::data(const QModelIndex &index, int role) const |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
326 |
{ |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
327 |
QVariant rc; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
328 |
QList<QContact> allContacts; |
23 | 329 |
QContact c; |
19
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
330 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
331 |
allContacts = this->m_manager->contacts(); |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
332 |
|
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
333 |
if (!index.isValid() || index.row() >= allContacts.size()) { |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
334 |
return rc; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
335 |
} |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
336 |
if (role == Qt::DisplayRole) { |
23 | 337 |
//rc = QVariant(allContacts.at(index.row()).displayLabel()); |
338 |
c = allContacts.at(index.row()); |
|
339 |
// organizations do not have first and last names. So the displayLabel() is empty. |
|
340 |
QContactDetail cd = c.detail(QContactName::DefinitionName); |
|
341 |
if (cd.isEmpty()) { |
|
342 |
rc = QVariant (c.detail(QContactOrganization::DefinitionName).value(QContactOrganization::FieldDepartment) ); |
|
343 |
} else { |
|
344 |
rc = QVariant ( c.displayLabel()); |
|
345 |
} |
|
19
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
346 |
} |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
347 |
return rc; |
e4b6ee329501
WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
348 |
} |