messagingapp/msgui/conversationview/src/msgcontactcardwidget.cpp
changeset 51 3507212d340e
parent 41 25fe1fe642e3
child 56 f42d9a78f435
equal deleted inserted replaced
49:2a272ef608c4 51:3507212d340e
    60 //---------------------------------------------------------------
    60 //---------------------------------------------------------------
    61 // MsgContactCardWidget::MsgContactCardWidget
    61 // MsgContactCardWidget::MsgContactCardWidget
    62 // @see header
    62 // @see header
    63 //---------------------------------------------------------------
    63 //---------------------------------------------------------------
    64 MsgContactCardWidget::MsgContactCardWidget(QGraphicsItem *parent) :
    64 MsgContactCardWidget::MsgContactCardWidget(QGraphicsItem *parent) :
    65     HbWidget(parent), mIgnoreEvents(false), mAvatarIconItem(NULL), mPresenceIconItem(NULL),
    65     HbWidget(parent), mAvatarIconItem(NULL), mPresenceIconItem(NULL),
    66         mAddressTextItem(NULL), mThumbnailManager(NULL)
    66         mAddressTextItem(NULL), mThumbnailManager(NULL)
    67 {
    67 {
    68     init();
    68     init();
    69 }
    69 }
    70 
    70 
   293 // MsgContactCardWidget::handleLongTap
   293 // MsgContactCardWidget::handleLongTap
   294 // @see header file
   294 // @see header file
   295 //---------------------------------------------------------------
   295 //---------------------------------------------------------------
   296 void MsgContactCardWidget::handleLongTap(const QPointF &position)
   296 void MsgContactCardWidget::handleLongTap(const QPointF &position)
   297 {
   297 {
   298     // Check if events need to be ignored/accepted
       
   299     if (mIgnoreEvents) {
       
   300         return;
       
   301     }
       
   302 
       
   303     if (KBluetoothMsgsConversationId != ConversationsEngine::instance()->getCurrentConversationId()) {
   298     if (KBluetoothMsgsConversationId != ConversationsEngine::instance()->getCurrentConversationId()) {
   304         HbMenu* contextMenu = new HbMenu();
   299         HbMenu* contextMenu = new HbMenu();
   305         contextMenu->setDismissPolicy(HbPopup::TapAnywhere);
   300         contextMenu->setDismissPolicy(HbPopup::TapAnywhere);
   306         contextMenu->setAttribute(Qt::WA_DeleteOnClose, true);
   301         contextMenu->setAttribute(Qt::WA_DeleteOnClose, true);
   307         contextMenu->setPreferredPos(position);   
   302         contextMenu->setPreferredPos(position);   
   325 // @see header
   320 // @see header
   326 //---------------------------------------------------------------
   321 //---------------------------------------------------------------
   327 void MsgContactCardWidget::handleShortTap(const QPointF &position)
   322 void MsgContactCardWidget::handleShortTap(const QPointF &position)
   328 {
   323 {
   329     this->ungrabGesture(Qt::TapGesture);
   324     this->ungrabGesture(Qt::TapGesture);
   330     
       
   331     // Check if events need to be ignored/accepted
       
   332     if (mIgnoreEvents) {
       
   333         return;
       
   334     }
       
   335     
   325     
   336     int contactId = resolveContactId(mContactNumber);
   326     int contactId = resolveContactId(mContactNumber);
   337     if(contactId > 0)
   327     if(contactId > 0)
   338     {
   328     {
   339         //resolved contact open contact card.
   329         //resolved contact open contact card.
   454         QList<QContactAvatar> avatarDetails = matchingContacts.at(0).details<QContactAvatar> ();
   444         QList<QContactAvatar> avatarDetails = matchingContacts.at(0).details<QContactAvatar> ();
   455 
   445 
   456         if (!avatarDetails.isEmpty()) {
   446         if (!avatarDetails.isEmpty()) {
   457             mThumbnailManager->getThumbnail(avatarDetails.at(0).imageUrl().toString());
   447             mThumbnailManager->getThumbnail(avatarDetails.at(0).imageUrl().toString());
   458         }
   448         }
       
   449         else {
       
   450             //Set default avatar since avtar is deleted        
       
   451             setAvatar(HbIcon(DEFAULT_AVATAR_ICON));
       
   452         }        
   459 	}
   453 	}
       
   454     else  {
       
   455         //case for deletion from contact card widget
       
   456         //set the default number as address
       
   457         setAddress(mContactNumber);
       
   458         //Set default avatar since contact is deleted
       
   459         setAvatar(HbIcon(DEFAULT_AVATAR_ICON));
       
   460     }
   460 	
   461 	
   461 	// Get the new conversation id.
   462 	// Get the new conversation id.
   462     qint64 convId = ConversationsEngine::instance()->getConversationIdFromAddress(
   463     qint64 convId = ConversationsEngine::instance()->getConversationIdFromAddress(
   463                 mContactNumber);
   464                 mContactNumber);
   464     emit conversationIdChanged(convId);
   465     emit conversationIdChanged(convId);
   515         setAvatar(HbIcon(DEFAULT_AVATAR_ICON));
   516         setAvatar(HbIcon(DEFAULT_AVATAR_ICON));
   516     }
   517     }
   517 }
   518 }
   518 
   519 
   519 //---------------------------------------------------------------
   520 //---------------------------------------------------------------
   520 // MsgContactCardWidget::ignoreSignals
       
   521 // @see header
       
   522 //---------------------------------------------------------------
       
   523 void MsgContactCardWidget::ignoreSignals(bool yes)
       
   524 {
       
   525     mIgnoreEvents = yes;
       
   526 }
       
   527 
       
   528 //---------------------------------------------------------------
       
   529 // MsgContactCardWidget::regrabGesture
   521 // MsgContactCardWidget::regrabGesture
   530 // @see header file
   522 // @see header file
   531 //---------------------------------------------------------------
   523 //---------------------------------------------------------------
   532 void MsgContactCardWidget::regrabGesture()
   524 void MsgContactCardWidget::regrabGesture()
   533 {
   525 {