67 } |
69 } |
68 |
70 |
69 /*! |
71 /*! |
70 Initialize contact details which include actions. |
72 Initialize contact details which include actions. |
71 */ |
73 */ |
72 void CntContactCardDataContainer::initializeActionsData() |
74 void CntContactCardDataContainer::initializeActionsData(bool myCard) |
73 { |
75 { |
74 QList<QContactActionDescriptor> actionDescriptors = mContact->availableActions(); |
76 QList<QContactActionDescriptor> actionDescriptors = mContact->availableActions(); |
75 QStringList availableActions; |
77 QStringList availableActions; |
|
78 QStringList extendedActions; |
76 for (int i = 0;i < actionDescriptors.count();i++) |
79 for (int i = 0;i < actionDescriptors.count();i++) |
77 { |
80 { |
78 availableActions << actionDescriptors.at(i).actionName(); |
81 QString action = actionDescriptors.at(i).actionName(); |
79 } |
82 if(actionDescriptors.at(i).vendorName() == "symbian" && actionDescriptors.at(i).implementationVersion() == 1) |
80 |
83 // String list for hardcoded actions, all actions falling in to this category must be hardcoded |
81 QList<QContactDetail> details = mContact->details(); |
84 // to show them on UI. |
|
85 availableActions << action; |
|
86 else if(!extendedActions.contains(action)) |
|
87 // String list for dynamically extendable actions. Duplicate actions |
|
88 // are handled later |
|
89 extendedActions << action; |
|
90 } |
|
91 |
|
92 QList<QContactPhoneNumber> details = mContact->details<QContactPhoneNumber>(); |
82 for (int i = 0; i < details.count(); i++) |
93 for (int i = 0; i < details.count(); i++) |
83 { |
94 { |
84 if (availableActions.contains("call", Qt::CaseInsensitive) && supportsDetail("call", details[i]) && details[i].definitionName() == QContactPhoneNumber::DefinitionName) |
95 //call |
85 { |
96 if (availableActions.contains("call", Qt::CaseInsensitive) && supportsDetail("call", details[i])) |
86 QContactPhoneNumber number(details.at(i)); |
97 { |
|
98 QString context = details[i].contexts().isEmpty() ? QString() : details[i].contexts().first(); |
|
99 QString subtype = details[i].subTypes().isEmpty() ? details[i].definitionName() : details[i].subTypes().first(); |
87 |
100 |
88 QString context = number.contexts().isEmpty() ? QString() : number.contexts().first(); |
101 int position = getPosition(subtype, context); |
89 QString subtype = number.subTypes().isEmpty() ? number.definitionName() : number.subTypes().first(); |
102 |
90 |
103 CntContactCardDataItem* dataItem = new CntContactCardDataItem(mStringMapper.getContactCardListLocString(subtype, context), position, true); |
91 CntContactCardDataItem* dataItem = new CntContactCardDataItem(mStringMapper.getContactCardListLocString(subtype, context), itemCount(), true); |
|
92 dataItem->setAction("call"); |
104 dataItem->setAction("call"); |
93 dataItem->setValueText(number.number()); |
105 dataItem->setValueText(details[i].number()); |
94 dataItem->setIcon(HbIcon(mStringMapper.getContactCardIconString(subtype, context))); |
106 dataItem->setIcon(HbIcon(mStringMapper.getContactCardIconString(subtype, context))); |
95 dataItem->setContactDetail(number); |
107 dataItem->setContactDetail(details[i]); |
96 mDataItemList.insert(itemCount(), dataItem); |
108 mDataItemList.append(dataItem); |
97 } |
109 } |
98 |
110 //message |
99 if (availableActions.contains("message", Qt::CaseInsensitive) && supportsDetail("message", details[i]) && details[i].definitionName() == QContactPhoneNumber::DefinitionName) |
111 if (availableActions.contains("message", Qt::CaseInsensitive) && supportsDetail("message", details[i])) |
100 { |
112 { |
101 QContactPhoneNumber number(details.at(i)); |
113 QString context = details[i].contexts().isEmpty() ? QString() : details[i].contexts().first(); |
102 CntContactCardDataItem* dataItem = new CntContactCardDataItem(hbTrId("txt_phob_dblist_send_message"), itemCount(), true); |
114 QString subtype = details[i].subTypes().isEmpty() ? details[i].definitionName() : details[i].subTypes().first(); |
|
115 |
|
116 int position = getPosition(subtype, context); |
|
117 |
|
118 CntContactCardDataItem* dataItem = new CntContactCardDataItem(hbTrId("txt_phob_dblist_send_message"), position, true); |
103 dataItem->setAction("message"); |
119 dataItem->setAction("message"); |
104 dataItem->setValueText(number.number()); |
120 dataItem->setValueText(details[i].number()); |
105 QString icon; |
121 QString icon; |
106 if (number.contexts().isEmpty()) |
122 if (details[i].contexts().isEmpty()) |
107 { |
123 { |
108 icon = "qtg_large_message"; |
124 icon = "qtg_large_message"; |
109 } |
125 } |
110 else if (number.contexts().first() == QContactDetail::ContextHome) |
126 else if (details[i].contexts().first() == QContactDetail::ContextHome) |
111 { |
127 { |
112 icon = "qtg_large_message_home"; |
128 icon = "qtg_large_message_home"; |
113 } |
129 } |
114 else if (number.contexts().first() == QContactDetail::ContextWork) |
130 else if (details[i].contexts().first() == QContactDetail::ContextWork) |
115 { |
131 { |
116 icon = "qtg_large_message_work"; |
132 icon = "qtg_large_message_work"; |
117 } |
133 } |
118 else |
134 else |
119 { |
135 { |
120 icon = "qtg_large_message"; |
136 icon = "qtg_large_message"; |
121 } |
137 } |
122 dataItem->setIcon(HbIcon(icon)); |
138 dataItem->setIcon(HbIcon(icon)); |
123 dataItem->setContactDetail(number); |
139 dataItem->setContactDetail(details[i]); |
124 mDataItemList.insert(itemCount(), dataItem); |
140 mDataItemList.append(dataItem); |
125 } |
141 } |
126 } |
142 } |
127 //email |
143 //email |
128 if (availableActions.contains("email", Qt::CaseInsensitive)) |
144 if (availableActions.contains("email", Qt::CaseInsensitive)) |
129 { |
145 { |
130 QList<QContactDetail> details = actionDetails("email", *mContact); |
146 QList<QContactDetail> details = actionDetails("email", *mContact); |
131 for (int i = 0; i < details.count(); i++) |
147 for (int i = 0; i < details.count(); i++) |
132 { |
148 { |
133 QContactEmailAddress email(details.at(i)); |
149 QContactEmailAddress email(details.at(i)); |
134 QString context = email.contexts().isEmpty() ? QString() : email.contexts().first(); |
150 QString context = email.contexts().isEmpty() ? QString() : email.contexts().first(); |
135 |
151 |
136 CntContactCardDataItem* dataItem = new CntContactCardDataItem(mStringMapper.getContactCardListLocString(email.definitionName(), context), itemCount(), true); |
152 int position = getPosition(email.definitionName(), context); |
|
153 |
|
154 CntContactCardDataItem* dataItem = new CntContactCardDataItem(mStringMapper.getContactCardListLocString(email.definitionName(), context), position, true); |
137 dataItem->setAction("email"); |
155 dataItem->setAction("email"); |
138 dataItem->setValueText(email.emailAddress(), Qt::ElideLeft); |
156 dataItem->setValueText(email.emailAddress(), Qt::ElideLeft); |
139 dataItem->setIcon(HbIcon(mStringMapper.getContactCardIconString(email.definitionName(), context))); |
157 dataItem->setIcon(HbIcon(mStringMapper.getContactCardIconString(email.definitionName(), context))); |
140 dataItem->setContactDetail(email); |
158 dataItem->setContactDetail(email); |
141 mDataItemList.insert(itemCount(), dataItem); |
159 mDataItemList.append(dataItem); |
142 } |
160 } |
143 } |
161 } |
144 //url |
162 //url |
145 QList<QContactUrl> urlDetails = mContact->details<QContactUrl>(); |
163 if (availableActions.contains("url", Qt::CaseInsensitive)) |
146 for (int i = 0; i < urlDetails.count(); i++) |
164 { |
147 { |
165 QList<QContactDetail> details = actionDetails("url", *mContact); |
148 QContactUrl url(urlDetails.at(i)); |
166 for (int i = 0; i < details.count(); i++) |
149 QString context = url.contexts().isEmpty() ? QString() : url.contexts().first(); |
167 { |
150 |
168 QContactUrl url(details.at(i)); |
151 CntContactCardDataItem* dataItem = new CntContactCardDataItem(mStringMapper.getContactCardListLocString(url.definitionName(), context), itemCount(), true); |
169 QString context = url.contexts().isEmpty() ? QString() : url.contexts().first(); |
152 dataItem->setAction("url"); |
170 |
153 dataItem->setValueText(url.url()); |
171 int position = getPosition(url.definitionName(), context); |
154 dataItem->setIcon(HbIcon(mStringMapper.getContactCardIconString(url.definitionName(), context))); |
172 |
155 dataItem->setContactDetail(url); |
173 CntContactCardDataItem* dataItem = new CntContactCardDataItem(mStringMapper.getContactCardListLocString(url.definitionName(), context), position, true); |
156 mDataItemList.insert(itemCount(), dataItem); |
174 dataItem->setAction("url"); |
|
175 dataItem->setValueText(url.url()); |
|
176 dataItem->setIcon(HbIcon(mStringMapper.getContactCardIconString(url.definitionName(), context))); |
|
177 dataItem->setContactDetail(url); |
|
178 mDataItemList.append(dataItem); |
|
179 } |
|
180 } |
|
181 |
|
182 if(!myCard && extendedActions.count()) |
|
183 { |
|
184 // Do not create actions for details in my card |
|
185 for (int i = 0; i < details.count(); i++) |
|
186 { |
|
187 for(int j = 0; j < extendedActions.count(); j++) |
|
188 { |
|
189 QList<QContactActionDescriptor> actionDescriptors = QContactAction::actionDescriptors(extendedActions[j]); |
|
190 for(int l = 0; l < actionDescriptors.count(); l++) |
|
191 { |
|
192 // Different implementations(vendor, version) for same actions handled in loop |
|
193 QContactAction* contactAction = QContactAction::action(actionDescriptors.at(l)); |
|
194 if(contactAction->isDetailSupported(details[i], *mContact)) |
|
195 { |
|
196 const QContactDetail detail = details.at(i); |
|
197 QVariantMap map = contactAction->metaData(); |
|
198 if(map.contains(KCntUiActionMetaTitleText) || map.contains(KCntUiActionMetaTitleTextDetail)) |
|
199 { |
|
200 // Actions without title text and title text detail are considered to be non UI items |
|
201 //action description |
|
202 QString title = map.value(KCntUiActionMetaTitleText, "").toString(); |
|
203 if(title.isEmpty()) |
|
204 { |
|
205 title = detail.value(map.value(KCntUiActionMetaTitleTextDetail).toString()); |
|
206 } |
|
207 else |
|
208 { |
|
209 //TODO: We shoud have localizations for "Home" and "Work" strings... |
|
210 // if (!detail.contexts().isEmpty()) |
|
211 // { |
|
212 // title += " "; |
|
213 // title += mStringMapper.getMappedDetail(detail.contexts().first()); |
|
214 // } |
|
215 } |
|
216 if(title.count()) |
|
217 { |
|
218 QString context = detail.contexts().isEmpty() ? QString() : detail.contexts().first(); |
|
219 int position = getPosition(detail.definitionName(), context, true); |
|
220 CntContactCardDataItem* dataItem = new CntContactCardDataItem(title, position, true); |
|
221 //type |
|
222 dataItem->setAction(extendedActions[j]); |
|
223 //data |
|
224 QString valueText = detail.value(map.value(KCntUiActionMetaValueTextDetail,"").toString()); |
|
225 if(valueText.isEmpty()) |
|
226 { |
|
227 valueText = map.value(KCntUiActionMetaValueText," ").toString(); |
|
228 } |
|
229 dataItem->setValueText(valueText); |
|
230 //icon |
|
231 dataItem->setIcon(HbIcon(map.value(KCntUiActionMetaIcon, "").value<QIcon>())); |
|
232 //detail |
|
233 dataItem->setContactDetail(detail); |
|
234 //save text for long press menu |
|
235 dataItem->setLongPressText(map.value(KCntUiActionMetaValueTextLongPress,"...").toString()); |
|
236 // We must save descriptor to be able to distinguish separate services for same action |
|
237 dataItem->setActionDescriptor(actionDescriptors.at(l)); |
|
238 mDataItemList.append(dataItem); |
|
239 } |
|
240 } |
|
241 } |
|
242 delete contactAction; |
|
243 } |
|
244 } |
|
245 } |
|
246 } |
|
247 |
|
248 // This is special action case. Here we query implementations that are generic |
|
249 // to contact, so it's not linked to any detail(usually generic my card actions). |
|
250 for(int j = 0; j < extendedActions.count(); j++) |
|
251 { |
|
252 QList<QContactActionDescriptor> actionDescriptors = QContactAction::actionDescriptors(extendedActions[j]); |
|
253 for(int l = 0; l < actionDescriptors.count(); l++) |
|
254 { |
|
255 // Different implementations(vendor, version) for same actions handled in loop |
|
256 QContactAction* contactAction = QContactAction::action(actionDescriptors.at(l)); |
|
257 if(contactAction->isDetailSupported(QContactDetail(), *mContact)) |
|
258 { |
|
259 QVariantMap map = contactAction->metaData(); |
|
260 if(map.contains(KCntUiActionMetaTitleText)) |
|
261 { |
|
262 // Actions without title text are considered to be non UI items |
|
263 //action description |
|
264 QString title = map.value(KCntUiActionMetaTitleText, "").toString(); |
|
265 // Put as last action item on UI |
|
266 CntContactCardDataItem* dataItem = new CntContactCardDataItem(title, CntContactCardDataItem::EGenericDynamic, true); |
|
267 //type |
|
268 dataItem->setAction(extendedActions[j]); |
|
269 //data |
|
270 dataItem->setValueText(map.value(KCntUiActionMetaValueText, "").toString()); |
|
271 //icon |
|
272 dataItem->setIcon(HbIcon(map.value(KCntUiActionMetaIcon, "").value<QIcon>())); |
|
273 //detail |
|
274 dataItem->setContactDetail(QContactDetail()); |
|
275 //save text for long press menu |
|
276 dataItem->setLongPressText(map.value(KCntUiActionMetaValueTextLongPress,"...").toString()); |
|
277 // We must save descriptor to be able to distinguish separate services for same action |
|
278 dataItem->setActionDescriptor(actionDescriptors.at(l)); |
|
279 mDataItemList.append(dataItem); |
|
280 } |
|
281 } |
|
282 delete contactAction; |
|
283 } |
157 } |
284 } |
158 } |
285 } |
159 |
286 |
160 /*! |
287 /*! |
161 Initialize group details which includes actions. |
288 Initialize group details which includes actions. |
171 CntContactCardDataItem* dataItem = new CntContactCardDataItem(hbTrId("txt_phob_dblist_conference_call"), itemCount(), true); |
298 CntContactCardDataItem* dataItem = new CntContactCardDataItem(hbTrId("txt_phob_dblist_conference_call"), itemCount(), true); |
172 dataItem->setAction("call"); |
299 dataItem->setAction("call"); |
173 dataItem->setValueText(confCallNumber.number()); |
300 dataItem->setValueText(confCallNumber.number()); |
174 dataItem->setIcon(HbIcon("qtg_large_call_group")); |
301 dataItem->setIcon(HbIcon("qtg_large_call_group")); |
175 dataItem->setContactDetail(confCallNumber); |
302 dataItem->setContactDetail(confCallNumber); |
176 mDataItemList.insert(itemCount(), dataItem); |
303 mDataItemList.append(dataItem); |
177 } |
304 } |
178 |
305 |
179 //message |
306 //message |
180 CntContactCardDataItem* dataMessageItem = new CntContactCardDataItem(hbTrId("txt_phob_dblist_send_val_members"), itemCount(), true); |
307 CntContactCardDataItem* dataMessageItem = new CntContactCardDataItem(hbTrId("txt_phob_dblist_send_val_members"), itemCount(), true); |
181 dataMessageItem->setAction("message"); |
308 dataMessageItem->setAction("message"); |
182 dataMessageItem->setValueText(confCallNumber.number()); |
309 dataMessageItem->setValueText(confCallNumber.number()); |
183 dataMessageItem->setIcon(HbIcon("qtg_large_message")); |
310 dataMessageItem->setIcon(HbIcon("qtg_large_message")); |
184 dataMessageItem->setContactDetail(confCallNumber); |
311 dataMessageItem->setContactDetail(confCallNumber); |
185 mDataItemList.insert(itemCount(), dataMessageItem); |
312 mDataItemList.append(dataMessageItem); |
186 |
313 |
187 //email |
314 //email |
188 CntContactCardDataItem* dataEmailItem = new CntContactCardDataItem(hbTrId("txt_phob_dblist_email"), itemCount(), true); |
315 CntContactCardDataItem* dataEmailItem = new CntContactCardDataItem(hbTrId("txt_phob_dblist_email"), itemCount(), true); |
189 dataEmailItem->setAction("email"); |
316 dataEmailItem->setAction("email"); |
190 dataEmailItem->setValueText(confCallNumber.number()); |
317 dataEmailItem->setValueText(confCallNumber.number()); |
191 dataEmailItem->setIcon(HbIcon("qtg_large_email")); |
318 dataEmailItem->setIcon(HbIcon("qtg_large_email")); |
192 dataEmailItem->setContactDetail(confCallNumber); |
319 dataEmailItem->setContactDetail(confCallNumber); |
193 mDataItemList.insert(itemCount(), dataEmailItem); |
320 mDataItemList.append(dataEmailItem); |
194 } |
321 } |
195 |
322 |
196 /*! |
323 /*! |
197 Initialize contact details which not include actions. |
324 Initialize contact details which not include actions. |
198 */ |
325 */ |
294 painter.end(); |
427 painter.end(); |
295 mapTileIcon.addPixmap(map); |
428 mapTileIcon.addPixmap(map); |
296 |
429 |
297 addSeparator(itemCount()); |
430 addSeparator(itemCount()); |
298 |
431 |
299 CntContactCardDataItem* dataItem = new CntContactCardDataItem(QString(), itemCount(), false); |
432 CntContactCardDataItem* dataItem = new CntContactCardDataItem(QString(), position, false); |
300 dataItem->setIcon(HbIcon(mapTileIcon)); |
433 dataItem->setIcon(HbIcon(mapTileIcon)); |
301 mDataItemList.insert(itemCount(), dataItem); |
434 mDataItemList.append(dataItem); |
302 } |
435 } |
303 } |
436 } |
304 } |
437 } |
305 |
438 |
306 //company |
439 //company |
307 QList<QContactOrganization> organizationDetails = mContact->details<QContactOrganization>(); |
440 QList<QContactOrganization> organizationDetails = mContact->details<QContactOrganization>(); |
308 for (int i = 0; i < organizationDetails.count(); i++) |
441 for (int i = 0; i < organizationDetails.count(); i++) |
309 { |
442 { |
310 CntContactCardDataItem* dataItem = new CntContactCardDataItem(hbTrId("txt_phob_formlabel_company_details"), itemCount(), false); |
443 CntContactCardDataItem* dataItem = new CntContactCardDataItem(hbTrId("txt_phob_formlabel_company_details"), CntContactCardDataItem::ECompanyDetails, false); |
311 QStringList companyList; |
444 QStringList companyList; |
312 companyList << organizationDetails[i].title() << organizationDetails[i].name() << organizationDetails[i].department(); |
445 companyList << organizationDetails[i].title() << organizationDetails[i].name() << organizationDetails[i].department(); |
313 dataItem->setValueText(companyList.join(" ").trimmed()); |
446 dataItem->setValueText(companyList.join(" ").trimmed()); |
314 dataItem->setContactDetail(organizationDetails[i]); |
447 dataItem->setContactDetail(organizationDetails[i]); |
315 addSeparator(itemCount()); |
448 addSeparator(itemCount()); |
316 mDataItemList.insert(itemCount(), dataItem); |
449 mDataItemList.append(dataItem); |
317 } |
450 } |
318 |
451 |
319 //birthday |
452 //birthday |
320 QList<QContactBirthday> birthdayDetails = mContact->details<QContactBirthday>(); |
453 QList<QContactBirthday> birthdayDetails = mContact->details<QContactBirthday>(); |
321 for (int i = 0; i < birthdayDetails.count(); i++) |
454 for (int i = 0; i < birthdayDetails.count(); i++) |
322 { |
455 { |
323 CntContactCardDataItem* dataItem = new CntContactCardDataItem(hbTrId("txt_phob_formlabel_birthday"), itemCount(), false); |
456 CntContactCardDataItem* dataItem = new CntContactCardDataItem(hbTrId("txt_phob_formlabel_birthday"), CntContactCardDataItem::EBirthday, false); |
324 dataItem->setValueText(birthdayDetails[i].date().toString("dd MMMM yyyy")); |
457 dataItem->setValueText(birthdayDetails[i].date().toString("dd MMMM yyyy")); |
325 dataItem->setContactDetail(birthdayDetails[i]); |
458 dataItem->setContactDetail(birthdayDetails[i]); |
326 addSeparator(itemCount()); |
459 addSeparator(itemCount()); |
327 mDataItemList.insert(itemCount(), dataItem); |
460 mDataItemList.append(dataItem); |
328 } |
461 } |
329 |
462 |
330 //anniversary |
463 //anniversary |
331 QList<QContactAnniversary> anniversaryDetails = mContact->details<QContactAnniversary>(); |
464 QList<QContactAnniversary> anniversaryDetails = mContact->details<QContactAnniversary>(); |
332 for (int i = 0; i < anniversaryDetails.count(); i++) |
465 for (int i = 0; i < anniversaryDetails.count(); i++) |
333 { |
466 { |
334 CntContactCardDataItem* dataItem = new CntContactCardDataItem(hbTrId("txt_phob_formlabel_anniversary"), itemCount(), false); |
467 CntContactCardDataItem* dataItem = new CntContactCardDataItem(hbTrId("txt_phob_formlabel_anniversary"), CntContactCardDataItem::EAnniversary, false); |
335 dataItem->setValueText(anniversaryDetails[i].originalDate().toString("dd MMMM yyyy")); |
468 dataItem->setValueText(anniversaryDetails[i].originalDate().toString("dd MMMM yyyy")); |
336 dataItem->setContactDetail(anniversaryDetails[i]); |
469 dataItem->setContactDetail(anniversaryDetails[i]); |
337 addSeparator(itemCount()); |
470 addSeparator(itemCount()); |
338 mDataItemList.insert(itemCount(), dataItem); |
471 mDataItemList.append(dataItem); |
339 } |
472 } |
340 |
473 |
341 //ringing tone |
474 //ringing tone |
342 QList<QContactRingtone> ringtoneDetails = mContact->details<QContactRingtone>(); |
475 QList<QContactRingtone> ringtoneDetails = mContact->details<QContactRingtone>(); |
343 for (int i = 0; i < ringtoneDetails.count(); i++) |
476 for (int i = 0; i < ringtoneDetails.count(); i++) |
344 { |
477 { |
345 if (!ringtoneDetails.at(i).audioRingtoneUrl().isEmpty()) |
478 if (!ringtoneDetails.at(i).audioRingtoneUrl().isEmpty()) |
346 { |
479 { |
347 CntContactCardDataItem* dataItem = new CntContactCardDataItem(hbTrId("txt_phob_formlabel_ringing_tone"), itemCount(), false); |
480 CntContactCardDataItem* dataItem = new CntContactCardDataItem(hbTrId("txt_phob_formlabel_ringing_tone"), CntContactCardDataItem::ERingtone, false); |
348 dataItem->setValueText(ringtoneDetails[i].audioRingtoneUrl().toString()); |
481 dataItem->setValueText(ringtoneDetails[i].audioRingtoneUrl().toString()); |
349 dataItem->setContactDetail(ringtoneDetails[i]); |
482 dataItem->setContactDetail(ringtoneDetails[i]); |
350 addSeparator(itemCount()); |
483 addSeparator(itemCount()); |
351 mDataItemList.insert(itemCount(), dataItem); |
484 mDataItemList.append(dataItem); |
352 break; |
485 break; |
353 } |
486 } |
354 } |
487 } |
355 |
488 |
356 //note |
489 //note |
357 QList<QContactNote> noteDetails = mContact->details<QContactNote>(); |
490 QList<QContactNote> noteDetails = mContact->details<QContactNote>(); |
358 for (int i = 0; i < noteDetails.count(); i++) |
491 for (int i = 0; i < noteDetails.count(); i++) |
359 { |
492 { |
360 CntContactCardDataItem* dataItem = new CntContactCardDataItem(hbTrId("txt_phob_formlabel_note"), itemCount(), false); |
493 CntContactCardDataItem* dataItem = new CntContactCardDataItem(hbTrId("txt_phob_formlabel_note"), CntContactCardDataItem::ENote, false); |
361 dataItem->setValueText(noteDetails[i].note()); |
494 dataItem->setValueText(noteDetails[i].note()); |
362 dataItem->setContactDetail(noteDetails[i]); |
495 dataItem->setContactDetail(noteDetails[i]); |
363 addSeparator(itemCount()); |
496 addSeparator(itemCount()); |
364 mDataItemList.insert(itemCount(), dataItem); |
497 mDataItemList.append(dataItem); |
365 } |
498 } |
366 |
499 |
367 //family details |
500 //family details |
368 QList<QContactFamily> familyDetails = mContact->details<QContactFamily>(); |
501 QList<QContactFamily> familyDetails = mContact->details<QContactFamily>(); |
369 for (int i = 0; i < familyDetails.count(); i++) |
502 for (int i = 0; i < familyDetails.count(); i++) |
370 { |
503 { |
371 CntContactCardDataItem* dataSpouseItem = new CntContactCardDataItem(hbTrId("txt_phob_formlabel_spouse"), itemCount(), false); |
504 if (!familyDetails[i].spouse().isEmpty()) |
372 dataSpouseItem->setValueText(familyDetails[i].spouse()); |
505 { |
373 dataSpouseItem->setContactDetail(familyDetails[i]); |
506 CntContactCardDataItem* dataSpouseItem = new CntContactCardDataItem(hbTrId("txt_phob_formlabel_spouse"), CntContactCardDataItem::EChildren, false); |
374 addSeparator(itemCount()); |
507 dataSpouseItem->setValueText(familyDetails[i].spouse()); |
375 mDataItemList.insert(itemCount(), dataSpouseItem); |
508 dataSpouseItem->setContactDetail(familyDetails[i]); |
|
509 addSeparator(itemCount()); |
|
510 mDataItemList.append(dataSpouseItem); |
|
511 } |
376 |
512 |
377 CntContactCardDataItem* dataChildrenItem = new CntContactCardDataItem(hbTrId("txt_phob_formlabel_children"), itemCount(), false); |
513 if (!familyDetails[i].children().isEmpty()) |
378 dataChildrenItem->setValueText(familyDetails[i].children().join(", ")); |
514 { |
379 dataChildrenItem->setContactDetail(familyDetails[i]); |
515 CntContactCardDataItem* dataChildrenItem = new CntContactCardDataItem(hbTrId("txt_phob_formlabel_children"), CntContactCardDataItem::ESpouse, false); |
380 addSeparator(itemCount()); |
516 dataChildrenItem->setValueText(familyDetails[i].children().join(", ")); |
381 mDataItemList.insert(itemCount(), dataChildrenItem); |
517 dataChildrenItem->setContactDetail(familyDetails[i]); |
|
518 addSeparator(itemCount()); |
|
519 mDataItemList.append(dataChildrenItem); |
|
520 } |
382 } |
521 } |
383 } |
522 } |
384 |
523 |
385 /*! |
524 /*! |
386 Returns true if contactDetails contains spesific action. |
525 Returns true if contactDetails contains spesific action. |
462 void CntContactCardDataContainer::sortDataItems() |
601 void CntContactCardDataContainer::sortDataItems() |
463 { |
602 { |
464 qStableSort(mDataItemList.begin(), mDataItemList.end(), compareObjects); |
603 qStableSort(mDataItemList.begin(), mDataItemList.end(), compareObjects); |
465 } |
604 } |
466 |
605 |
467 |
606 /*! |
468 |
607 Returns position of specific item |
|
608 */ |
|
609 int CntContactCardDataContainer::getPosition(const QString& aId, const QString& aContext, bool dynamicAction) |
|
610 { |
|
611 int position = CntContactCardDataItem::EOther; |
|
612 |
|
613 if (aId == QContactPhoneNumber::SubTypeAssistant && aContext.isEmpty() && !dynamicAction) |
|
614 { |
|
615 position = CntContactCardDataItem::ECallAssistant; |
|
616 } |
|
617 else if (aId == QContactPhoneNumber::SubTypeCar && aContext.isEmpty() && !dynamicAction) |
|
618 { |
|
619 position = CntContactCardDataItem::ECallCar; |
|
620 } |
|
621 else if (aId == QContactPhoneNumber::SubTypeMobile && aContext.isEmpty() && !dynamicAction) |
|
622 { |
|
623 position = CntContactCardDataItem::ECallMobile; |
|
624 } |
|
625 else if (aId == QContactPhoneNumber::SubTypeMobile && aContext == QContactDetail::ContextHome && !dynamicAction) |
|
626 { |
|
627 position = CntContactCardDataItem::ECallMobileHome; |
|
628 } |
|
629 else if (aId == QContactPhoneNumber::SubTypeMobile && aContext == QContactDetail::ContextWork && !dynamicAction) |
|
630 { |
|
631 position = CntContactCardDataItem::ECallMobileWork; |
|
632 } |
|
633 else if (aId == QContactPhoneNumber::SubTypeLandline && aContext.isEmpty() && !dynamicAction) |
|
634 { |
|
635 position = CntContactCardDataItem::ECallPhone; |
|
636 } |
|
637 else if (aId == QContactPhoneNumber::SubTypeLandline && aContext == QContactDetail::ContextHome && !dynamicAction) |
|
638 { |
|
639 position = CntContactCardDataItem::ECallPhoneHome; |
|
640 } |
|
641 else if (aId == QContactPhoneNumber::SubTypeLandline && aContext == QContactDetail::ContextWork && !dynamicAction) |
|
642 { |
|
643 position = CntContactCardDataItem::ECallPhoneWork; |
|
644 } |
|
645 else if (aId == QContactPhoneNumber::SubTypeFacsimile && aContext.isEmpty() && !dynamicAction) |
|
646 { |
|
647 position = CntContactCardDataItem::ECallFax; |
|
648 } |
|
649 else if (aId == QContactPhoneNumber::SubTypeFacsimile && aContext == QContactDetail::ContextHome && !dynamicAction) |
|
650 { |
|
651 position = CntContactCardDataItem::ECallFaxHome; |
|
652 } |
|
653 else if (aId == QContactPhoneNumber::SubTypeFacsimile && aContext == QContactDetail::ContextWork && !dynamicAction) |
|
654 { |
|
655 position = CntContactCardDataItem::ECallFaxWork; |
|
656 } |
|
657 else if (aId == QContactPhoneNumber::SubTypePager && aContext.isEmpty() && !dynamicAction) |
|
658 { |
|
659 position = CntContactCardDataItem::ECallPager; |
|
660 } |
|
661 else if (aId == QContactPhoneNumber::DefinitionName && aContext == QContactDetail::ContextHome && dynamicAction) |
|
662 { |
|
663 position = CntContactCardDataItem::ECallDynamicHome; |
|
664 } |
|
665 else if (aId == QContactPhoneNumber::DefinitionName && aContext == QContactDetail::ContextWork && dynamicAction) |
|
666 { |
|
667 position = CntContactCardDataItem::ECallDynamicWork; |
|
668 } |
|
669 else if (aId == QContactPhoneNumber::DefinitionName && aContext.isEmpty() && dynamicAction) |
|
670 { |
|
671 position = CntContactCardDataItem::ECallDynamic; |
|
672 } |
|
673 else if (aId == QContactOnlineAccount::SubTypeSipVoip && aContext.isEmpty() && !dynamicAction) |
|
674 { |
|
675 position = CntContactCardDataItem::EInternetTelephone; |
|
676 } |
|
677 else if (aId == QContactOnlineAccount::SubTypeSipVoip && aContext == QContactDetail::ContextHome && !dynamicAction) |
|
678 { |
|
679 position = CntContactCardDataItem::EInternetTelephoneHome; |
|
680 } |
|
681 else if (aId == QContactOnlineAccount::SubTypeSipVoip && aContext == QContactDetail::ContextWork && !dynamicAction) |
|
682 { |
|
683 position = CntContactCardDataItem::EInternetTelephoneWork; |
|
684 } |
|
685 else if (aId == QContactOnlineAccount::SubTypeSip && aContext.isEmpty() && !dynamicAction) |
|
686 { |
|
687 position = CntContactCardDataItem::ESip; |
|
688 } |
|
689 else if (aId == QContactOnlineAccount::DefinitionName && aContext == QContactDetail::ContextHome && dynamicAction) |
|
690 { |
|
691 position = CntContactCardDataItem::EInternetDynamicHome; |
|
692 } |
|
693 else if (aId == QContactOnlineAccount::DefinitionName && aContext == QContactDetail::ContextWork && dynamicAction) |
|
694 { |
|
695 position = CntContactCardDataItem::EInternetDynamicWork; |
|
696 } |
|
697 else if (aId == QContactOnlineAccount::DefinitionName && aContext.isEmpty() && dynamicAction) |
|
698 { |
|
699 position = CntContactCardDataItem::EInternetDynamic; |
|
700 } |
|
701 else if (aId == QContactEmailAddress::DefinitionName && aContext.isEmpty()) |
|
702 { |
|
703 if(!dynamicAction) |
|
704 position = CntContactCardDataItem::EEmail; |
|
705 else |
|
706 position = CntContactCardDataItem::EEmailDynamic; |
|
707 } |
|
708 else if (aId == QContactEmailAddress::DefinitionName && aContext == QContactDetail::ContextHome) |
|
709 { |
|
710 if(!dynamicAction) |
|
711 position = CntContactCardDataItem::EEmailHome; |
|
712 else |
|
713 position = CntContactCardDataItem::EEmailDynamicHome; |
|
714 } |
|
715 else if (aId == QContactEmailAddress::DefinitionName && aContext == QContactDetail::ContextWork) |
|
716 { |
|
717 if(!dynamicAction) |
|
718 position = CntContactCardDataItem::EEmailWork; |
|
719 else |
|
720 position = CntContactCardDataItem::EEmailDynamicWork; |
|
721 } |
|
722 else if (aId == QContactAddress::DefinitionName && aContext.isEmpty()) |
|
723 { |
|
724 if(!dynamicAction) |
|
725 position = CntContactCardDataItem::EAddress; |
|
726 else |
|
727 position = CntContactCardDataItem::EAddressDynamic; |
|
728 } |
|
729 else if (aId == QContactAddress::DefinitionName && aContext == QContactDetail::ContextHome) |
|
730 { |
|
731 if(!dynamicAction) |
|
732 position = CntContactCardDataItem::EAddressHome; |
|
733 else |
|
734 position = CntContactCardDataItem::EAddressDynamicHome; |
|
735 } |
|
736 else if (aId == QContactAddress::DefinitionName && aContext == QContactDetail::ContextWork) |
|
737 { |
|
738 if(!dynamicAction) |
|
739 position = CntContactCardDataItem::EAddressWork; |
|
740 else |
|
741 position = CntContactCardDataItem::EAddressDynamicWork; |
|
742 } |
|
743 else if (aId == QContactUrl::DefinitionName && aContext.isEmpty()) |
|
744 { |
|
745 if(!dynamicAction) |
|
746 position = CntContactCardDataItem::EUrl; |
|
747 else |
|
748 position = CntContactCardDataItem::EUrlDynamic; |
|
749 } |
|
750 else if (aId == QContactUrl::DefinitionName && aContext == QContactDetail::ContextHome) |
|
751 { |
|
752 if(!dynamicAction) |
|
753 position = CntContactCardDataItem::EUrlHome; |
|
754 else |
|
755 position = CntContactCardDataItem::EUrlDynamicHome; |
|
756 } |
|
757 else if (aId == QContactUrl::DefinitionName && aContext == QContactDetail::ContextWork) |
|
758 { |
|
759 if(!dynamicAction) |
|
760 position = CntContactCardDataItem::EUrlWork; |
|
761 else |
|
762 position = CntContactCardDataItem::EUrlDynamicWork; |
|
763 } |
|
764 else if (aId == QContactPhoneNumber::DefinitionName && aContext.isEmpty()) |
|
765 { |
|
766 position = CntContactCardDataItem::ELastAction; |
|
767 } |
|
768 else if (aId == QContactPhoneNumber::DefinitionName && aContext == QContactDetail::ContextHome) |
|
769 { |
|
770 position = CntContactCardDataItem::ELastActionHome; |
|
771 } |
|
772 else if (aId == QContactPhoneNumber::DefinitionName && aContext == QContactDetail::ContextWork) |
|
773 { |
|
774 position = CntContactCardDataItem::ELastActionWork; |
|
775 } |
|
776 else if (!dynamicAction) |
|
777 { |
|
778 position = CntContactCardDataItem::EOther; |
|
779 } |
|
780 else |
|
781 { |
|
782 position = CntContactCardDataItem::EDynamic; |
|
783 } |
|
784 |
|
785 return position; |
|
786 } |
|
787 |