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( |