36 #include <thumbnailmanager_qt.h> |
38 #include <thumbnailmanager_qt.h> |
37 #include <cntmaptileservice.h> //For maptile processing |
39 #include <cntmaptileservice.h> //For maptile processing |
38 #include <qversitcontactexporter.h> |
40 #include <qversitcontactexporter.h> |
39 #include <qversitwriter.h> |
41 #include <qversitwriter.h> |
40 #include <xqservicerequest.h> |
42 #include <xqservicerequest.h> |
|
43 |
41 #include "cntcontactcarddatacontainer.h" |
44 #include "cntcontactcarddatacontainer.h" |
42 #include "cntcontactcarddetailitem.h" |
45 #include "cntcontactcarddetailitem.h" |
43 #include "cntcontactcardheadingitem.h" |
46 #include "cntcontactcardheadingitem.h" |
44 #include "cntcontactcarddataitem.h" |
47 #include "cntcontactcarddataitem.h" |
45 #include "cntcontactcardcontextmenu.h" |
48 #include "cntcontactcardcontextmenu.h" |
46 #include "cntmainwindow.h" |
49 #include "cntmainwindow.h" |
47 #include "cntstringmapper.h" |
50 #include "cntstringmapper.h" |
48 #include "cntdocumentloader.h" |
51 #include "cntdocumentloader.h" |
49 #include "cntimagelabel.h" |
52 #include "cntimagelabel.h" |
50 #include "cntimageutility.h" |
53 #include "cntimageutility.h" |
|
54 #include "cntfavourite.h" |
51 |
55 |
52 const char *CNT_CONTACTCARDVIEW_XML = ":/xml/contacts_contactcard.docml"; |
56 const char *CNT_CONTACTCARDVIEW_XML = ":/xml/contacts_contactcard.docml"; |
53 |
57 |
54 /*! |
58 /*! |
55 Constructor, initialize member variables. |
59 Constructor, initialize member variables. |
143 break; |
142 break; |
144 } |
143 } |
145 } |
144 } |
146 } |
145 } |
147 |
146 |
148 CntViewParameters viewParameters; |
147 mViewManager->back( mArgs ); |
149 if (mIsGroupMember) |
|
150 { |
|
151 QVariant var; |
|
152 var.setValue(*mGroupContact); |
|
153 viewParameters.insert(ESelectedContact, var); |
|
154 } |
|
155 mViewManager->back(viewParameters); |
|
156 } |
148 } |
157 |
149 |
158 /* |
150 /* |
159 Activates a default view and setup name label texts |
151 Activates a default view and setup name label texts |
160 */ |
152 */ |
161 void CntContactCardViewPrivate::activate(CntAbstractViewManager* aMgr, const CntViewParameters aArgs) |
153 void CntContactCardViewPrivate::activate(CntAbstractViewManager* aMgr, const CntViewParameters aArgs) |
162 { |
154 { |
|
155 mViewManager = aMgr; |
|
156 mArgs = aArgs; |
|
157 |
163 mView->installEventFilter(this); |
158 mView->installEventFilter(this); |
164 |
|
165 mViewManager = aMgr; |
|
166 |
159 |
167 HbMainWindow* window = mView->mainWindow(); |
160 HbMainWindow* window = mView->mainWindow(); |
168 connect(window, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(setOrientation(Qt::Orientation))); |
161 connect(window, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(setOrientation(Qt::Orientation))); |
169 setOrientation(window->orientation()); |
162 setOrientation(window->orientation()); |
170 |
163 |
171 if (aArgs.value(ECustomParam).toInt() == imageEditorView) |
|
172 { |
|
173 mIsPreviousImageEditorView = true; |
|
174 } |
|
175 |
|
176 QContact contact = aArgs.value(ESelectedContact).value<QContact>(); |
164 QContact contact = aArgs.value(ESelectedContact).value<QContact>(); |
177 mContact = new QContact(contact); |
165 mContact = new QContact( contact ); |
178 |
|
179 //my card |
166 //my card |
180 if (mContact->localId() == contactManager()->selfContactId()) |
167 bool myCard = mContact->localId() == contactManager()->selfContactId(); |
|
168 if (myCard) |
181 { |
169 { |
182 mView->menu()->clearActions(); |
170 mView->menu()->clearActions(); |
183 mView->toolBar()->removeAction(static_cast<HbAction*>(document()->findObject(QString("cnt:history")))); |
171 mView->toolBar()->removeAction(static_cast<HbAction*>(document()->findObject(QString("cnt:history")))); |
184 } |
172 } |
185 else |
173 else |
186 { |
174 { |
187 mView->toolBar()->removeAction(static_cast<HbAction*>(document()->findObject(QString("cnt:sendMyCard")))); |
175 mView->toolBar()->removeAction(static_cast<HbAction*>(document()->findObject(QString("cnt:sendMyCard")))); |
188 } |
176 } |
189 |
177 |
190 if (aArgs.value(ESelectedAction).toString() == "FromGroupMemberView") |
|
191 { |
|
192 mIsGroupMember = true; |
|
193 QContact groupContact = aArgs.value(ESelectedGroupContact).value<QContact>(); |
|
194 mGroupContact = new QContact(groupContact); |
|
195 } |
|
196 // add heading widget to the content |
178 // add heading widget to the content |
197 QGraphicsWidget *c = document()->findWidget(QString("content")); |
179 QGraphicsWidget *c = document()->findWidget(QString("content")); |
198 QGraphicsLinearLayout* l = static_cast<QGraphicsLinearLayout*>(c->layout()); |
180 QGraphicsLinearLayout* l = static_cast<QGraphicsLinearLayout*>(c->layout()); |
199 |
181 |
200 mHeadingItem = static_cast<CntContactCardHeadingItem*>(document()->findWidget(QString("cnt_contactcard_heading"))); |
182 mHeadingItem = static_cast<CntContactCardHeadingItem*>(document()->findWidget(QString("cnt_contactcard_heading"))); |
201 mHeadingItem->setDetails(mContact); |
183 mHeadingItem->setDetails(mContact); |
202 mHeadingItem->setSecondaryIcon(isFavoriteGroupContact()); |
|
203 |
|
204 connect(mHeadingItem, SIGNAL(passLongPressed(const QPointF&)), this, SLOT(drawMenu(const QPointF&))); |
184 connect(mHeadingItem, SIGNAL(passLongPressed(const QPointF&)), this, SLOT(drawMenu(const QPointF&))); |
|
185 connect(mHeadingItem, SIGNAL(passShortPressed(const QPointF&)), this, SLOT(doChangeImage())); |
205 |
186 |
206 mImageLabel = static_cast<CntImageLabel*>(document()->findWidget("cnt_contactcard_image")); |
187 mImageLabel = static_cast<CntImageLabel*>(document()->findWidget("cnt_contactcard_image")); |
207 connect(mImageLabel, SIGNAL(iconClicked()), this, SLOT(doChangeImage())); |
188 connect(mImageLabel, SIGNAL(iconClicked()), this, SLOT(doChangeImage())); |
|
189 connect(mImageLabel, SIGNAL(iconLongPressed(const QPointF&)), this, SLOT(drawMenu(const QPointF&))); |
208 |
190 |
209 // avatar |
191 // avatar |
210 QList<QContactAvatar> details = mContact->details<QContactAvatar>(); |
192 QList<QContactAvatar> details = mContact->details<QContactAvatar>(); |
211 for (int i = 0;i < details.count();i++) |
193 for (int i = 0;i < details.count();i++) |
212 { |
194 { |
294 mContainerLayout->addItem(item); |
276 mContainerLayout->addItem(item); |
295 } |
277 } |
296 } |
278 } |
297 } |
279 } |
298 |
280 |
299 bool setAsFavorite = false; |
281 bool setAsFavorite( false ); |
300 if(isFavoriteGroupCreated()) |
282 QContactLocalId favouriteGroupId = CntFavourite::favouriteGroupId( contactManager() ); |
301 { |
283 if( favouriteGroupId != 0 ) |
302 QContact favoriteGroup = contactManager()->contact(mFavoriteGroupId); |
284 { |
303 // Use relationship filter to get list of contacts in the relationship (if any) |
285 setAsFavorite = CntFavourite::isMemberOfFavouriteGroup( contactManager(), mContact ); |
304 QContactRelationshipFilter filter; |
286 mHeadingItem->setSecondaryIcon( setAsFavorite ); // if contact is part of favourites group |
305 filter.setRelationshipType(QContactRelationship::HasMember); |
287 } |
306 filter.setRelatedContactRole(QContactRelationship::First); |
288 qobject_cast<HbAction *>(document()->findObject("cnt:setasfavorite"))->setVisible( !setAsFavorite ); |
307 filter.setRelatedContactId(favoriteGroup.id()); |
289 qobject_cast<HbAction *>(document()->findObject("cnt:removefromfavorite"))->setVisible( setAsFavorite ); |
308 |
|
309 QList<QContactLocalId> mContactsList = contactManager()->contactIds(filter); |
|
310 int count = mContactsList.count(); |
|
311 if (count) |
|
312 { |
|
313 for (int i = 0 ; i < count ; i++) |
|
314 { |
|
315 if (mContactsList.at(i) == mContact->localId()) |
|
316 { |
|
317 setAsFavorite = true; |
|
318 } |
|
319 } |
|
320 } |
|
321 } |
|
322 |
|
323 if (setAsFavorite) |
|
324 { |
|
325 qobject_cast<HbAction *>(document()->findObject("cnt:setasfavorite"))->setVisible(false); |
|
326 } |
|
327 else |
|
328 { |
|
329 qobject_cast<HbAction *>(document()->findObject("cnt:removefromfavorite"))->setVisible(false); |
|
330 } |
|
331 |
290 |
332 // Menu items |
291 // Menu items |
333 connect(qobject_cast<HbAction *>(document()->findObject("cnt:sendbusinesscard")), SIGNAL(triggered()), |
292 connect(qobject_cast<HbAction *>(document()->findObject("cnt:sendbusinesscard")), SIGNAL(triggered()), |
334 this, SLOT (sendBusinessCard())); |
293 this, SLOT (sendBusinessCard())); |
335 connect(qobject_cast<HbAction *>(document()->findObject("cnt:deletecontact")), SIGNAL(triggered()), |
294 connect(qobject_cast<HbAction *>(document()->findObject("cnt:deletecontact")), SIGNAL(triggered()), |
347 connect(qobject_cast<HbAction *>(document()->findObject("cnt:history")), SIGNAL(triggered()), |
306 connect(qobject_cast<HbAction *>(document()->findObject("cnt:history")), SIGNAL(triggered()), |
348 this, SLOT(viewHistory())); |
307 this, SLOT(viewHistory())); |
349 connect(qobject_cast<HbAction *>(document()->findObject("cnt:sendMyCard")), SIGNAL(triggered()), |
308 connect(qobject_cast<HbAction *>(document()->findObject("cnt:sendMyCard")), SIGNAL(triggered()), |
350 this, SLOT (sendBusinessCard())); |
309 this, SLOT (sendBusinessCard())); |
351 |
310 |
352 emit viewActivated(*mContact, aArgs.value(ESelectedDetail).value<QContactDetail>()); |
311 emit viewActivated( mViewManager, aArgs ); |
353 } |
312 } |
354 |
313 |
355 void CntContactCardViewPrivate::thumbnailReady(const QPixmap& pixmap, void *data, int id, int error) |
314 void CntContactCardViewPrivate::thumbnailReady(const QPixmap& pixmap, void *data, int id, int error) |
356 { |
315 { |
357 Q_UNUSED(data); |
316 Q_UNUSED(data); |
386 /*! |
345 /*! |
387 Launch contact editor |
346 Launch contact editor |
388 */ |
347 */ |
389 void CntContactCardViewPrivate::editContact() |
348 void CntContactCardViewPrivate::editContact() |
390 { |
349 { |
391 CntViewParameters viewParameters; |
|
392 viewParameters.insert(EViewId, editView); |
|
393 QVariant var; |
350 QVariant var; |
394 var.setValue(*mContact); |
351 var.setValue(*mContact); |
395 viewParameters.insert(ESelectedContact, var); |
352 |
396 mViewManager->changeView(viewParameters); |
353 mArgs.insert(ESelectedContact, var); |
|
354 mArgs.insert(EViewId, editView); |
|
355 |
|
356 mViewManager->changeView( mArgs ); |
397 } |
357 } |
398 |
358 |
399 void CntContactCardViewPrivate::addToGroup() |
359 void CntContactCardViewPrivate::addToGroup() |
400 { |
360 { |
401 } |
361 } |
402 |
362 |
403 void CntContactCardViewPrivate::setAsFavorite() |
363 void CntContactCardViewPrivate::setAsFavorite() |
404 { |
364 { |
405 QContact favoriteGroup; |
365 QContactId id = mContact->id(); |
406 if (!isFavoriteGroupCreated() ) |
366 CntFavourite::addContactToFavouriteGroup( contactManager(), id ); |
407 { |
367 |
408 //Create Fav grp |
368 qobject_cast<HbAction *>(document()->findObject("cnt:removefromfavorite"))->setVisible(true); |
409 favoriteGroup.setType(QContactType::TypeGroup); |
|
410 QContactName favoriteGroupName; |
|
411 favoriteGroupName.setCustomLabel("Favorites"); |
|
412 favoriteGroup.saveDetail(&favoriteGroupName); |
|
413 contactManager()->saveContact(&favoriteGroup); |
|
414 mFavoriteGroupId = favoriteGroup.localId(); |
|
415 } |
|
416 else |
|
417 { |
|
418 favoriteGroup = contactManager()->contact(mFavoriteGroupId); |
|
419 } |
|
420 |
|
421 // new contact added to the favorite group |
|
422 QContactRelationship relationship; |
|
423 relationship.setRelationshipType(QContactRelationship::HasMember); |
|
424 relationship.setFirst(favoriteGroup.id()); |
|
425 relationship.setSecond(mContact->id()); |
|
426 // save relationship |
|
427 contactManager()->saveRelationship(&relationship); |
|
428 |
|
429 qobject_cast<HbAction *>(document()->findObject("cnt:setasfavorite"))->setVisible(false); |
369 qobject_cast<HbAction *>(document()->findObject("cnt:setasfavorite"))->setVisible(false); |
430 qobject_cast<HbAction *>(document()->findObject("cnt:removefromfavorite"))->setVisible(true); |
|
431 mHeadingItem->setSecondaryIcon(true); |
370 mHeadingItem->setSecondaryIcon(true); |
432 } |
371 } |
433 |
372 |
434 void CntContactCardViewPrivate::removeFromFavorite() |
373 void CntContactCardViewPrivate::removeFromFavorite() |
435 { |
374 { |
436 QContact favoriteGroup = contactManager()->contact(mFavoriteGroupId); |
375 QContactId id = mContact->id(); |
437 QContactRelationship relationship; |
376 CntFavourite::removeContactFromFavouriteGroup( contactManager(), id ); |
438 relationship.setRelationshipType(QContactRelationship::HasMember); |
|
439 relationship.setFirst(favoriteGroup.id()); |
|
440 relationship.setSecond(mContact->id()); |
|
441 contactManager()->removeRelationship(relationship); |
|
442 |
377 |
443 qobject_cast<HbAction *>(document()->findObject("cnt:removefromfavorite"))->setVisible(false); |
378 qobject_cast<HbAction *>(document()->findObject("cnt:removefromfavorite"))->setVisible(false); |
444 qobject_cast<HbAction *>(document()->findObject("cnt:setasfavorite"))->setVisible(true); |
379 qobject_cast<HbAction *>(document()->findObject("cnt:setasfavorite"))->setVisible(true); |
445 mHeadingItem->setSecondaryIcon(false); |
380 mHeadingItem->setSecondaryIcon(false); |
446 } |
381 } |
464 HbMessageBox *note = static_cast<HbMessageBox*>(sender()); |
399 HbMessageBox *note = static_cast<HbMessageBox*>(sender()); |
465 |
400 |
466 if (note && action == note->actions().first()) |
401 if (note && action == note->actions().first()) |
467 { |
402 { |
468 contactManager()->removeContact(mContact->localId()); |
403 contactManager()->removeContact(mContact->localId()); |
469 CntViewParameters viewParameters; |
404 mArgs.insert(EViewId, namesView); |
470 viewParameters.insert(EViewId, namesView); |
405 mViewManager->changeView( mArgs ); |
471 mViewManager->changeView(viewParameters); |
|
472 } |
406 } |
473 } |
407 } |
474 |
408 |
475 /*! |
409 /*! |
476 Launch history view |
410 Launch history view |
477 */ |
411 */ |
478 void CntContactCardViewPrivate::viewHistory() |
412 void CntContactCardViewPrivate::viewHistory() |
479 { |
413 { |
480 CntViewParameters viewParameters; |
|
481 viewParameters.insert(EViewId, historyView); |
|
482 QVariant var; |
414 QVariant var; |
483 var.setValue(*mContact); |
415 var.setValue(*mContact); |
484 viewParameters.insert(ESelectedContact, var); |
416 mArgs.insert(ESelectedContact, var); |
485 mViewManager->changeView(viewParameters); |
417 mArgs.insert(EViewId, historyView); |
|
418 |
|
419 mViewManager->changeView( mArgs ); |
486 } |
420 } |
487 |
421 |
488 /*! |
422 /*! |
489 Deactivate the view |
423 Deactivate the view |
490 */ |
424 */ |
555 */ |
492 */ |
556 void CntContactCardViewPrivate::onItemActivated() |
493 void CntContactCardViewPrivate::onItemActivated() |
557 { |
494 { |
558 CntContactCardDetailItem *item = qobject_cast<CntContactCardDetailItem*>(sender()); |
495 CntContactCardDetailItem *item = qobject_cast<CntContactCardDetailItem*>(sender()); |
559 int index = item->index(); |
496 int index = item->index(); |
560 launchAction(*mContact, mDataContainer->dataItem(index)->detail(), mDataContainer->dataItem(index)->action()); |
497 QString action = mDataContainer->dataItem(index)->action(); |
|
498 // Check if action is internal |
|
499 QList<QContactActionDescriptor> actionDescriptors = QContactAction::actionDescriptors(action, "symbian", 1); |
|
500 if(0 < actionDescriptors.count()) |
|
501 { |
|
502 // These actions are considered internal(vendor=symbian and version=1) |
|
503 launchAction(*mContact, mDataContainer->dataItem(index)->detail(), action); |
|
504 } |
|
505 else |
|
506 { |
|
507 //Handle dynamic actions differently |
|
508 launchDynamicAction(*mContact, mDataContainer->dataItem(index)->detail(), mDataContainer->dataItem(index)->actionDescriptor()); |
|
509 } |
561 } |
510 } |
562 |
511 |
563 /*! |
512 /*! |
564 Launch the call / message / email action |
513 Launch the call / message / email action |
565 */ |
514 */ |
575 connect(mContactAction, SIGNAL(stateChanged(QContactAction::State)), |
524 connect(mContactAction, SIGNAL(stateChanged(QContactAction::State)), |
576 this, SLOT(progress(QContactAction::State))); |
525 this, SLOT(progress(QContactAction::State))); |
577 mContactAction->invokeAction(contact, detail); |
526 mContactAction->invokeAction(contact, detail); |
578 } |
527 } |
579 |
528 |
|
529 /*! |
|
530 Launch dynamic action |
|
531 */ |
|
532 void CntContactCardViewPrivate::launchDynamicAction(QContact contact, QContactDetail detail, QContactActionDescriptor actionDescriptor) |
|
533 { |
|
534 // detail might be empty -> in that case engine uses the preferred detail for the selected action |
|
535 mContactAction = QContactAction::action(actionDescriptor); |
|
536 connect(mContactAction, SIGNAL(stateChanged(QContactAction::State)), |
|
537 this, SLOT(progress(QContactAction::State))); |
|
538 mContactAction->invokeAction(contact, detail); |
|
539 } |
|
540 |
580 void CntContactCardViewPrivate::progress(QContactAction::State status) |
541 void CntContactCardViewPrivate::progress(QContactAction::State status) |
581 { |
542 { |
582 switch(status) |
543 switch(status) |
583 { |
544 { |
584 case QContactAction::FinishedState: |
545 case QContactAction::FinishedState: |
585 case QContactAction::FinishedWithErrorState: |
546 case QContactAction::FinishedWithErrorState: |
586 mContactAction->deleteLater(); |
547 mContactAction->deleteLater(); |
587 mContactAction = 0; |
|
588 break; |
548 break; |
589 default: |
549 default: |
590 break; |
550 break; |
591 } |
551 } |
592 } |
552 } |
608 CntContactCardDetailItem *item = qobject_cast<CntContactCardDetailItem*>(sender()); |
568 CntContactCardDetailItem *item = qobject_cast<CntContactCardDetailItem*>(sender()); |
609 int index = item->index(); |
569 int index = item->index(); |
610 |
570 |
611 CntContactCardContextMenu *menu = new CntContactCardContextMenu( item ); |
571 CntContactCardContextMenu *menu = new CntContactCardContextMenu( item ); |
612 HbAction *communicationAction = 0; |
572 HbAction *communicationAction = 0; |
|
573 HbAction *dynamicAction = 0; |
613 HbAction *videoCommunicationAction = 0; |
574 HbAction *videoCommunicationAction = 0; |
614 HbAction *preferredAction = 0; |
575 HbAction *preferredAction = 0; |
615 CntStringMapper stringMapper; |
576 CntStringMapper stringMapper; |
616 |
577 |
617 QString action = mDataContainer->dataItem(index)->action(); |
578 QString action = mDataContainer->dataItem(index)->action(); |
627 QString subtype = number.subTypes().isEmpty() ? number.definitionName() : number.subTypes().first(); |
588 QString subtype = number.subTypes().isEmpty() ? number.definitionName() : number.subTypes().first(); |
628 |
589 |
629 communicationAction = menu->addAction(stringMapper.getItemSpecificMenuLocString(subtype, context)); |
590 communicationAction = menu->addAction(stringMapper.getItemSpecificMenuLocString(subtype, context)); |
630 |
591 |
631 // TODO : uncomment next line when videotelephony is released |
592 // TODO : uncomment next line when videotelephony is released |
632 //videoCommunicationAction = menu->addAction(QString("VideoCall")); |
593 Q_UNUSED(videoCommunicationAction) |
|
594 //videoCommunicationAction = menu->addAction(QString("txt_phob_menu_call_video_number")); |
633 } |
595 } |
634 } |
596 } |
635 else if (action.compare("message", Qt::CaseInsensitive) == 0) |
597 else if (action.compare("message", Qt::CaseInsensitive) == 0) |
636 { |
598 { |
637 communicationAction = menu->addAction(hbTrId("txt_phob_menu_send_message")); |
599 communicationAction = menu->addAction(hbTrId("txt_phob_menu_send_message")); |
643 communicationAction = menu->addAction(stringMapper.getItemSpecificMenuLocString(detail.definitionName(), detail.contexts().first())); |
605 communicationAction = menu->addAction(stringMapper.getItemSpecificMenuLocString(detail.definitionName(), detail.contexts().first())); |
644 } |
606 } |
645 else |
607 else |
646 { |
608 { |
647 communicationAction = menu->addAction(stringMapper.getItemSpecificMenuLocString(detail.definitionName(), QString())); |
609 communicationAction = menu->addAction(stringMapper.getItemSpecificMenuLocString(detail.definitionName(), QString())); |
648 } |
610 } |
|
611 } |
|
612 else if (action.compare("url", Qt::CaseInsensitive) == 0) |
|
613 { |
|
614 if (!detail.contexts().isEmpty()) |
|
615 { |
|
616 communicationAction = menu->addAction(stringMapper.getItemSpecificMenuLocString(detail.definitionName(), detail.contexts().first())); |
|
617 } |
|
618 else |
|
619 { |
|
620 communicationAction = menu->addAction(stringMapper.getItemSpecificMenuLocString(detail.definitionName(), QString())); |
|
621 } |
|
622 } |
|
623 else if (1 > QContactAction::actionDescriptors(action, "symbian", 1).count()) |
|
624 { |
|
625 // Do verification that action is not internal type(vendor=symbian and version=1) |
|
626 // If hard coded action is not found, fetch localization from dynamic action |
|
627 // and create dynamic action item. |
|
628 dynamicAction = menu->addAction(mDataContainer->dataItem(index)->longPressText()); |
649 } |
629 } |
650 |
630 |
651 if (action.compare("call", Qt::CaseInsensitive) == 0) |
631 if (action.compare("call", Qt::CaseInsensitive) == 0) |
652 { |
632 { |
653 preferredAction = menu->addAction(hbTrId("txt_phob_menu_set_as_default_number")); |
633 preferredAction = menu->addAction(hbTrId("txt_phob_menu_set_as_default_number")); |
760 vCardPath.append(vCardName); |
751 vCardPath.append(vCardName); |
761 vCardPath = QDir::toNativeSeparators(vCardPath); |
752 vCardPath = QDir::toNativeSeparators(vCardPath); |
762 |
753 |
763 QVersitContactExporter exporter; |
754 QVersitContactExporter exporter; |
764 // The vCard version needs to be 2.1 due to backward compatiblity when sending |
755 // The vCard version needs to be 2.1 due to backward compatiblity when sending |
765 if (!exporter.exportContacts(list, QVersitDocument::VCard21Type)) |
756 if (exporter.exportContacts(list, QVersitDocument::VCard21Type)) |
766 { |
757 { |
767 |
758 qDebug() << "CntContactCardViewPrivate::handleSendBusinessCard, VCard21Type"; |
768 QList<QVersitDocument> docs = exporter.documents(); |
759 QList<QVersitDocument> docs = exporter.documents(); |
769 QFile f(vCardPath); |
760 QFile f(vCardPath); |
770 if ( f.open(QIODevice::WriteOnly) ) |
761 if ( f.open(QIODevice::WriteOnly) ) |
771 { |
762 { |
|
763 qDebug() << "CntContactCardViewPrivate::handleSendBusinessCard write VCard"; |
772 // Start creating the vCard |
764 // Start creating the vCard |
773 QVersitWriter writer; |
765 QVersitWriter writer; |
774 writer.setDevice(&f); |
766 writer.setDevice(&f); |
775 |
767 |
776 bool ret = writer.startWriting(docs); |
768 bool ret = writer.startWriting(docs); |
819 Called after the user clicked "Change Image" from popup menu after |
807 Called after the user clicked "Change Image" from popup menu after |
820 longpressing the image in this view. |
808 longpressing the image in this view. |
821 */ |
809 */ |
822 void CntContactCardViewPrivate::doChangeImage() |
810 void CntContactCardViewPrivate::doChangeImage() |
823 { |
811 { |
824 CntViewParameters viewParameters; |
|
825 viewParameters.insert(EViewId, imageEditorView); |
|
826 QVariant var; |
812 QVariant var; |
827 var.setValue(*mContact); |
813 var.setValue(*mContact); |
828 viewParameters.insert(ESelectedContact, var); |
814 |
829 mViewManager->changeView(viewParameters); |
815 mArgs.insert(ESelectedContact, var); |
|
816 mArgs.insert(EViewId, imageEditorView); |
|
817 |
|
818 mViewManager->changeView( mArgs ); |
830 } |
819 } |
831 |
820 |
832 /*! |
821 /*! |
833 Called after the user clicked "Remove Image" from popup menu after |
822 Called after the user clicked "Remove Image" from popup menu after |
834 longpressing the image in this view. |
823 longpressing the image in this view. |
869 // multiple emitted signals, set state that we are handling the signal |
858 // multiple emitted signals, set state that we are handling the signal |
870 mIsHandlingMenu = true; |
859 mIsHandlingMenu = true; |
871 |
860 |
872 HbMenu *menu = new HbMenu(); |
861 HbMenu *menu = new HbMenu(); |
873 menu->addAction(hbTrId("txt_phob_menu_change_picture"), this, SLOT(doChangeImage()) ); |
862 menu->addAction(hbTrId("txt_phob_menu_change_picture"), this, SLOT(doChangeImage()) ); |
874 menu->addAction(hbTrId("txt_phob_menu_remove_image"), this, SLOT(doRemoveImage()) ); |
863 if (mAvatar) |
875 |
864 { |
|
865 menu->addAction(hbTrId("txt_phob_menu_remove_image"), this, SLOT(doRemoveImage()) ); |
|
866 } |
876 menu->setAttribute( Qt::WA_DeleteOnClose ); |
867 menu->setAttribute( Qt::WA_DeleteOnClose ); |
877 menu->setPreferredPos( aCoords ); |
868 menu->setPreferredPos( aCoords ); |
878 menu->open(); |
869 menu->open(); |
879 } |
870 } |
880 |
871 |
881 /*! |
872 /*! |
882 Check if the favourite group created |
|
883 */ |
|
884 bool CntContactCardViewPrivate::isFavoriteGroupCreated() |
|
885 { |
|
886 bool favoriteGroupCreated = false; |
|
887 QContactDetailFilter groupFilter; |
|
888 groupFilter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType); |
|
889 groupFilter.setValue(QString(QLatin1String(QContactType::TypeGroup))); |
|
890 |
|
891 QList<QContactLocalId> groupContactIds = contactManager()->contactIds(groupFilter); |
|
892 |
|
893 if (!groupContactIds.isEmpty()) |
|
894 { |
|
895 for(int i = 0;i < groupContactIds.count();i++) |
|
896 { |
|
897 QContact contact = contactManager()->contact(groupContactIds.at(i)); |
|
898 QContactName contactName = contact.detail<QContactName>(); |
|
899 QString groupName = contactName.customLabel(); |
|
900 if(groupName.compare("Favorites") == 0) |
|
901 { |
|
902 favoriteGroupCreated = true; |
|
903 mFavoriteGroupId = groupContactIds.at(i); |
|
904 break; |
|
905 } |
|
906 } |
|
907 } |
|
908 return favoriteGroupCreated; |
|
909 } |
|
910 |
|
911 /*! |
|
912 Check if the contact is the favourite group |
|
913 */ |
|
914 bool CntContactCardViewPrivate::isFavoriteGroupContact() |
|
915 { |
|
916 bool favoriteGroupContact = false; |
|
917 |
|
918 if (isFavoriteGroupCreated()) |
|
919 { |
|
920 QContact favoriteGroup = contactManager()->contact(mFavoriteGroupId); |
|
921 QContactRelationshipFilter rFilter; |
|
922 rFilter.setRelationshipType(QContactRelationship::HasMember); |
|
923 rFilter.setRelatedContactRole(QContactRelationship::First); |
|
924 rFilter.setRelatedContactId(favoriteGroup.id()); |
|
925 |
|
926 QList<QContactLocalId> contactsLocalIdList = contactManager()->contactIds(rFilter); |
|
927 if (!contactsLocalIdList.isEmpty()) |
|
928 { |
|
929 for(int i = 0;i < contactsLocalIdList.count();i++) |
|
930 { |
|
931 QContact favContact = contactManager()->contact(contactsLocalIdList.at(i)); |
|
932 if (favContact.localId() == mContact->localId()) |
|
933 { |
|
934 favoriteGroupContact = true; |
|
935 } |
|
936 } |
|
937 } |
|
938 } |
|
939 return favoriteGroupContact; |
|
940 } |
|
941 |
|
942 /*! |
|
943 Return the pointer to the document loader |
873 Return the pointer to the document loader |
944 */ |
874 */ |
945 CntDocumentLoader* CntContactCardViewPrivate::document() |
875 CntDocumentLoader* CntContactCardViewPrivate::document() |
946 { |
876 { |
947 if (!mLoader) |
877 if (!mLoader) |