61 #include "cntimageutility.h" |
61 #include "cntimageutility.h" |
62 #include "cntfavourite.h" |
62 #include "cntfavourite.h" |
63 #include "cntactionlauncher.h" |
63 #include "cntactionlauncher.h" |
64 #include "cntpresencelistener.h" |
64 #include "cntpresencelistener.h" |
65 #include "cntactionpopup.h" |
65 #include "cntactionpopup.h" |
|
66 #include "cntvcarddetailhandler.h" |
66 |
67 |
67 #define CNT_MAPTILE_PROGRESS_TIMER 100 //100 msec |
68 #define CNT_MAPTILE_PROGRESS_TIMER 100 //100 msec |
68 #define CNT_UNKNOWN_MAPTILE_STATUS -1 |
69 #define CNT_UNKNOWN_MAPTILE_STATUS -1 |
69 |
70 |
70 const char *CNT_CONTACTCARDVIEW_XML = ":/xml/contacts_contactcard.docml"; |
71 const char *CNT_CONTACTCARDVIEW_XML = ":/xml/contacts_contactcard.docml"; |
72 const char *CNT_MAPTILE_SEARCH_STOP_ICON = "qtg_mono_search_stop"; |
73 const char *CNT_MAPTILE_SEARCH_STOP_ICON = "qtg_mono_search_stop"; |
73 /*! |
74 /*! |
74 Constructor, initialize member variables. |
75 Constructor, initialize member variables. |
75 \a viewManager is the parent that creates this view. \a parent is a pointer to parent QGraphicsItem (by default this is 0) |
76 \a viewManager is the parent that creates this view. \a parent is a pointer to parent QGraphicsItem (by default this is 0) |
76 */ |
77 */ |
77 CntContactCardViewPrivate::CntContactCardViewPrivate() : |
78 CntContactCardViewPrivate::CntContactCardViewPrivate(bool isTemporary) : |
78 QObject(), |
79 QObject(), |
79 mScrollArea(NULL), |
80 mScrollArea(NULL), |
80 mContainerWidget(NULL), |
81 mContainerWidget(NULL), |
81 mContainerLayout(NULL), |
82 mContainerLayout(NULL), |
82 mContact(NULL), |
83 mContact(NULL), |
117 |
120 |
118 //back button |
121 //back button |
119 mBackKey = new HbAction(Hb::BackNaviAction, mView); |
122 mBackKey = new HbAction(Hb::BackNaviAction, mView); |
120 mView->setNavigationAction(mBackKey); |
123 mView->setNavigationAction(mBackKey); |
121 connect(mBackKey, SIGNAL(triggered()), this, SLOT(showPreviousView())); |
124 connect(mBackKey, SIGNAL(triggered()), this, SLOT(showPreviousView())); |
122 |
125 |
123 mProgressTimer = new QTimer(this); |
126 mProgressTimer = new QTimer(this); |
124 mProgressTimer->setSingleShot(true); |
127 mProgressTimer->setSingleShot(true); |
125 connect(mProgressTimer, SIGNAL(timeout()),this, SLOT(updateSpinningIndicator())); |
128 connect(mProgressTimer, SIGNAL(timeout()),this, SLOT(updateSpinningIndicator())); |
126 |
129 |
127 mMaptile = new CntMapTileService; |
130 mMaptile = new CntMapTileService; |
211 CNT_ENTRY |
223 CNT_ENTRY |
212 |
224 |
213 mViewManager = aMgr; |
225 mViewManager = aMgr; |
214 mArgs = aArgs; |
226 mArgs = aArgs; |
215 |
227 |
216 mView->installEventFilter(this); |
|
217 |
|
218 HbMainWindow* window = mView->mainWindow(); |
228 HbMainWindow* window = mView->mainWindow(); |
219 connect(window, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(setOrientation(Qt::Orientation))); |
229 if (window) |
220 connect(window, SIGNAL(keyPressed(QKeyEvent*)), this, SLOT(keyPressed(QKeyEvent*))); |
230 { |
221 |
231 connect(window, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(setOrientation(Qt::Orientation))); |
222 setOrientation(window->orientation()); |
232 window->installEventFilter(this); |
|
233 |
|
234 setOrientation(window->orientation()); |
|
235 } |
223 |
236 |
224 QContact contact = aArgs.value(ESelectedContact).value<QContact>(); |
237 QContact contact = aArgs.value(ESelectedContact).value<QContact>(); |
225 mContact = new QContact( contact ); |
238 mContact = new QContact( contact ); |
226 //my card |
239 //my card |
227 bool myCard = mContact->localId() == contactManager()->selfContactId(); |
240 bool myCard = mContact->localId() == contactManager()->selfContactId(); |
232 } |
245 } |
233 else |
246 else |
234 { |
247 { |
235 mView->toolBar()->removeAction(static_cast<HbAction*>(document()->findObject(QString("cnt:sendMyCard")))); |
248 mView->toolBar()->removeAction(static_cast<HbAction*>(document()->findObject(QString("cnt:sendMyCard")))); |
236 } |
249 } |
|
250 if (mIsTemporary) |
|
251 { |
|
252 mView->menu()->clearActions(); |
|
253 mView->toolBar()->clearActions(); |
|
254 mView->toolBar()->addAction(static_cast<HbAction*>(document()->findObject(QString("cnt:addtocontact")))); |
|
255 } |
237 |
256 |
238 // add heading widget to the content |
257 // add heading widget to the content |
239 QGraphicsWidget *c = document()->findWidget(QString("content")); |
258 QGraphicsWidget *c = document()->findWidget(QString("content")); |
240 QGraphicsLinearLayout* l = static_cast<QGraphicsLinearLayout*>(c->layout()); |
259 QGraphicsLinearLayout* l = static_cast<QGraphicsLinearLayout*>(c->layout()); |
241 |
260 |
242 mHeadingItem = static_cast<CntContactCardHeadingItem*>(document()->findWidget(QString("cnt_contactcard_heading"))); |
261 mHeadingItem = static_cast<CntContactCardHeadingItem*>(document()->findWidget(QString("cnt_contactcard_heading"))); |
243 mHeadingItem->setDetails(mContact); |
262 mHeadingItem->setDetails(mContact); |
244 connect(mHeadingItem, SIGNAL(passLongPressed(const QPointF&)), this, SLOT(drawMenu(const QPointF&))); |
263 |
245 connect(mHeadingItem, SIGNAL(passShortPressed(const QPointF&)), this, SLOT(doChangeImage())); |
264 mImageLabel = static_cast<CntImageLabel*>(document()->findWidget("cnt_contactcard_image")); |
|
265 |
|
266 if (!mIsTemporary) |
|
267 { |
|
268 connect(mHeadingItem, SIGNAL(passLongPressed(const QPointF&)), this, SLOT(drawMenu(const QPointF&))); |
|
269 connect(mHeadingItem, SIGNAL(passShortPressed(const QPointF&)), this, SLOT(doChangeImage())); |
|
270 connect(mImageLabel, SIGNAL(iconClicked()), this, SLOT(doChangeImage())); |
|
271 connect(mImageLabel, SIGNAL(iconLongPressed(const QPointF&)), this, SLOT(drawMenu(const QPointF&))); |
|
272 } |
|
273 else |
|
274 { |
|
275 mHeadingItem->ungrabGesture(Qt::TapGesture); |
|
276 mImageLabel->ungrabGesture(Qt::TapGesture); |
|
277 } |
246 |
278 |
247 // presence listener |
279 // presence listener |
248 mPresenceListener = new CntPresenceListener(*mContact); |
280 mPresenceListener = new CntPresenceListener(*mContact); |
249 connect(mPresenceListener, SIGNAL(fullPresenceUpdated(bool)), mHeadingItem, SLOT(setOnlineStatus(bool))); |
281 connect(mPresenceListener, SIGNAL(fullPresenceUpdated(bool)), mHeadingItem, SLOT(setOnlineStatus(bool))); |
|
282 connect(mPresenceListener, SIGNAL(accountPresenceUpdated(const QString&, bool)), |
|
283 this, SLOT(updateItemPresence(const QString&, bool))); |
250 bool online; |
284 bool online; |
251 mPresenceListener->initialPresences(online); |
285 QMap<QString, bool> presences = mPresenceListener->initialPresences(online); |
252 mHeadingItem->setOnlineStatus(online); |
286 mHeadingItem->setOnlineStatus(online); |
253 |
287 |
254 mImageLabel = static_cast<CntImageLabel*>(document()->findWidget("cnt_contactcard_image")); |
288 |
255 connect(mImageLabel, SIGNAL(iconClicked()), this, SLOT(doChangeImage())); |
|
256 connect(mImageLabel, SIGNAL(iconLongPressed(const QPointF&)), this, SLOT(drawMenu(const QPointF&))); |
|
257 |
289 |
258 // avatar |
290 // avatar |
259 QList<QContactAvatar> details = mContact->details<QContactAvatar>(); |
291 QList<QContactAvatar> details = mContact->details<QContactAvatar>(); |
260 for (int i = 0;i < details.count();i++) |
292 for (int i = 0;i < details.count();i++) |
261 { |
293 { |
293 if (pos < CntContactCardDataItem::ESeparator && dataItem->isFocusable()) |
325 if (pos < CntContactCardDataItem::ESeparator && dataItem->isFocusable()) |
294 { |
326 { |
295 CntContactCardDetailItem* item = new CntContactCardDetailItem(index, mContainerWidget); |
327 CntContactCardDetailItem* item = new CntContactCardDetailItem(index, mContainerWidget); |
296 |
328 |
297 connect(item, SIGNAL(clicked()), this, SLOT(onItemActivated())); |
329 connect(item, SIGNAL(clicked()), this, SLOT(onItemActivated())); |
298 connect(item, SIGNAL(longPressed(const QPointF&)), this, SLOT(onLongPressed(const QPointF&))); |
330 |
299 |
331 if (!mIsTemporary) |
|
332 { |
|
333 connect(item, SIGNAL(longPressed(const QPointF&)), this, SLOT(onLongPressed(const QPointF&))); |
|
334 } |
|
335 |
300 if (mContact->isPreferredDetail(dataItem->action(), dataItem->detail())) |
336 if (mContact->isPreferredDetail(dataItem->action(), dataItem->detail())) |
301 { |
337 { |
302 dataItem->setSecondaryIcon(HbIcon("qtg_mono_favourites")); |
338 dataItem->setSecondaryIcon(HbIcon("qtg_mono_favourites")); |
303 mPreferredItems.insert(dataItem->action(), item); |
339 mPreferredItems.insert(dataItem->action(), item); |
|
340 } |
|
341 |
|
342 if (dataItem->detail().definitionName() == QContactOnlineAccount::DefinitionName) |
|
343 { |
|
344 for (int i = 0;i < presences.keys().count();i++) |
|
345 { |
|
346 QString fullAccount = presences.keys().at(i); |
|
347 QContactOnlineAccount account = dataItem->detail(); |
|
348 QString currentFullAccount = account.serviceProvider() + ':' + account.accountUri(); |
|
349 if (fullAccount == currentFullAccount) |
|
350 { |
|
351 if (presences.values().at(i)) |
|
352 { |
|
353 dataItem->setSecondaryIcon(HbIcon("qtg_small_online")); |
|
354 } |
|
355 mPresenceItems.insert(fullAccount, item); |
|
356 break; |
|
357 } |
|
358 } |
304 } |
359 } |
305 |
360 |
306 item->setDetails(dataItem); |
361 item->setDetails(dataItem); |
307 mContainerLayout->addItem(item); |
362 mContainerLayout->addItem(item); |
308 } |
363 } |
393 if( favouriteGroupId != 0 ) |
448 if( favouriteGroupId != 0 ) |
394 { |
449 { |
395 setAsFavorite = CntFavourite::isMemberOfFavouriteGroup( contactManager(), mContact ); |
450 setAsFavorite = CntFavourite::isMemberOfFavouriteGroup( contactManager(), mContact ); |
396 mHeadingItem->setFavoriteStatus( setAsFavorite ); // if contact is part of favourites group |
451 mHeadingItem->setFavoriteStatus( setAsFavorite ); // if contact is part of favourites group |
397 } |
452 } |
398 qobject_cast<HbAction *>(document()->findObject("cnt:setasfavorite"))->setVisible( !setAsFavorite ); |
453 static_cast<HbAction *>(document()->findObject("cnt:setasfavorite"))->setVisible( !setAsFavorite ); |
399 qobject_cast<HbAction *>(document()->findObject("cnt:removefromfavorite"))->setVisible( setAsFavorite ); |
454 static_cast<HbAction *>(document()->findObject("cnt:removefromfavorite"))->setVisible( setAsFavorite ); |
400 } |
455 } |
401 document()->findWidget("viewToolbar")->setParent(mView); |
456 document()->findWidget("viewToolbar")->setParent(mView); |
402 document()->findWidget("viewMenu")->setParent(mView); |
457 document()->findWidget("viewMenu")->setParent(mView); |
403 |
458 |
404 // Menu items |
459 // Menu items |
408 connectAction("cnt:removefromfavorite", SLOT(removeFromFavorite())); |
463 connectAction("cnt:removefromfavorite", SLOT(removeFromFavorite())); |
409 connectAction("cnt:placecontacttohs", SLOT(sendToHs())); |
464 connectAction("cnt:placecontacttohs", SLOT(sendToHs())); |
410 connectAction("cnt:edit", SLOT(editContact())); |
465 connectAction("cnt:edit", SLOT(editContact())); |
411 connectAction("cnt:history", SLOT(viewHistory())); |
466 connectAction("cnt:history", SLOT(viewHistory())); |
412 connectAction("cnt:sendMyCard", SLOT(sendBusinessCard())); |
467 connectAction("cnt:sendMyCard", SLOT(sendBusinessCard())); |
|
468 connectAction("cnt:addtocontact", SLOT(onAddedToContacts())); |
413 connectAction("cnt:activityStream", NULL); // placeholder until this action is implemented (needed to avoid memory leak) |
469 connectAction("cnt:activityStream", NULL); // placeholder until this action is implemented (needed to avoid memory leak) |
|
470 |
|
471 // disabled until this action is implemented |
|
472 static_cast<HbAction *>(document()->findObject("cnt:activityStream"))->setEnabled(false); |
|
473 |
|
474 connect(contactManager(), SIGNAL(contactsRemoved(const QList<QContactLocalId>&)), |
|
475 this, SLOT(contactDeletedFromOtherSource(const QList<QContactLocalId>&))); |
414 |
476 |
415 emit viewActivated( mViewManager, aArgs ); |
477 emit viewActivated( mViewManager, aArgs ); |
416 |
478 |
417 CNT_EXIT |
479 CNT_EXIT |
418 } |
480 } |
666 Place contact to homescreen as widget |
749 Place contact to homescreen as widget |
667 */ |
750 */ |
668 void CntContactCardViewPrivate::sendToHs() |
751 void CntContactCardViewPrivate::sendToHs() |
669 { |
752 { |
670 QVariantHash preferences; |
753 QVariantHash preferences; |
671 preferences["contactId"] = mContact->id().localId(); |
754 preferences["contactId"] = mContact->localId(); |
672 |
755 |
673 XQServiceRequest snd("com.nokia.services.hsapplication.IHomeScreenClient", |
756 XQServiceRequest snd("com.nokia.symbian.IHomeScreenClient", |
674 "addWidget(QString,QVariantHash)" |
757 "addWidget(QString,QVariantHash)" |
675 ,false); |
758 ,false); |
676 snd << QString("contactwidgethsplugin"); |
759 snd << QString("contactwidgethsplugin"); |
677 snd << preferences; |
760 snd << preferences; |
678 snd.send(); |
761 snd.send(); |
|
762 |
|
763 /* |
|
764 if (mRequest) |
|
765 { |
|
766 delete mRequest; |
|
767 mRequest = 0; |
|
768 } |
|
769 |
|
770 mRequest = mAppManager.create("com.nokia.symbian.IHomeScreenClient", "addWidget(QString,QVariantHash)", false); |
|
771 |
|
772 if (mRequest) |
|
773 { |
|
774 QList<QVariant> args; |
|
775 QVariantHash preferences; |
|
776 preferences["contactId"] = mContact->localId(); |
|
777 args << preferences; |
|
778 args << QString("contactwidgethsplugin"); |
|
779 mRequest->setArguments(args); |
|
780 mRequest->send(); |
|
781 } |
|
782 */ |
679 } |
783 } |
680 |
784 |
681 /*! |
785 /*! |
682 Launch contact editor |
786 Launch contact editor |
683 */ |
787 */ |
719 /*! |
823 /*! |
720 Delete contact |
824 Delete contact |
721 */ |
825 */ |
722 void CntContactCardViewPrivate::deleteContact() |
826 void CntContactCardViewPrivate::deleteContact() |
723 { |
827 { |
724 QString name = contactManager()->synthesizedDisplayLabel(*mContact); |
828 QString name = contactManager()->synthesizedContactDisplayLabel(*mContact); |
725 |
829 if (name.isEmpty()) |
726 HbMessageBox::question(HbParameterLengthLimiter(hbTrId("txt_phob_info_delete_1")).arg(name), this, SLOT(handleDeleteContact(HbAction*)), |
830 { |
727 hbTrId("txt_common_button_delete"), hbTrId("txt_common_button_cancel")); |
831 name = hbTrId("txt_phob_list_unnamed"); |
|
832 } |
|
833 |
|
834 HbMessageBox::question(HbParameterLengthLimiter(hbTrId("txt_phob_info_delete_1")).arg(name), this, SLOT(handleDeleteContact(int)), |
|
835 HbMessageBox::Delete | HbMessageBox::Cancel); |
728 } |
836 } |
729 |
837 |
730 /*! |
838 /*! |
731 Handle action for deleting a contact |
839 Handle action for deleting a contact |
732 */ |
840 */ |
733 void CntContactCardViewPrivate::handleDeleteContact(HbAction *action) |
841 void CntContactCardViewPrivate::handleDeleteContact(int action) |
734 { |
842 { |
735 HbMessageBox *note = static_cast<HbMessageBox*>(sender()); |
843 if (action == HbMessageBox::Delete) |
736 |
844 { |
737 if (note && action == note->actions().first()) |
845 disconnect(contactManager(), SIGNAL(contactsRemoved(const QList<QContactLocalId>&)), |
738 { |
846 this, SLOT(contactDeletedFromOtherSource(const QList<QContactLocalId>&))); |
739 contactManager()->removeContact(mContact->localId()); |
847 |
740 mViewManager->back( mArgs ); |
848 contactManager()->removeContact(mContact->localId()); |
|
849 emit backPressed(); |
|
850 mViewManager->back( mArgs, true ); |
741 } |
851 } |
742 } |
852 } |
743 |
853 |
744 /*! |
854 /*! |
745 Launch history view |
855 Launch history view |
757 /*! |
867 /*! |
758 Deactivate the view |
868 Deactivate the view |
759 */ |
869 */ |
760 void CntContactCardViewPrivate::deactivate() |
870 void CntContactCardViewPrivate::deactivate() |
761 { |
871 { |
762 mView->removeEventFilter(this); |
872 |
763 } |
873 } |
764 |
874 |
765 /*! |
875 /*! |
766 Send the business card / my card |
876 Send the business card / my card |
767 */ |
877 */ |
768 void CntContactCardViewPrivate::sendBusinessCard() |
878 void CntContactCardViewPrivate::sendBusinessCard() |
769 { |
879 { |
770 qDebug() << "CntContactCardViewPrivate::sendBusinessCard - IN"; |
880 CNT_ENTRY |
|
881 |
771 // Check if the contact has an image. |
882 // Check if the contact has an image. |
772 QList<QContactAvatar> avatars = mContact->details<QContactAvatar>(); |
883 QList<QContactAvatar> avatars = mContact->details<QContactAvatar>(); |
773 bool imageExists( false ); |
884 bool imageExists( false ); |
774 /*foreach(QContactAvatar a, mContact->details<QContactAvatar>()) |
885 /*foreach(QContactAvatar a, mContact->details<QContactAvatar>()) |
775 { |
886 { |
850 /*! |
962 /*! |
851 Execute the call / message / email action |
963 Execute the call / message / email action |
852 */ |
964 */ |
853 void CntContactCardViewPrivate::executeAction(QContact& aContact, const QContactDetail& aDetail, const QString& aAction, CntContactCardDetailItem* aItem) |
965 void CntContactCardViewPrivate::executeAction(QContact& aContact, const QContactDetail& aDetail, const QString& aAction, CntContactCardDetailItem* aItem) |
854 { |
966 { |
|
967 if (mIsExecutingAction) |
|
968 { |
|
969 return; |
|
970 } |
|
971 else |
|
972 { |
|
973 mIsExecutingAction = true; |
|
974 } |
|
975 |
855 CntActionLauncher* other = new CntActionLauncher(*contactManager(), aAction); |
976 CntActionLauncher* other = new CntActionLauncher(*contactManager(), aAction); |
856 connect(other, SIGNAL(actionExecuted(CntActionLauncher*)), this, SLOT(actionExecuted(CntActionLauncher*))); |
977 connect(other, SIGNAL(actionExecuted(CntActionLauncher*)), this, SLOT(actionExecuted(CntActionLauncher*))); |
857 if (aItem && aContact.preferredDetail(aAction).isEmpty()) |
978 if (aItem && aContact.preferredDetail(aAction).isEmpty()) |
858 { |
979 { |
859 setPreferredAction(aAction, aDetail, aItem); |
980 setPreferredAction(aAction, aDetail, aItem); |
885 /*! |
1007 /*! |
886 Execute dynamic action |
1008 Execute dynamic action |
887 */ |
1009 */ |
888 void CntContactCardViewPrivate::executeDynamicAction(QContact& aContact, QContactDetail aDetail, QContactActionDescriptor aActionDescriptor) |
1010 void CntContactCardViewPrivate::executeDynamicAction(QContact& aContact, QContactDetail aDetail, QContactActionDescriptor aActionDescriptor) |
889 { |
1011 { |
|
1012 if (mIsExecutingAction) |
|
1013 { |
|
1014 return; |
|
1015 } |
|
1016 else |
|
1017 { |
|
1018 mIsExecutingAction = true; |
|
1019 } |
|
1020 |
890 CntActionLauncher* other = new CntActionLauncher(*contactManager()); |
1021 CntActionLauncher* other = new CntActionLauncher(*contactManager()); |
891 connect(other, SIGNAL(actionExecuted(CntActionLauncher*)), this, SLOT(actionExecuted(CntActionLauncher*))); |
1022 connect(other, SIGNAL(actionExecuted(CntActionLauncher*)), this, SLOT(actionExecuted(CntActionLauncher*))); |
892 other->execute(aContact, aDetail, aActionDescriptor); |
1023 other->execute(aContact, aDetail, aActionDescriptor); |
893 } |
1024 } |
894 |
1025 |
895 void CntContactCardViewPrivate::actionExecuted(CntActionLauncher* aAction) |
1026 void CntContactCardViewPrivate::actionExecuted(CntActionLauncher* aAction) |
896 { |
1027 { |
897 aAction->deleteLater(); |
1028 aAction->deleteLater(); |
|
1029 mIsExecutingAction = false; |
898 } |
1030 } |
899 |
1031 |
900 /*! |
1032 /*! |
901 Item specific menu |
1033 Item specific menu |
902 */ |
1034 */ |
1109 dir.remove(s); |
1242 dir.remove(s); |
1110 } |
1243 } |
1111 } |
1244 } |
1112 } |
1245 } |
1113 |
1246 |
1114 QString vCardName = QString(mContact->displayLabel().append(".vcf")); |
1247 QString vCardName; |
|
1248 if ( mContact->displayLabel().isEmpty() ) { |
|
1249 vCardName = hbTrId("txt_phob_list_unnamed").append(".vcf"); |
|
1250 } else |
|
1251 vCardName = mContact->displayLabel().append(".vcf"); |
|
1252 |
1115 QString vCardPath = dir.absolutePath().append(QDir::separator()); |
1253 QString vCardPath = dir.absolutePath().append(QDir::separator()); |
1116 vCardPath.append(vCardName); |
1254 vCardPath.append(vCardName); |
1117 vCardPath = QDir::toNativeSeparators(vCardPath); |
1255 vCardPath = QDir::toNativeSeparators(vCardPath); |
1118 |
1256 |
1119 QVersitContactExporter exporter; |
1257 QVersitContactExporter exporter; |
|
1258 CntVCardDetailHandler hanlder; |
|
1259 exporter.setDetailHandler(&hanlder); |
1120 // The vCard version needs to be 2.1 due to backward compatiblity when sending |
1260 // The vCard version needs to be 2.1 due to backward compatiblity when sending |
1121 if (exporter.exportContacts(list, QVersitDocument::VCard21Type)) |
1261 if (exporter.exportContacts(list, QVersitDocument::VCard21Type)) |
1122 { |
1262 { |
1123 qDebug() << "CntContactCardViewPrivate::handleSendBusinessCard, VCard21Type"; |
1263 CNT_LOG_ARGS("VCard21Type"); |
1124 QList<QVersitDocument> docs = exporter.documents(); |
1264 QList<QVersitDocument> docs = exporter.documents(); |
1125 QFile f(vCardPath); |
1265 QFile f(vCardPath); |
1126 if ( f.open(QIODevice::WriteOnly) ) |
1266 if ( f.open(QIODevice::WriteOnly) ) |
1127 { |
1267 { |
1128 qDebug() << "CntContactCardViewPrivate::handleSendBusinessCard write VCard"; |
1268 CNT_LOG_ARGS("write VCard"); |
1129 // Start creating the vCard |
1269 // Start creating the vCard |
1130 QVersitWriter writer; |
1270 QVersitWriter writer; |
1131 writer.setDevice(&f); |
1271 writer.setDevice(&f); |
1132 |
1272 |
1133 bool ret = writer.startWriting(docs); |
1273 bool ret = writer.startWriting(docs); |
1198 */ |
1339 */ |
1199 void CntContactCardViewPrivate::drawMenu(const QPointF &aCoords) |
1340 void CntContactCardViewPrivate::drawMenu(const QPointF &aCoords) |
1200 { |
1341 { |
1201 HbMenu *menu = new HbMenu(); |
1342 HbMenu *menu = new HbMenu(); |
1202 menu->addAction(hbTrId("txt_phob_menu_change_picture"), this, SLOT(doChangeImage()) ); |
1343 menu->addAction(hbTrId("txt_phob_menu_change_picture"), this, SLOT(doChangeImage()) ); |
1203 if (mAvatar) |
1344 if (mAvatar && !mAvatar->imageUrl().isEmpty()) |
1204 { |
1345 { |
1205 menu->addAction(hbTrId("txt_phob_menu_remove_image"), this, SLOT(doRemoveImage()) ); |
1346 menu->addAction(hbTrId("txt_phob_menu_remove_image"), this, SLOT(doRemoveImage()) ); |
1206 } |
1347 } |
1207 menu->setAttribute( Qt::WA_DeleteOnClose ); |
1348 menu->setAttribute( Qt::WA_DeleteOnClose ); |
1208 menu->setPreferredPos( aCoords ); |
1349 menu->setPreferredPos( aCoords ); |
1227 QContactManager* CntContactCardViewPrivate::contactManager() |
1368 QContactManager* CntContactCardViewPrivate::contactManager() |
1228 { |
1369 { |
1229 return mViewManager->contactManager(SYMBIAN_BACKEND); |
1370 return mViewManager->contactManager(SYMBIAN_BACKEND); |
1230 } |
1371 } |
1231 |
1372 |
1232 void CntContactCardViewPrivate::keyPressed(QKeyEvent *event) |
1373 bool CntContactCardViewPrivate::eventFilter(QObject *obj, QEvent *event) |
1233 { |
1374 { |
1234 if (event->key() == Qt::Key_Yes ) |
1375 if (event->type() == QEvent::KeyPress && obj == mView->mainWindow()) |
1235 { |
1376 { |
1236 sendKeyPressed(); |
1377 QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); |
1237 } |
1378 if (keyEvent->key() == Qt::Key_Yes) |
1238 } |
1379 { |
1239 |
1380 return sendKeyPressed(); |
1240 void CntContactCardViewPrivate::sendKeyPressed() |
1381 } |
|
1382 } |
|
1383 return false; |
|
1384 } |
|
1385 |
|
1386 bool CntContactCardViewPrivate::sendKeyPressed() |
1241 { |
1387 { |
1242 int count = 0; |
1388 int count = 0; |
|
1389 bool keyConsumed = false; |
|
1390 |
1243 for (int index = 0; index < mDataContainer->itemCount(); index++) |
1391 for (int index = 0; index < mDataContainer->itemCount(); index++) |
1244 { |
1392 { |
1245 CntContactCardDataItem* dataItem = mDataContainer->dataItem(index); |
1393 CntContactCardDataItem* dataItem = mDataContainer->dataItem(index); |
1246 if (dataItem->action().compare("call", Qt::CaseInsensitive) == 0) |
1394 if (dataItem->action().compare("call", Qt::CaseInsensitive) == 0) |
1247 { |
1395 { |
1248 count++; |
1396 count++; |
1249 } |
1397 } |
1250 } |
1398 } |
1251 if (!count) |
1399 |
1252 { |
1400 if (count) |
1253 XQServiceRequest snd("com.nokia.services.logsservices.starter", "start(int,bool)", false); |
|
1254 snd << 0; // all calls |
|
1255 snd << true; // show dialpad |
|
1256 snd.send(); |
|
1257 } |
|
1258 else |
|
1259 { |
1401 { |
1260 QContactDetail preferredDetail = mContact->preferredDetail("call"); |
1402 QContactDetail preferredDetail = mContact->preferredDetail("call"); |
1261 if (!preferredDetail.isEmpty()) |
1403 if (!preferredDetail.isEmpty()) |
1262 { |
1404 { |
1263 executeAction(*mContact, preferredDetail, "call", NULL); |
1405 keyConsumed = true; |
|
1406 executeAction(*mContact, preferredDetail, "call"); |
1264 } |
1407 } |
1265 else if (count == 1 ) |
1408 else if (count == 1 ) |
1266 { |
1409 { |
1267 mContact->setPreferredDetail("call", mContact->details<QContactPhoneNumber>().first()); |
1410 keyConsumed = true; |
1268 executeAction( *mContact, mContact->details<QContactPhoneNumber>().first(), "call", NULL); |
1411 executeAction( *mContact, mContact->details<QContactPhoneNumber>().first(), "call"); |
1269 } |
1412 } |
1270 else if(count >= 2 && mAcceptSendKey) |
1413 else if(count >= 2 && mAcceptSendKey) |
1271 { |
1414 { |
|
1415 keyConsumed = true; |
1272 mAcceptSendKey = false; |
1416 mAcceptSendKey = false; |
1273 CntActionPopup *actionPopup = new CntActionPopup(mContact); |
1417 CntActionPopup *actionPopup = new CntActionPopup(mContact); |
1274 actionPopup->showActionPopup("call"); |
1418 actionPopup->showActionPopup("call"); |
1275 connect( actionPopup, SIGNAL(executeContactAction(QContact&, QContactDetail, QString)), this, |
1419 connect( actionPopup, SIGNAL(executeContactAction(QContact&, QContactDetail, QString)), this, |
1276 SLOT(executeAction(QContact&, QContactDetail, QString))); |
1420 SLOT(executeAction(QContact&, QContactDetail, QString))); |
1277 connect( actionPopup, SIGNAL(actionPopupCancelPressed()), this, |
1421 connect( actionPopup, SIGNAL(actionPopupCancelPressed()), this, |
1278 SLOT(sendKeyCancelSlot())); |
1422 SLOT(sendKeyCancelSlot())); |
1279 |
1423 } |
1280 } |
1424 else |
1281 } |
1425 { |
|
1426 //ignore |
|
1427 } |
|
1428 } |
|
1429 |
|
1430 return keyConsumed; |
1282 } |
1431 } |
1283 |
1432 |
1284 void CntContactCardViewPrivate::sendKeyCancelSlot() |
1433 void CntContactCardViewPrivate::sendKeyCancelSlot() |
1285 { |
1434 { |
1286 mAcceptSendKey = true; |
1435 mAcceptSendKey = true; |
1287 } |
1436 } |
|
1437 |
|
1438 void CntContactCardViewPrivate::onAddedToContacts() |
|
1439 { |
|
1440 emit addToContacts(); |
|
1441 } |
|
1442 |
|
1443 void CntContactCardViewPrivate::contactDeletedFromOtherSource(const QList<QContactLocalId>& contactIds) |
|
1444 { |
|
1445 if ( contactIds.contains(mContact->localId()) ) |
|
1446 { |
|
1447 // Do not switch to the previous view immediately. List views are |
|
1448 // not updated properly if this is not done in the event loop |
|
1449 QTimer::singleShot(0, this, SLOT(showRootView())); |
|
1450 } |
|
1451 } |
|
1452 |
1288 // end of file |
1453 // end of file |