phonebookui/pbkcommonui/src/cntcollectionview.cpp
changeset 37 fd64c38c277d
parent 31 2a11b5b00470
child 40 b46a585f6909
--- a/phonebookui/pbkcommonui/src/cntcollectionview.cpp	Fri May 14 15:42:23 2010 +0300
+++ b/phonebookui/pbkcommonui/src/cntcollectionview.cpp	Thu May 27 12:45:19 2010 +0300
@@ -22,10 +22,11 @@
 #include "cntcollectionlistmodel.h"
 #include "cntextensionmanager.h"
 #include "qtpbkglobal.h"
+#include "cntfavourite.h"
 
 #include <cntuiextensionfactory.h>
 #include <cntuigroupsupplier.h>
-
+#include <hblabel.h>
 #include <hblistview.h>
 #include <hblistviewitem.h>
 #include <hbmenu.h>
@@ -88,6 +89,7 @@
     mNamesAction = static_cast<HbAction*>(mDocumentLoader.findObject("cnt:names"));
     connect(mNamesAction, SIGNAL(triggered()), this, SLOT(showPreviousView()));
     mFindAction = static_cast<HbAction*>(mDocumentLoader.findObject("cnt:find"));
+    mFindAction->setEnabled(false);
     mExtensionAction = static_cast<HbAction*> (mDocumentLoader.findObject("cnt:activity"));
 }
 
@@ -156,6 +158,14 @@
 }
 
 /*!
+Handle view switching request from an extension group item 
+*/
+void CntCollectionView::openView(CntViewParameters& viewParams)
+{
+    mViewManager->changeView(viewParams);
+}
+
+/*!
 Go back to previous view
 */
 void CntCollectionView::showPreviousView()
@@ -180,7 +190,7 @@
     else
     {
         int id = index.data(Qt::UserRole).toInt();
-        int favoriteGrpId = mModel->favoriteGroupId();
+        int favoriteGrpId = CntFavourite::favouriteGroupId(mViewManager->contactManager(SYMBIAN_BACKEND));
 
         if (id == favoriteGrpId )
         {
@@ -198,7 +208,7 @@
                 viewParameters.insert(EViewId, collectionFavoritesView);
                 QVariant var;
                 var.setValue(favoriteGroup);
-                viewParameters.insert(ESelectedContact, var);
+                viewParameters.insert(ESelectedGroupContact, var);
                 mViewManager->changeView(viewParameters);
             }
             else
@@ -207,7 +217,7 @@
                 viewParameters.insert(EViewId, FavoritesMemberView);
                 QVariant var;
                 var.setValue(favoriteGroup);
-                viewParameters.insert(ESelectedContact, var);
+                viewParameters.insert(ESelectedGroupContact, var);
                 mViewManager->changeView(viewParameters);
             }
         }
@@ -219,7 +229,7 @@
             viewParameters.insert(EViewId, groupMemberView);
             QVariant var;
             var.setValue(groupContact);
-            viewParameters.insert(ESelectedContact, var);
+            viewParameters.insert(ESelectedGroupContact, var);
             mViewManager->changeView(viewParameters);
         }
     }
@@ -229,18 +239,14 @@
 {
     if (mModel->isExtensionGroup(item->modelIndex()))
     {
-        CntViewParameters params = mModel->extensionGroupLongPressed(item->modelIndex().row(), coords);
-        if (params.count())
-        {
-            mViewManager->changeView(params);
-        }
+        mModel->extensionGroupLongPressed(item->modelIndex().row(), coords, this);
     }
     else
     {
         int id = item->modelIndex().data(Qt::UserRole).toInt();
         QVariant data( item->modelIndex().row() );
-        
-        int favoriteGrpId = mModel->favoriteGroupId();
+
+        int favoriteGrpId = CntFavourite::favouriteGroupId(mViewManager->contactManager(SYMBIAN_BACKEND));
         
         HbMenu *menu = new HbMenu();
         menu->setAttribute(Qt::WA_DeleteOnClose);
@@ -287,8 +293,13 @@
     popup->setAttribute(Qt::WA_DeleteOnClose, true);
     
     popup->setPromptText(hbTrId("txt_phob_title_new_group_name"));
-    popup->setPrimaryAction(new HbAction(hbTrId("txt_phob_button_create"), popup));
-    popup->setSecondaryAction(new HbAction(hbTrId("txt_common_button_cancel"), popup));
+    popup->clearActions();
+    HbAction* primaryAction = new HbAction(hbTrId("txt_phob_button_create"));
+    popup->addAction(primaryAction);
+    
+    HbAction* secondaryAction = new HbAction(hbTrId("txt_common_button_cancel"));
+    popup->addAction(secondaryAction);
+           
     popup->setInputMode(HbInputDialog::TextInput);
 
     popup->open(this, SLOT(handleNewGroup(HbAction*)));
@@ -318,7 +329,7 @@
         // Select some contact(s) to add to the group
         QString groupNameCreated(mHandledContact->displayLabel());
         mFetchView->setDetails(HbParameterLengthLimiter(hbTrId("txt_phob_subtitle_1_group")).arg(groupNameCreated),
-                               hbTrId("Save"));
+                               hbTrId("txt_common_button_save"));
         mFetchView->displayContacts(CntFetchContacts::popup,
                                     HbAbstractItemView::MultiSelection,
                                     contactsSet);
@@ -335,7 +346,7 @@
         viewParameters.insert(EViewId, groupMemberView);
         QVariant var;
         var.setValue(*mHandledContact);
-        viewParameters.insert(ESelectedContact, var);
+        viewParameters.insert(ESelectedGroupContact, var);
         mViewManager->changeView(viewParameters);
     }
     
@@ -364,8 +375,12 @@
     mHandledContact = new QContact(group);
     QString name = mHandledContact->displayLabel();
 
-    HbMessageBox::question(HbParameterLengthLimiter(hbTrId("txt_phob_dialog_delete_1_group")).arg(name), this, SLOT(handleDeleteGroup(HbAction*)),
-            hbTrId("txt_phob_button_delete"), hbTrId("txt_common_button_cancel"));
+    HbLabel *headingLabel = new HbLabel();
+    headingLabel->setPlainText(HbParameterLengthLimiter(hbTrId("txt_phob_dialog_delete_1_group")).arg(name));
+          
+    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);
 }
 
 void CntCollectionView::handleDeleteGroup(HbAction* action)