phonebookui/pbkcommonui/src/cntgroupmemberview.cpp
changeset 47 7cbcb2896f0e
parent 46 efe85016a067
child 50 77bc263e1626
child 59 a642906a277a
--- a/phonebookui/pbkcommonui/src/cntgroupmemberview.cpp	Wed Jun 23 18:02:44 2010 +0300
+++ b/phonebookui/pbkcommonui/src/cntgroupmemberview.cpp	Tue Jul 06 14:05:47 2010 +0300
@@ -66,7 +66,6 @@
     mFetchView(NULL),
     mAvatar(NULL)
 {
-
     mDocument = new CntDocumentLoader;
     
     bool ok;
@@ -202,13 +201,13 @@
     
     createModel();
     
-    if (mArgs.value(ESelectedAction).toString() == "save")
+    if (mArgs.value(ESelectedAction).toString() == CNT_SAVE_ACTION)
     {
         QString name = getContactManager()->synthesizedDisplayLabel(*mGroupContact);
         HbNotificationDialog::launchDialog(HbParameterLengthLimiter(hbTrId("txt_phob_dpophead_new_group_1_created").arg(name)));
     }
     
-    mFetchView = new CntFetchContacts(mViewManager->contactManager( SYMBIAN_BACKEND ));
+    mFetchView = new CntFetchContacts(*mViewManager->contactManager( SYMBIAN_BACKEND ));
     connect(mFetchView, SIGNAL(clicked()), this, SLOT(handleManageMembers()));
 }
 
@@ -223,15 +222,7 @@
     QContact contact = mViewManager->contactManager( SYMBIAN_BACKEND )->contact(mGroupContact->localId());
     if ( contact != *mGroupContact )
     {
-        QList<QContactAvatar> details = mGroupContact->details<QContactAvatar>();
-        for (int i = 0; i < details.count(); i++)
-        {
-            if (!details.at(i).imageUrl().isEmpty())
-            {
-                getContactManager()->saveContact(mGroupContact);
-                break;
-            }
-        }
+        getContactManager()->saveContact(mGroupContact);
     }
     mViewManager->back(mArgs);
 }
@@ -259,14 +250,12 @@
     QString groupName(groupContactName.value( QContactName::FieldCustomLabel ));
     
     if (!mFetchView) {
-        mFetchView = new CntFetchContacts(mViewManager->contactManager( SYMBIAN_BACKEND ));
+        mFetchView = new CntFetchContacts(*mViewManager->contactManager( SYMBIAN_BACKEND ));
         connect(mFetchView, SIGNAL(clicked()), this, SLOT(handleManageMembers()));
     }
     mFetchView->setDetails(HbParameterLengthLimiter(hbTrId("txt_phob_title_members_of_1_group")).arg(groupName),
                            hbTrId("txt_common_button_save"));
-    mFetchView->displayContacts(CntFetchContacts::popup,
-                                HbAbstractItemView::MultiSelection,
-                                contactsSet);
+    mFetchView->displayContacts(HbAbstractItemView::MultiSelection, contactsSet);
 }
 
 void CntGroupMemberView::handleManageMembers()
@@ -297,12 +286,6 @@
     if (!removedMemberships.isEmpty()) {
         getContactManager()->removeRelationships(removedMemberships, &errors);
     }
-    
-    // delete the model and recreate it with relationship changes
-    delete mModel;
-    mModel = 0;
-    
-    createModel();
 }
 
 void CntGroupMemberView::createModel()
@@ -312,7 +295,6 @@
     rFilter.setRelatedContactRole(QContactRelationship::First);
     rFilter.setRelatedContactId(mGroupContact->id());
 
-
     mModel = new CntListModel(getContactManager(), rFilter, false);
     mListView->setModel(mModel);
 }
@@ -421,12 +403,6 @@
     relationship.setFirst(mGroupContact->id());
     relationship.setSecond(selectedContact.id());
     getContactManager()->removeRelationship(relationship);
-    
-    // delete the model and recreate it with relationship changes
-    delete mModel;
-    mModel = NULL;
-    
-    createModel();
 }
 
 void CntGroupMemberView::editContact(const QModelIndex &index)
@@ -512,16 +488,19 @@
     {
         if (!mAvatar->imageUrl().isEmpty())
         {
-            mGroupContact->removeDetail(mAvatar);
+            bool success = mGroupContact->removeDetail(mAvatar);
             // Check if image removable.
             CntImageUtility imageUtility;
             if(imageUtility.isImageRemovable(mAvatar->imageUrl().toString()))
             {
                 imageUtility.removeImage(mAvatar->imageUrl().toString());
             }
+            mAvatar->setImageUrl(QUrl());
+            mImageLabel->clear();
+            mImageLabel->setIcon(HbIcon("qtg_large_add_group_picture"));
+            mHeadingItem->setIcon(HbIcon("qtg_large_add_group_picture"));
             mViewManager->contactManager( SYMBIAN_BACKEND )->saveContact(mGroupContact);
-            mHeadingItem->setIcon(HbIcon("qtg_large_avatar"));
-        }
+       }
     }
 }