phonebookui/pbkcommonui/src/cntcontactcarddatacontainer.cpp
changeset 71 7cc7d74059f9
parent 65 ae724a111993
equal deleted inserted replaced
65:ae724a111993 71:7cc7d74059f9
    53     MapTileService* maptile,
    53     MapTileService* maptile,
    54     CntExtensionManager& aExtensionManager,
    54     CntExtensionManager& aExtensionManager,
    55     Qt::Orientations orientation,
    55     Qt::Orientations orientation,
    56     QObject *parent) :
    56     QObject *parent) :
    57             mContact(NULL), 
    57             mContact(NULL), 
       
    58             mCallAction(NULL),
       
    59             mMessageAction(NULL),
    58             mSeparatorIndex(-1),
    60             mSeparatorIndex(-1),
    59             mLocationFeatureEnabled(false), 
    61             mLocationFeatureEnabled(false), 
    60             mMaptileInterface(maptile),
    62             mMaptileInterface(maptile),
    61             mOrientation( orientation ),
    63             mOrientation( orientation ),
    62             mExtensionManager( &aExtensionManager )
    64             mExtensionManager( &aExtensionManager )
    63 {
    65 {
    64     Q_UNUSED(parent); 
    66     Q_UNUSED(parent); 
       
    67     QList<QContactActionDescriptor> callActionDescriptors = QContactAction::actionDescriptors("call", "symbian");
       
    68     if (!callActionDescriptors.isEmpty())
       
    69     {
       
    70         mCallAction = QContactAction::action(callActionDescriptors.first());
       
    71     }
       
    72     QList<QContactActionDescriptor> messageActionDescriptors = QContactAction::actionDescriptors("message", "symbian");
       
    73     if (!messageActionDescriptors.isEmpty())
       
    74     {
       
    75         mMessageAction = QContactAction::action(messageActionDescriptors.first());
       
    76     }
    65 }
    77 }
    66 
    78 
    67 void CntContactCardDataContainer::setContactData(QContact* contact, bool aMyCard)
    79 void CntContactCardDataContainer::setContactData(QContact* contact, bool aMyCard)
    68 {
    80 {
    69     clearContactData();
    81     clearContactData();
    86 Destructor
    98 Destructor
    87 */
    99 */
    88 CntContactCardDataContainer::~CntContactCardDataContainer()
   100 CntContactCardDataContainer::~CntContactCardDataContainer()
    89 {
   101 {
    90     clearContactData();
   102     clearContactData();
       
   103     delete mCallAction;
       
   104     mCallAction = NULL;
       
   105     delete mMessageAction;
       
   106     mMessageAction = NULL;
    91 }
   107 }
    92 
   108 
    93 void CntContactCardDataContainer::clearContactData()
   109 void CntContactCardDataContainer::clearContactData()
    94 {
   110 {
    95     qDeleteAll(mDataItemList);
   111     qDeleteAll(mDataItemList);
   284                     delete contactAction;
   300                     delete contactAction;
   285                 }
   301                 }
   286             }
   302             }
   287         }
   303         }
   288     }
   304     }
   289     
   305 
   290     // This is special action case. Here we query implementations that are generic
   306     // This is special action case. Here we query implementations that are generic
   291     // to contact, so it's not linked to any detail(usually generic my card actions).
   307     // to contact, so it's not linked to any detail(usually generic my card actions).
   292     for(int j = 0; j < extendedActions.count(); j++)
   308     for(int j = 0; j < extendedActions.count(); j++)
   293     {
   309     {
   294         QList<QContactActionDescriptor> actionDescriptors = QContactAction::actionDescriptors(extendedActions[j]);
   310         QList<QContactActionDescriptor> actionDescriptors = QContactAction::actionDescriptors(extendedActions[j]);
   473             {
   489             {
   474                 sourceAddressType = MapTileService::AddressWork;
   490                 sourceAddressType = MapTileService::AddressWork;
   475                 title = hbTrId("txt_phob_formlabel_address_work");
   491                 title = hbTrId("txt_phob_formlabel_address_work");
   476                 position = CntContactCardDataItem::EAddressWork;
   492                 position = CntContactCardDataItem::EAddressWork;
   477             }
   493             }
       
   494             else
       
   495             {
       
   496                 title = hbTrId("txt_phob_formlabel_address");
       
   497                 position = CntContactCardDataItem::EAddress;
       
   498             }
   478         }
   499         }
   479         CntContactCardDataItem* dataItem = new CntContactCardDataItem(title, position, false);
   500         CntContactCardDataItem* dataItem = new CntContactCardDataItem(title, position, false);
   480         
   501         
   481         QStringList address;
   502         QStringList address;
   482         if (!addressDetails[i].street().isEmpty())
   503         if (!addressDetails[i].street().isEmpty())
   655 
   676 
   656 /*!
   677 /*!
   657 Returns true if contactDetails contains spesific action.
   678 Returns true if contactDetails contains spesific action.
   658 */
   679 */
   659 bool CntContactCardDataContainer::supportsDetail(const QString &actionName, const QContactDetail &contactDetail)
   680 bool CntContactCardDataContainer::supportsDetail(const QString &actionName, const QContactDetail &contactDetail)
   660 {    
   681 {
   661     QList<QContactActionDescriptor> actionDescriptors = QContactAction::actionDescriptors(actionName, "symbian");
   682     QContactAction* action = NULL;
   662     if (actionDescriptors.isEmpty())
   683 
   663     {
   684     if (actionName == "call") {
   664         return false;
   685         action = mCallAction;
   665     }
   686     } else if (actionName == "message") {
   666     
   687         action = mMessageAction;
   667     QContactAction* contactAction = QContactAction::action(actionDescriptors.first());
   688     }
   668     bool isSupportDetail = contactAction->isDetailSupported(contactDetail);
   689     
   669     
   690     return (action != NULL && action->isDetailSupported(contactDetail));
   670     delete contactAction;
       
   671     
       
   672     return isSupportDetail;
       
   673 }
   691 }
   674 
   692 
   675 /*!
   693 /*!
   676 Returns the list of details which current action support.
   694 Returns the list of details which current action support.
   677 */
   695 */