diff -r b46a585f6909 -r efe85016a067 phonebookui/pbkcommonui/src/cntgroupmemberview.cpp --- a/phonebookui/pbkcommonui/src/cntgroupmemberview.cpp Fri Jun 11 13:29:23 2010 +0300 +++ b/phonebookui/pbkcommonui/src/cntgroupmemberview.cpp Wed Jun 23 18:02:44 2010 +0300 @@ -284,30 +284,10 @@ QList addedMemberships; QSet removedMembers = mOriginalGroupMembers.toSet() - selectedContacts; - - // TODO Notice the duplication with these loops. Refactor to use one only - foreach (QContactLocalId id, removedMembers) { - QContact contact = getContactManager()->contact(id); - - // new contact added to the group - QContactRelationship membership; - membership.setRelationshipType(QContactRelationship::HasMember); - membership.setFirst(mGroupContact->id()); - membership.setSecond(contact.id()); - removedMemberships.append(membership); - } + setRelationship(removedMembers, removedMemberships); QSet addedMembers = selectedContacts - mOriginalGroupMembers.toSet(); - foreach (QContactLocalId id, addedMembers) { - QContact contact = getContactManager()->contact(id); - - // new contact added to the group - QContactRelationship membership; - membership.setRelationshipType(QContactRelationship::HasMember); - membership.setFirst(mGroupContact->id()); - membership.setSecond(contact.id()); - addedMemberships.append(membership); - } + setRelationship(addedMembers, addedMemberships); QMap errors; if (!addedMemberships.isEmpty()) { @@ -331,22 +311,9 @@ rFilter.setRelationshipType(QContactRelationship::HasMember); rFilter.setRelatedContactRole(QContactRelationship::First); rFilter.setRelatedContactId(mGroupContact->id()); - - QContactSortOrder sortOrderFirstName; - sortOrderFirstName.setDetailDefinitionName(QContactName::DefinitionName, - QContactName::FieldFirstName); - sortOrderFirstName.setCaseSensitivity(Qt::CaseInsensitive); + - QContactSortOrder sortOrderLastName; - sortOrderLastName.setDetailDefinitionName(QContactName::DefinitionName, - QContactName::FieldLastName); - sortOrderLastName.setCaseSensitivity(Qt::CaseInsensitive); - - QList sortOrders; - sortOrders.append(sortOrderFirstName); - sortOrders.append(sortOrderLastName); - - mModel = new CntListModel(getContactManager(), rFilter, sortOrders, false); + mModel = new CntListModel(getContactManager(), rFilter, false); mListView->setModel(mModel); } @@ -366,7 +333,7 @@ headingLabel->setPlainText(HbParameterLengthLimiter(hbTrId("txt_phob_dialog_delete_1_group")).arg(groupName)); HbMessageBox::question(hbTrId("txt_phob_dialog_only_group_will_be_removed_contac"), this, SLOT(handleDeleteGroup(HbAction*)), - hbTrId("txt_phob_button_delete"), hbTrId("txt_common_button_cancel"), headingLabel); + hbTrId("txt_common_button_delete"), hbTrId("txt_common_button_cancel"), headingLabel); } void CntGroupMemberView::handleDeleteGroup(HbAction *action) @@ -509,6 +476,20 @@ return mViewManager->contactManager(SYMBIAN_BACKEND); } +void CntGroupMemberView::setRelationship(QSet &aLocalId, + QList &aRelationshipList) +{ + foreach (QContactLocalId id, aLocalId) { + QContact contact = getContactManager()->contact(id); + + QContactRelationship membership; + membership.setRelationshipType(QContactRelationship::HasMember); + membership.setFirst(mGroupContact->id()); + membership.setSecond(contact.id()); + aRelationshipList.append(membership); + } +} + /*! Draw the image specific content menu */