phonebookui/pbkcommonui/src/cntactionmenubuilder.cpp
changeset 37 fd64c38c277d
parent 31 2a11b5b00470
child 40 b46a585f6909
equal deleted inserted replaced
31:2a11b5b00470 37:fd64c38c277d
    49         foreach ( QContactActionDescriptor d, aContact.availableActions() )
    49         foreach ( QContactActionDescriptor d, aContact.availableActions() )
    50             {
    50             {
    51             actions << d.actionName();
    51             actions << d.actionName();
    52             }
    52             }
    53         
    53         
    54         if ( actions.contains("call", Qt::CaseInsensitive) )
    54         if ( actions.contains("call", Qt::CaseInsensitive) && isSupportedDetails("call", aContact))
    55             {
    55             {
    56             createCallAction( *menu, aContact );
    56             createCallAction( *menu, aContact );
    57             }
    57             }
    58         
    58         
    59         if ( actions.contains("message", Qt::CaseInsensitive) )
    59         if ( actions.contains("message", Qt::CaseInsensitive) && isSupportedDetails("message", aContact) )
    60             {
    60             {
    61             createMessageAction( *menu, aContact );
    61             createMessageAction( *menu, aContact );
    62             }
    62             }
    63         
    63         
    64         if ( actions.contains("email", Qt::CaseInsensitive) )
    64         if ( actions.contains("email", Qt::CaseInsensitive) )
    78         menu->addAction(hbTrId("txt_common_menu_delete_contact"), this, SLOT(emitDeleteContact()));
    78         menu->addAction(hbTrId("txt_common_menu_delete_contact"), this, SLOT(emitDeleteContact()));
    79         }
    79         }
    80     return menu;
    80     return menu;
    81     }
    81     }
    82 
    82 
    83 HbMenu* CntActionMenuBuilder::actionMenu( QContact& aContact )
    83 HbMenu* CntActionMenuBuilder::actionMenu( QContact& aContact, QContactLocalId myCardId)
    84 {
    84 {
       
    85     iMyCardId = myCardId;
    85     mContact = new QContact( aContact );
    86     mContact = new QContact( aContact );
    86     return buildActionMenu( aContact );
    87     return buildActionMenu( aContact );
    87 }
    88 }
    88 
    89 
    89 void CntActionMenuBuilder::emitOpenContact()
    90 void CntActionMenuBuilder::emitOpenContact()
   141     {
   142     {
   142     Q_UNUSED( aContact );
   143     Q_UNUSED( aContact );
   143     
   144     
   144     aMenu.addAction(hbTrId("txt_phob_menu_send_message"), this, SLOT(emitSmsContact()));
   145     aMenu.addAction(hbTrId("txt_phob_menu_send_message"), this, SLOT(emitSmsContact()));
   145     }
   146     }
       
   147 
       
   148 bool CntActionMenuBuilder::isSupportedDetails( const QString &actionName, const QContact &contact )
       
   149     {
       
   150     QList<QContactActionDescriptor> actionDescriptors = QContactAction::actionDescriptors(actionName, "symbian");
       
   151     if (actionDescriptors.isEmpty())
       
   152         {
       
   153         return false;
       
   154         }
       
   155     
       
   156     QContactAction* contactAction = QContactAction::action(actionDescriptors.first()); 
       
   157     QList<QContactDetail> details = contactAction->supportedDetails(contact);
       
   158 
       
   159     delete contactAction;
       
   160     
       
   161     for (int i = 0; i < details.count(); i++)
       
   162         {
       
   163         if (contact.details().contains(details[i]))
       
   164             {
       
   165             return true;
       
   166             }
       
   167         }
       
   168     
       
   169     return false;
       
   170     }
   146     
   171     
   147 // End of File
   172 // End of File