phonebookui/cntcommonui/collections/cntgroupmemberview_p.cpp
changeset 72 6abfb1094884
child 81 640d30f4fb64
equal deleted inserted replaced
67:59984e68247d 72:6abfb1094884
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #include "cntgroupmemberview_p.h"
       
    19 #include "cntfetchcontactpopup.h"
       
    20 #include "cntcontactcardheadingitem.h"
       
    21 #include "cntglobal.h"
       
    22 #include "cntimagelabel.h"
       
    23 #include "cntimageutility.h"
       
    24 #include "cntthumbnailmanager.h"
       
    25 #include <hbnotificationdialog.h>
       
    26 #include <hbmessagebox.h>
       
    27 #include <hbmenu.h>
       
    28 #include <hblistview.h>
       
    29 #include <hblistviewitem.h>
       
    30 #include <hbframebackground.h>
       
    31 #include <hbindexfeedback.h>
       
    32 #include <hbscrollbar.h>
       
    33 #include <hbview.h>
       
    34 #include <hbaction.h>
       
    35 #include <hblabel.h>
       
    36 #include <hbparameterlengthlimiter.h>
       
    37 #include <cntlistmodel.h>
       
    38 #include <hbmainwindow.h>
       
    39 #include <xqservicerequest.h>
       
    40 
       
    41 #include "cntdocumentloader.h"
       
    42 
       
    43 const char *CNT_GROUPMEMBERVIEW_XML = ":/xml/contacts_groupmembers.docml";
       
    44 
       
    45 /*!
       
    46 \class CntGroupMemberViewPrivate
       
    47 \brief
       
    48 
       
    49 This is the group members view class that shows list of contacts for a user group. View contains a listview that shows actual contacts that
       
    50 have been added to a particular group. There is also toolbar and menu for navigating between different views. Instance of this class is
       
    51 created by our viewmanager but view itself is owned by the mainwindow which will also delete it in the end.
       
    52 
       
    53 */
       
    54 
       
    55 /*!
       
    56 Constructor, initialize member variables.
       
    57 \a viewManager is the parent that creates this view. \a parent is a pointer to parent QGraphicsItem (by default this is 0)
       
    58 
       
    59 */
       
    60 CntGroupMemberViewPrivate::CntGroupMemberViewPrivate() :
       
    61     mGroupContact(NULL),
       
    62     mViewManager(NULL),
       
    63     mHeadingItem(NULL),
       
    64     mModel(NULL),
       
    65     mImageLabel(NULL), 
       
    66     mListView(NULL),
       
    67     mAvatar(NULL)
       
    68 {
       
    69     mDocument = new CntDocumentLoader;
       
    70     
       
    71     bool ok;
       
    72     mDocument->load( CNT_GROUPMEMBERVIEW_XML, &ok );
       
    73     if ( !ok ){
       
    74         qFatal( "Unable to load %S", CNT_GROUPMEMBERVIEW_XML );
       
    75     }
       
    76 
       
    77     mView = static_cast<HbView*>( mDocument->findWidget("view") );
       
    78     
       
    79     //back button
       
    80     mSoftkey = new HbAction(Hb::BackNaviAction, mView);
       
    81     connect(mSoftkey, SIGNAL(triggered()), this, SLOT(showPreviousView()));
       
    82     
       
    83     mImageLabel = static_cast<CntImageLabel*>(mDocument->findWidget("imageLabel"));
       
    84     connect( mImageLabel, SIGNAL(iconClicked()), this, SLOT(openImageEditor()) );
       
    85     connect( mImageLabel, SIGNAL(iconLongPressed(const QPointF&)), this, SLOT(drawImageMenu(const QPointF&)) );
       
    86     
       
    87     mListView = static_cast<HbListView*>( mDocument->findWidget("listView") );
       
    88     connect(mListView, SIGNAL(longPressed(HbAbstractViewItem*,QPointF)), this,
       
    89         SLOT(showContextMenu(HbAbstractViewItem*,QPointF)));
       
    90     connect(mListView, SIGNAL(activated (const QModelIndex&)), this,
       
    91         SLOT(showContactView(const QModelIndex&)));
       
    92     
       
    93     mHeadingItem = static_cast<CntContactCardHeadingItem*>( mDocument->findWidget("groupHeading") );
       
    94     connect(mHeadingItem, SIGNAL(passShortPressed(const QPointF&)), this, SLOT(openImageEditor()) );
       
    95     connect(mHeadingItem, SIGNAL(passLongPressed(const QPointF&)), this, SLOT(drawImageMenu(const QPointF&)));
       
    96 
       
    97     // menu actions
       
    98     mEditGroupAction = static_cast<HbAction*>( mDocument->findObject("cnt:editgroupdetails"));
       
    99     connect(mEditGroupAction, SIGNAL(triggered()), this, SLOT(editGroup()));
       
   100     
       
   101     // toolbar actions
       
   102     mManageAction = static_cast<HbAction*>( mDocument->findObject("cnt:managemembers"));
       
   103     connect(mManageAction, SIGNAL(triggered()), this, SLOT(manageMembers()));
       
   104     mDeleteAction = static_cast<HbAction*>( mDocument->findObject("cnt:deletegroup"));
       
   105     connect(mDeleteAction, SIGNAL(triggered()), this, SLOT(deleteGroup()));
       
   106     mShowActionsAction = static_cast<HbAction*>( mDocument->findObject("cnt:groupactions"));
       
   107     connect(mShowActionsAction, SIGNAL(triggered()), this, SLOT(openGroupActions()));
       
   108     
       
   109     //Always disable by default. 
       
   110     //Only enable, when atleast one contact contains a CommunicationAddress defined. 
       
   111     mShowActionsAction->setDisabled(true);
       
   112 }
       
   113 
       
   114 /*!
       
   115 Destructor
       
   116 */
       
   117 CntGroupMemberViewPrivate::~CntGroupMemberViewPrivate()
       
   118 {
       
   119     mView->deleteLater();
       
   120     
       
   121     delete mGroupContact;
       
   122     mGroupContact = NULL;
       
   123     
       
   124     delete mModel;
       
   125     mModel = NULL;
       
   126     
       
   127     delete mAvatar;
       
   128     mAvatar = NULL;
       
   129 }
       
   130 
       
   131 void CntGroupMemberViewPrivate::setOrientation(Qt::Orientation orientation)
       
   132 {
       
   133     if (orientation == Qt::Vertical) 
       
   134     {
       
   135         // reading "portrait" section
       
   136         mDocument->load( CNT_GROUPMEMBERVIEW_XML, "portrait" );
       
   137     } 
       
   138     else 
       
   139     {
       
   140         // reading "landscape" section
       
   141         mDocument->load( CNT_GROUPMEMBERVIEW_XML, "landscape" );
       
   142     }
       
   143 }
       
   144 
       
   145 void CntGroupMemberViewPrivate::activate( const CntViewParameters aArgs )
       
   146 {
       
   147     mArgs = aArgs;
       
   148     mViewManager = &mEngine->viewManager();
       
   149     mThumbnailManager = &mEngine->thumbnailManager();
       
   150 
       
   151     connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void*, int, int)),
       
   152             this, SLOT(thumbnailReady(QPixmap, void*, int, int)));
       
   153         
       
   154     if (mView->navigationAction() != mSoftkey)
       
   155         {
       
   156         mView->setNavigationAction(mSoftkey);   
       
   157         }
       
   158         
       
   159     QVariant contact = mArgs.value( ESelectedGroupContact );
       
   160     mGroupContact = new QContact( contact.value<QContact>() );
       
   161     
       
   162     HbMainWindow* window = mView->mainWindow();
       
   163     if ( window )
       
   164     {
       
   165         connect(window, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(setOrientation(Qt::Orientation)));
       
   166         setOrientation(window->orientation());
       
   167     }
       
   168     
       
   169     mHeadingItem->setGroupDetails(mGroupContact);
       
   170 
       
   171     // avatar
       
   172     QList<QContactAvatar> details = mGroupContact->details<QContactAvatar>();
       
   173     for (int i = 0;i < details.count();i++)
       
   174     {
       
   175         if (details.at(i).imageUrl().isValid())
       
   176             {
       
   177             mAvatar = new QContactAvatar(details.at(i));
       
   178             mThumbnailManager->getThumbnail(ThumbnailManager::ThumbnailLarge, mAvatar->imageUrl().toString());
       
   179             break;
       
   180             }
       
   181     }
       
   182     
       
   183     // create list & model
       
   184     mListView->setFrictionEnabled(true);
       
   185     mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn);
       
   186     mListView->verticalScrollBar()->setInteractive(true);
       
   187     mListView->setUniformItemSizes(true);
       
   188     
       
   189     HbFrameBackground frame;
       
   190     frame.setFrameGraphicsName("qtg_fr_list_normal");
       
   191     frame.setFrameType(HbFrameDrawer::NinePieces);
       
   192     HbListViewItem* prototype = mListView->listItemPrototype();
       
   193     prototype->setDefaultFrame(frame);
       
   194     
       
   195     HbIndexFeedback *indexFeedback = new HbIndexFeedback(mView);
       
   196     indexFeedback->setIndexFeedbackPolicy(HbIndexFeedback::IndexFeedbackSingleCharacter);
       
   197     indexFeedback->setItemView(mListView);
       
   198     
       
   199     mListView->setLayoutName("groupmemberlist");
       
   200 
       
   201     // if no contacts are present, then disable the Manage Members toolbar 
       
   202     QContactDetailFilter filter;
       
   203     filter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType);
       
   204     filter.setValue(QLatin1String(QContactType::TypeContact));
       
   205    
       
   206     QList<QContactLocalId> contactIds = getContactManager()->contactIds(filter);   
       
   207     if (contactIds.isEmpty())
       
   208     {
       
   209        mManageAction->setEnabled(false); 
       
   210     }      
       
   211     
       
   212     createModel();
       
   213     
       
   214     if (mArgs.value(ESelectedAction).toString() == CNT_SAVE_ACTION)
       
   215     {
       
   216         QString name = getContactManager()->synthesizedContactDisplayLabel(*mGroupContact);
       
   217         HbNotificationDialog::launchDialog(HbParameterLengthLimiter(hbTrId("txt_phob_dpophead_new_group_1_created").arg(name)));
       
   218     }
       
   219     decideActionButtonContext();
       
   220 }
       
   221 
       
   222 void CntGroupMemberViewPrivate::deactivate()
       
   223 {
       
   224 }
       
   225 
       
   226 void CntGroupMemberViewPrivate::showPreviousView()
       
   227 {
       
   228     Q_Q(CntGroupMemberView);
       
   229     
       
   230     emit q->backPressed();
       
   231     
       
   232     //save the contact if avatar has been changed.
       
   233     QContact contact = getContactManager()->contact(mGroupContact->localId());
       
   234     if ( contact != *mGroupContact )
       
   235     {
       
   236         getContactManager()->saveContact(mGroupContact);
       
   237     }
       
   238     mViewManager->back(mArgs);
       
   239 }
       
   240 
       
   241 void CntGroupMemberViewPrivate::openGroupActions()
       
   242 {
       
   243     QVariant var;
       
   244     var.setValue(*mGroupContact);
       
   245     
       
   246     mArgs.insert(EViewId, groupActionsView);
       
   247     mArgs.insert(ESelectedGroupContact, var);
       
   248     mViewManager->changeView(mArgs);
       
   249 }
       
   250 
       
   251 void CntGroupMemberViewPrivate::manageMembers()
       
   252 {
       
   253     QContactRelationshipFilter membersFilter;
       
   254     membersFilter.setRelationshipType(QContactRelationship::HasMember);
       
   255     membersFilter.setRelatedContactRole(QContactRelationship::First);
       
   256     membersFilter.setRelatedContactId(mGroupContact->id());   
       
   257     
       
   258     mOriginalGroupMembers = getContactManager()->contactIds(membersFilter);
       
   259     
       
   260     QContactName contactName = mGroupContact->detail( QContactName::DefinitionName );
       
   261     QString groupName = contactName.value( QContactName::FieldCustomLabel );
       
   262     if (groupName.isEmpty())
       
   263     {
       
   264         groupName = hbTrId("txt_phob_list_unnamed");
       
   265     }
       
   266     
       
   267     CntFetchContactPopup* popup = CntFetchContactPopup::createMultiSelectionPopup(
       
   268             HbParameterLengthLimiter(hbTrId("txt_phob_title_members_of_1_group")).arg(groupName),
       
   269             hbTrId("txt_common_button_save"),
       
   270             mEngine->contactManager(SYMBIAN_BACKEND));
       
   271     connect( popup, SIGNAL(fetchReady(QSet<QContactLocalId>)),this, SLOT(handleManageMembers(QSet<QContactLocalId>)) );
       
   272     popup->setSelectedContacts( mOriginalGroupMembers.toSet() );
       
   273     popup->showPopup();
       
   274 }
       
   275 
       
   276 void CntGroupMemberViewPrivate::handleManageMembers( QSet<QContactLocalId> aIds )
       
   277 {
       
   278     QList<QContactRelationship> removedMemberships;
       
   279     QList<QContactRelationship> addedMemberships;
       
   280 
       
   281     QSet<QContactLocalId> removedMembers = mOriginalGroupMembers.toSet() - aIds;
       
   282     setRelationship(removedMembers, removedMemberships);
       
   283 
       
   284     QSet<QContactLocalId> addedMembers = aIds - mOriginalGroupMembers.toSet();
       
   285     setRelationship(addedMembers, addedMemberships);
       
   286     
       
   287     if (!addedMemberships.isEmpty()) 
       
   288     {
       
   289         getContactManager()->saveRelationships(&addedMemberships, NULL);
       
   290     }
       
   291     
       
   292     if (!removedMemberships.isEmpty()) 
       
   293     {
       
   294         getContactManager()->removeRelationships(removedMemberships, NULL);
       
   295     }
       
   296     
       
   297     decideActionButtonContext();
       
   298 }
       
   299 
       
   300 void CntGroupMemberViewPrivate::createModel()
       
   301 {
       
   302     QContactRelationshipFilter rFilter;
       
   303     rFilter.setRelationshipType(QContactRelationship::HasMember);
       
   304     rFilter.setRelatedContactRole(QContactRelationship::First);
       
   305     rFilter.setRelatedContactId(mGroupContact->id());
       
   306     
       
   307     mModel = new CntListModel(getContactManager(), rFilter, false);
       
   308     mListView->setModel(mModel);
       
   309 }
       
   310 
       
   311 void CntGroupMemberViewPrivate::editGroup()
       
   312 {
       
   313     mArgs.insert(EViewId, groupEditorView);
       
   314     QVariant var;
       
   315     var.setValue(*mGroupContact);
       
   316     mArgs.insert(ESelectedGroupContact, var);
       
   317     mViewManager->changeView(mArgs);
       
   318 }
       
   319 
       
   320 void CntGroupMemberViewPrivate::deleteGroup()
       
   321 {
       
   322     QContactName contactName = mGroupContact->detail( QContactName::DefinitionName );
       
   323     QString groupName = contactName.value( QContactName::FieldCustomLabel );
       
   324     if (groupName.isNull())
       
   325     {
       
   326         groupName = hbTrId("txt_phob_list_unnamed");
       
   327     }
       
   328     
       
   329     HbLabel *headingLabel = new HbLabel();
       
   330     headingLabel->setPlainText(HbParameterLengthLimiter(hbTrId("txt_phob_dialog_delete_1_group")).arg(groupName));
       
   331     
       
   332     HbMessageBox::question(hbTrId("txt_phob_dialog_only_group_will_be_removed_contac"), this, SLOT(handleDeleteGroup(int)),
       
   333             HbMessageBox::Delete | HbMessageBox::Cancel, headingLabel);
       
   334 }
       
   335 
       
   336 void CntGroupMemberViewPrivate::handleDeleteGroup(int action)
       
   337 {
       
   338     if (action == HbMessageBox::Delete)
       
   339     {
       
   340         getContactManager()->removeContact(mGroupContact->localId());
       
   341         showPreviousView();
       
   342     }
       
   343 }
       
   344 
       
   345 /*!
       
   346 Called when a list item is longpressed
       
   347 */
       
   348 void CntGroupMemberViewPrivate::showContextMenu(HbAbstractViewItem *aItem, const QPointF &aCoords)
       
   349 {
       
   350     QVariant data( aItem->modelIndex().row() );
       
   351    
       
   352     QModelIndex index = aItem->modelIndex();
       
   353 
       
   354     HbMenu *menu = new HbMenu();
       
   355     menu->setAttribute(Qt::WA_DeleteOnClose);
       
   356     menu->setPreferredPos( aCoords );
       
   357     
       
   358     HbAction *removeFromGroupAction = 0;
       
   359     HbAction *openContactAction = 0;
       
   360     HbAction *editContactAction = 0;
       
   361     HbAction *sendToHsAction = 0;
       
   362 
       
   363     openContactAction = menu->addAction(hbTrId("txt_common_menu_open"));
       
   364     editContactAction = menu->addAction(hbTrId("txt_common_menu_edit"));
       
   365     removeFromGroupAction = menu->addAction(hbTrId("txt_phob_menu_remove_from_group"));
       
   366     sendToHsAction = menu->addAction(hbTrId("txt_phob_menu_send_to_homescreen"));
       
   367     
       
   368     openContactAction->setData( data );
       
   369     editContactAction->setData( data );
       
   370     removeFromGroupAction->setData( data );
       
   371     sendToHsAction->setData( data );
       
   372 
       
   373     menu->open(this, SLOT(handleMenu(HbAction*)));
       
   374 }
       
   375 
       
   376 void CntGroupMemberViewPrivate::handleMenu(HbAction* action)
       
   377 {
       
   378     int row = action->data().toInt();
       
   379     HbMenu *menuItem = static_cast<HbMenu*>(sender());
       
   380     QModelIndex index = mModel->index(row);
       
   381     
       
   382     if ( action == menuItem->actions().first() )
       
   383         {
       
   384         showContactView(index);
       
   385         }
       
   386     else if (action == menuItem->actions().at(1))
       
   387         {
       
   388         editContact(index);
       
   389         }
       
   390     else if (action == menuItem->actions().at(2))
       
   391         {
       
   392         removeFromGroup(index);
       
   393         }
       
   394     else if (action == menuItem->actions().at(3))
       
   395         {
       
   396         sendToHs(index);
       
   397         }
       
   398 }
       
   399 
       
   400 /*!
       
   401 Called after user clicked on the listview.
       
   402 */
       
   403 void CntGroupMemberViewPrivate::sendToHs(const QModelIndex &index)
       
   404 {
       
   405     QVariantHash preferences;
       
   406     preferences["contactId"] = mModel->contact(index).id().localId();
       
   407     
       
   408     XQServiceRequest snd("com.nokia.symbian.IHomeScreenClient",
       
   409                          "addWidget(QString,QVariantHash)",
       
   410                          false);
       
   411     snd << QString("contactwidgethsplugin");
       
   412     snd << preferences;
       
   413     snd.send();
       
   414 }
       
   415 
       
   416 /*!
       
   417 Called after user clicked on the listview.
       
   418 */
       
   419 void CntGroupMemberViewPrivate::showContactView(const QModelIndex &index)
       
   420 {
       
   421     mArgs.insert(EViewId, contactCardView);
       
   422     QVariant var;
       
   423     var.setValue(mModel->contact(index));
       
   424     mArgs.insert(ESelectedContact, var);
       
   425     QVariant varGroup;
       
   426     varGroup.setValue(*mGroupContact);
       
   427     mArgs.insert(ESelectedGroupContact, varGroup);
       
   428     mViewManager->changeView(mArgs);
       
   429         
       
   430 }
       
   431 
       
   432 void CntGroupMemberViewPrivate::removeFromGroup(const QModelIndex &index)
       
   433 {
       
   434     // get contact id using index
       
   435     QContact selectedContact = mModel->contact(index);
       
   436     QContactRelationship relationship;
       
   437     relationship.setRelationshipType(QContactRelationship::HasMember);
       
   438     relationship.setFirst(mGroupContact->id());
       
   439     relationship.setSecond(selectedContact.id());
       
   440     getContactManager()->removeRelationship(relationship);
       
   441     decideActionButtonContext();
       
   442 }
       
   443 
       
   444 void CntGroupMemberViewPrivate::editContact(const QModelIndex &index)
       
   445 {
       
   446 
       
   447     mArgs.insert(EViewId, editView);
       
   448     QVariant var;
       
   449     var.setValue(mModel->contact(index));
       
   450     mArgs.insert(ESelectedContact, var);
       
   451     mViewManager->changeView(mArgs);
       
   452 }
       
   453 
       
   454 void CntGroupMemberViewPrivate::thumbnailReady(const QPixmap& pixmap, void *data, int id, int error)
       
   455 {
       
   456     Q_UNUSED(data);
       
   457     Q_UNUSED(id);
       
   458     Q_UNUSED(error);
       
   459     if (!error)
       
   460     {
       
   461         HbIcon icon(pixmap);
       
   462         mHeadingItem->setIcon(icon);
       
   463         
       
   464         mImageLabel->clear();
       
   465         mImageLabel->setIcon(pixmap);
       
   466     }
       
   467 }
       
   468 
       
   469 void CntGroupMemberViewPrivate::openImageEditor()
       
   470 {
       
   471     QVariant var;
       
   472     var.setValue(*mGroupContact);
       
   473        
       
   474     // only group contact is assigned since we want to only
       
   475     // change the groups image
       
   476     mArgs.insert(ESelectedGroupContact, var);
       
   477     
       
   478     mArgs.insert(EViewId, imageEditorView );
       
   479         
       
   480     mViewManager->changeView( mArgs );
       
   481 }
       
   482 
       
   483 QContactManager* CntGroupMemberViewPrivate::getContactManager()
       
   484 {
       
   485     return &mEngine->contactManager(SYMBIAN_BACKEND);
       
   486 }
       
   487 
       
   488 void CntGroupMemberViewPrivate::setRelationship(QSet<QContactLocalId>        &aLocalIds,
       
   489                                          QList<QContactRelationship>  &aRelationshipList)
       
   490 {
       
   491     foreach (QContactLocalId localId, aLocalIds) {
       
   492 		QContactId id;
       
   493 		id.setLocalId(localId);
       
   494         QContactRelationship membership;
       
   495         membership.setRelationshipType(QContactRelationship::HasMember);
       
   496         membership.setFirst(mGroupContact->id());
       
   497         membership.setSecond(id);
       
   498         aRelationshipList.append(membership);
       
   499     }
       
   500 }
       
   501 
       
   502 /*!
       
   503 Draw the image specific content menu
       
   504 */
       
   505 void CntGroupMemberViewPrivate::drawImageMenu(const QPointF &aCoords)
       
   506 {
       
   507     HbMenu *menu = new HbMenu();
       
   508     HbAction *changeImageAction = menu->addAction(hbTrId("txt_phob_menu_change_picture"), this, SLOT(openImageEditor()));
       
   509     if (mAvatar && !mAvatar->imageUrl().isEmpty())
       
   510     {
       
   511         menu->addAction(hbTrId("txt_phob_menu_remove_image"), this, SLOT(removeImage()));
       
   512     }
       
   513     menu->setPreferredPos(aCoords);
       
   514     menu->open();
       
   515 }
       
   516 
       
   517 
       
   518 void CntGroupMemberViewPrivate::removeImage()
       
   519 {
       
   520     if (mAvatar) 
       
   521     {
       
   522         if (!mAvatar->imageUrl().isEmpty())
       
   523         {
       
   524             bool success = mGroupContact->removeDetail(mAvatar);
       
   525             // Check if image removable.
       
   526             CntImageUtility imageUtility;
       
   527             if(imageUtility.isImageRemovable(mAvatar->imageUrl().toString()))
       
   528             {
       
   529                 imageUtility.removeImage(mAvatar->imageUrl().toString());
       
   530             }
       
   531             mAvatar->setImageUrl(QUrl());
       
   532             mImageLabel->clear();
       
   533             mImageLabel->setAvatarIcon(HbIcon("qtg_large_add_group_picture"));
       
   534             mHeadingItem->setIcon(HbIcon("qtg_large_add_group_picture"));
       
   535             getContactManager()->saveContact(mGroupContact);
       
   536        }
       
   537     }
       
   538 }
       
   539 
       
   540 void CntGroupMemberViewPrivate::decideActionButtonContext()
       
   541 {
       
   542     bool isActionDefined( false );
       
   543     
       
   544     QContactPhoneNumber confCallNumber = mGroupContact->detail<QContactPhoneNumber>();
       
   545     //first check whether Conf Num is defined for a group.    
       
   546     if( !confCallNumber.number().isEmpty() )
       
   547     {
       
   548         isActionDefined = true;
       
   549     }
       
   550     else
       
   551     {
       
   552         //Since no conf number has been defined.
       
   553         //lets try to find if any group member has a communication field set or not
       
   554         
       
   555         int count = mModel->rowCount();
       
   556         
       
   557         for ( int i = 0; i<count; i++ )
       
   558         {
       
   559             QModelIndex modelIndex = mModel->index(i,0);
       
   560             QContact groupMember = mModel->contact(modelIndex);
       
   561             
       
   562             QContactDetail phoneDetail = groupMember.detail( QContactPhoneNumber::DefinitionName );
       
   563             QContactDetail emailDetail = groupMember.detail( QContactEmailAddress::DefinitionName );        
       
   564             
       
   565             if ( !phoneDetail.isEmpty() || !emailDetail.isEmpty() )
       
   566             {
       
   567                 isActionDefined = true;
       
   568                 break;
       
   569             }
       
   570         }
       
   571     }
       
   572  
       
   573     if ( isActionDefined )
       
   574     {
       
   575         //Enable when atleast 1 of the contacts in the current group have a 
       
   576         //communication address Defined or When a Group has Conf number defined.
       
   577         mShowActionsAction->setDisabled(false);    
       
   578     }
       
   579     else
       
   580     {
       
   581         //Disable when none of the contacts in the current group have any 
       
   582         //communication address Defined.         
       
   583         mShowActionsAction->setDisabled(true);
       
   584     }
       
   585 }
       
   586 
       
   587 
       
   588 
       
   589 // end of file