282 |
282 |
283 QList<QContactRelationship> removedMemberships; |
283 QList<QContactRelationship> removedMemberships; |
284 QList<QContactRelationship> addedMemberships; |
284 QList<QContactRelationship> addedMemberships; |
285 |
285 |
286 QSet<QContactLocalId> removedMembers = mOriginalGroupMembers.toSet() - selectedContacts; |
286 QSet<QContactLocalId> removedMembers = mOriginalGroupMembers.toSet() - selectedContacts; |
287 |
287 setRelationship(removedMembers, removedMemberships); |
288 // TODO Notice the duplication with these loops. Refactor to use one only |
|
289 foreach (QContactLocalId id, removedMembers) { |
|
290 QContact contact = getContactManager()->contact(id); |
|
291 |
|
292 // new contact added to the group |
|
293 QContactRelationship membership; |
|
294 membership.setRelationshipType(QContactRelationship::HasMember); |
|
295 membership.setFirst(mGroupContact->id()); |
|
296 membership.setSecond(contact.id()); |
|
297 removedMemberships.append(membership); |
|
298 } |
|
299 |
288 |
300 QSet<QContactLocalId> addedMembers = selectedContacts - mOriginalGroupMembers.toSet(); |
289 QSet<QContactLocalId> addedMembers = selectedContacts - mOriginalGroupMembers.toSet(); |
301 foreach (QContactLocalId id, addedMembers) { |
290 setRelationship(addedMembers, addedMemberships); |
302 QContact contact = getContactManager()->contact(id); |
|
303 |
|
304 // new contact added to the group |
|
305 QContactRelationship membership; |
|
306 membership.setRelationshipType(QContactRelationship::HasMember); |
|
307 membership.setFirst(mGroupContact->id()); |
|
308 membership.setSecond(contact.id()); |
|
309 addedMemberships.append(membership); |
|
310 } |
|
311 |
291 |
312 QMap<int, QContactManager::Error> errors; |
292 QMap<int, QContactManager::Error> errors; |
313 if (!addedMemberships.isEmpty()) { |
293 if (!addedMemberships.isEmpty()) { |
314 getContactManager()->saveRelationships(&addedMemberships, &errors); |
294 getContactManager()->saveRelationships(&addedMemberships, &errors); |
315 } |
295 } |
329 { |
309 { |
330 QContactRelationshipFilter rFilter; |
310 QContactRelationshipFilter rFilter; |
331 rFilter.setRelationshipType(QContactRelationship::HasMember); |
311 rFilter.setRelationshipType(QContactRelationship::HasMember); |
332 rFilter.setRelatedContactRole(QContactRelationship::First); |
312 rFilter.setRelatedContactRole(QContactRelationship::First); |
333 rFilter.setRelatedContactId(mGroupContact->id()); |
313 rFilter.setRelatedContactId(mGroupContact->id()); |
334 |
314 |
335 QContactSortOrder sortOrderFirstName; |
315 |
336 sortOrderFirstName.setDetailDefinitionName(QContactName::DefinitionName, |
316 mModel = new CntListModel(getContactManager(), rFilter, false); |
337 QContactName::FieldFirstName); |
|
338 sortOrderFirstName.setCaseSensitivity(Qt::CaseInsensitive); |
|
339 |
|
340 QContactSortOrder sortOrderLastName; |
|
341 sortOrderLastName.setDetailDefinitionName(QContactName::DefinitionName, |
|
342 QContactName::FieldLastName); |
|
343 sortOrderLastName.setCaseSensitivity(Qt::CaseInsensitive); |
|
344 |
|
345 QList<QContactSortOrder> sortOrders; |
|
346 sortOrders.append(sortOrderFirstName); |
|
347 sortOrders.append(sortOrderLastName); |
|
348 |
|
349 mModel = new CntListModel(getContactManager(), rFilter, sortOrders, false); |
|
350 mListView->setModel(mModel); |
317 mListView->setModel(mModel); |
351 } |
318 } |
352 |
319 |
353 void CntGroupMemberView::editGroup() |
320 void CntGroupMemberView::editGroup() |
354 { |
321 { |
364 QString groupName = mGroupContact->displayLabel(); |
331 QString groupName = mGroupContact->displayLabel(); |
365 HbLabel *headingLabel = new HbLabel(); |
332 HbLabel *headingLabel = new HbLabel(); |
366 headingLabel->setPlainText(HbParameterLengthLimiter(hbTrId("txt_phob_dialog_delete_1_group")).arg(groupName)); |
333 headingLabel->setPlainText(HbParameterLengthLimiter(hbTrId("txt_phob_dialog_delete_1_group")).arg(groupName)); |
367 |
334 |
368 HbMessageBox::question(hbTrId("txt_phob_dialog_only_group_will_be_removed_contac"), this, SLOT(handleDeleteGroup(HbAction*)), |
335 HbMessageBox::question(hbTrId("txt_phob_dialog_only_group_will_be_removed_contac"), this, SLOT(handleDeleteGroup(HbAction*)), |
369 hbTrId("txt_phob_button_delete"), hbTrId("txt_common_button_cancel"), headingLabel); |
336 hbTrId("txt_common_button_delete"), hbTrId("txt_common_button_cancel"), headingLabel); |
370 } |
337 } |
371 |
338 |
372 void CntGroupMemberView::handleDeleteGroup(HbAction *action) |
339 void CntGroupMemberView::handleDeleteGroup(HbAction *action) |
373 { |
340 { |
374 HbDialog *popup = static_cast<HbDialog*>(sender()); |
341 HbDialog *popup = static_cast<HbDialog*>(sender()); |
507 QContactManager* CntGroupMemberView::getContactManager() |
474 QContactManager* CntGroupMemberView::getContactManager() |
508 { |
475 { |
509 return mViewManager->contactManager(SYMBIAN_BACKEND); |
476 return mViewManager->contactManager(SYMBIAN_BACKEND); |
510 } |
477 } |
511 |
478 |
|
479 void CntGroupMemberView::setRelationship(QSet<QContactLocalId> &aLocalId, |
|
480 QList<QContactRelationship> &aRelationshipList) |
|
481 { |
|
482 foreach (QContactLocalId id, aLocalId) { |
|
483 QContact contact = getContactManager()->contact(id); |
|
484 |
|
485 QContactRelationship membership; |
|
486 membership.setRelationshipType(QContactRelationship::HasMember); |
|
487 membership.setFirst(mGroupContact->id()); |
|
488 membership.setSecond(contact.id()); |
|
489 aRelationshipList.append(membership); |
|
490 } |
|
491 } |
|
492 |
512 /*! |
493 /*! |
513 Draw the image specific content menu |
494 Draw the image specific content menu |
514 */ |
495 */ |
515 void CntGroupMemberView::drawImageMenu(const QPointF &aCoords) |
496 void CntGroupMemberView::drawImageMenu(const QPointF &aCoords) |
516 { |
497 { |