messagingapp/msgui/conversationview/src/msgcontactcardwidget.cpp
changeset 73 ecf6a73a9186
parent 67 fc91263aee62
child 76 60a8a215b0ec
equal deleted inserted replaced
68:e8a69c93c830 73:ecf6a73a9186
    34 #include <HbMenu>
    34 #include <HbMenu>
    35 #include <thumbnailmanager_qt.h>
    35 #include <thumbnailmanager_qt.h>
    36 #include <QTimer>
    36 #include <QTimer>
    37 
    37 
    38 #include <ccsdefs.h>
    38 #include <ccsdefs.h>
       
    39 #include <debugtraces.h>
    39 
    40 
    40 // USER INCLUDES
    41 // USER INCLUDES
    41 #include "conversationsenginedefines.h"
    42 #include "conversationsenginedefines.h"
    42 #include "conversationsengine.h"
    43 #include "conversationsengine.h"
    43 #include "convergedmessage.h"
    44 #include "convergedmessage.h"
    48 const QString DEFAULT_AVATAR_ICON("qtg_large_avatar");
    49 const QString DEFAULT_AVATAR_ICON("qtg_large_avatar");
    49 const QString BT_ICON("qtg_large_bluetooth");
    50 const QString BT_ICON("qtg_large_bluetooth");
    50 const QString BG_FRAME_NORMAL("qtg_fr_groupbox_normal");
    51 const QString BG_FRAME_NORMAL("qtg_fr_groupbox_normal");
    51 const QString BG_FRAME_PRESSED("qtg_fr_groupbox_pressed");
    52 const QString BG_FRAME_PRESSED("qtg_fr_groupbox_pressed");
    52 
    53 
       
    54 static const char PLUS[] = "+";
       
    55 
    53 // LOCALIZATION CONSTANTS
    56 // LOCALIZATION CONSTANTS
    54 #define LOC_RECEIVED_FILES hbTrId("txt_messaging_title_received_files")
    57 #define LOC_RECEIVED_FILES hbTrId("txt_messaging_title_received_files")
    55 #define LOC_MENU_CONTACT_INFO hbTrId("txt_messaging_menu_contact_info")
    58 #define LOC_MENU_CONTACT_INFO hbTrId("txt_messaging_menu_contact_info")
    56 #define LOC_COMMON_MENU_CALL hbTrId("txt_common_menu_call_verb")
    59 #define LOC_COMMON_MENU_CALL hbTrId("txt_common_menu_call_verb")
    57 #define LOC_SAVETO_CONTACTS hbTrId("txt_messaging_menu_save_to_contacts")
    60 #define LOC_SAVETO_CONTACTS hbTrId("txt_messaging_menu_save_to_contacts")
   139 // MsgContactCardWidget::address
   142 // MsgContactCardWidget::address
   140 // @see header
   143 // @see header
   141 //---------------------------------------------------------------
   144 //---------------------------------------------------------------
   142 ConvergedMessageAddressList MsgContactCardWidget::address()
   145 ConvergedMessageAddressList MsgContactCardWidget::address()
   143 {
   146 {
       
   147     QCRITICAL_WRITE("MsgContactCardWidget::address start.")
   144     ConvergedMessageAddressList addresses;
   148     ConvergedMessageAddressList addresses;
   145     QStandardItemModel* msgModel = ConversationsEngine::instance()->getConversationsModel();
   149     QStandardItemModel* msgModel = ConversationsEngine::instance()->getConversationsModel();
       
   150     
   146     const int rowCnt = msgModel->rowCount();
   151     const int rowCnt = msgModel->rowCount();
   147     QModelIndex index = msgModel->index(rowCnt-1, 0);
   152     
   148     QString addr = index.data(ConversationAddress).toString();
   153     QModelIndex recentIndex = msgModel->index(rowCnt-1, 0);
       
   154     QString recentAddr = recentIndex.data(ConversationAddress).toString();
       
   155     
       
   156     
       
   157     QModelIndexList indexList = msgModel->match(msgModel->index(0, 0), SendingState,
       
   158         ConvergedMessage::SentState, -1, Qt::MatchExactly);
       
   159 
       
   160     QString addr;
       
   161     
       
   162     bool found = false;
       
   163     if(indexList.count() > 0)
       
   164     {
       
   165         QCRITICAL_WRITE("MsgContactCardWidget::address indexList.")
       
   166         for (int i = indexList.count()-1; i >= 0; --i) 
       
   167         {
       
   168             addr = indexList[i].data(ConversationAddress).toString();
       
   169             if (addr.length() >= recentAddr.length() && addr.endsWith(recentAddr)) 
       
   170             {
       
   171               QCRITICAL_WRITE("MsgContactCardWidget::address inside for indexList.")
       
   172 			  found = true; 
       
   173               break;
       
   174             }
       
   175         }
       
   176         
       
   177     }
       
   178     else 
       
   179     {   
       
   180         QCRITICAL_WRITE("MsgContactCardWidget::address inside else of indexList.")
       
   181         for(int i=rowCnt-1; i>=0;--i)
       
   182             {
       
   183             QModelIndex index = msgModel->index(i, 0);
       
   184             addr = index.data(ConversationAddress).toString();
       
   185             if(addr.startsWith(PLUS) && addr.length() >= recentAddr.length() && addr.endsWith(recentAddr))
       
   186                 {
       
   187                 found = true; 
       
   188                 break;
       
   189                 }
       
   190             }
       
   191            
       
   192     }
       
   193     
       
   194     if (!found) 
       
   195     {
       
   196         addr = recentAddr;
       
   197     }
       
   198     
   149     ConvergedMessageAddress* address = new ConvergedMessageAddress(addr);
   199     ConvergedMessageAddress* address = new ConvergedMessageAddress(addr);
   150     // resolve contact
   200     // resolve contact
   151     QString displayname;
   201     QString displayname;
   152     int count;
   202     int count;
   153     int retval = MsgContactHandler::resolveContactDisplayName(
   203     int retval = MsgContactHandler::resolveContactDisplayName(
   155     if(retval != -1)
   205     if(retval != -1)
   156     {
   206     {
   157         address->setAlias(displayname);
   207         address->setAlias(displayname);
   158     }
   208     }
   159     addresses.append(address);
   209     addresses.append(address);
       
   210     QCRITICAL_WRITE("MsgContactCardWidget::address end.")
   160     return addresses;
   211     return addresses;
   161 }
   212 }
   162 
   213 
   163 //---------------------------------------------------------------
   214 //---------------------------------------------------------------
   164 // MsgContactCardWidget::updateContents
   215 // MsgContactCardWidget::updateContents