|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * Description: |
|
14 * |
|
15 */ |
|
16 |
|
17 #include "cntcontactcardview_p.h" |
|
18 #include "cntthumbnailmanager.h" |
|
19 |
|
20 #include <QGraphicsLinearLayout> |
|
21 #include <QGraphicsSceneResizeEvent> |
|
22 #include <QStringList> |
|
23 #include <QStandardItemModel> |
|
24 #include <QKeyEvent> |
|
25 #include <QDir> |
|
26 |
|
27 #include <cntservicescontact.h> |
|
28 #include <qtcontacts.h> |
|
29 #include <hbapplication.h> |
|
30 #include <hbscrollarea.h> |
|
31 #include <hblabel.h> |
|
32 #include <hbmenu.h> |
|
33 #include <hbview.h> |
|
34 #include <hbtoolbar.h> |
|
35 #include <hbgroupbox.h> |
|
36 #include <hbaction.h> |
|
37 #include <hbmessagebox.h> |
|
38 #include <hbicon.h> |
|
39 #include <hbparameterlengthlimiter.h> |
|
40 #include <hbframeitem.h> |
|
41 #include <hbframedrawer.h> |
|
42 #include <hbselectiondialog.h> |
|
43 #include <hblistview.h> |
|
44 #include <hblistviewitem.h> |
|
45 #include <shareui.h> |
|
46 #include <maptileservice.h> //For maptile processing |
|
47 #include <qversitcontactexporter.h> |
|
48 #include <qversitwriter.h> |
|
49 #include <xqservicerequest.h> |
|
50 #include <QTimer> //Progress indication icon |
|
51 #include <QApplication> |
|
52 |
|
53 #include <cntdebug.h> |
|
54 #include "cntcontactcarddatacontainer.h" |
|
55 #include "cntcontactcardheadingitem.h" |
|
56 #include "cntcontactcarddataitem.h" |
|
57 #include "cntcontactcarddetailitem.h" |
|
58 #include "cntcontactcardcontextmenu.h" |
|
59 #include "cntmainwindow.h" |
|
60 #include "cntstringmapper.h" |
|
61 #include "cntdocumentloader.h" |
|
62 #include "cntimagelabel.h" |
|
63 #include "cntimageutility.h" |
|
64 #include "cntfavourite.h" |
|
65 #include "cntactionlauncher.h" |
|
66 #include "cntpresencelistener.h" |
|
67 #include "cntactionpopup.h" |
|
68 #include "cntvcarddetailhandler.h" |
|
69 #include "cntsavemanager.h" |
|
70 #include "cntextensionmanager.h" |
|
71 #include <cntabstractengine.h> |
|
72 #include <cntuiextensionfactory.h> |
|
73 #include <cntuicontactcardextension.h> |
|
74 #include <cntuisocialextension.h> |
|
75 |
|
76 #define CNT_MAPTILE_PROGRESS_TIMER 100 // 100 msec |
|
77 #define CNT_UNKNOWN_MAPTILE_STATUS -1 |
|
78 |
|
79 // A few list items (CntInitialPopulation) will be populated before the first view; |
|
80 // if there are more list items, they will be fetched and added one by one after the |
|
81 // first view has been shown to the user |
|
82 static const int CntListPopulationNotInProgress = -1; |
|
83 static const QEvent::Type ProcessPopulateListEvent = QEvent::User; |
|
84 static const int CntInitialPopulation = 8; |
|
85 |
|
86 const char *CNT_CONTACTCARDVIEW_XML = ":/xml/contacts_contactcard.docml"; |
|
87 const char *CNT_MAPTILE_INPROGRESS_ICON = "qtg_anim_small_loading_1"; |
|
88 const char *CNT_MAPTILE_SEARCH_STOP_ICON = "qtg_mono_search_stop"; |
|
89 /*! |
|
90 Constructor, initialize member variables. |
|
91 \a viewManager is the parent that creates this view. \a parent is a pointer to parent QGraphicsItem (by default this is 0) |
|
92 */ |
|
93 CntContactCardViewPrivate::CntContactCardViewPrivate(bool isTemporary) : |
|
94 QObject(), |
|
95 mContainerLayout(NULL), |
|
96 mContainerWidget(NULL), |
|
97 mContact(NULL), |
|
98 mDataContainer(NULL), |
|
99 mAvatar(NULL), |
|
100 mLoader(NULL), |
|
101 mVCardIcon(NULL), |
|
102 mShareUi(NULL), |
|
103 mAcceptSendKey(true), |
|
104 mPresenceListener(NULL), |
|
105 mIsTemporary(isTemporary), |
|
106 mIsExecutingAction(false), |
|
107 mMyCardId(0), |
|
108 mSaveManager(NULL), |
|
109 mListPopulationProgress(CntListPopulationNotInProgress), |
|
110 mStopListPopulation(false) |
|
111 { |
|
112 bool ok; |
|
113 document()->load(CNT_CONTACTCARDVIEW_XML, &ok); |
|
114 if (!ok) |
|
115 { |
|
116 qFatal("Unable to read :/xml/contacts_contactcard.docml"); |
|
117 } |
|
118 |
|
119 mView = static_cast<HbView*>(document()->findWidget("view")); |
|
120 |
|
121 //back button |
|
122 mBackKey = new HbAction(Hb::BackNaviAction, mView); |
|
123 mView->setNavigationAction(mBackKey); |
|
124 connect(mBackKey, SIGNAL(triggered()), this, SLOT(showPreviousView())); |
|
125 |
|
126 mProgressTimer = new QTimer(this); |
|
127 mProgressTimer->setSingleShot(true); |
|
128 connect(mProgressTimer, SIGNAL(timeout()),this, SLOT(updateSpinningIndicator())); |
|
129 |
|
130 mMaptile = new MapTileService; |
|
131 if( mMaptile->isLocationFeatureEnabled(MapTileService::AppTypeContacts) ) |
|
132 { |
|
133 //Connect for maptile status evenet |
|
134 QObject::connect( mMaptile, SIGNAL(maptileFetchingStatusUpdate(int, |
|
135 int,int)),this,SLOT(mapTileStatusReceived(int,int,int))); |
|
136 } |
|
137 |
|
138 mScrollArea = static_cast<HbScrollArea*>(document()->findWidget(QString("scrollArea"))); |
|
139 mHeadingItem = static_cast<CntContactCardHeadingItem*>(document()->findWidget(QString("cnt_contactcard_heading"))); |
|
140 mImageLabel = static_cast<CntImageLabel*>(document()->findWidget("cnt_contactcard_image")); |
|
141 |
|
142 // presence listener |
|
143 mPresenceListener = new CntPresenceListener(); |
|
144 connect(mPresenceListener, SIGNAL(fullPresenceUpdated(bool)), mHeadingItem, SLOT(setOnlineStatus(bool))); |
|
145 connect(mPresenceListener, SIGNAL(accountPresenceUpdated(const QString&, bool)), |
|
146 this, SLOT(updateItemPresence(const QString&, bool))); |
|
147 |
|
148 |
|
149 mSaveManager = new CntSaveManager(); |
|
150 } |
|
151 |
|
152 /*! |
|
153 Destructor |
|
154 */ |
|
155 CntContactCardViewPrivate::~CntContactCardViewPrivate() |
|
156 { |
|
157 // stop the progress timer |
|
158 if ( mProgressTimer && mProgressTimer->isActive()) |
|
159 { |
|
160 mProgressTimer->stop(); |
|
161 } |
|
162 |
|
163 // Clear the container to avoid double deletion |
|
164 if (mContainerLayout != NULL) |
|
165 { |
|
166 int count = mContainerLayout->count(); |
|
167 for (int i=0; i<count; i++) |
|
168 { |
|
169 // do not delete items. They will be deleted automatically |
|
170 mContainerLayout->removeAt(i); |
|
171 } |
|
172 } |
|
173 |
|
174 // Delete all the detail pointers if any |
|
175 qDeleteAll(mDetailPtrs); |
|
176 mDetailPtrs.clear(); |
|
177 |
|
178 mView->deleteLater(); |
|
179 |
|
180 delete mContact; |
|
181 mContact = NULL; |
|
182 |
|
183 delete mDataContainer; |
|
184 mDataContainer = NULL; |
|
185 |
|
186 delete mAvatar; |
|
187 mAvatar = NULL; |
|
188 |
|
189 delete mLoader; |
|
190 mLoader = NULL; |
|
191 |
|
192 if (mVCardIcon) |
|
193 { |
|
194 delete mVCardIcon; |
|
195 mVCardIcon = NULL; |
|
196 } |
|
197 |
|
198 if (mShareUi) |
|
199 { |
|
200 delete mShareUi; |
|
201 mShareUi = NULL; |
|
202 } |
|
203 |
|
204 delete mPresenceListener; |
|
205 mPresenceListener = NULL; |
|
206 |
|
207 delete mMaptile; |
|
208 mMaptile = NULL; |
|
209 |
|
210 //delete maptile label memory |
|
211 for ( int index = 0; index < mMaptileLabelList.count(); index++ ) |
|
212 { |
|
213 if( mMaptileLabelList[index] ) |
|
214 { |
|
215 delete mMaptileLabelList[index]; |
|
216 mMaptileLabelList[index] = NULL ; |
|
217 } |
|
218 } |
|
219 |
|
220 delete mSaveManager; |
|
221 mSaveManager = NULL; |
|
222 } |
|
223 |
|
224 /*! |
|
225 Activates a previous view |
|
226 */ |
|
227 void CntContactCardViewPrivate::showPreviousView() |
|
228 { |
|
229 // stop list population, if it is still in progress |
|
230 mStopListPopulation = true; |
|
231 |
|
232 int returnValue = KCntServicesReturnValueContactNotModified; |
|
233 |
|
234 //save the contact if avatar has been changed. |
|
235 QContact contact = contactManager()->contact(mContact->localId()); |
|
236 if ( contact != *mContact && contactManager()->error() == QContactManager::NoError) |
|
237 { |
|
238 disconnect(contactManager(), SIGNAL(contactsRemoved(const QList<QContactLocalId>&)), |
|
239 this, SLOT(contactDeletedFromOtherSource(const QList<QContactLocalId>&))); |
|
240 CntSaveManager::CntSaveResult result = mSaveManager->saveContact(mContact, contactManager()); |
|
241 |
|
242 if (result != CntSaveManager::ENothingDone) |
|
243 returnValue = KCntServicesReturnValueContactSaved; |
|
244 else |
|
245 returnValue = KCntServicesReturnValueContactNotModified; |
|
246 } |
|
247 |
|
248 emit backPressed(returnValue); |
|
249 |
|
250 mViewManager->back( mArgs ); |
|
251 } |
|
252 |
|
253 /*! |
|
254 Activates the root view |
|
255 */ |
|
256 void CntContactCardViewPrivate::showRootView() |
|
257 { |
|
258 // stop list population, if it is still in progress |
|
259 mStopListPopulation = true; |
|
260 |
|
261 mViewManager->back( mArgs, true ); |
|
262 } |
|
263 |
|
264 /*! |
|
265 Handle extension action (tapping on activity stream button) |
|
266 */ |
|
267 void CntContactCardViewPrivate::handleExtensionAction() |
|
268 { |
|
269 CNT_ENTRY |
|
270 CntExtensionManager& mgr = mEngine->extensionManager(); |
|
271 for (int i = 0; i < mgr.pluginCount(); i++) |
|
272 { |
|
273 CntUiSocialExtension* socialExtension = mgr.pluginAt(i)->socialExtension(); |
|
274 if (socialExtension) |
|
275 { |
|
276 CntViewParameters params; |
|
277 socialExtension->handleToolbarAction(params); |
|
278 if (params.count()) |
|
279 { |
|
280 QList<int> keys = params.keys(); |
|
281 for (int j = 0; j < keys.count(); j++) |
|
282 { |
|
283 mArgs.insert(keys.at(j), params.value(keys.at(j))); |
|
284 } |
|
285 mViewManager->changeView(mArgs); |
|
286 break; |
|
287 } |
|
288 } |
|
289 } |
|
290 |
|
291 CNT_EXIT |
|
292 } |
|
293 |
|
294 /* |
|
295 Activates a default view and setup name label texts |
|
296 */ |
|
297 void CntContactCardViewPrivate::activate(const CntViewParameters aArgs) |
|
298 { |
|
299 CNT_ENTRY |
|
300 mArgs = aArgs; |
|
301 |
|
302 mViewManager = &mEngine->viewManager(); |
|
303 mThumbnailManager = &mEngine->thumbnailManager(); |
|
304 connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void*, int, int)), |
|
305 this, SLOT(thumbnailReady(QPixmap, void*, int, int))); |
|
306 |
|
307 HbMainWindow* window = mView->mainWindow(); |
|
308 if (window) |
|
309 { |
|
310 connect(window, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(setOrientation(Qt::Orientation))); |
|
311 window->installEventFilter(this); |
|
312 |
|
313 setOrientation(window->orientation()); |
|
314 } |
|
315 |
|
316 qApp->installEventFilter(this); |
|
317 |
|
318 QContact contact = aArgs.value(ESelectedContact).value<QContact>(); |
|
319 mContact = new QContact( contact ); |
|
320 |
|
321 //my card |
|
322 mMyCardId = contactManager()->selfContactId(); |
|
323 |
|
324 populateHeadingItem(); |
|
325 |
|
326 populateListItems(); |
|
327 |
|
328 bool myCard = mContact->localId() == mMyCardId; |
|
329 if (myCard) |
|
330 { |
|
331 mView->menu()->clearActions(); |
|
332 mView->toolBar()->removeAction(static_cast<HbAction*>(document()->findObject(QString("cnt:history")))); |
|
333 } |
|
334 else |
|
335 { |
|
336 mView->toolBar()->removeAction(static_cast<HbAction*>(document()->findObject(QString("cnt:sendMyCard")))); |
|
337 } |
|
338 if (mIsTemporary) |
|
339 { |
|
340 mView->menu()->clearActions(); |
|
341 mView->toolBar()->clearActions(); |
|
342 mView->toolBar()->addAction(static_cast<HbAction*>(document()->findObject(QString("cnt:addtocontact")))); |
|
343 } |
|
344 |
|
345 document()->findWidget("viewToolbar")->setParent(mView); |
|
346 document()->findWidget("viewMenu")->setParent(mView); |
|
347 |
|
348 // Menu items |
|
349 connectAction("cnt:sendbusinesscard", SLOT(sendBusinessCard())); |
|
350 connectAction("cnt:deletecontact", SLOT(deleteContact())); |
|
351 connectAction("cnt:setasfavorite", SLOT(setAsFavorite())); |
|
352 connectAction("cnt:removefromfavorite", SLOT(removeFromFavorite())); |
|
353 connectAction("cnt:placecontacttohs", SLOT(sendToHs())); |
|
354 connectAction("cnt:edit", SLOT(editContact())); |
|
355 connectAction("cnt:history", SLOT(viewHistory())); |
|
356 connectAction("cnt:sendMyCard", SLOT(sendBusinessCard())); |
|
357 connectAction("cnt:addtocontact", SLOT(onAddedToContacts())); |
|
358 connectAction("cnt:activityStream", SLOT(handleExtensionAction())); |
|
359 |
|
360 CntExtensionManager& mgr = mEngine->extensionManager(); |
|
361 if (mgr.pluginCount()) |
|
362 { |
|
363 for (int i = 0; i < mgr.pluginCount(); i++) |
|
364 { |
|
365 CntUiSocialExtension* socialExtension = mgr.pluginAt(i)->socialExtension(); |
|
366 if (socialExtension) |
|
367 { |
|
368 static_cast<HbAction*> (document()->findObject("cnt:activityStream"))->setEnabled(true); |
|
369 break; |
|
370 } |
|
371 else |
|
372 { |
|
373 static_cast<HbAction*> (document()->findObject("cnt:activityStream"))->setEnabled(false); |
|
374 } |
|
375 } |
|
376 } |
|
377 else |
|
378 { |
|
379 static_cast<HbAction*> (document()->findObject("cnt:activityStream"))->setEnabled(false); |
|
380 } |
|
381 |
|
382 |
|
383 connect(contactManager(), SIGNAL(contactsRemoved(const QList<QContactLocalId>&)), |
|
384 this, SLOT(contactDeletedFromOtherSource(const QList<QContactLocalId>&))); |
|
385 |
|
386 emit viewActivated( mViewManager, aArgs ); |
|
387 |
|
388 CNT_EXIT |
|
389 } |
|
390 |
|
391 void CntContactCardViewPrivate::populateHeadingItem() |
|
392 { |
|
393 CNT_ENTRY |
|
394 |
|
395 Q_ASSERT(mHeadingItem != NULL && mContact != NULL); |
|
396 |
|
397 mHeadingItem->setDetails(mContact); |
|
398 |
|
399 bool myCard = mContact->localId() == mMyCardId; |
|
400 |
|
401 if (!mIsTemporary) |
|
402 { |
|
403 connect(mHeadingItem, SIGNAL(passLongPressed(const QPointF&)), this, SLOT(drawMenu(const QPointF&)), Qt::UniqueConnection); |
|
404 connect(mHeadingItem, SIGNAL(passShortPressed(const QPointF&)), this, SLOT(doChangeImage()), Qt::UniqueConnection); |
|
405 connect(mImageLabel, SIGNAL(iconClicked()), this, SLOT(doChangeImage()), Qt::UniqueConnection); |
|
406 connect(mImageLabel, SIGNAL(iconLongPressed(const QPointF&)), this, SLOT(drawMenu(const QPointF&)), Qt::UniqueConnection); |
|
407 } |
|
408 else |
|
409 { |
|
410 mHeadingItem->ungrabGesture(Qt::TapGesture); |
|
411 mImageLabel->ungrabGesture(Qt::TapGesture); |
|
412 } |
|
413 |
|
414 bool online; |
|
415 mInitiialPrecenceData = mPresenceListener->initialPresences(*mContact, online); |
|
416 mHeadingItem->setOnlineStatus(online); |
|
417 |
|
418 if (!myCard) { |
|
419 bool setAsFavorite = CntFavourite::isMemberOfFavouriteGroup(contactManager(), mContact); |
|
420 mHeadingItem->setFavoriteStatus(setAsFavorite); // if contact is part of favourites group |
|
421 static_cast<HbAction *>(document()->findObject("cnt:setasfavorite"))->setVisible( !setAsFavorite ); |
|
422 static_cast<HbAction *>(document()->findObject("cnt:removefromfavorite"))->setVisible( setAsFavorite ); |
|
423 } |
|
424 |
|
425 // avatar |
|
426 QList<QContactAvatar> details = mContact->details<QContactAvatar>(); |
|
427 for (int i = 0;i < details.count();i++) |
|
428 { |
|
429 if (details.at(i).imageUrl().isValid()) |
|
430 { |
|
431 if (!mAvatar) |
|
432 { |
|
433 mAvatar = new QContactAvatar(details.at(i)); |
|
434 mThumbnailManager->getThumbnail(ThumbnailManager::ThumbnailLarge, mAvatar->imageUrl().toString()); |
|
435 } |
|
436 else if (*mAvatar != details.at(i)) |
|
437 { |
|
438 delete mAvatar; |
|
439 mAvatar = new QContactAvatar(details.at(i)); |
|
440 mThumbnailManager->getThumbnail(ThumbnailManager::ThumbnailLarge, mAvatar->imageUrl().toString()); |
|
441 } |
|
442 break; |
|
443 } |
|
444 } |
|
445 |
|
446 CNT_EXIT |
|
447 } |
|
448 |
|
449 void CntContactCardViewPrivate::populateListItems() |
|
450 { |
|
451 CNT_ENTRY |
|
452 |
|
453 Q_ASSERT(mContact != NULL && mScrollArea != NULL); |
|
454 |
|
455 if (mListPopulationProgress == CntListPopulationNotInProgress) { |
|
456 mListPopulationProgress = 0; |
|
457 |
|
458 if (!mDataContainer) { |
|
459 mDataContainer = new CntContactCardDataContainer( |
|
460 mMaptile, |
|
461 mEngine->extensionManager(), |
|
462 mView->mainWindow()->orientation()); |
|
463 } |
|
464 |
|
465 // fill the data container with contact details |
|
466 mDataContainer->setContactData(mContact); |
|
467 |
|
468 // scroll area + container widget |
|
469 mContainerWidget = mScrollArea->contentWidget(); |
|
470 if (!mContainerWidget) { |
|
471 // initialize |
|
472 mScrollArea->setScrollDirections(Qt::Vertical); |
|
473 |
|
474 mContainerWidget = new QGraphicsWidget(); |
|
475 mScrollArea->setContentWidget(mContainerWidget); // takes ownership. Old widget is deleted |
|
476 |
|
477 mContainerLayout = new QGraphicsLinearLayout(Qt::Vertical); |
|
478 mContainerLayout->setContentsMargins(0, 0, 0, 0); |
|
479 mContainerLayout->setSpacing(0); |
|
480 mContainerLayout->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); |
|
481 |
|
482 mContainerWidget->setLayout(mContainerLayout); // takes ownership. Old layout is deleted |
|
483 } else { |
|
484 // Already initialized |
|
485 Q_ASSERT(mContainerLayout != NULL); |
|
486 |
|
487 // Clear the container |
|
488 int count = mContainerLayout->count(); |
|
489 for (int i = 0; i < count; i++) { |
|
490 // do not delete items. They will be deleted automatically |
|
491 mContainerLayout->removeAt(i); |
|
492 } |
|
493 } |
|
494 |
|
495 // Delete all the detail pointers if any |
|
496 qDeleteAll(mDetailPtrs); |
|
497 mDetailPtrs.clear(); |
|
498 } |
|
499 |
|
500 |
|
501 do { |
|
502 if (mListPopulationProgress == mDataContainer->itemCount() || mStopListPopulation) { |
|
503 // population of the list has completed |
|
504 mListPopulationProgress = CntListPopulationNotInProgress; |
|
505 mStopListPopulation = false; |
|
506 disconnect(mView->mainWindow(), SIGNAL(viewReady()), this, SLOT(populateListItems())); |
|
507 return; |
|
508 } |
|
509 |
|
510 CntContactCardDataItem* dataItem = mDataContainer->dataItem(mListPopulationProgress); |
|
511 int pos = dataItem->position(); |
|
512 |
|
513 // communication methods |
|
514 if (pos < CntContactCardDataItem::ESeparator && dataItem->isFocusable()) |
|
515 { |
|
516 CntContactCardDetailItem* item = new CntContactCardDetailItem(mListPopulationProgress, mContainerWidget); |
|
517 mDetailPtrs.append(item); |
|
518 |
|
519 connect(item, SIGNAL(clicked()), this, SLOT(onItemActivated())); |
|
520 |
|
521 if (!mIsTemporary) |
|
522 { |
|
523 connect(item, SIGNAL(longPressed(const QPointF&)), this, SLOT(onLongPressed(const QPointF&))); |
|
524 } |
|
525 |
|
526 if (mContact->isPreferredDetail(dataItem->action(), dataItem->detail())) |
|
527 { |
|
528 dataItem->setSecondaryIcon(HbIcon("qtg_mono_favourites")); |
|
529 mPreferredItems.insert(dataItem->action(), item); |
|
530 } |
|
531 |
|
532 if (dataItem->detail().definitionName() == QContactOnlineAccount::DefinitionName) |
|
533 { |
|
534 for (int i = 0;i < mInitiialPrecenceData.keys().count();i++) |
|
535 { |
|
536 QString fullAccount = mInitiialPrecenceData.keys().at(i); |
|
537 QContactOnlineAccount account = dataItem->detail(); |
|
538 QString currentFullAccount = account.serviceProvider() + ':' + account.accountUri(); |
|
539 if (fullAccount == currentFullAccount) |
|
540 { |
|
541 if (mInitiialPrecenceData.values().at(i)) |
|
542 { |
|
543 dataItem->setSecondaryIcon(HbIcon("qtg_small_online")); |
|
544 } |
|
545 mPresenceItems.insert(fullAccount, item); |
|
546 break; |
|
547 } |
|
548 } |
|
549 } |
|
550 |
|
551 item->setDetails(dataItem); |
|
552 mContainerLayout->addItem(item); |
|
553 } |
|
554 |
|
555 // separator |
|
556 else if (pos == CntContactCardDataItem::ESeparator) |
|
557 { |
|
558 HbFrameItem* frameItem = new HbFrameItem(QString("qtg_fr_list_separator"), HbFrameDrawer::NinePieces); |
|
559 HbLabel* label = static_cast<HbLabel*>(document()->findWidget(QString("separator"))); |
|
560 label->setPlainText(dataItem->titleText()); |
|
561 label->setBackgroundItem(frameItem); // takes ownership |
|
562 mContainerLayout->addItem(label); |
|
563 } |
|
564 |
|
565 // details |
|
566 else |
|
567 { |
|
568 //map support (image only) |
|
569 if (pos >= CntContactCardDataItem::EAddress && pos <= CntContactCardDataItem::EAddressWork && !dataItem->icon().isNull()) |
|
570 { |
|
571 int addressType = MapTileService::AddressPreference; |
|
572 |
|
573 if( pos == CntContactCardDataItem::EAddressHome ) |
|
574 { |
|
575 addressType = MapTileService::AddressHome; |
|
576 } |
|
577 else if( pos == CntContactCardDataItem::EAddressWork ) |
|
578 { |
|
579 addressType = MapTileService::AddressWork; |
|
580 } |
|
581 |
|
582 HbLabel* maptileLabel = loadMaptileLabel( addressType ); |
|
583 setMaptileLabel( maptileLabel, dataItem->icon() ); |
|
584 mContainerLayout->addItem( maptileLabel ); |
|
585 mMaptileLabelList.insert( addressType, maptileLabel ); |
|
586 } |
|
587 //other details |
|
588 else |
|
589 { |
|
590 CntContactCardDetailItem* item = new CntContactCardDetailItem(mListPopulationProgress, mContainerWidget, false); |
|
591 mDetailPtrs.append(item); |
|
592 |
|
593 //To check whether maptile status icon is set with the address |
|
594 if( ( dataItem->titleText() == hbTrId("txt_phob_formlabel_address") || |
|
595 dataItem->titleText() == hbTrId("txt_phob_formlabel_address_home")|| |
|
596 dataItem->titleText() == hbTrId("txt_phob_formlabel_address_work") ) && |
|
597 dataItem->secondaryIcon().iconName() == QString(CNT_MAPTILE_INPROGRESS_ICON) ) |
|
598 |
|
599 { |
|
600 //Information for displaying maptile fetching progress bar. |
|
601 //Memory will be deleted from the queue. |
|
602 CntContactCardMapTileDetail* detail = new CntContactCardMapTileDetail; |
|
603 detail->mContactId = mContact->localId(); |
|
604 |
|
605 if( dataItem->titleText() == hbTrId("txt_phob_formlabel_address") ) |
|
606 { |
|
607 detail->mAddressType = MapTileService::AddressPreference; |
|
608 } |
|
609 else if ( dataItem->titleText() == hbTrId("txt_phob_formlabel_address_home") ) |
|
610 { |
|
611 detail->mAddressType = MapTileService::AddressHome; |
|
612 } |
|
613 else if( dataItem->titleText() == hbTrId("txt_phob_formlabel_address_work") ) |
|
614 { |
|
615 detail->mAddressType = MapTileService::AddressWork; |
|
616 } |
|
617 |
|
618 detail->mProgressCount = 0; |
|
619 detail->mDetailItem = item; |
|
620 detail->maptileStatus = CNT_UNKNOWN_MAPTILE_STATUS; |
|
621 mAddressList.append( detail ); |
|
622 |
|
623 //Update the spinning indicator |
|
624 updateSpinningIndicator(); |
|
625 |
|
626 } |
|
627 item->setDetails(dataItem); |
|
628 mContainerLayout->addItem(item); |
|
629 } |
|
630 } |
|
631 |
|
632 ++mListPopulationProgress; |
|
633 } while (mListPopulationProgress < CntInitialPopulation); |
|
634 |
|
635 if (mListPopulationProgress <= CntInitialPopulation) { |
|
636 connect(mView->mainWindow(), SIGNAL(viewReady()), this, SLOT(populateListItems())); |
|
637 } else { |
|
638 disconnect(mView->mainWindow(), SIGNAL(viewReady()), this, SLOT(populateListItems())); |
|
639 HbApplication::instance()->postEvent(this, new QEvent(ProcessPopulateListEvent)); |
|
640 } |
|
641 |
|
642 CNT_EXIT |
|
643 } |
|
644 |
|
645 /* |
|
646 Connects the action with a slot and also sets the view as the parent for the action. |
|
647 */ |
|
648 void CntContactCardViewPrivate::connectAction(QString actionName, const char* slot) |
|
649 { |
|
650 HbAction *action = qobject_cast<HbAction *>(document()->findObject(actionName)); |
|
651 if (action) { |
|
652 action->setParent(mView); |
|
653 if (slot != NULL) { |
|
654 connect(action, SIGNAL(triggered()), this, slot); |
|
655 } |
|
656 } |
|
657 } |
|
658 |
|
659 /* |
|
660 Updates the maptile fetching spinning indicator icon |
|
661 */ |
|
662 void CntContactCardViewPrivate::updateSpinningIndicator() |
|
663 { |
|
664 //Check all address details( Preferred, Home, Work ) |
|
665 for( int index = 0 ; index < mAddressList.count(); ) |
|
666 { |
|
667 //Maptile status not received update the rotating icon |
|
668 if( mAddressList[index]->maptileStatus == CNT_UNKNOWN_MAPTILE_STATUS ) |
|
669 { |
|
670 QString iconName("qtg_anim_small_loading_"); |
|
671 mAddressList[index]->mProgressCount = mAddressList[index]->mProgressCount % 10 + 1; |
|
672 iconName.append(QVariant(mAddressList[index]->mProgressCount).toString()); |
|
673 |
|
674 HbIcon icon(iconName); |
|
675 mAddressList[index]->mDetailItem->setSecondaryIconItem( icon ); |
|
676 mAddressList[index]->mDetailItem->update(); |
|
677 mProgressTimer->start(CNT_MAPTILE_PROGRESS_TIMER); |
|
678 index++; |
|
679 } |
|
680 else |
|
681 { |
|
682 //Maptile status received. Show the maptile image if available |
|
683 MapTileService::AddressType sourceAddressType = |
|
684 static_cast <MapTileService::AddressType>( mAddressList[index]->mAddressType ); |
|
685 |
|
686 QContactLocalId contactId = mContact->localId(); |
|
687 |
|
688 if( mAddressList[index] != NULL ) |
|
689 { |
|
690 if( mAddressList[index]->maptileStatus == MapTileService::MapTileFetchingCompleted ) |
|
691 { |
|
692 |
|
693 //Read the maptile path and update the image |
|
694 QString imagePath; |
|
695 mMaptile->getMapTileImage( |
|
696 contactId, sourceAddressType, imagePath, mView->mainWindow()->orientation() ); |
|
697 |
|
698 if( !imagePath.isEmpty() ) |
|
699 { |
|
700 //Empty icon. Clear the inprogress icon |
|
701 HbIcon emptyIcon; |
|
702 mAddressList[index]->mDetailItem->setSecondaryIconItem( emptyIcon ); |
|
703 |
|
704 HbIcon icon( imagePath ); |
|
705 |
|
706 HbLabel* maptileLabel = loadMaptileLabel( sourceAddressType ); |
|
707 setMaptileLabel( maptileLabel, icon ); |
|
708 mMaptileLabelList.insert( sourceAddressType, maptileLabel ); |
|
709 |
|
710 //find the index of the item and insert maptile in the next index |
|
711 for( int itemIndex = 0 ; itemIndex < mContainerLayout->count(); itemIndex++ ) |
|
712 { |
|
713 if( mContainerLayout->itemAt(itemIndex) == mAddressList[index]->mDetailItem ) |
|
714 { |
|
715 mContainerLayout->insertItem( itemIndex+1, maptileLabel ); |
|
716 break; |
|
717 } |
|
718 } |
|
719 |
|
720 } |
|
721 else |
|
722 { |
|
723 //Maptile image not available. Show the search stop icon |
|
724 setMaptileSearchStopIcon( index ); |
|
725 } |
|
726 } |
|
727 else |
|
728 { |
|
729 //Maptile fetching failed. Show the search stop icon |
|
730 setMaptileSearchStopIcon( index ); |
|
731 } |
|
732 |
|
733 delete mAddressList[index]; |
|
734 mAddressList.removeAt(index); |
|
735 } |
|
736 else |
|
737 { |
|
738 //increment the index now |
|
739 index++; |
|
740 } |
|
741 } |
|
742 } |
|
743 } |
|
744 |
|
745 /* |
|
746 * Sets the search stop icon to secondary icon item |
|
747 */ |
|
748 void CntContactCardViewPrivate::setMaptileSearchStopIcon( int index ) |
|
749 { |
|
750 if( index < mAddressList.count() ) |
|
751 { |
|
752 QString iconName(CNT_MAPTILE_SEARCH_STOP_ICON); |
|
753 HbIcon icon(iconName); |
|
754 mAddressList[index]->mDetailItem->setSecondaryIconItem( icon ); |
|
755 mAddressList[index]->mDetailItem->update(); |
|
756 } |
|
757 } |
|
758 |
|
759 /* |
|
760 * Slot to receive the maptile status information |
|
761 */ |
|
762 void CntContactCardViewPrivate::mapTileStatusReceived( int contactid, int addressType, int status) |
|
763 { |
|
764 //Update the maptile status information for all 3( Preferred, Work, Home ) address |
|
765 for( int index = 0 ; index < mAddressList.count(); index++ ) |
|
766 { |
|
767 if( mAddressList[index]->mContactId == contactid && |
|
768 mAddressList[index]->mAddressType == addressType ) |
|
769 { |
|
770 mAddressList[index]->maptileStatus = status; |
|
771 } |
|
772 } |
|
773 |
|
774 updateSpinningIndicator(); |
|
775 } |
|
776 |
|
777 /* |
|
778 * Updates correct maptile image when screen orientation changes. |
|
779 */ |
|
780 void CntContactCardViewPrivate::updateMaptileImage() |
|
781 { |
|
782 //If there is no maptile displayed, return immediately |
|
783 if( mMaptileLabelList.count() > 0 ) |
|
784 { |
|
785 QContactLocalId contactId = mContact->localId(); |
|
786 |
|
787 QList<QContactAddress> addressDetails = mContact->details<QContactAddress>(); |
|
788 |
|
789 //address |
|
790 QString contextHome(QContactAddress::ContextHome.operator QString()); |
|
791 QString contextWork(QContactAddress::ContextWork.operator QString()); |
|
792 MapTileService::AddressType sourceAddressType |
|
793 = MapTileService::AddressPreference; |
|
794 |
|
795 QString imagePath; |
|
796 |
|
797 for ( int i = 0; i < addressDetails.count(); i++ ) |
|
798 { |
|
799 if ( !addressDetails[i].contexts().isEmpty() && |
|
800 addressDetails[i].contexts().at(0) == contextHome ) |
|
801 { |
|
802 sourceAddressType = MapTileService::AddressHome; |
|
803 } |
|
804 else if ( !addressDetails[i].contexts().isEmpty() && |
|
805 addressDetails[i].contexts().at(0) == contextWork ) |
|
806 { |
|
807 sourceAddressType = MapTileService::AddressWork; |
|
808 } |
|
809 |
|
810 int status = mMaptile->getMapTileImage( |
|
811 contactId, |
|
812 sourceAddressType, |
|
813 imagePath, |
|
814 mView->mainWindow()->orientation() ); |
|
815 if( !imagePath.isEmpty() ) |
|
816 { |
|
817 HbIcon icon( imagePath ); |
|
818 HbLabel* label = mMaptileLabelList.value( sourceAddressType ); |
|
819 if( label ) |
|
820 { |
|
821 setMaptileLabel( label, icon ); |
|
822 } |
|
823 } |
|
824 } |
|
825 } |
|
826 } |
|
827 |
|
828 |
|
829 /* |
|
830 * Asscoiate the maptile label widget with maptile image |
|
831 */ |
|
832 void CntContactCardViewPrivate::setMaptileLabel( HbLabel*& mapLabel, const HbIcon& icon ) |
|
833 { |
|
834 mapLabel->clear(); |
|
835 mapLabel->setIcon( icon ); |
|
836 |
|
837 qreal leftMarginSize; |
|
838 mapLabel->getContentsMargins( &leftMarginSize, 0 , 0 , 0 ); |
|
839 mapLabel->setPreferredSize( |
|
840 QSizeF(icon.width() + leftMarginSize, icon.height())); |
|
841 |
|
842 } |
|
843 |
|
844 /* |
|
845 * Load the maptile label based on the address type |
|
846 */ |
|
847 HbLabel* CntContactCardViewPrivate::loadMaptileLabel( int addressType ) |
|
848 { |
|
849 HbLabel* maptileLabel = NULL; |
|
850 |
|
851 if( addressType == MapTileService::AddressPreference ) |
|
852 { |
|
853 maptileLabel = static_cast<HbLabel*>(document()->findWidget(QString("maptilePreferenceWidget"))); |
|
854 } |
|
855 else if( addressType == MapTileService::AddressHome ) |
|
856 { |
|
857 maptileLabel = static_cast<HbLabel*>(document()->findWidget(QString("maptileHomeWidget"))); |
|
858 } |
|
859 else if( addressType == MapTileService::AddressWork ) |
|
860 { |
|
861 maptileLabel = static_cast<HbLabel*>(document()->findWidget(QString("maptileWorkWidget"))); |
|
862 } |
|
863 |
|
864 return maptileLabel; |
|
865 } |
|
866 |
|
867 /* |
|
868 * Update the presence status icon of action item with the given accountUri |
|
869 */ |
|
870 void CntContactCardViewPrivate::updateItemPresence(const QString& accountUri, bool online) |
|
871 { |
|
872 CntContactCardDetailItem* item = mPresenceItems.value(accountUri); |
|
873 |
|
874 if (item) |
|
875 { |
|
876 if (online) |
|
877 { |
|
878 mDataContainer->dataItem(item->index())->setSecondaryIcon(HbIcon("qtg_small_online")); |
|
879 } |
|
880 else |
|
881 { |
|
882 mDataContainer->dataItem(item->index())->setSecondaryIcon(HbIcon()); |
|
883 } |
|
884 item->setDetails(mDataContainer->dataItem(item->index())); |
|
885 } |
|
886 } |
|
887 |
|
888 void CntContactCardViewPrivate::thumbnailReady(const QPixmap& pixmap, void *data, int id, int error) |
|
889 { |
|
890 CNT_ENTRY |
|
891 |
|
892 Q_UNUSED(data); |
|
893 Q_UNUSED(id); |
|
894 if (!error) |
|
895 { |
|
896 HbIcon icon(pixmap); |
|
897 mHeadingItem->setIcon(icon); |
|
898 mVCardIcon = new HbIcon(pixmap); |
|
899 mImageLabel->clear(); |
|
900 mImageLabel->setIcon(pixmap); |
|
901 } |
|
902 |
|
903 CNT_EXIT |
|
904 } |
|
905 |
|
906 /*! |
|
907 Place contact to homescreen as widget |
|
908 */ |
|
909 void CntContactCardViewPrivate::sendToHs() |
|
910 { |
|
911 QVariantHash preferences; |
|
912 preferences["contactId"] = mContact->localId(); |
|
913 |
|
914 XQServiceRequest snd("com.nokia.symbian.IHomeScreenClient", |
|
915 "addWidget(QString,QVariantHash)" |
|
916 ,false); |
|
917 snd << QString("contactwidgethsplugin"); |
|
918 snd << preferences; |
|
919 snd.send(); |
|
920 |
|
921 /* |
|
922 if (mRequest) |
|
923 { |
|
924 delete mRequest; |
|
925 mRequest = 0; |
|
926 } |
|
927 |
|
928 mRequest = mAppManager.create("com.nokia.symbian.IHomeScreenClient", "addWidget(QString,QVariantHash)", false); |
|
929 |
|
930 if (mRequest) |
|
931 { |
|
932 QList<QVariant> args; |
|
933 QVariantHash preferences; |
|
934 preferences["contactId"] = mContact->localId(); |
|
935 args << preferences; |
|
936 args << QString("contactwidgethsplugin"); |
|
937 mRequest->setArguments(args); |
|
938 mRequest->send(); |
|
939 } |
|
940 */ |
|
941 } |
|
942 |
|
943 /*! |
|
944 Launch contact editor |
|
945 */ |
|
946 void CntContactCardViewPrivate::editContact() |
|
947 { |
|
948 QVariant var; |
|
949 var.setValue(*mContact); |
|
950 |
|
951 mArgs.insert(ESelectedContact, var); |
|
952 mArgs.insert(EViewId, editView); |
|
953 |
|
954 mViewManager->changeView( mArgs ); |
|
955 } |
|
956 |
|
957 void CntContactCardViewPrivate::addToGroup() |
|
958 { |
|
959 } |
|
960 |
|
961 void CntContactCardViewPrivate::setAsFavorite() |
|
962 { |
|
963 QContactId id = mContact->id(); |
|
964 CntFavourite::addContactToFavouriteGroup( contactManager(), id ); |
|
965 |
|
966 QContact c = contactManager()->contact(mContact->localId()); |
|
967 |
|
968 delete mContact; |
|
969 mContact = NULL; |
|
970 |
|
971 mContact = new QContact(c); |
|
972 |
|
973 qobject_cast<HbAction *>(document()->findObject("cnt:removefromfavorite"))->setVisible(true); |
|
974 qobject_cast<HbAction *>(document()->findObject("cnt:setasfavorite"))->setVisible(false); |
|
975 mHeadingItem->setFavoriteStatus(true); |
|
976 } |
|
977 |
|
978 void CntContactCardViewPrivate::removeFromFavorite() |
|
979 { |
|
980 QContactId id = mContact->id(); |
|
981 CntFavourite::removeContactFromFavouriteGroup( contactManager(), id ); |
|
982 |
|
983 QContact c = contactManager()->contact(mContact->localId()); |
|
984 |
|
985 delete mContact; |
|
986 mContact = NULL; |
|
987 |
|
988 mContact = new QContact(c); |
|
989 |
|
990 qobject_cast<HbAction *>(document()->findObject("cnt:removefromfavorite"))->setVisible(false); |
|
991 qobject_cast<HbAction *>(document()->findObject("cnt:setasfavorite"))->setVisible(true); |
|
992 mHeadingItem->setFavoriteStatus(false); |
|
993 } |
|
994 |
|
995 /*! |
|
996 Delete contact |
|
997 */ |
|
998 void CntContactCardViewPrivate::deleteContact() |
|
999 { |
|
1000 QString name = contactManager()->synthesizedContactDisplayLabel(*mContact); |
|
1001 if (name.isEmpty()) |
|
1002 { |
|
1003 name = hbTrId("txt_phob_list_unnamed"); |
|
1004 } |
|
1005 |
|
1006 HbMessageBox::question(HbParameterLengthLimiter(hbTrId("txt_phob_info_delete_1")).arg(name), this, SLOT(handleDeleteContact(int)), |
|
1007 HbMessageBox::Delete | HbMessageBox::Cancel); |
|
1008 } |
|
1009 |
|
1010 /*! |
|
1011 Handle action for deleting a contact |
|
1012 */ |
|
1013 void CntContactCardViewPrivate::handleDeleteContact(int action) |
|
1014 { |
|
1015 if (action == HbMessageBox::Delete) |
|
1016 { |
|
1017 disconnect(contactManager(), SIGNAL(contactsRemoved(const QList<QContactLocalId>&)), |
|
1018 this, SLOT(contactDeletedFromOtherSource(const QList<QContactLocalId>&))); |
|
1019 |
|
1020 bool success = contactManager()->removeContact(mContact->localId()); |
|
1021 |
|
1022 int returnValue = success ? KCntServicesReturnValueContactDeleted : KCntServicesReturnValueContactNotModified; |
|
1023 |
|
1024 emit backPressed(returnValue); |
|
1025 |
|
1026 mViewManager->back( mArgs, true ); |
|
1027 } |
|
1028 } |
|
1029 |
|
1030 /*! |
|
1031 Launch history view |
|
1032 */ |
|
1033 void CntContactCardViewPrivate::viewHistory() |
|
1034 { |
|
1035 QVariant var; |
|
1036 var.setValue(*mContact); |
|
1037 mArgs.insert(ESelectedContact, var); |
|
1038 mArgs.insert(EViewId, historyView); |
|
1039 |
|
1040 mViewManager->changeView( mArgs ); |
|
1041 } |
|
1042 |
|
1043 /*! |
|
1044 Deactivate the view |
|
1045 */ |
|
1046 void CntContactCardViewPrivate::deactivate() |
|
1047 { |
|
1048 } |
|
1049 |
|
1050 /*! |
|
1051 Send the business card / my card |
|
1052 */ |
|
1053 void CntContactCardViewPrivate::sendBusinessCard() |
|
1054 { |
|
1055 CNT_ENTRY |
|
1056 |
|
1057 // Check if the contact has an image. |
|
1058 QList<QContactAvatar> avatars = mContact->details<QContactAvatar>(); |
|
1059 bool imageExists( false ); |
|
1060 /*foreach(QContactAvatar a, mContact->details<QContactAvatar>()) |
|
1061 { |
|
1062 if (!a.imageUrl().isEmpty()) |
|
1063 { |
|
1064 imageExists = true; |
|
1065 HbMessageBox *note = new HbMessageBox( |
|
1066 hbTrId("txt_phob_info_add_contact_card_image_to_business_c"), |
|
1067 HbMessageBox::MessageTypeQuestion); |
|
1068 note->setIcon(*mVCardIcon); |
|
1069 note->clearActions(); |
|
1070 |
|
1071 HbAction* ok = new HbAction(hbTrId("txt_common_button_ok"), note); |
|
1072 HbAction* cancel = new HbAction(hbTrId("txt_common_button_cancel"), note); |
|
1073 |
|
1074 ok->setObjectName( "ok" ); |
|
1075 cancel->setObjectName( "cancel" ); |
|
1076 |
|
1077 note->addAction( ok ); |
|
1078 note->addAction( cancel ); |
|
1079 |
|
1080 note->setModal( true ); |
|
1081 note->setAttribute(Qt::WA_DeleteOnClose, true ); |
|
1082 note->open( this, SLOT(handleSendBusinessCard(HbAction*))); |
|
1083 break; |
|
1084 } |
|
1085 }*/ |
|
1086 |
|
1087 if ( !imageExists ) |
|
1088 { |
|
1089 CNT_LOG_ARGS("snd vCard without image") |
|
1090 handleSendBusinessCard( NULL ); // no image |
|
1091 } |
|
1092 |
|
1093 CNT_EXIT |
|
1094 } |
|
1095 |
|
1096 /*! |
|
1097 Set orientation of the view |
|
1098 */ |
|
1099 void CntContactCardViewPrivate::setOrientation(Qt::Orientation orientation) |
|
1100 { |
|
1101 if (orientation == Qt::Vertical) |
|
1102 { |
|
1103 // reading "portrait" section |
|
1104 document()->load(CNT_CONTACTCARDVIEW_XML, "portrait"); |
|
1105 } |
|
1106 else |
|
1107 { |
|
1108 // reading "landscape" section |
|
1109 document()->load(CNT_CONTACTCARDVIEW_XML, "landscape"); |
|
1110 } |
|
1111 //Update the maptile image |
|
1112 updateMaptileImage(); |
|
1113 } |
|
1114 |
|
1115 /*! |
|
1116 Called after user clicked on the listview. |
|
1117 */ |
|
1118 void CntContactCardViewPrivate::onItemActivated() |
|
1119 { |
|
1120 CntContactCardDetailItem *item = qobject_cast<CntContactCardDetailItem*>(sender()); |
|
1121 int index = item->index(); |
|
1122 CntContactCardDataItem& dataItem = *mDataContainer->dataItem(index); |
|
1123 QString action = mDataContainer->dataItem(index)->action(); |
|
1124 CntUiContactCardExtension* extension = dataItem.contactCardExtension(); |
|
1125 if (!extension) |
|
1126 { |
|
1127 //It's not an extension action. |
|
1128 // Check if action is internal |
|
1129 QList<QContactActionDescriptor> actionDescriptors = QContactAction::actionDescriptors(action, "symbian", 1); |
|
1130 if (0 < actionDescriptors.count()) |
|
1131 { |
|
1132 // These actions are considered internal(vendor=symbian and version=1) |
|
1133 executeAction(*mContact, dataItem.detail(), action, item); |
|
1134 } |
|
1135 else |
|
1136 { |
|
1137 //Handle dynamic actions differently |
|
1138 executeDynamicAction(*mContact, dataItem.detail(), dataItem.actionDescriptor()); |
|
1139 } |
|
1140 } else { |
|
1141 // The action is from an extension |
|
1142 int indexWithinPlugin = dataItem.contactCardExtensionActionIndex(); |
|
1143 extension->handleShortPress(indexWithinPlugin); |
|
1144 } |
|
1145 } |
|
1146 |
|
1147 /*! |
|
1148 Execute the call / message / email action |
|
1149 */ |
|
1150 void CntContactCardViewPrivate::executeAction(QContact& aContact, const QContactDetail& aDetail, const QString& aAction, CntContactCardDetailItem* aItem) |
|
1151 { |
|
1152 if (mIsExecutingAction) |
|
1153 { |
|
1154 return; |
|
1155 } |
|
1156 else |
|
1157 { |
|
1158 mIsExecutingAction = true; |
|
1159 } |
|
1160 |
|
1161 CntActionLauncher* other = new CntActionLauncher(*contactManager(), aAction); |
|
1162 connect(other, SIGNAL(actionExecuted(CntActionLauncher*)), this, SLOT(actionExecuted(CntActionLauncher*))); |
|
1163 if (aItem && aContact.preferredDetail(aAction).isEmpty()) |
|
1164 { |
|
1165 setPreferredAction(aAction, aDetail, aItem); |
|
1166 } |
|
1167 other->execute(aContact, aDetail); |
|
1168 } |
|
1169 |
|
1170 |
|
1171 /*! |
|
1172 Execute the call / message / email action |
|
1173 */ |
|
1174 void CntContactCardViewPrivate::executeAction(QContact& aContact, const QContactDetail& aDetail, const QString& aAction) |
|
1175 { |
|
1176 //TODO: need refactoring |
|
1177 CntContactCardDetailItem* detailItem = NULL; |
|
1178 for (int index = 0; index < mDataContainer->itemCount(); index++) |
|
1179 { |
|
1180 QContactDetail detail = mDataContainer->dataItem(index)->detail(); |
|
1181 QString action = mDataContainer->dataItem(index)->action(); |
|
1182 if (detail == aDetail && action == aAction) |
|
1183 { |
|
1184 detailItem = static_cast<CntContactCardDetailItem*>(mContainerLayout->itemAt(index)); |
|
1185 break; |
|
1186 } |
|
1187 } |
|
1188 executeAction(aContact, aDetail, aAction, detailItem); |
|
1189 mAcceptSendKey=true; |
|
1190 } |
|
1191 |
|
1192 /*! |
|
1193 Execute dynamic action |
|
1194 */ |
|
1195 void CntContactCardViewPrivate::executeDynamicAction(QContact& aContact, QContactDetail aDetail, QContactActionDescriptor aActionDescriptor) |
|
1196 { |
|
1197 if (mIsExecutingAction) |
|
1198 { |
|
1199 return; |
|
1200 } |
|
1201 else |
|
1202 { |
|
1203 mIsExecutingAction = true; |
|
1204 } |
|
1205 |
|
1206 CntActionLauncher* other = new CntActionLauncher(*contactManager()); |
|
1207 connect(other, SIGNAL(actionExecuted(CntActionLauncher*)), this, SLOT(actionExecuted(CntActionLauncher*))); |
|
1208 other->execute(aContact, aDetail, aActionDescriptor); |
|
1209 } |
|
1210 |
|
1211 void CntContactCardViewPrivate::actionExecuted(CntActionLauncher* aAction) |
|
1212 { |
|
1213 aAction->deleteLater(); |
|
1214 mIsExecutingAction = false; |
|
1215 } |
|
1216 |
|
1217 /*! |
|
1218 Item specific menu |
|
1219 */ |
|
1220 void CntContactCardViewPrivate::onLongPressed(const QPointF &aCoords) |
|
1221 { |
|
1222 CntContactCardDetailItem *item = qobject_cast<CntContactCardDetailItem*>(sender()); |
|
1223 int index = item->index(); |
|
1224 |
|
1225 CntContactCardContextMenu *menu = new CntContactCardContextMenu( item ); |
|
1226 HbAction *communicationAction = 0; |
|
1227 HbAction *dynamicAction = 0; |
|
1228 HbAction *videoCommunicationAction = 0; |
|
1229 HbAction *preferredAction = 0; |
|
1230 CntStringMapper stringMapper; |
|
1231 |
|
1232 QString action = mDataContainer->dataItem(index)->action(); |
|
1233 QContactDetail detail = mDataContainer->dataItem(index)->detail(); |
|
1234 |
|
1235 if (action.compare("call", Qt::CaseInsensitive) == 0) |
|
1236 { |
|
1237 QContactDetail detail = mDataContainer->dataItem(index)->detail(); |
|
1238 if (detail.definitionName() == QContactPhoneNumber::DefinitionName) |
|
1239 { |
|
1240 QContactPhoneNumber number = static_cast<QContactPhoneNumber>(detail); |
|
1241 QString context = number.contexts().isEmpty() ? QString() : number.contexts().first(); |
|
1242 QString subtype = number.subTypes().isEmpty() ? number.definitionName() : number.subTypes().first(); |
|
1243 |
|
1244 communicationAction = menu->addAction(stringMapper.getItemSpecificMenuLocString(subtype, context)); |
|
1245 videoCommunicationAction = menu->addAction(hbTrId("txt_phob_menu_call_video_number")); |
|
1246 } |
|
1247 } |
|
1248 else if (action.compare("message", Qt::CaseInsensitive) == 0) |
|
1249 { |
|
1250 communicationAction = menu->addAction(hbTrId("txt_phob_menu_send_message")); |
|
1251 } |
|
1252 else if (action.compare("email", Qt::CaseInsensitive) == 0) |
|
1253 { |
|
1254 if (!detail.contexts().isEmpty()) |
|
1255 { |
|
1256 communicationAction = menu->addAction(stringMapper.getItemSpecificMenuLocString(detail.definitionName(), detail.contexts().first())); |
|
1257 } |
|
1258 else |
|
1259 { |
|
1260 communicationAction = menu->addAction(stringMapper.getItemSpecificMenuLocString(detail.definitionName(), QString())); |
|
1261 } |
|
1262 } |
|
1263 else if (action.compare("url", Qt::CaseInsensitive) == 0) |
|
1264 { |
|
1265 if (!detail.contexts().isEmpty()) |
|
1266 { |
|
1267 communicationAction = menu->addAction(stringMapper.getItemSpecificMenuLocString(detail.definitionName(), detail.contexts().first())); |
|
1268 } |
|
1269 else |
|
1270 { |
|
1271 communicationAction = menu->addAction(stringMapper.getItemSpecificMenuLocString(detail.definitionName(), QString())); |
|
1272 } |
|
1273 } |
|
1274 else if (1 > QContactAction::actionDescriptors(action, "symbian", 1).count()) |
|
1275 { |
|
1276 // Do verification that action is not internal type(vendor=symbian and version=1) |
|
1277 // If hard coded action is not found, fetch localization from dynamic action |
|
1278 // and create dynamic action item. |
|
1279 dynamicAction = menu->addAction(mDataContainer->dataItem(index)->longPressText()); |
|
1280 } |
|
1281 |
|
1282 if (action.compare("call", Qt::CaseInsensitive) == 0) |
|
1283 { |
|
1284 preferredAction = menu->addAction(hbTrId("txt_phob_menu_set_as_default_number")); |
|
1285 } |
|
1286 else if (action.compare("message", Qt::CaseInsensitive) == 0) |
|
1287 { |
|
1288 preferredAction = menu->addAction(hbTrId("txt_phob_menu_set_as_default_number")); |
|
1289 } |
|
1290 else if (action.compare("email", Qt::CaseInsensitive) == 0) |
|
1291 { |
|
1292 preferredAction = menu->addAction(hbTrId("txt_phob_menu_set_as_default_email")); |
|
1293 } |
|
1294 |
|
1295 if (mContact->isPreferredDetail(action, detail) && preferredAction) |
|
1296 { |
|
1297 preferredAction->setEnabled(false); |
|
1298 } |
|
1299 |
|
1300 if ( communicationAction ) |
|
1301 { |
|
1302 communicationAction->setObjectName( "communicationAction" ); |
|
1303 } |
|
1304 if ( videoCommunicationAction ) |
|
1305 { |
|
1306 videoCommunicationAction->setObjectName( "videoCommunicationAction" ); |
|
1307 } |
|
1308 |
|
1309 if ( dynamicAction ) |
|
1310 { |
|
1311 dynamicAction->setObjectName( "dynamicAction" ); |
|
1312 } |
|
1313 |
|
1314 if ( preferredAction ) |
|
1315 { |
|
1316 preferredAction->setObjectName( "preferredAction" ); |
|
1317 menu->insertSeparator(preferredAction); |
|
1318 } |
|
1319 |
|
1320 menu->setPreferredPos( aCoords ); |
|
1321 menu->setAttribute( Qt::WA_DeleteOnClose, true ); |
|
1322 menu->open( this, SLOT(handleMenuAction(HbAction*)) ); |
|
1323 } |
|
1324 |
|
1325 void CntContactCardViewPrivate::handleMenuAction(HbAction* aAction) |
|
1326 { |
|
1327 CntContactCardContextMenu* menu = static_cast<CntContactCardContextMenu*>(sender()); |
|
1328 CntContactCardDetailItem *item = menu->item(); |
|
1329 int index = item->index(); |
|
1330 |
|
1331 QString action = mDataContainer->dataItem(index)->action(); |
|
1332 QContactDetail detail = mDataContainer->dataItem(index)->detail(); |
|
1333 |
|
1334 QString name = aAction->objectName(); |
|
1335 |
|
1336 if ( name == "communicationAction" ) |
|
1337 { |
|
1338 executeAction(*mContact, detail, action, item); |
|
1339 } |
|
1340 |
|
1341 if ( name == "videoCommunicationAction" ) |
|
1342 { |
|
1343 //service name latter on should come from service table. |
|
1344 executeAction(*mContact, detail, "videocall", item); |
|
1345 } |
|
1346 if ( name == "dynamicAction" ) |
|
1347 { |
|
1348 executeDynamicAction(*mContact, detail, mDataContainer->dataItem(index)->actionDescriptor()); |
|
1349 } |
|
1350 |
|
1351 if ( name == "preferredAction" ) |
|
1352 { |
|
1353 setPreferredAction(action, detail, item); |
|
1354 } |
|
1355 } |
|
1356 |
|
1357 /*! |
|
1358 Set selected detail as preferred for selected action in detail item |
|
1359 */ |
|
1360 void CntContactCardViewPrivate::setPreferredAction(const QString &aAction, const QContactDetail &aDetail, CntContactCardDetailItem *aDetailItem) |
|
1361 { |
|
1362 if (aAction == "call" || aAction == "message" || aAction == "email") |
|
1363 { |
|
1364 mContact->setPreferredDetail(aAction, aDetail); |
|
1365 contactManager()->saveContact(mContact); |
|
1366 if (mPreferredItems.contains(aAction)) |
|
1367 { |
|
1368 CntContactCardDetailItem *oldItem = mPreferredItems.value(aAction); |
|
1369 mDataContainer->dataItem(oldItem->index())->setSecondaryIcon(HbIcon()); |
|
1370 oldItem->setDetails(mDataContainer->dataItem(oldItem->index())); |
|
1371 } |
|
1372 |
|
1373 mDataContainer->dataItem(aDetailItem->index())->setSecondaryIcon(HbIcon("qtg_mono_favourites")); |
|
1374 aDetailItem->setDetails(mDataContainer->dataItem(aDetailItem->index())); |
|
1375 |
|
1376 mPreferredItems.insert(aAction, aDetailItem); |
|
1377 } |
|
1378 } |
|
1379 |
|
1380 |
|
1381 void CntContactCardViewPrivate::handleSendBusinessCard( HbAction* aAction ) |
|
1382 { |
|
1383 CNT_ENTRY |
|
1384 Q_UNUSED(aAction); |
|
1385 |
|
1386 QList<QContact> list; |
|
1387 /*if ( aAction && aAction->objectName() == "cancel" ) |
|
1388 { |
|
1389 QContact tmpContact( *mContact ); |
|
1390 foreach ( QContactAvatar a, tmpContact.details<QContactAvatar>() ) |
|
1391 { |
|
1392 tmpContact.removeDetail( &a ); |
|
1393 } |
|
1394 list.append( tmpContact ); |
|
1395 } |
|
1396 else |
|
1397 { |
|
1398 list.append( *mContact ); |
|
1399 }*/ |
|
1400 QContact tmpContact( *mContact ); |
|
1401 foreach ( QContactAvatar a, tmpContact.details<QContactAvatar>() ) |
|
1402 { |
|
1403 tmpContact.removeDetail( &a ); |
|
1404 } |
|
1405 |
|
1406 //temproral solution for a contact without name - add an empty name, |
|
1407 //so vcard construction doesn't fail |
|
1408 //TODO: use custom handler again when new QVersitContactExporterDetailHandlerV2 |
|
1409 //(part of QtVersit) is available in the platform |
|
1410 QList<QContactName> names = tmpContact.details<QContactName>(); |
|
1411 if (names.count() > 0) |
|
1412 { |
|
1413 QContactName name = names.at(0); |
|
1414 if (name.firstName().isEmpty() && name.lastName().isEmpty()) |
|
1415 { |
|
1416 //empty first and last names - update with empty string |
|
1417 name.setFirstName(QString("")); |
|
1418 tmpContact.saveDetail(&name); |
|
1419 } |
|
1420 } |
|
1421 else |
|
1422 { |
|
1423 //no name detail - create one |
|
1424 QContactName name; |
|
1425 name.setFirstName(QString("")); |
|
1426 tmpContact.saveDetail(&name); |
|
1427 } //temproral solution for a contact without name - add an empty name, |
|
1428 //so vcard construction doesn't fail - end |
|
1429 |
|
1430 list.append( tmpContact ); |
|
1431 |
|
1432 QString tempDir = QDir::tempPath().append("/tempcntvcard"); |
|
1433 QDir dir(tempDir); |
|
1434 |
|
1435 // Temporary directory to store the vCard file |
|
1436 if (!dir.exists()) |
|
1437 { |
|
1438 // Create a temp directory |
|
1439 if (!QDir::temp().mkdir("tempcntvcard")) |
|
1440 { |
|
1441 return; |
|
1442 } |
|
1443 } |
|
1444 else |
|
1445 { |
|
1446 // Empty the temp directory since the other vCards are not required |
|
1447 QStringList l = dir.entryList(); |
|
1448 foreach(QString s, l) |
|
1449 { |
|
1450 if (dir.exists(s)) |
|
1451 { |
|
1452 dir.remove(s); |
|
1453 } |
|
1454 } |
|
1455 } |
|
1456 |
|
1457 QString vCardName; |
|
1458 if ( mContact->displayLabel().isEmpty() ) { |
|
1459 vCardName = hbTrId("txt_phob_list_unnamed").append(".vcf"); |
|
1460 } |
|
1461 else { |
|
1462 // Remove invalid characters from file name |
|
1463 QString filename = mContact->displayLabel().trimmed(); |
|
1464 QString invalidChars("?*<>/\"|\\:"); |
|
1465 QChar replaceChar('_'); |
|
1466 QChar *data = filename.data(); |
|
1467 int count(0); |
|
1468 while ( !data->isNull() ) { |
|
1469 if ( invalidChars.contains(*data) ) { |
|
1470 *data = replaceChar; |
|
1471 count++; |
|
1472 } |
|
1473 ++data; |
|
1474 } |
|
1475 |
|
1476 // Check if filename contains only special characters |
|
1477 if ( count == filename.count() ) |
|
1478 filename = "_"; |
|
1479 vCardName = filename.append(".vcf"); |
|
1480 } |
|
1481 |
|
1482 |
|
1483 QString vCardPath = dir.absolutePath().append(QDir::separator()); |
|
1484 vCardPath.append(vCardName); |
|
1485 vCardPath = QDir::toNativeSeparators(vCardPath); |
|
1486 |
|
1487 QVersitContactExporter exporter; |
|
1488 //TODO: use custom handler again when new QVersitContactExporterDetailHandlerV2 |
|
1489 //(part of QtVersit) is available in the platform |
|
1490 //CntVCardDetailHandler hanlder; |
|
1491 //exporter.setDetailHandler(&hanlder); |
|
1492 // The vCard version needs to be 2.1 due to backward compatiblity when sending |
|
1493 if (exporter.exportContacts(list, QVersitDocument::VCard21Type)) |
|
1494 { |
|
1495 CNT_LOG_ARGS("VCard21Type"); |
|
1496 QList<QVersitDocument> docs = exporter.documents(); |
|
1497 QFile f(vCardPath); |
|
1498 if ( f.open(QIODevice::WriteOnly) ) |
|
1499 { |
|
1500 CNT_LOG_ARGS("write VCard"); |
|
1501 // Start creating the vCard |
|
1502 QVersitWriter writer; |
|
1503 writer.setDevice(&f); |
|
1504 |
|
1505 bool ret = writer.startWriting(docs); |
|
1506 ret = writer.waitForFinished(); |
|
1507 |
|
1508 // Create the vCard and send it to messaging service |
|
1509 if (!mShareUi) { |
|
1510 mShareUi = new ShareUi(); |
|
1511 } |
|
1512 QStringList l; |
|
1513 l << vCardPath; |
|
1514 mShareUi->send(l, true); |
|
1515 } |
|
1516 } |
|
1517 |
|
1518 CNT_EXIT |
|
1519 } |
|
1520 |
|
1521 |
|
1522 /*! |
|
1523 Called after the user clicked "Change Image" from popup menu after |
|
1524 longpressing the image in this view. |
|
1525 */ |
|
1526 void CntContactCardViewPrivate::doChangeImage() |
|
1527 { |
|
1528 QVariant var; |
|
1529 var.setValue(*mContact); |
|
1530 |
|
1531 mArgs.insert(ESelectedContact, var); |
|
1532 mArgs.insert(EViewId, imageEditorView); |
|
1533 |
|
1534 mViewManager->changeView( mArgs ); |
|
1535 } |
|
1536 |
|
1537 /*! |
|
1538 Called after the user clicked "Remove Image" from popup menu after |
|
1539 longpressing the image in this view. |
|
1540 */ |
|
1541 void CntContactCardViewPrivate::doRemoveImage() |
|
1542 { |
|
1543 if (mAvatar) |
|
1544 { |
|
1545 CntImageUtility imageUtility; |
|
1546 QString filePath=mAvatar->imageUrl().toString(); |
|
1547 |
|
1548 bool success = mContact->removeDetail(mAvatar); |
|
1549 if (success) |
|
1550 { |
|
1551 if (!filePath.isEmpty()) |
|
1552 { |
|
1553 // Check if image removable. |
|
1554 CntImageUtility imageUtility; |
|
1555 if(imageUtility.isImageRemovable(filePath)) |
|
1556 { |
|
1557 imageUtility.removeImage(filePath); |
|
1558 } |
|
1559 } |
|
1560 mAvatar->setImageUrl(QUrl()); |
|
1561 mImageLabel->clear(); |
|
1562 mImageLabel->setAvatarIcon(HbIcon("qtg_large_add_contact_picture")); |
|
1563 mHeadingItem->setIcon(HbIcon("qtg_large_add_contact_picture")); |
|
1564 |
|
1565 disconnect(contactManager(), SIGNAL(contactsRemoved(const QList<QContactLocalId>&)), |
|
1566 this, SLOT(contactDeletedFromOtherSource(const QList<QContactLocalId>&))); |
|
1567 CntSaveManager::CntSaveResult result = mSaveManager->saveContact(mContact, contactManager()); |
|
1568 } |
|
1569 } |
|
1570 } |
|
1571 |
|
1572 /*! |
|
1573 Draw the image specific content menu |
|
1574 */ |
|
1575 void CntContactCardViewPrivate::drawMenu(const QPointF &aCoords) |
|
1576 { |
|
1577 HbMenu *menu = new HbMenu(); |
|
1578 menu->addAction(hbTrId("txt_phob_menu_change_picture"), this, SLOT(doChangeImage()) ); |
|
1579 if (mAvatar && !mAvatar->imageUrl().isEmpty()) |
|
1580 { |
|
1581 menu->addAction(hbTrId("txt_phob_menu_remove_image"), this, SLOT(doRemoveImage()) ); |
|
1582 } |
|
1583 menu->setAttribute( Qt::WA_DeleteOnClose ); |
|
1584 menu->setPreferredPos( aCoords ); |
|
1585 menu->open(); |
|
1586 } |
|
1587 |
|
1588 /*! |
|
1589 Return the pointer to the document loader |
|
1590 */ |
|
1591 CntDocumentLoader* CntContactCardViewPrivate::document() |
|
1592 { |
|
1593 if (!mLoader) |
|
1594 { |
|
1595 mLoader = new CntDocumentLoader(); |
|
1596 } |
|
1597 return mLoader; |
|
1598 } |
|
1599 |
|
1600 /*! |
|
1601 Return pointer to the contact manager |
|
1602 */ |
|
1603 QContactManager* CntContactCardViewPrivate::contactManager() |
|
1604 { |
|
1605 return &mEngine->contactManager(SYMBIAN_BACKEND); |
|
1606 } |
|
1607 |
|
1608 bool CntContactCardViewPrivate::eventFilter(QObject *obj, QEvent *event) |
|
1609 { |
|
1610 if (event->type() == ProcessPopulateListEvent && obj == this) { |
|
1611 populateListItems(); |
|
1612 return true; |
|
1613 } |
|
1614 |
|
1615 if (event->type() == QEvent::KeyPress && obj == mView->mainWindow()) |
|
1616 { |
|
1617 QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); |
|
1618 if (keyEvent->key() == Qt::Key_Yes) |
|
1619 { |
|
1620 return sendKeyPressed(); |
|
1621 } |
|
1622 } |
|
1623 |
|
1624 // Update the contact only when the application is in the backgound |
|
1625 // This avoids flickering when the contact card is in focus |
|
1626 if ( event->type() == QEvent::ApplicationActivate ) |
|
1627 { |
|
1628 CNT_LOG_ARGS("app activated") |
|
1629 |
|
1630 disconnect(contactManager(), SIGNAL(contactsChanged(const QList<QContactLocalId>&)), |
|
1631 this, SLOT(contactUpdatedFromOtherSource(const QList<QContactLocalId>&))); |
|
1632 |
|
1633 QContact c = contactManager()->contact(mContact->localId()); |
|
1634 |
|
1635 QContactTimestamp latestTimeStamp = c.detail<QContactTimestamp>(); |
|
1636 QContactTimestamp localTimeStamp = mContact->detail<QContactTimestamp>(); |
|
1637 |
|
1638 // Once we regain focus check if the contact was modified in the background |
|
1639 if (contactManager()->error() == QContactManager::NoError |
|
1640 && latestTimeStamp.lastModified() > localTimeStamp.lastModified()) |
|
1641 { |
|
1642 if (mContact) |
|
1643 delete mContact; |
|
1644 mContact = new QContact(c); |
|
1645 |
|
1646 populateHeadingItem(); |
|
1647 populateListItems(); |
|
1648 } |
|
1649 } |
|
1650 |
|
1651 if ( event->type() == QEvent::ApplicationDeactivate ) |
|
1652 { |
|
1653 CNT_LOG_ARGS("app deactivated") |
|
1654 |
|
1655 connect(contactManager(), SIGNAL(contactsChanged(const QList<QContactLocalId>&)), |
|
1656 this, SLOT(contactUpdatedFromOtherSource(const QList<QContactLocalId>&)), Qt::UniqueConnection); |
|
1657 } |
|
1658 |
|
1659 return false; |
|
1660 } |
|
1661 |
|
1662 bool CntContactCardViewPrivate::sendKeyPressed() |
|
1663 { |
|
1664 int count = 0; |
|
1665 bool keyConsumed = false; |
|
1666 |
|
1667 for (int index = 0; index < mDataContainer->itemCount(); index++) |
|
1668 { |
|
1669 CntContactCardDataItem* dataItem = mDataContainer->dataItem(index); |
|
1670 if (dataItem->action().compare("call", Qt::CaseInsensitive) == 0) |
|
1671 { |
|
1672 count++; |
|
1673 } |
|
1674 } |
|
1675 |
|
1676 if (count) |
|
1677 { |
|
1678 QContactDetail preferredDetail = mContact->preferredDetail("call"); |
|
1679 if (!preferredDetail.isEmpty()) |
|
1680 { |
|
1681 keyConsumed = true; |
|
1682 executeAction(*mContact, preferredDetail, "call"); |
|
1683 } |
|
1684 else if (count == 1 ) |
|
1685 { |
|
1686 keyConsumed = true; |
|
1687 executeAction( *mContact, mContact->details<QContactPhoneNumber>().first(), "call"); |
|
1688 } |
|
1689 else if(count >= 2 && mAcceptSendKey) |
|
1690 { |
|
1691 keyConsumed = true; |
|
1692 mAcceptSendKey = false; |
|
1693 CntActionPopup *actionPopup = new CntActionPopup(mContact); |
|
1694 actionPopup->showActionPopup("call"); |
|
1695 connect( actionPopup, SIGNAL(executeContactAction(QContact&, QContactDetail, QString)), this, |
|
1696 SLOT(executeAction(QContact&, QContactDetail, QString))); |
|
1697 connect( actionPopup, SIGNAL(actionPopupCancelPressed()), this, |
|
1698 SLOT(sendKeyCancelSlot())); |
|
1699 } |
|
1700 else |
|
1701 { |
|
1702 //ignore |
|
1703 } |
|
1704 } |
|
1705 |
|
1706 return keyConsumed; |
|
1707 } |
|
1708 |
|
1709 void CntContactCardViewPrivate::sendKeyCancelSlot() |
|
1710 { |
|
1711 mAcceptSendKey = true; |
|
1712 } |
|
1713 |
|
1714 void CntContactCardViewPrivate::onAddedToContacts() |
|
1715 { |
|
1716 emit addToContacts(); |
|
1717 } |
|
1718 |
|
1719 void CntContactCardViewPrivate::contactDeletedFromOtherSource(const QList<QContactLocalId>& contactIds) |
|
1720 { |
|
1721 if ( contactIds.contains(mContact->localId()) ) |
|
1722 { |
|
1723 // Do not switch to the previous view immediately. List views are |
|
1724 // not updated properly if this is not done in the event loop |
|
1725 QTimer::singleShot(0, this, SLOT(showRootView())); |
|
1726 } |
|
1727 } |
|
1728 |
|
1729 void CntContactCardViewPrivate::contactUpdatedFromOtherSource(const QList<QContactLocalId>& contactIds) |
|
1730 { |
|
1731 if ( contactIds.contains(mContact->localId()) ) |
|
1732 { |
|
1733 QContact c = contactManager()->contact(mContact->localId()); |
|
1734 if (contactManager()->error() == QContactManager::NoError) |
|
1735 { |
|
1736 if (mContact) |
|
1737 delete mContact; |
|
1738 mContact = new QContact(c); |
|
1739 |
|
1740 populateHeadingItem(); |
|
1741 populateListItems(); |
|
1742 } |
|
1743 } |
|
1744 } |
|
1745 |
|
1746 // end of file |