19 |
19 |
20 // SYSTEM INCLUDES |
20 // SYSTEM INCLUDES |
21 #include <HbStyle> |
21 #include <HbStyle> |
22 #include <HbIconItem> |
22 #include <HbIconItem> |
23 #include <HbTextItem> |
23 #include <HbTextItem> |
24 #include <HbFrameDrawer> |
24 #include <HbTapGesture> |
25 #include <HbGesture> |
25 #include <HbInstantFeedback> |
26 #include <HbGestureSceneFilter> |
|
27 #include <HbWidgetFeedback> |
|
28 #include <HbFrameItem> |
26 #include <HbFrameItem> |
29 #include <qmobilityglobal.h> |
|
30 #include <qcontactphonenumber.h> |
27 #include <qcontactphonenumber.h> |
31 #include <qcontactfilter.h> |
28 #include <qcontactavatar.h> |
32 #include <qcontactmanager.h> |
|
33 #include <qcontactdetailfilter.h> |
|
34 #include <xqaiwrequest.h> |
29 #include <xqaiwrequest.h> |
35 #include <xqappmgr.h> |
30 #include <xqappmgr.h> |
36 #include <XQServiceRequest.h> |
31 #include <xqservicerequest.h> |
37 #include <cntservicescontact.h> |
32 #include <cntservicescontact.h> |
38 #include <QGraphicsSceneMouseEvent> |
33 #include <QGraphicsSceneMouseEvent> |
39 #include <HbMenu> |
34 #include <HbMenu> |
40 #include <HbMainWindow> |
35 #include <thumbnailmanager_qt.h> |
|
36 #include <QTimer> |
41 |
37 |
42 #include <ccsdefs.h> |
38 #include <ccsdefs.h> |
43 |
39 |
44 // USER INCLUDES |
40 // USER INCLUDES |
45 #include "conversationsenginedefines.h" |
41 #include "conversationsenginedefines.h" |
46 #include "debugtraces.h" |
|
47 #include "conversationsengine.h" |
42 #include "conversationsengine.h" |
48 #include "convergedmessage.h" |
43 #include "convergedmessage.h" |
49 |
44 #include "msgcontacthandler.h" |
50 QTM_USE_NAMESPACE |
|
51 |
45 |
52 // LOCAL CONSTANTS |
46 // LOCAL CONSTANTS |
53 const QString DEFAULT_AVATAR_ICON("qtg_large_avatar"); |
47 const QString DEFAULT_AVATAR_ICON("qtg_large_avatar"); |
54 const QString BT_ICON("qtg_large_bluetooth"); |
48 const QString BT_ICON("qtg_large_bluetooth"); |
55 const QString BACKGROUND_FRAME_NORMAL("qtg_fr_groupbox"); |
49 const QString BG_FRAME_NORMAL("qtg_fr_groupbox_normal"); |
56 const QString GROUPBOX_BG_FRAME_PRESSED("qtg_fr_groupbox_pressed"); |
50 const QString BG_FRAME_PRESSED("qtg_fr_groupbox_pressed"); |
57 |
|
58 const QString PLUGINPATH("conversationviewplugin.dll"); |
|
59 |
51 |
60 // LOCALIZATION CONSTANTS |
52 // LOCALIZATION CONSTANTS |
61 #define LOC_RECEIVED_FILES hbTrId("txt_messaging_title_received_files") |
53 #define LOC_RECEIVED_FILES hbTrId("txt_messaging_title_received_files") |
62 #define LOC_MENU_CONTACT_INFO hbTrId("txt_messaging_menu_open_contact_info") |
54 #define LOC_MENU_CONTACT_INFO hbTrId("txt_messaging_menu_contact_info") |
63 #define LOC_COMMON_MENU_CALL hbTrId("txt_common_menu_call_verb") |
55 #define LOC_COMMON_MENU_CALL hbTrId("txt_common_menu_call_verb") |
64 #define LOC_SAVETO_CONTACTS hbTrId("txt_messaging_menu_save_to_contacts") |
56 #define LOC_SAVETO_CONTACTS hbTrId("txt_messaging_menu_save_to_contacts") |
65 |
57 |
|
58 // LOCAL FUNCTIONS |
|
59 |
66 //--------------------------------------------------------------- |
60 //--------------------------------------------------------------- |
67 // MsgContactCardWidget::MsgContactCardWidget |
61 // MsgContactCardWidget::MsgContactCardWidget |
68 // @see header |
62 // @see header |
69 //--------------------------------------------------------------- |
63 //--------------------------------------------------------------- |
70 MsgContactCardWidget::MsgContactCardWidget(QGraphicsItem *parent) : |
64 MsgContactCardWidget::MsgContactCardWidget(QGraphicsItem *parent) : |
71 HbWidget(parent), |
65 HbWidget(parent), mIgnoreEvents(false), mAvatarIconItem(NULL), mPresenceIconItem(NULL), |
72 mMenuShown(false), |
66 mAddressTextItem(NULL), mThumbnailManager(NULL) |
73 mAvatarIconItem(NULL), |
67 { |
74 mPresenceIconItem(NULL), |
68 init(); |
75 mAddressTextItem(NULL), |
|
76 mGestureFilter(NULL) |
|
77 |
|
78 { |
|
79 int baseId = style()->registerPlugin(PLUGINPATH); |
|
80 QDEBUG_WRITE_FORMAT("MsgContactCardWidget BASE ID --->", baseId); |
|
81 setPluginBaseId(baseId); |
|
82 |
|
83 init(); |
|
84 setBackGround(BACKGROUND_FRAME_NORMAL); |
|
85 connectSignals(true); |
|
86 |
|
87 connect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(initGesture())); |
|
88 } |
69 } |
89 |
70 |
90 //--------------------------------------------------------------- |
71 //--------------------------------------------------------------- |
91 // MsgContactCardWidget::~MsgContactCardWidget |
72 // MsgContactCardWidget::~MsgContactCardWidget |
92 // @see header |
73 // @see header |
93 //--------------------------------------------------------------- |
74 //--------------------------------------------------------------- |
94 MsgContactCardWidget::~MsgContactCardWidget() |
75 MsgContactCardWidget::~MsgContactCardWidget() |
95 { |
76 { |
96 style()->unregisterPlugin(PLUGINPATH); |
|
97 |
|
98 if(mGestureFilter) |
|
99 { |
|
100 removeSceneEventFilter(mGestureFilter); |
|
101 } |
|
102 } |
77 } |
103 |
78 |
104 //--------------------------------------------------------------- |
79 //--------------------------------------------------------------- |
105 // MsgContactCardWidget::init |
80 // MsgContactCardWidget::init |
106 // @see header |
81 // @see header |
107 //--------------------------------------------------------------- |
82 //--------------------------------------------------------------- |
108 void MsgContactCardWidget::init() |
83 void MsgContactCardWidget::init() |
109 { |
84 { |
|
85 this->setProperty("state", "normal"); |
|
86 this->grabGesture(Qt::TapGesture); |
|
87 |
|
88 HbFrameItem *frameItem = new HbFrameItem(BG_FRAME_NORMAL, HbFrameDrawer::NinePieces, this); |
|
89 this->setBackgroundItem(frameItem); |
|
90 |
110 mAvatarIconItem = new HbIconItem(this); |
91 mAvatarIconItem = new HbIconItem(this); |
111 HbStyle::setItemName(mAvatarIconItem, "avatar"); |
92 HbStyle::setItemName(mAvatarIconItem, "avatar"); |
112 |
93 |
113 mPresenceIconItem = new HbIconItem(this); |
94 mPresenceIconItem = new HbIconItem(this); |
114 HbStyle::setItemName(mPresenceIconItem, "presence"); |
95 HbStyle::setItemName(mPresenceIconItem, "presence"); |
115 |
96 |
116 mAddressTextItem = new HbTextItem(this); |
97 mAddressTextItem = new HbTextItem(this); |
117 HbStyle::setItemName(mAddressTextItem, "addressText"); |
98 HbStyle::setItemName(mAddressTextItem, "addressText"); |
118 |
99 |
|
100 mThumbnailManager = new ThumbnailManager(this); |
|
101 mThumbnailManager->setMode(ThumbnailManager::Default); |
|
102 mThumbnailManager->setQualityPreference(ThumbnailManager::OptimizeForQuality); |
|
103 mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailLarge); |
|
104 |
|
105 connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void*, int, int)), this, |
|
106 SLOT(thumbnailReady(QPixmap, void*, int, int))); |
119 } |
107 } |
120 |
108 |
121 //--------------------------------------------------------------- |
109 //--------------------------------------------------------------- |
122 // MsgContactCardWidget::setAvatar |
110 // MsgContactCardWidget::setAvatar |
123 // @see header |
111 // @see header |
225 setAddress(""); |
221 setAddress(""); |
226 setAvatar(HbIcon()); |
222 setAvatar(HbIcon()); |
227 } |
223 } |
228 |
224 |
229 //--------------------------------------------------------------- |
225 //--------------------------------------------------------------- |
230 // MsgContactCardWidget::initGesture |
226 // MsgContactCardWidget::gestureEvent |
231 // @see header file |
227 // @see header file |
232 //--------------------------------------------------------------- |
228 //--------------------------------------------------------------- |
233 void MsgContactCardWidget::initGesture() |
229 void MsgContactCardWidget::gestureEvent(QGestureEvent *event) |
234 { |
230 { |
235 // Create gesture filter |
231 HbTapGesture *tapGesture = qobject_cast<HbTapGesture*> (event->gesture(Qt::TapGesture)); |
236 QGraphicsScene* sc = this->scene(); |
232 if (tapGesture) { |
237 mGestureFilter = new HbGestureSceneFilter( Qt::LeftButton, this ); |
233 switch (tapGesture->state()) { |
238 |
234 case Qt::GestureStarted: |
239 // Add gestures for longpress |
235 { |
240 HbGesture* gestureLongpressed = new HbGesture( HbGesture::longpress,5 ); |
236 // Trigger haptic feedback. |
241 |
237 HbInstantFeedback::play(HbFeedback::Basic); |
242 mGestureFilter->addGesture( gestureLongpressed ); |
238 setPressed(true); |
243 |
239 break; |
244 connect( gestureLongpressed, SIGNAL(longPress(QPointF)), |
240 } |
245 this, SLOT(handleLongPress(QPointF))); |
241 case Qt::GestureUpdated: |
246 |
242 { |
247 //install gesture filter. |
243 if (HbTapGesture::TapAndHold == tapGesture->tapStyleHint()) { |
248 this->installSceneEventFilter(mGestureFilter); |
244 // Handle longtap. |
249 |
245 setPressed(false); |
250 disconnect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(initGesture())); |
246 handleLongTap(tapGesture->scenePosition()); |
251 } |
247 } |
252 |
248 break; |
253 //--------------------------------------------------------------- |
249 } |
254 // MsgContactCardWidget::mousePressEvent |
250 case Qt::GestureFinished: |
|
251 { |
|
252 HbInstantFeedback::play(HbFeedback::Basic); |
|
253 if (HbTapGesture::Tap == tapGesture->tapStyleHint()) { |
|
254 // Handle short tap. |
|
255 setPressed(false); |
|
256 handleShortTap(tapGesture->scenePosition()); |
|
257 } |
|
258 break; |
|
259 } |
|
260 case Qt::GestureCanceled: |
|
261 { |
|
262 HbInstantFeedback::play(HbFeedback::Basic); |
|
263 setPressed(false); |
|
264 break; |
|
265 } |
|
266 } |
|
267 } |
|
268 else { |
|
269 HbWidget::gestureEvent(event); |
|
270 } |
|
271 } |
|
272 |
|
273 //--------------------------------------------------------------- |
|
274 // MsgContactCardWidget::setPressed |
255 // @see header file |
275 // @see header file |
256 //--------------------------------------------------------------- |
276 //--------------------------------------------------------------- |
257 void MsgContactCardWidget::mousePressEvent(QGraphicsSceneMouseEvent *event) |
277 void MsgContactCardWidget::setPressed(bool pressed) |
258 { |
278 { |
259 mMenuShown = false; |
279 HbFrameItem *frameItem = static_cast<HbFrameItem *> (this->backgroundItem()); |
260 |
280 if (pressed) { |
261 HbWidgetFeedback::triggered(this, Hb::InstantPressed); |
281 this->setProperty("state", "pressed"); |
262 |
282 frameItem->frameDrawer().setFrameGraphicsName(BG_FRAME_PRESSED); |
263 setBackGround(GROUPBOX_BG_FRAME_PRESSED); |
283 } |
264 |
284 else { |
265 event->accept(); |
285 this->setProperty("state", "normal"); |
266 } |
286 frameItem->frameDrawer().setFrameGraphicsName(BG_FRAME_NORMAL); |
267 |
287 } |
268 |
288 } |
269 //--------------------------------------------------------------- |
289 |
270 // MsgContactCardWidget::mouseReleaseEvent |
290 //--------------------------------------------------------------- |
|
291 // MsgContactCardWidget::handleLongTap |
271 // @see header file |
292 // @see header file |
272 //--------------------------------------------------------------- |
293 //--------------------------------------------------------------- |
273 void MsgContactCardWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
294 void MsgContactCardWidget::handleLongTap(const QPointF &position) |
274 { |
295 { |
275 setBackGround(BACKGROUND_FRAME_NORMAL); |
296 // Check if events need to be ignored/accepted |
276 |
297 if (mIgnoreEvents) { |
277 if(this->rect().contains(event->pos())&& !mMenuShown) |
298 return; |
278 { |
299 } |
279 HbWidgetFeedback::triggered(this, Hb::InstantClicked); |
300 |
280 emit clicked(); |
301 if (KBluetoothMsgsConversationId != ConversationsEngine::instance()->getCurrentConversationId()) { |
281 } |
|
282 |
|
283 event->accept(); |
|
284 } |
|
285 |
|
286 //--------------------------------------------------------------- |
|
287 // MsgContactCardWidget::setBackGround |
|
288 // @see header file |
|
289 //--------------------------------------------------------------- |
|
290 void MsgContactCardWidget::setBackGround(const QString& bg) |
|
291 { |
|
292 HbFrameItem* backGround = new HbFrameItem(this); |
|
293 backGround->frameDrawer().setFrameGraphicsName(bg); |
|
294 backGround->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
|
295 this->setBackgroundItem(backGround); |
|
296 this->repolish(); |
|
297 } |
|
298 |
|
299 //--------------------------------------------------------------- |
|
300 // MsgContactCardWidget::handleLongPress |
|
301 // @see header file |
|
302 //--------------------------------------------------------------- |
|
303 void MsgContactCardWidget::handleLongPress(QPointF position) |
|
304 { |
|
305 if(KBluetoothMsgsConversationId |
|
306 != ConversationsEngine::instance()->getCurrentConversationId()) |
|
307 { |
|
308 HbMenu* contextMenu = new HbMenu(); |
302 HbMenu* contextMenu = new HbMenu(); |
309 contextMenu->setDismissPolicy(HbPopup::TapAnywhere); |
303 contextMenu->setDismissPolicy(HbPopup::TapAnywhere); |
310 contextMenu->setAttribute(Qt::WA_DeleteOnClose, true); |
304 contextMenu->setAttribute(Qt::WA_DeleteOnClose, true); |
311 contextMenu->setPreferredPos(position); |
305 contextMenu->setPreferredPos(position); |
312 |
306 |
313 contextMenu->addAction(LOC_MENU_CONTACT_INFO,this, SLOT(openContactInfo())); |
|
314 contextMenu->addAction(LOC_COMMON_MENU_CALL, this, SLOT(call())); |
|
315 |
|
316 //If contact doesn't exist in phonebook then add another menu item "Save to Contacts" |
307 //If contact doesn't exist in phonebook then add another menu item "Save to Contacts" |
317 int contactId = resolveContactId(mContactNumber); |
308 int contactId = resolveContactId(mContactNumber); |
318 if(contactId < 0) |
309 if (contactId < 0) { |
319 { |
|
320 contextMenu->addAction(LOC_SAVETO_CONTACTS, this, SLOT(addToContacts())); |
310 contextMenu->addAction(LOC_SAVETO_CONTACTS, this, SLOT(addToContacts())); |
321 } |
311 } |
322 |
312 else{ |
|
313 contextMenu->addAction(LOC_MENU_CONTACT_INFO, this, SLOT(openContactInfo())); |
|
314 } |
|
315 contextMenu->addAction(LOC_COMMON_MENU_CALL, this, SLOT(call())); |
|
316 |
323 contextMenu->show(); |
317 contextMenu->show(); |
324 |
318 } |
325 mMenuShown = true; |
319 } |
326 } |
320 |
327 } |
321 //--------------------------------------------------------------- |
328 |
322 // MsgContactCardWidget::handleShortTap |
329 //--------------------------------------------------------------- |
323 // @see header |
330 // MsgContactCardWidget::overrideFeedback |
324 //--------------------------------------------------------------- |
331 // @see header file |
325 void MsgContactCardWidget::handleShortTap(const QPointF &position) |
332 //--------------------------------------------------------------- |
326 { |
333 HbFeedback::InstantEffect MsgContactCardWidget::overrideFeedback(Hb::InstantInteraction interaction) const |
327 this->ungrabGesture(Qt::TapGesture); |
334 { |
328 |
335 switch(interaction) |
329 // Check if events need to be ignored/accepted |
336 { |
330 if (mIgnoreEvents) { |
337 case Hb::InstantPressed: |
331 return; |
338 case Hb::InstantClicked: |
332 } |
339 return HbFeedback::Basic; |
333 |
340 default: |
334 int contactId = resolveContactId(mContactNumber); |
341 return HbFeedback::NoOverride; |
335 if(contactId > 0) |
342 } |
336 { |
343 } |
337 //resolved contact open contact card. |
344 |
338 openContactInfo(); |
|
339 } |
|
340 else |
|
341 { |
|
342 //unresolved contact show longpress options menu. |
|
343 handleLongTap(position); |
|
344 } |
|
345 |
|
346 //fire timer to regrab gesture after some delay. |
|
347 QTimer::singleShot(300,this,SLOT(regrabGesture())); |
|
348 } |
|
349 |
345 //--------------------------------------------------------------- |
350 //--------------------------------------------------------------- |
346 // MsgContactCardWidget::openContactInfo |
351 // MsgContactCardWidget::openContactInfo |
347 // @see header |
352 // @see header |
348 //--------------------------------------------------------------- |
353 //--------------------------------------------------------------- |
349 void MsgContactCardWidget::openContactInfo() |
354 void MsgContactCardWidget::openContactInfo() |
350 { |
355 { |
351 QString operation; |
356 QString operation; |
352 QList<QVariant> args; |
357 QList<QVariant> args; |
353 if(KBluetoothMsgsConversationId |
358 if (KBluetoothMsgsConversationId != ConversationsEngine::instance()->getCurrentConversationId()) { |
354 != ConversationsEngine::instance()->getCurrentConversationId()) |
359 int contactId = resolveContactId(mContactNumber); |
355 { |
360 if (contactId > 0) { |
356 int contactId = resolveContactId(mContactNumber); |
|
357 if(contactId > 0) |
|
358 { |
|
359 //open existing contact card |
361 //open existing contact card |
360 operation = QString("open(int)"); |
362 operation = QString("open(int)"); |
361 args << contactId; |
363 args << contactId; |
362 } |
364 } |
363 else |
365 else { |
364 { |
|
365 //populate data and open unknown contact template |
366 //populate data and open unknown contact template |
366 operation = QString("editCreateNew(QString,QString)"); |
367 operation = QString("editCreateNew(QString,QString)"); |
367 QString type = QContactPhoneNumber::DefinitionName; |
368 QString type = QContactPhoneNumber::DefinitionName; |
368 |
369 |
369 args << type; |
370 args << type; |
370 args << mAddress; |
371 args << mAddress; |
371 } |
372 } |
372 //service stuff. |
373 //service stuff. |
373 QString serviceName("com.nokia.services.phonebookservices"); |
374 QString serviceName("com.nokia.services.phonebookservices"); |
374 |
375 |
375 XQAiwRequest* request; |
376 XQAiwRequest* request; |
376 XQApplicationManager appManager; |
377 XQApplicationManager appManager; |
377 request = appManager.create(serviceName, "Fetch", operation, true); // embedded |
378 request = appManager.create(serviceName, "Fetch", operation, true); // embedded |
378 if ( request == NULL ) |
379 if (request == NULL) { |
379 { |
380 return; |
380 return; |
381 } |
381 } |
382 |
382 |
|
383 // Result handlers |
383 // Result handlers |
384 connect (request, SIGNAL(requestOk(const QVariant&)), this, SLOT(handleOk(const QVariant&))); |
384 connect(request, SIGNAL(requestOk(const QVariant&)), this, SLOT(handleOk(const QVariant&))); |
385 connect (request, SIGNAL(requestError(const QVariant&)), this, SLOT(handleError(const QVariant&))); |
385 connect(request, SIGNAL(requestError(const QVariant&)), this, |
386 |
386 SLOT(handleError(const QVariant&))); |
|
387 |
|
388 //disbale subscritption for the CV events |
|
389 ConversationsEngine::instance()->disableRegisterationForCVEvents(); |
|
390 |
387 request->setArguments(args); |
391 request->setArguments(args); |
388 request->send(); |
392 request->send(); |
389 delete request; |
393 delete request; |
390 } |
394 } |
391 } |
395 } |
394 // MsgContactCardWidget::resolveContactId |
398 // MsgContactCardWidget::resolveContactId |
395 // @see header |
399 // @see header |
396 //--------------------------------------------------------------- |
400 //--------------------------------------------------------------- |
397 int MsgContactCardWidget::resolveContactId(const QString& value) |
401 int MsgContactCardWidget::resolveContactId(const QString& value) |
398 { |
402 { |
399 int contactId = -1; |
403 QString displayLabel; |
400 |
404 |
401 QContactManager phonebookManager("symbian"); |
405 int count; |
402 |
406 return MsgContactHandler::resolveContactDisplayName(value, displayLabel, count); |
403 QContactDetailFilter phoneFilter; |
|
404 phoneFilter.setDetailDefinitionName(QContactPhoneNumber::DefinitionName, |
|
405 QContactPhoneNumber::FieldNumber); |
|
406 phoneFilter.setValue(value); |
|
407 phoneFilter.setMatchFlags(QContactFilter::MatchEndsWith); |
|
408 |
|
409 QList<QContactSortOrder> sortOrder; |
|
410 QList<QContact> matchingContacts = phonebookManager.contacts( |
|
411 phoneFilter, |
|
412 sortOrder, |
|
413 QStringList()); |
|
414 |
|
415 if ( matchingContacts.count() > 0 ) |
|
416 { |
|
417 contactId = matchingContacts.at(0).localId(); |
|
418 } |
|
419 |
|
420 return contactId; |
|
421 } |
407 } |
422 |
408 |
423 //--------------------------------------------------------------- |
409 //--------------------------------------------------------------- |
424 // MsgContactCardWidget::call |
410 // MsgContactCardWidget::call |
425 // @see header |
411 // @see header |
426 //--------------------------------------------------------------- |
412 //--------------------------------------------------------------- |
427 void MsgContactCardWidget::call() |
413 void MsgContactCardWidget::call() |
428 { |
414 { |
429 //Launch dialer service |
415 //Launch dialer service |
430 QString serviceName("com.nokia.services.telephony"); |
416 QString serviceName("com.nokia.symbian.ICallDial"); |
431 QString operation("dial(QString)"); |
417 QString operation("dial(QString)"); |
432 |
418 |
433 XQServiceRequest* serviceRequest = new XQServiceRequest(serviceName,operation,false); |
419 XQServiceRequest* serviceRequest = new XQServiceRequest(serviceName, operation, false); |
434 |
420 |
435 connect(serviceRequest, SIGNAL(requestCompleted(QVariant)), |
421 connect(serviceRequest, SIGNAL(requestCompleted(QVariant)), this, |
436 this, SLOT(onServiceRequestCompleted())); |
422 SLOT(onServiceRequestCompleted())); |
437 |
423 |
438 connect(serviceRequest, SIGNAL(requestError(int)), |
424 connect(serviceRequest, SIGNAL(requestError(int)), this, SLOT(onServiceRequestCompleted())); |
439 this, SLOT(onServiceRequestCompleted())); |
425 |
440 |
|
441 *serviceRequest << mContactNumber; |
426 *serviceRequest << mContactNumber; |
442 serviceRequest->send(); |
427 serviceRequest->send(); |
443 } |
428 } |
444 |
429 |
445 //--------------------------------------------------------------- |
430 //--------------------------------------------------------------- |
446 // MsgContactCardWidget::addToContacts |
431 // MsgContactCardWidget::addToContacts |
447 // @see header |
432 // @see header |
448 //--------------------------------------------------------------- |
433 //--------------------------------------------------------------- |
449 void MsgContactCardWidget::addToContacts() |
434 void MsgContactCardWidget::addToContacts() |
450 { |
435 { |
|
436 openContactInfo(); |
451 } |
437 } |
452 |
438 |
453 //--------------------------------------------------------------- |
439 //--------------------------------------------------------------- |
454 // MsgContactCardWidget::handleOk |
440 // MsgContactCardWidget::handleOk |
455 // @see header |
441 // @see header |
456 //--------------------------------------------------------------- |
442 //--------------------------------------------------------------- |
457 void MsgContactCardWidget::handleOk(const QVariant& result) |
443 void MsgContactCardWidget::handleOk(const QVariant& result) |
458 { |
444 { |
459 Q_UNUSED(result) |
445 Q_UNUSED(result) |
|
446 |
|
447 QList<QContact> matchingContacts = MsgContactHandler::findContactList(mContactNumber); |
|
448 |
|
449 if (!matchingContacts.isEmpty()) { |
|
450 setAddress(matchingContacts.at(0).displayLabel()); |
|
451 |
|
452 QList<QContactAvatar> avatarDetails = matchingContacts.at(0).details<QContactAvatar> (); |
|
453 |
|
454 if (!avatarDetails.isEmpty()) { |
|
455 mThumbnailManager->getThumbnail(avatarDetails.at(0).imageUrl().toString()); |
|
456 } |
|
457 } |
|
458 |
|
459 // Get the new conversation id. |
|
460 qint64 convId = ConversationsEngine::instance()->getConversationIdFromAddress( |
|
461 mContactNumber); |
|
462 emit conversationIdChanged(convId); |
|
463 |
|
464 ConversationsEngine::instance( |
|
465 )->emitOpenConversationViewIdUpdate(convId); |
460 |
466 |
461 QContactManager phonebookManager("symbian"); |
467 } |
462 |
468 |
463 QContactDetailFilter phoneFilter; |
469 //--------------------------------------------------------------- |
464 phoneFilter.setDetailDefinitionName(QContactPhoneNumber::DefinitionName, |
470 // MsgContactCardWidget::handleError |
465 QContactPhoneNumber::FieldNumber); |
471 // @see header |
466 phoneFilter.setValue(mContactNumber); |
472 //--------------------------------------------------------------- |
467 phoneFilter.setMatchFlags(QContactFilter::MatchEndsWith); |
473 void MsgContactCardWidget::handleError(int errorCode, const QString& errorMessage) |
468 |
474 { |
469 QList<QContactSortOrder> sortOrder; |
475 Q_UNUSED(errorMessage) |
470 QList<QContact> matchingContacts = phonebookManager.contacts(phoneFilter, |
476 Q_UNUSED(errorCode) |
471 sortOrder, QStringList()); |
|
472 |
477 |
473 if(matchingContacts.count()) |
478 //unblock the cv events in case of contacts save error |
474 { |
479 ConversationsEngine::instance( |
475 setAddress(matchingContacts.at(0).displayLabel()); |
480 )->emitOpenConversationViewIdUpdate( |
476 } |
481 ConversationsEngine::instance( |
477 } |
482 )->getCurrentConversationId( |
478 |
483 )); |
479 //--------------------------------------------------------------- |
484 } |
480 // MsgContactCardWidget::handleError |
485 |
481 // @see header |
|
482 //--------------------------------------------------------------- |
|
483 void MsgContactCardWidget::handleError(int errorCode, const QString& errorMessage) |
|
484 { |
|
485 Q_UNUSED(errorMessage) |
|
486 Q_UNUSED(errorCode) |
|
487 } |
|
488 |
|
489 //--------------------------------------------------------------- |
486 //--------------------------------------------------------------- |
490 // MsgContactCardWidget::onServiceRequestCompleted |
487 // MsgContactCardWidget::onServiceRequestCompleted |
491 // @see header |
488 // @see header |
492 //--------------------------------------------------------------- |
489 //--------------------------------------------------------------- |
493 void MsgContactCardWidget::onServiceRequestCompleted() |
490 void MsgContactCardWidget::onServiceRequestCompleted() |
494 { |
491 { |
495 //service request is now complete. delete it. |
492 //service request is now complete. delete it. |
496 XQServiceRequest* request = qobject_cast<XQServiceRequest*>(sender()); |
493 XQServiceRequest* request = qobject_cast<XQServiceRequest*> (sender()); |
497 if(request) |
494 if (request) { |
498 { |
|
499 delete request; |
495 delete request; |
500 } |
496 } |
501 } |
497 } |
502 |
498 |
503 //--------------------------------------------------------------- |
499 //--------------------------------------------------------------- |
504 // MsgContactCardWidget::connectSignals |
500 // MsgContactCardWidget::thumbnailReady |
505 // @see header |
501 // @see header |
506 //--------------------------------------------------------------- |
502 //--------------------------------------------------------------- |
507 void MsgContactCardWidget::connectSignals(bool yes) |
503 void MsgContactCardWidget::thumbnailReady(const QPixmap& pixmap, void *data, int id, int error) |
508 { |
504 { |
509 if(yes) |
505 Q_UNUSED(data) |
510 { |
506 Q_UNUSED(id) |
511 connect(this,SIGNAL(clicked()),this,SLOT(openContactInfo())); |
507 |
512 } |
508 if (!error) { |
513 else |
509 QIcon icon(pixmap); |
514 { |
510 setAvatar(HbIcon(icon)); |
515 disconnect(this,SIGNAL(clicked()),this,SLOT(openContactInfo())); |
511 } |
516 } |
512 else { |
|
513 setAvatar(HbIcon(DEFAULT_AVATAR_ICON)); |
|
514 } |
|
515 } |
|
516 |
|
517 //--------------------------------------------------------------- |
|
518 // MsgContactCardWidget::ignoreSignals |
|
519 // @see header |
|
520 //--------------------------------------------------------------- |
|
521 void MsgContactCardWidget::ignoreSignals(bool yes) |
|
522 { |
|
523 mIgnoreEvents = yes; |
|
524 } |
|
525 |
|
526 //--------------------------------------------------------------- |
|
527 // MsgContactCardWidget::regrabGesture |
|
528 // @see header file |
|
529 //--------------------------------------------------------------- |
|
530 void MsgContactCardWidget::regrabGesture() |
|
531 { |
|
532 this->grabGesture(Qt::TapGesture); |
517 } |
533 } |
518 // EOF |
534 // EOF |