phonebookui/pbkcommonui/src/cntcontactcarddatacontainer.cpp
changeset 46 efe85016a067
parent 40 b46a585f6909
child 47 7cbcb2896f0e
equal deleted inserted replaced
40:b46a585f6909 46:efe85016a067
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include "cntcontactcarddatacontainer.h"
    18 #include "cntcontactcarddatacontainer.h"
    19 #include "cntcontactcarddataitem.h"
    19 #include "cntcontactcarddataitem.h"
       
    20 #include "cntdetailorderinghelper.h"
    20 #include <cntmaptileservice.h> //For fetching maptile
    21 #include <cntmaptileservice.h> //For fetching maptile
    21 #include "cntuiactionextension.h"
    22 #include "cntuiactionextension.h"
    22 
    23 
    23 #include <QPainter>
    24 #include <QPainter>
    24 #include <QList>
    25 #include <QList>
    42 }
    43 }
    43 
    44 
    44 /*!
    45 /*!
    45 Constructor
    46 Constructor
    46 */
    47 */
    47 CntContactCardDataContainer::CntContactCardDataContainer(QContact* contact, QObject *parent, bool myCard) : mContact(contact), mSeparatorIndex(-1)
    48 CntContactCardDataContainer::CntContactCardDataContainer(QContact* contact, QObject *parent, bool myCard, CntMapTileService* maptile) :
       
    49                                                             mContact(contact), 
       
    50                                                             mSeparatorIndex(-1),
       
    51                                                             mLocationFeatureEnabled(false), 
       
    52                                                             mMaptileInterface(maptile)
    48 {
    53 {
    49     Q_UNUSED(parent);
    54     Q_UNUSED(parent);
    50     if (contact->type() == QContactType::TypeGroup)
    55     if (contact->type() == QContactType::TypeGroup)
    51     {
    56     {
    52         initializeGroupData();
    57         initializeGroupData();
    89             // String list for dynamically extendable actions. Duplicate actions
    94             // String list for dynamically extendable actions. Duplicate actions
    90             // are handled later
    95             // are handled later
    91             extendedActions << action;
    96             extendedActions << action;
    92     }
    97     }
    93 
    98 
    94     QList<QContactPhoneNumber> details = mContact->details<QContactPhoneNumber>();
    99     QList<QContactPhoneNumber> details = CntDetailOrderingHelper::getOrderedSupportedPhoneNumbers(*mContact);
    95     for (int i = 0; i < details.count(); i++)
   100     for (int i = 0; i < details.count(); i++)
    96     { 
   101     { 
    97         //call
   102         //call
    98         if (availableActions.contains("call", Qt::CaseInsensitive) && supportsDetail("call", details[i]))
   103         if (availableActions.contains("call", Qt::CaseInsensitive) && supportsDetail("call", details[i]))
    99         {            
   104         {            
   354 Initialize contact details which not include actions.
   359 Initialize contact details which not include actions.
   355 */
   360 */
   356 void CntContactCardDataContainer::initializeDetailsData()
   361 void CntContactCardDataContainer::initializeDetailsData()
   357 {
   362 {
   358     //sip & internet call
   363     //sip & internet call
   359     QList<QContactOnlineAccount> onlinedDetails = mContact->details<QContactOnlineAccount>();
   364     QList<QContactOnlineAccount> onlinedDetails = CntDetailOrderingHelper::getOrderedSupportedOnlineAccounts(*mContact);
   360     for (int i = 0; i < onlinedDetails.count(); i++)
   365     for (int i = 0; i < onlinedDetails.count(); i++)
   361     {
   366     {
   362         QContactOnlineAccount online(onlinedDetails.at(i));
   367         QContactOnlineAccount online(onlinedDetails.at(i));
   363         QString context = online.contexts().isEmpty() ? QString() : online.contexts().first();
   368         QString context = online.contexts().isEmpty() ? QString() : online.contexts().first();
   364         QString subtype = online.subTypes().isEmpty() ? online.definitionName() : online.subTypes().first();
   369         QString subtype = online.subTypes().isEmpty() ? online.definitionName() : online.subTypes().first();
   377     
   382     
   378     //address
   383     //address
   379     QString contextHome(QContactAddress::ContextHome.operator QString());
   384     QString contextHome(QContactAddress::ContextHome.operator QString());
   380     QString contextWork(QContactAddress::ContextWork.operator QString());
   385     QString contextWork(QContactAddress::ContextWork.operator QString());
   381     CntMapTileService::ContactAddressType sourceAddressType;  
   386     CntMapTileService::ContactAddressType sourceAddressType;  
   382     mLocationFeatureEnabled = CntMapTileService::isLocationFeatureEnabled() ;
   387     if( mMaptileInterface )
       
   388     {
       
   389         mLocationFeatureEnabled = mMaptileInterface->isLocationFeatureEnabled() ;
       
   390     }
   383 
   391 
   384     QList<QContactAddress> addressDetails = mContact->details<QContactAddress>();
   392     QList<QContactAddress> addressDetails = mContact->details<QContactAddress>();
   385     for (int i = 0; i < addressDetails.count(); i++)
   393     for (int i = 0; i < addressDetails.count(); i++)
   386     {
   394     {
   387         sourceAddressType = CntMapTileService::AddressPreference;
   395         sourceAddressType = CntMapTileService::AddressPreference;
   420             address.append(addressDetails[i].locality());
   428             address.append(addressDetails[i].locality());
   421         if (!addressDetails[i].region().isEmpty())
   429         if (!addressDetails[i].region().isEmpty())
   422             address.append(addressDetails[i].region());
   430             address.append(addressDetails[i].region());
   423         if (!addressDetails[i].country().isEmpty())
   431         if (!addressDetails[i].country().isEmpty())
   424             address.append(addressDetails[i].country());
   432             address.append(addressDetails[i].country());
   425                 
   433 	    bool maptileAvailable = false;
       
   434 		QString imageFile;
       
   435 		
       
   436 		if( mLocationFeatureEnabled && mMaptileInterface )
       
   437         {
       
   438         
       
   439             QContactLocalId contactId = mContact->id().localId();
       
   440             
       
   441 			      //Get the maptile image path
       
   442             int status = mMaptileInterface->getMapTileImage(
       
   443                         contactId, sourceAddressType, imageFile );
       
   444                  
       
   445             if( status == CntMapTileService::MapTileFetchingInProgress || status == 
       
   446                     CntMapTileService::MapTileFetchingNetworkError )
       
   447             {
       
   448                 //Load the progress indicator icon
       
   449                 QString iconName("qtg_anim_small_loading_1");
       
   450                 HbIcon inProgressIcon(iconName);
       
   451                 dataItem->setSecondaryIcon( inProgressIcon );
       
   452             }
       
   453             else if( status == CntMapTileService::MapTileFetchingUnknownError || 
       
   454                         status == CntMapTileService::MapTileFetchingInvalidAddress  )
       
   455             {
       
   456                 //Load the search stop icon
       
   457                 QString iconName("qtg_mono_search_stop");
       
   458                 HbIcon stopIcon(iconName);
       
   459                 dataItem->setSecondaryIcon( stopIcon );
       
   460             }
       
   461             else if( status == CntMapTileService::MapTileFetchingCompleted )
       
   462             {
       
   463                 maptileAvailable = true;
       
   464             }
       
   465         }
   426         dataItem->setValueText(address.join(" "));
   466         dataItem->setValueText(address.join(" "));
   427         dataItem->setContactDetail(addressDetails[i]);
   467         dataItem->setContactDetail(addressDetails[i]);
   428         addSeparator(itemCount());
   468         addSeparator(itemCount());
   429         mDataItemList.append(dataItem);
   469         mDataItemList.append(dataItem);
   430         
   470         
   431         //Check whether location feature enabled
   471         //Check whether location feature enabled
   432         if (mLocationFeatureEnabled)
   472         if ( mLocationFeatureEnabled && maptileAvailable && !imageFile.isNull() )
   433         {
   473         {
   434             QContactLocalId contactId = mContact->id().localId();
   474             //Display the maptile image
   435          
   475             HbIcon icon(imageFile);
   436             //Get the maptile image path
   476             if( !icon.isNull() )
   437             QString imageFile = CntMapTileService::getMapTileImage(contactId, sourceAddressType);
   477             {
   438         
       
   439 		        if ( !imageFile.isNull() )
       
   440 		        {   
       
   441 		            //Display the maptile image
       
   442                 HbIcon icon(imageFile);
       
   443                 
       
   444                 CntContactCardDataItem* dataItem = new CntContactCardDataItem(QString(), position, false);
   478                 CntContactCardDataItem* dataItem = new CntContactCardDataItem(QString(), position, false);
   445                 dataItem->setIcon(icon);
   479                 dataItem->setIcon(icon);
   446                 addSeparator(itemCount());
   480                 addSeparator(itemCount());
   447                 mDataItemList.append(dataItem);
   481                 mDataItemList.append(dataItem);
   448 		       }
   482 		       }
   653     }
   687     }
   654     else if (aId == QContactPhoneNumber::SubTypeLandline && aContext == QContactDetail::ContextWork && !dynamicAction)
   688     else if (aId == QContactPhoneNumber::SubTypeLandline && aContext == QContactDetail::ContextWork && !dynamicAction)
   655     {
   689     {
   656         position = CntContactCardDataItem::ECallPhoneWork;
   690         position = CntContactCardDataItem::ECallPhoneWork;
   657     }
   691     }
   658     else if (aId == QContactPhoneNumber::SubTypeFacsimile && aContext.isEmpty() && !dynamicAction)
   692     else if (aId == QContactPhoneNumber::SubTypeFax && aContext.isEmpty() && !dynamicAction)
   659     {
   693     {
   660         position = CntContactCardDataItem::ECallFax;
   694         position = CntContactCardDataItem::ECallFax;
   661     }
   695     }
   662     else if (aId == QContactPhoneNumber::SubTypeFacsimile && aContext == QContactDetail::ContextHome && !dynamicAction)
   696     else if (aId == QContactPhoneNumber::SubTypeFax && aContext == QContactDetail::ContextHome && !dynamicAction)
   663     {
   697     {
   664         position = CntContactCardDataItem::ECallFaxHome;
   698         position = CntContactCardDataItem::ECallFaxHome;
   665     }
   699     }
   666     else if (aId == QContactPhoneNumber::SubTypeFacsimile && aContext == QContactDetail::ContextWork && !dynamicAction)
   700     else if (aId == QContactPhoneNumber::SubTypeFax && aContext == QContactDetail::ContextWork && !dynamicAction)
   667     {
   701     {
   668         position = CntContactCardDataItem::ECallFaxWork;
   702         position = CntContactCardDataItem::ECallFaxWork;
   669     }
   703     }
   670     else if (aId == QContactPhoneNumber::SubTypePager && aContext.isEmpty() && !dynamicAction)
   704     else if (aId == QContactPhoneNumber::SubTypePager && aContext.isEmpty() && !dynamicAction)
   671     {
   705     {
   786     {
   820     {
   787         position = CntContactCardDataItem::ELastActionWork;
   821         position = CntContactCardDataItem::ELastActionWork;
   788     }
   822     }
   789     else if (!dynamicAction)
   823     else if (!dynamicAction)
   790     {
   824     {
   791         position = CntContactCardDataItem::EOther;
   825         position = CntContactCardDataItem::ENotSupported;
   792     }
   826     }
   793     else
   827     else
   794     {
   828     {
   795         position = CntContactCardDataItem::EDynamic;
   829         position = CntContactCardDataItem::EDynamic;
   796     }
   830     }