phonebookui/pbkcommonui/src/cntgroupactionsview.cpp
changeset 61 d30183af6ca6
parent 54 47627ab5d7a4
child 66 554fe4dbbb59
equal deleted inserted replaced
56:d508aa856878 61:d30183af6ca6
    36 #include <hbnumbergrouping.h>
    36 #include <hbnumbergrouping.h>
    37 #include <QKeyEvent> 
    37 #include <QKeyEvent> 
    38 #include <qtcontacts.h>
    38 #include <qtcontacts.h>
    39 #include <hbmainwindow.h>
    39 #include <hbmainwindow.h>
    40 #include "cntactionlauncher.h"
    40 #include "cntactionlauncher.h"
    41 
       
    42 #include <QEvent>
    41 #include <QEvent>
    43 #include <QStandardItemModel>
    42 #include <QStandardItemModel>
    44 
    43 
    45 const char *CNT_GROUPACTIONSVIEW_XML = ":/xml/contacts_groupactions.docml";
    44 const char *CNT_GROUPACTIONSVIEW_XML = ":/xml/contacts_groupactions.docml";
    46 
    45 
   121 }
   120 }
   122 
   121 
   123 /*
   122 /*
   124 Activates a default view and setup name label texts
   123 Activates a default view and setup name label texts
   125 */
   124 */
   126 void CntGroupActionsView::activate( CntAbstractViewManager* aMgr, const CntViewParameters aArgs )
   125 void CntGroupActionsView::activate( const CntViewParameters aArgs )
   127 {
   126 {
   128     if (mView->navigationAction() != mSoftkey)
   127     if (mView->navigationAction() != mSoftkey)
   129         mView->setNavigationAction(mSoftkey);   
   128         mView->setNavigationAction(mSoftkey);   
   130     
   129     
   131     mGroupContact = new QContact(aArgs.value(ESelectedGroupContact).value<QContact>());
   130     mGroupContact = new QContact(aArgs.value(ESelectedGroupContact).value<QContact>());
   132     mViewManager = aMgr;
   131     mViewManager = &mEngine->viewManager();
   133 
   132 
   134     QContactName contactName = mGroupContact->detail( QContactName::DefinitionName );
   133     QContactName contactName = mGroupContact->detail( QContactName::DefinitionName );
   135     QString groupName = contactName.value( QContactName::FieldCustomLabel );        
   134     QString groupName = contactName.value( QContactName::FieldCustomLabel );        
   136     if (groupName.isEmpty())
   135     if (groupName.isEmpty())
   137     {
   136     {
   208         mPopupCount=0;
   207         mPopupCount=0;
   209         mEmailActionParams.clear();
   208         mEmailActionParams.clear();
   210         mMessageActionParams.clear();
   209         mMessageActionParams.clear();
   211         
   210         
   212         QString action = mModel->item(index.row())->data(Qt::UserRole+1).toString();
   211         QString action = mModel->item(index.row())->data(Qt::UserRole+1).toString();
       
   212         QContactManager& mgr = mEngine->contactManager( SYMBIAN_BACKEND );
   213         
   213         
   214         //conference call
   214         //conference call
   215         if (action.compare("call", Qt::CaseInsensitive) == 0 ) {
   215         if (action.compare("call", Qt::CaseInsensitive) == 0 ) {
   216             CntActionLauncher* other = new CntActionLauncher(*mViewManager->contactManager(SYMBIAN_BACKEND), action);
   216             CntActionLauncher* other = new CntActionLauncher( mgr, action);
   217             connect(other, SIGNAL(actionExecuted(CntActionLauncher*)), this, SLOT(actionExecuted(CntActionLauncher*)));
   217             connect(other, SIGNAL(actionExecuted(CntActionLauncher*)), this, SLOT(actionExecuted(CntActionLauncher*)));
   218             other->execute(*mGroupContact, QContactDetail());
   218             other->execute(*mGroupContact, QContactDetail());
   219         }
   219         }
   220         //group email, message
   220         //group email, message
   221         else {
   221         else {
   222             QContactRelationshipFilter relationshipFilter;
   222             QContactRelationshipFilter relationshipFilter;
   223             relationshipFilter.setRelationshipType(QContactRelationship::HasMember);
   223             relationshipFilter.setRelationshipType(QContactRelationship::HasMember);
   224             relationshipFilter.setRelatedContactRole(QContactRelationship::First);
   224             relationshipFilter.setRelatedContactRole(QContactRelationship::First);
   225             relationshipFilter.setRelatedContactId(mGroupContact->id());   
   225             relationshipFilter.setRelatedContactId(mGroupContact->id());   
   226             QList<QContactLocalId> groupMembers = mViewManager->contactManager(SYMBIAN_BACKEND)->contactIds(relationshipFilter);
   226             QList<QContactLocalId> groupMembers = mgr.contactIds(relationshipFilter);
   227             
   227             
   228             for (int i = 0;i<groupMembers.count();i++) {
   228             for (int i = 0;i<groupMembers.count();i++) {
   229                 QContact contact = mViewManager->contactManager(SYMBIAN_BACKEND)->contact(groupMembers.at(i));
   229                 QContact contact = mgr.contact(groupMembers.at(i));
   230                 QContactDetail preferredDetail = contact.preferredDetail(action);
   230                 QContactDetail preferredDetail = contact.preferredDetail(action);
   231                 //use preferred detail if exits
   231                 //use preferred detail if exits
   232                 if (!preferredDetail.isEmpty()) {
   232                 if (!preferredDetail.isEmpty()) {
   233                     if(action.compare("message", Qt::CaseInsensitive) == 0) {
   233                     if(action.compare("message", Qt::CaseInsensitive) == 0) {
   234                         QContactPhoneNumber phoneNumber = contact.detail<QContactPhoneNumber>();
   234                         QContactPhoneNumber phoneNumber = contact.detail<QContactPhoneNumber>();
   263                 }
   263                 }
   264                 else if (action.compare("email", Qt::CaseInsensitive) == 0) {
   264                 else if (action.compare("email", Qt::CaseInsensitive) == 0) {
   265                     params.setValue(mEmailActionParams);
   265                     params.setValue(mEmailActionParams);
   266                 }
   266                 }
   267                 map.insert(action,params);
   267                 map.insert(action,params);
   268                 CntActionLauncher* other = new CntActionLauncher(*mViewManager->contactManager(SYMBIAN_BACKEND), action);
   268                 CntActionLauncher* other = new CntActionLauncher(mgr, action);
   269                 connect(other, SIGNAL(actionExecuted(CntActionLauncher*)), this, SLOT(actionExecuted(CntActionLauncher*)));
   269                 connect(other, SIGNAL(actionExecuted(CntActionLauncher*)), this, SLOT(actionExecuted(CntActionLauncher*)));
   270                 other->execute(*mGroupContact, QContactDetail(), map);
   270                 other->execute(*mGroupContact, QContactDetail(), map);
   271             }
   271             }
   272         }
   272         }
   273     }
   273     }
   297         else if (action.compare("email", Qt::CaseInsensitive) == 0) {
   297         else if (action.compare("email", Qt::CaseInsensitive) == 0) {
   298             params.setValue(mEmailActionParams);
   298             params.setValue(mEmailActionParams);
   299         }
   299         }
   300         map.insert(action,params);
   300         map.insert(action,params);
   301         
   301         
   302         CntActionLauncher* other = new CntActionLauncher(*mViewManager->contactManager(SYMBIAN_BACKEND), action);
   302         CntActionLauncher* other = new CntActionLauncher( mEngine->contactManager(SYMBIAN_BACKEND), action);
   303         connect(other, SIGNAL(actionExecuted(CntActionLauncher*)), this, SLOT(actionExecuted(CntActionLauncher*)));
   303         connect(other, SIGNAL(actionExecuted(CntActionLauncher*)), this, SLOT(actionExecuted(CntActionLauncher*)));
   304         other->execute(*mGroupContact, QContactDetail(), map);
   304         other->execute(*mGroupContact, QContactDetail(), map);
   305         }
   305         }
   306 }
   306 }
   307 
   307 
   343     else
   343     else
   344     {
   344     {
   345         mIsExecutingAction = true;
   345         mIsExecutingAction = true;
   346     }
   346     }
   347     
   347     
   348     CntActionLauncher* other = new CntActionLauncher(*mViewManager->contactManager(SYMBIAN_BACKEND), aAction);
   348     CntActionLauncher* other = new CntActionLauncher( mEngine->contactManager(SYMBIAN_BACKEND), aAction);
   349     connect(other, SIGNAL(actionExecuted(CntActionLauncher*)), this, SLOT(actionExecuted(CntActionLauncher*)));
   349     connect(other, SIGNAL(actionExecuted(CntActionLauncher*)), this, SLOT(actionExecuted(CntActionLauncher*)));
   350     other->execute(aContact, aDetail);  
   350     other->execute(aContact, aDetail);  
   351 }
   351 }
   352 
   352 
   353 void CntGroupActionsView::actionCancelled()
   353 void CntGroupActionsView::actionCancelled()