39 #include <hbframedrawer.h> |
41 #include <hbframedrawer.h> |
40 #include <hbselectiondialog.h> |
42 #include <hbselectiondialog.h> |
41 #include <hblistview.h> |
43 #include <hblistview.h> |
42 #include <hblistviewitem.h> |
44 #include <hblistviewitem.h> |
43 #include <shareui.h> |
45 #include <shareui.h> |
44 #include <thumbnailmanager_qt.h> |
46 #include <maptileservice.h> //For maptile processing |
45 #include <cntmaptileservice.h> //For maptile processing |
|
46 #include <qversitcontactexporter.h> |
47 #include <qversitcontactexporter.h> |
47 #include <qversitwriter.h> |
48 #include <qversitwriter.h> |
48 #include <xqservicerequest.h> |
49 #include <xqservicerequest.h> |
49 #include <QTimer> //Progress indication icon |
50 #include <QTimer> //Progress indication icon |
|
51 #include <QApplication> |
50 |
52 |
51 #include <cntdebug.h> |
53 #include <cntdebug.h> |
52 #include "cntcontactcarddatacontainer.h" |
54 #include "cntcontactcarddatacontainer.h" |
53 #include "cntcontactcarddetailitem.h" |
|
54 #include "cntcontactcardheadingitem.h" |
55 #include "cntcontactcardheadingitem.h" |
55 #include "cntcontactcarddataitem.h" |
56 #include "cntcontactcarddataitem.h" |
|
57 #include "cntcontactcarddetailitem.h" |
56 #include "cntcontactcardcontextmenu.h" |
58 #include "cntcontactcardcontextmenu.h" |
57 #include "cntmainwindow.h" |
59 #include "cntmainwindow.h" |
58 #include "cntstringmapper.h" |
60 #include "cntstringmapper.h" |
59 #include "cntdocumentloader.h" |
61 #include "cntdocumentloader.h" |
60 #include "cntimagelabel.h" |
62 #include "cntimagelabel.h" |
74 /*! |
79 /*! |
75 Constructor, initialize member variables. |
80 Constructor, initialize member variables. |
76 \a viewManager is the parent that creates this view. \a parent is a pointer to parent QGraphicsItem (by default this is 0) |
81 \a viewManager is the parent that creates this view. \a parent is a pointer to parent QGraphicsItem (by default this is 0) |
77 */ |
82 */ |
78 CntContactCardViewPrivate::CntContactCardViewPrivate(bool isTemporary) : |
83 CntContactCardViewPrivate::CntContactCardViewPrivate(bool isTemporary) : |
79 QObject(), |
84 QObject(), |
80 mScrollArea(NULL), |
|
81 mContainerWidget(NULL), |
|
82 mContainerLayout(NULL), |
85 mContainerLayout(NULL), |
83 mContact(NULL), |
86 mContact(NULL), |
84 mDetailsWidget(NULL), |
|
85 mDataContainer(NULL), |
87 mDataContainer(NULL), |
86 mHeadingItem(NULL), |
|
87 mThumbnailManager(NULL), |
|
88 mAvatar(NULL), |
88 mAvatar(NULL), |
89 mFavoriteGroupId(-1), |
|
90 mLoader(NULL), |
89 mLoader(NULL), |
91 mContactAction(NULL), |
|
92 mBackKey(NULL), |
|
93 mImageLabel(NULL), |
|
94 mVCardIcon(NULL), |
90 mVCardIcon(NULL), |
95 mShareUi(NULL), |
91 mShareUi(NULL), |
96 mAcceptSendKey(true), |
92 mAcceptSendKey(true), |
97 mSendKeyListModel(NULL), |
|
98 mPresenceListener(NULL), |
93 mPresenceListener(NULL), |
99 mMaptile(NULL), |
|
100 mProgressTimer(NULL), |
|
101 mIsTemporary(isTemporary), |
94 mIsTemporary(isTemporary), |
102 mIsExecutingAction(false) |
95 mIsExecutingAction(false), |
|
96 mMyCardId(0), |
|
97 mSaveManager(NULL) |
103 { |
98 { |
104 bool ok; |
99 bool ok; |
105 document()->load(CNT_CONTACTCARDVIEW_XML, &ok); |
100 document()->load(CNT_CONTACTCARDVIEW_XML, &ok); |
106 if (!ok) |
101 if (!ok) |
107 { |
102 { |
108 qFatal("Unable to read :/xml/contacts_contactcard.docml"); |
103 qFatal("Unable to read :/xml/contacts_contactcard.docml"); |
109 } |
104 } |
110 |
105 |
111 mView = static_cast<HbView*>(document()->findWidget("view")); |
106 mView = static_cast<HbView*>(document()->findWidget("view")); |
112 |
107 |
113 mThumbnailManager = new ThumbnailManager(this); |
|
114 mThumbnailManager->setMode(ThumbnailManager::Default); |
|
115 mThumbnailManager->setQualityPreference(ThumbnailManager::OptimizeForQuality); |
|
116 mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailLarge); |
|
117 |
|
118 connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void*, int, int)), |
|
119 this, SLOT(thumbnailReady(QPixmap, void*, int, int))); |
|
120 |
|
121 //back button |
108 //back button |
122 mBackKey = new HbAction(Hb::BackNaviAction, mView); |
109 mBackKey = new HbAction(Hb::BackNaviAction, mView); |
123 mView->setNavigationAction(mBackKey); |
110 mView->setNavigationAction(mBackKey); |
124 connect(mBackKey, SIGNAL(triggered()), this, SLOT(showPreviousView())); |
111 connect(mBackKey, SIGNAL(triggered()), this, SLOT(showPreviousView())); |
125 |
112 |
126 mProgressTimer = new QTimer(this); |
113 mProgressTimer = new QTimer(this); |
127 mProgressTimer->setSingleShot(true); |
114 mProgressTimer->setSingleShot(true); |
128 connect(mProgressTimer, SIGNAL(timeout()),this, SLOT(updateSpinningIndicator())); |
115 connect(mProgressTimer, SIGNAL(timeout()),this, SLOT(updateSpinningIndicator())); |
129 |
116 |
130 mMaptile = new CntMapTileService; |
117 mMaptile = new MapTileService; |
131 if( mMaptile->isLocationFeatureEnabled() ) |
118 if( mMaptile->isLocationFeatureEnabled(MapTileService::AppTypeContacts) ) |
132 { |
119 { |
133 //Connect for maptile status evenet |
120 //Connect for maptile status evenet |
134 QObject::connect( mMaptile, SIGNAL(maptileFetchingStatusUpdate(int, |
121 QObject::connect( mMaptile, SIGNAL(maptileFetchingStatusUpdate(int, |
135 int,int)),this,SLOT(mapTileStatusReceived(int,int,int))); |
122 int,int)),this,SLOT(mapTileStatusReceived(int,int,int))); |
136 } |
123 } |
|
124 |
|
125 mScrollArea = static_cast<HbScrollArea*>(document()->findWidget(QString("scrollArea"))); |
|
126 mHeadingItem = static_cast<CntContactCardHeadingItem*>(document()->findWidget(QString("cnt_contactcard_heading"))); |
|
127 mImageLabel = static_cast<CntImageLabel*>(document()->findWidget("cnt_contactcard_image")); |
|
128 |
|
129 // presence listener |
|
130 mPresenceListener = new CntPresenceListener(); |
|
131 connect(mPresenceListener, SIGNAL(fullPresenceUpdated(bool)), mHeadingItem, SLOT(setOnlineStatus(bool))); |
|
132 connect(mPresenceListener, SIGNAL(accountPresenceUpdated(const QString&, bool)), |
|
133 this, SLOT(updateItemPresence(const QString&, bool))); |
|
134 |
|
135 |
|
136 mSaveManager = new CntSaveManager(); |
137 } |
137 } |
138 |
138 |
139 /*! |
139 /*! |
140 Destructor |
140 Destructor |
141 */ |
141 */ |
142 CntContactCardViewPrivate::~CntContactCardViewPrivate() |
142 CntContactCardViewPrivate::~CntContactCardViewPrivate() |
143 { |
143 { |
|
144 // Clear the container to avoid double deletion |
|
145 if (mContainerLayout != NULL) |
|
146 { |
|
147 int count = mContainerLayout->count(); |
|
148 for (int i=0; i<count; i++) |
|
149 { |
|
150 // do not delete items. They will be deleted automatically |
|
151 mContainerLayout->removeAt(i); |
|
152 } |
|
153 } |
|
154 |
|
155 // Delete all the detail pointers if any |
|
156 qDeleteAll(mDetailPtrs); |
|
157 mDetailPtrs.clear(); |
|
158 |
144 mView->deleteLater(); |
159 mView->deleteLater(); |
145 |
160 |
146 delete mContact; |
161 delete mContact; |
147 mContact = 0; |
162 mContact = NULL; |
148 |
163 |
149 delete mDataContainer; |
164 delete mDataContainer; |
150 mDataContainer = NULL; |
165 mDataContainer = NULL; |
151 |
166 |
152 delete mAvatar; |
167 delete mAvatar; |
165 { |
180 { |
166 delete mShareUi; |
181 delete mShareUi; |
167 mShareUi = NULL; |
182 mShareUi = NULL; |
168 } |
183 } |
169 |
184 |
170 delete mSendKeyListModel; |
|
171 mSendKeyListModel = NULL; |
|
172 |
|
173 delete mPresenceListener; |
185 delete mPresenceListener; |
174 mPresenceListener = NULL; |
186 mPresenceListener = NULL; |
175 |
187 |
176 delete mMaptile; |
188 delete mMaptile; |
177 mMaptile = NULL; |
189 mMaptile = NULL; |
178 |
190 |
179 delete mProgressTimer; |
|
180 mProgressTimer = NULL; |
|
181 |
|
182 //delete maptile label memory |
191 //delete maptile label memory |
183 for ( int index = 0; index < mMaptileLabelList.count(); index++ ) |
192 for ( int index = 0; index < mMaptileLabelList.count(); index++ ) |
184 { |
193 { |
185 if( mMaptileLabelList[index] ) |
194 if( mMaptileLabelList[index] ) |
186 { |
195 { |
187 delete mMaptileLabelList[index]; |
196 delete mMaptileLabelList[index]; |
188 mMaptileLabelList[index] = NULL ; |
197 mMaptileLabelList[index] = NULL ; |
189 } |
198 } |
190 } |
199 } |
|
200 |
|
201 delete mSaveManager; |
|
202 mSaveManager = NULL; |
191 } |
203 } |
192 |
204 |
193 /*! |
205 /*! |
194 Activates a previous view |
206 Activates a previous view |
195 */ |
207 */ |
196 void CntContactCardViewPrivate::showPreviousView() |
208 void CntContactCardViewPrivate::showPreviousView() |
197 { |
209 { |
198 emit backPressed(); |
210 int returnValue = KCntServicesReturnValueContactNotModified; |
199 |
|
200 //save the contact if avatar has been changed. |
211 //save the contact if avatar has been changed. |
201 QContact contact = contactManager()->contact(mContact->localId()); |
212 QContact contact = contactManager()->contact(mContact->localId()); |
202 if ( contact != *mContact && contactManager()->error() == QContactManager::NoError) |
213 if ( contact != *mContact && contactManager()->error() == QContactManager::NoError) |
203 { |
214 { |
204 contactManager()->saveContact(mContact); |
215 disconnect(contactManager(), SIGNAL(contactsRemoved(const QList<QContactLocalId>&)), |
205 } |
216 this, SLOT(contactDeletedFromOtherSource(const QList<QContactLocalId>&))); |
|
217 CntSaveManager::CntSaveResult result = mSaveManager->saveContact(mContact, contactManager()); |
|
218 |
|
219 if (result != CntSaveManager::ENothingDone) |
|
220 returnValue = KCntServicesReturnValueContactSaved; |
|
221 else |
|
222 returnValue = KCntServicesReturnValueContactNotModified; |
|
223 } |
|
224 |
|
225 emit backPressed(returnValue); |
206 |
226 |
207 mViewManager->back( mArgs ); |
227 mViewManager->back( mArgs ); |
208 } |
228 } |
209 |
229 |
210 /*! |
230 /*! |
216 } |
236 } |
217 |
237 |
218 /* |
238 /* |
219 Activates a default view and setup name label texts |
239 Activates a default view and setup name label texts |
220 */ |
240 */ |
221 void CntContactCardViewPrivate::activate(CntAbstractViewManager* aMgr, const CntViewParameters aArgs) |
241 void CntContactCardViewPrivate::activate(const CntViewParameters aArgs) |
222 { |
242 { |
223 CNT_ENTRY |
243 CNT_ENTRY |
224 |
|
225 mViewManager = aMgr; |
|
226 mArgs = aArgs; |
244 mArgs = aArgs; |
|
245 |
|
246 mViewManager = &mEngine->viewManager(); |
|
247 mThumbnailManager = &mEngine->thumbnailManager(); |
|
248 connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void*, int, int)), |
|
249 this, SLOT(thumbnailReady(QPixmap, void*, int, int))); |
|
250 |
227 |
251 |
228 HbMainWindow* window = mView->mainWindow(); |
252 HbMainWindow* window = mView->mainWindow(); |
229 if (window) |
253 if (window) |
230 { |
254 { |
231 connect(window, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(setOrientation(Qt::Orientation))); |
255 connect(window, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(setOrientation(Qt::Orientation))); |
232 window->installEventFilter(this); |
256 window->installEventFilter(this); |
233 |
257 |
234 setOrientation(window->orientation()); |
258 setOrientation(window->orientation()); |
235 } |
259 } |
|
260 |
|
261 qApp->installEventFilter(this); |
236 |
262 |
237 QContact contact = aArgs.value(ESelectedContact).value<QContact>(); |
263 QContact contact = aArgs.value(ESelectedContact).value<QContact>(); |
238 mContact = new QContact( contact ); |
264 mContact = new QContact( contact ); |
|
265 |
239 //my card |
266 //my card |
240 bool myCard = mContact->localId() == contactManager()->selfContactId(); |
267 mMyCardId = contactManager()->selfContactId(); |
|
268 |
|
269 populateHeadingItem(); |
|
270 populateListItems(); |
|
271 |
|
272 bool myCard = mContact->localId() == mMyCardId; |
241 if (myCard) |
273 if (myCard) |
242 { |
274 { |
243 mView->menu()->clearActions(); |
275 mView->menu()->clearActions(); |
244 mView->toolBar()->removeAction(static_cast<HbAction*>(document()->findObject(QString("cnt:history")))); |
276 mView->toolBar()->removeAction(static_cast<HbAction*>(document()->findObject(QString("cnt:history")))); |
245 } |
277 } |
251 { |
283 { |
252 mView->menu()->clearActions(); |
284 mView->menu()->clearActions(); |
253 mView->toolBar()->clearActions(); |
285 mView->toolBar()->clearActions(); |
254 mView->toolBar()->addAction(static_cast<HbAction*>(document()->findObject(QString("cnt:addtocontact")))); |
286 mView->toolBar()->addAction(static_cast<HbAction*>(document()->findObject(QString("cnt:addtocontact")))); |
255 } |
287 } |
256 |
288 |
257 // add heading widget to the content |
289 document()->findWidget("viewToolbar")->setParent(mView); |
258 QGraphicsWidget *c = document()->findWidget(QString("content")); |
290 document()->findWidget("viewMenu")->setParent(mView); |
259 QGraphicsLinearLayout* l = static_cast<QGraphicsLinearLayout*>(c->layout()); |
291 |
260 |
292 // Menu items |
261 mHeadingItem = static_cast<CntContactCardHeadingItem*>(document()->findWidget(QString("cnt_contactcard_heading"))); |
293 connectAction("cnt:sendbusinesscard", SLOT(sendBusinessCard())); |
|
294 connectAction("cnt:deletecontact", SLOT(deleteContact())); |
|
295 connectAction("cnt:setasfavorite", SLOT(setAsFavorite())); |
|
296 connectAction("cnt:removefromfavorite", SLOT(removeFromFavorite())); |
|
297 connectAction("cnt:placecontacttohs", SLOT(sendToHs())); |
|
298 connectAction("cnt:edit", SLOT(editContact())); |
|
299 connectAction("cnt:history", SLOT(viewHistory())); |
|
300 connectAction("cnt:sendMyCard", SLOT(sendBusinessCard())); |
|
301 connectAction("cnt:addtocontact", SLOT(onAddedToContacts())); |
|
302 connectAction("cnt:activityStream", NULL); // placeholder until this action is implemented (needed to avoid memory leak) |
|
303 |
|
304 // disabled until this action is implemented |
|
305 static_cast<HbAction *>(document()->findObject("cnt:activityStream"))->setEnabled(false); |
|
306 |
|
307 connect(contactManager(), SIGNAL(contactsRemoved(const QList<QContactLocalId>&)), |
|
308 this, SLOT(contactDeletedFromOtherSource(const QList<QContactLocalId>&))); |
|
309 |
|
310 emit viewActivated( mViewManager, aArgs ); |
|
311 |
|
312 CNT_EXIT |
|
313 } |
|
314 |
|
315 void CntContactCardViewPrivate::populateHeadingItem() |
|
316 { |
|
317 Q_ASSERT(mHeadingItem != NULL && mContact != NULL); |
|
318 |
262 mHeadingItem->setDetails(mContact); |
319 mHeadingItem->setDetails(mContact); |
263 |
320 |
264 mImageLabel = static_cast<CntImageLabel*>(document()->findWidget("cnt_contactcard_image")); |
321 bool myCard = mContact->localId() == mMyCardId; |
265 |
322 |
266 if (!mIsTemporary) |
323 if (!mIsTemporary) |
267 { |
324 { |
268 connect(mHeadingItem, SIGNAL(passLongPressed(const QPointF&)), this, SLOT(drawMenu(const QPointF&))); |
325 connect(mHeadingItem, SIGNAL(passLongPressed(const QPointF&)), this, SLOT(drawMenu(const QPointF&)), Qt::UniqueConnection); |
269 connect(mHeadingItem, SIGNAL(passShortPressed(const QPointF&)), this, SLOT(doChangeImage())); |
326 connect(mHeadingItem, SIGNAL(passShortPressed(const QPointF&)), this, SLOT(doChangeImage()), Qt::UniqueConnection); |
270 connect(mImageLabel, SIGNAL(iconClicked()), this, SLOT(doChangeImage())); |
327 connect(mImageLabel, SIGNAL(iconClicked()), this, SLOT(doChangeImage()), Qt::UniqueConnection); |
271 connect(mImageLabel, SIGNAL(iconLongPressed(const QPointF&)), this, SLOT(drawMenu(const QPointF&))); |
328 connect(mImageLabel, SIGNAL(iconLongPressed(const QPointF&)), this, SLOT(drawMenu(const QPointF&)), Qt::UniqueConnection); |
272 } |
329 } |
273 else |
330 else |
274 { |
331 { |
275 mHeadingItem->ungrabGesture(Qt::TapGesture); |
332 mHeadingItem->ungrabGesture(Qt::TapGesture); |
276 mImageLabel->ungrabGesture(Qt::TapGesture); |
333 mImageLabel->ungrabGesture(Qt::TapGesture); |
277 } |
334 } |
278 |
335 |
279 // presence listener |
336 |
280 mPresenceListener = new CntPresenceListener(*mContact); |
|
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))); |
|
284 bool online; |
337 bool online; |
285 QMap<QString, bool> presences = mPresenceListener->initialPresences(online); |
338 mInitiialPrecenceData = mPresenceListener->initialPresences(*mContact, online); |
286 mHeadingItem->setOnlineStatus(online); |
339 mHeadingItem->setOnlineStatus(online); |
287 |
340 |
288 |
341 if (!myCard) |
|
342 { |
|
343 bool setAsFavorite( false ); |
|
344 setAsFavorite = CntFavourite::isMemberOfFavouriteGroup( contactManager(), mContact ); |
|
345 mHeadingItem->setFavoriteStatus( setAsFavorite ); // if contact is part of favourites group |
|
346 static_cast<HbAction *>(document()->findObject("cnt:setasfavorite"))->setVisible( !setAsFavorite ); |
|
347 static_cast<HbAction *>(document()->findObject("cnt:removefromfavorite"))->setVisible( setAsFavorite ); |
|
348 } |
289 |
349 |
290 // avatar |
350 // avatar |
291 QList<QContactAvatar> details = mContact->details<QContactAvatar>(); |
351 QList<QContactAvatar> details = mContact->details<QContactAvatar>(); |
292 for (int i = 0;i < details.count();i++) |
352 for (int i = 0;i < details.count();i++) |
293 { |
353 { |
294 if (details.at(i).imageUrl().isValid()) |
354 if (details.at(i).imageUrl().isValid()) |
295 { |
355 { |
296 mAvatar = new QContactAvatar(details.at(i)); |
356 if (!mAvatar) |
297 mThumbnailManager->getThumbnail(mAvatar->imageUrl().toString()); |
357 { |
|
358 mAvatar = new QContactAvatar(details.at(i)); |
|
359 mThumbnailManager->getThumbnail(ThumbnailManager::ThumbnailLarge, mAvatar->imageUrl().toString()); |
|
360 } |
|
361 else if (*mAvatar != details.at(i)) |
|
362 { |
|
363 delete mAvatar; |
|
364 mAvatar = new QContactAvatar(details.at(i)); |
|
365 mThumbnailManager->getThumbnail(ThumbnailManager::ThumbnailLarge, mAvatar->imageUrl().toString()); |
|
366 } |
298 break; |
367 break; |
299 } |
368 } |
300 } |
369 } |
301 |
370 |
302 // data |
371 } |
303 mDataContainer = new CntContactCardDataContainer( |
372 |
304 mContact, NULL, myCard, mMaptile, mView->mainWindow()->orientation() ); |
373 void CntContactCardViewPrivate::populateListItems() |
305 |
374 { |
|
375 Q_ASSERT(mContact != NULL && mScrollArea != NULL); |
|
376 |
|
377 // data container |
|
378 if (!mDataContainer) { |
|
379 mDataContainer = new CntContactCardDataContainer( |
|
380 mMaptile, |
|
381 mEngine->extensionManager(), |
|
382 mView->mainWindow()->orientation() ); |
|
383 } |
|
384 |
|
385 // fill the data container with contact details |
|
386 mDataContainer->setContactData(mContact); |
|
387 |
306 // scroll area + container widget |
388 // scroll area + container widget |
307 mScrollArea = static_cast<HbScrollArea*>(document()->findWidget(QString("scrollArea"))); |
389 QGraphicsWidget* containerWidget = mScrollArea->contentWidget(); |
308 mScrollArea->setScrollDirections(Qt::Vertical); |
390 if (!containerWidget) |
309 mContainerWidget = new QGraphicsWidget(mScrollArea); |
391 { |
310 mScrollArea->setContentWidget(mContainerWidget); |
392 // initialize |
311 |
393 mScrollArea->setScrollDirections(Qt::Vertical); |
312 mContainerLayout = new QGraphicsLinearLayout(Qt::Vertical); |
394 |
313 mContainerLayout->setContentsMargins(0, 0, 0, 0); |
395 containerWidget = new QGraphicsWidget(); |
314 mContainerLayout->setSpacing(0); |
396 mScrollArea->setContentWidget(containerWidget); // takes ownership. |
315 mContainerLayout->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); |
397 |
316 |
398 mContainerLayout = new QGraphicsLinearLayout(Qt::Vertical); |
317 mContainerWidget->setLayout(mContainerLayout); |
399 mContainerLayout->setContentsMargins(0, 0, 0, 0); |
318 |
400 mContainerLayout->setSpacing(0); |
319 for (int index = 0; index < mDataContainer->itemCount(); index++) |
401 mContainerLayout->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); |
|
402 |
|
403 containerWidget->setLayout(mContainerLayout); // takes ownership. |
|
404 } else { |
|
405 // Already initialized |
|
406 Q_ASSERT(mContainerLayout != NULL); |
|
407 |
|
408 // Clear the container |
|
409 int count = mContainerLayout->count(); |
|
410 for (int i=0; i<count; i++) |
|
411 { |
|
412 // do not delete items. They will be deleted automatically |
|
413 mContainerLayout->removeAt(i); |
|
414 } |
|
415 } |
|
416 |
|
417 // Delete all the detail pointers if any |
|
418 qDeleteAll(mDetailPtrs); |
|
419 mDetailPtrs.clear(); |
|
420 for(int index = 0; index < mDataContainer->itemCount(); index++) |
320 { |
421 { |
321 CntContactCardDataItem* dataItem = mDataContainer->dataItem(index); |
422 CntContactCardDataItem* dataItem = mDataContainer->dataItem(index); |
322 int pos = dataItem->position(); |
423 int pos = dataItem->position(); |
323 |
424 |
324 // communication methods |
425 // communication methods |
325 if (pos < CntContactCardDataItem::ESeparator && dataItem->isFocusable()) |
426 if (pos < CntContactCardDataItem::ESeparator && dataItem->isFocusable()) |
326 { |
427 { |
327 CntContactCardDetailItem* item = new CntContactCardDetailItem(index, mContainerWidget); |
428 CntContactCardDetailItem* item = new CntContactCardDetailItem(index, containerWidget); |
|
429 mDetailPtrs.append(item); |
328 |
430 |
329 connect(item, SIGNAL(clicked()), this, SLOT(onItemActivated())); |
431 connect(item, SIGNAL(clicked()), this, SLOT(onItemActivated())); |
330 |
432 |
331 if (!mIsTemporary) |
433 if (!mIsTemporary) |
332 { |
434 { |
366 else if (pos == CntContactCardDataItem::ESeparator) |
468 else if (pos == CntContactCardDataItem::ESeparator) |
367 { |
469 { |
368 HbFrameItem* frameItem = new HbFrameItem(QString("qtg_fr_list_separator"), HbFrameDrawer::NinePieces); |
470 HbFrameItem* frameItem = new HbFrameItem(QString("qtg_fr_list_separator"), HbFrameDrawer::NinePieces); |
369 HbLabel* label = static_cast<HbLabel*>(document()->findWidget(QString("separator"))); |
471 HbLabel* label = static_cast<HbLabel*>(document()->findWidget(QString("separator"))); |
370 label->setPlainText(dataItem->titleText()); |
472 label->setPlainText(dataItem->titleText()); |
371 label->setBackgroundItem(frameItem); |
473 label->setBackgroundItem(frameItem); // takes ownership |
372 mContainerLayout->addItem(label); |
474 mContainerLayout->addItem(label); |
373 } |
475 } |
374 |
476 |
375 // details |
477 // details |
376 else |
478 else |
377 { |
479 { |
378 //map support (image only) |
480 //map support (image only) |
379 if (pos >= CntContactCardDataItem::EAddress && pos <= CntContactCardDataItem::EAddressWork && !dataItem->icon().isNull()) |
481 if (pos >= CntContactCardDataItem::EAddress && pos <= CntContactCardDataItem::EAddressWork && !dataItem->icon().isNull()) |
380 { |
482 { |
381 int addressType = CntMapTileService::AddressPreference; |
483 int addressType = MapTileService::AddressPreference; |
382 |
484 |
383 if( pos == CntContactCardDataItem::EAddressHome ) |
485 if( pos == CntContactCardDataItem::EAddressHome ) |
384 { |
486 { |
385 addressType = CntMapTileService::AddressHome; |
487 addressType = MapTileService::AddressHome; |
386 } |
488 } |
387 else if( pos == CntContactCardDataItem::EAddressWork ) |
489 else if( pos == CntContactCardDataItem::EAddressWork ) |
388 { |
490 { |
389 addressType = CntMapTileService::AddressWork; |
491 addressType = MapTileService::AddressWork; |
390 } |
492 } |
391 |
493 |
392 HbLabel* maptileLabel = loadMaptileLabel( addressType ); |
494 HbLabel* maptileLabel = loadMaptileLabel( addressType ); |
393 setMaptileLabel( maptileLabel, dataItem->icon() ); |
495 setMaptileLabel( maptileLabel, dataItem->icon() ); |
394 mContainerLayout->addItem( maptileLabel ); |
496 mContainerLayout->addItem( maptileLabel ); |
395 mMaptileLabelList.insert( addressType, maptileLabel ); |
497 mMaptileLabelList.insert( addressType, maptileLabel ); |
396 } |
498 } |
397 //other details |
499 //other details |
398 else |
500 else |
399 { |
501 { |
400 CntContactCardDetailItem* item = new CntContactCardDetailItem(index, mContainerWidget, false); |
502 CntContactCardDetailItem* item = new CntContactCardDetailItem(index, containerWidget, false); |
401 //To check whether maptile status icon is set with the address |
503 mDetailPtrs.append(item); |
|
504 |
|
505 //To check whether maptile status icon is set with the address |
402 if( ( dataItem->titleText() == hbTrId("txt_phob_formlabel_address") || |
506 if( ( dataItem->titleText() == hbTrId("txt_phob_formlabel_address") || |
403 dataItem->titleText() == hbTrId("txt_phob_formlabel_address_home")|| |
507 dataItem->titleText() == hbTrId("txt_phob_formlabel_address_home")|| |
404 dataItem->titleText() == hbTrId("txt_phob_formlabel_address_work") ) && |
508 dataItem->titleText() == hbTrId("txt_phob_formlabel_address_work") ) && |
405 dataItem->secondaryIcon().iconName() == QString(CNT_MAPTILE_INPROGRESS_ICON) ) |
509 dataItem->secondaryIcon().iconName() == QString(CNT_MAPTILE_INPROGRESS_ICON) ) |
406 |
510 |
407 { |
511 { |
408 //Information for displaying maptile fetching progress bar. |
512 //Information for displaying maptile fetching progress bar. |
409 //Memory will be deleted from the queue. |
513 //Memory will be deleted from the queue. |
410 CntContactCardMapTileDetail* detail = new CntContactCardMapTileDetail; |
514 CntContactCardMapTileDetail* detail = new CntContactCardMapTileDetail; |
411 if( detail ) |
515 detail->mContactId = mContact->localId(); |
|
516 |
|
517 if( dataItem->titleText() == hbTrId("txt_phob_formlabel_address") ) |
412 { |
518 { |
413 detail->mContactId = mContact->localId(); |
519 detail->mAddressType = MapTileService::AddressPreference; |
414 |
520 } |
415 if( dataItem->titleText() == hbTrId("txt_phob_formlabel_address") ) |
521 else if ( dataItem->titleText() == hbTrId("txt_phob_formlabel_address_home") ) |
|
522 { |
|
523 detail->mAddressType = MapTileService::AddressHome; |
|
524 } |
|
525 else if( dataItem->titleText() == hbTrId("txt_phob_formlabel_address_work") ) |
416 { |
526 { |
417 detail->mAddressType = CntMapTileService::AddressPreference; |
527 detail->mAddressType = MapTileService::AddressWork; |
418 } |
|
419 else if ( dataItem->titleText() == hbTrId("txt_phob_formlabel_address_home") ) |
|
420 { |
|
421 detail->mAddressType = CntMapTileService::AddressHome; |
|
422 } |
|
423 else if( dataItem->titleText() == hbTrId("txt_phob_formlabel_address_work") ) |
|
424 { |
|
425 detail->mAddressType = CntMapTileService::AddressWork; |
|
426 } |
|
427 |
|
428 detail->mProgressCount = 0; |
|
429 detail->mDetailItem = item; |
|
430 detail->maptileStatus = CNT_UNKNOWN_MAPTILE_STATUS; |
|
431 mAddressList.append( detail ); |
|
432 } |
528 } |
|
529 |
|
530 detail->mProgressCount = 0; |
|
531 detail->mDetailItem = item; |
|
532 detail->maptileStatus = CNT_UNKNOWN_MAPTILE_STATUS; |
|
533 mAddressList.append( detail ); |
433 |
534 |
434 //Update the spinning indicator |
535 //Update the spinning indicator |
435 updateSpinningIndicator(); |
536 updateSpinningIndicator(); |
436 |
537 |
437 } |
538 } |
438 item->setDetails(dataItem); |
539 item->setDetails(dataItem); |
439 mContainerLayout->addItem(item); |
540 mContainerLayout->addItem(item); |
440 } |
541 } |
441 } |
542 } |
442 } |
543 } |
443 |
|
444 if (!myCard) |
|
445 { |
|
446 bool setAsFavorite( false ); |
|
447 QContactLocalId favouriteGroupId = CntFavourite::favouriteGroupId( contactManager() ); |
|
448 if( favouriteGroupId != 0 ) |
|
449 { |
|
450 setAsFavorite = CntFavourite::isMemberOfFavouriteGroup( contactManager(), mContact ); |
|
451 mHeadingItem->setFavoriteStatus( setAsFavorite ); // if contact is part of favourites group |
|
452 } |
|
453 static_cast<HbAction *>(document()->findObject("cnt:setasfavorite"))->setVisible( !setAsFavorite ); |
|
454 static_cast<HbAction *>(document()->findObject("cnt:removefromfavorite"))->setVisible( setAsFavorite ); |
|
455 } |
|
456 document()->findWidget("viewToolbar")->setParent(mView); |
|
457 document()->findWidget("viewMenu")->setParent(mView); |
|
458 |
|
459 // Menu items |
|
460 connectAction("cnt:sendbusinesscard", SLOT(sendBusinessCard())); |
|
461 connectAction("cnt:deletecontact", SLOT(deleteContact())); |
|
462 connectAction("cnt:setasfavorite", SLOT(setAsFavorite())); |
|
463 connectAction("cnt:removefromfavorite", SLOT(removeFromFavorite())); |
|
464 connectAction("cnt:placecontacttohs", SLOT(sendToHs())); |
|
465 connectAction("cnt:edit", SLOT(editContact())); |
|
466 connectAction("cnt:history", SLOT(viewHistory())); |
|
467 connectAction("cnt:sendMyCard", SLOT(sendBusinessCard())); |
|
468 connectAction("cnt:addtocontact", SLOT(onAddedToContacts())); |
|
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>&))); |
|
476 |
|
477 emit viewActivated( mViewManager, aArgs ); |
|
478 |
|
479 CNT_EXIT |
|
480 } |
544 } |
481 |
545 |
482 /* |
546 /* |
483 Connects the action with a slot and also sets the view as the parent for the action. |
547 Connects the action with a slot and also sets the view as the parent for the action. |
484 */ |
548 */ |
669 void CntContactCardViewPrivate::setMaptileLabel( HbLabel*& mapLabel, const HbIcon& icon ) |
733 void CntContactCardViewPrivate::setMaptileLabel( HbLabel*& mapLabel, const HbIcon& icon ) |
670 { |
734 { |
671 mapLabel->clear(); |
735 mapLabel->clear(); |
672 mapLabel->setIcon( icon ); |
736 mapLabel->setIcon( icon ); |
673 |
737 |
674 int width = icon.width(); |
738 qreal leftMarginSize; |
675 int height = icon.height(); |
739 mapLabel->getContentsMargins( &leftMarginSize, 0 , 0 , 0 ); |
676 |
740 mapLabel->setPreferredSize( |
677 //HbLabel setPreferredSize is not working properly, |
741 QSizeF(icon.width() + leftMarginSize, icon.height())); |
678 //so added minimum , maximum size to fix the issue |
742 |
679 mapLabel->setPreferredSize(QSizeF(width,height)); |
|
680 mapLabel->setMinimumSize(QSizeF(width, height)); |
|
681 mapLabel->setMaximumSize(QSizeF(width, height)); |
|
682 mapLabel->setSizePolicy(QSizePolicy( QSizePolicy::Fixed, |
|
683 QSizePolicy::Fixed)); |
|
684 } |
743 } |
685 |
744 |
686 /* |
745 /* |
687 * Load the maptile label based on the address type |
746 * Load the maptile label based on the address type |
688 */ |
747 */ |
689 HbLabel* CntContactCardViewPrivate::loadMaptileLabel( int addressType ) |
748 HbLabel* CntContactCardViewPrivate::loadMaptileLabel( int addressType ) |
690 { |
749 { |
691 HbLabel* maptileLabel = NULL ; |
750 HbLabel* maptileLabel = NULL; |
692 |
751 |
693 if( addressType == CntMapTileService::AddressPreference ) |
752 if( addressType == MapTileService::AddressPreference ) |
694 { |
753 { |
695 maptileLabel = static_cast<HbLabel*>(document()->findWidget(QString("maptilePreferenceWidget"))); |
754 maptileLabel = static_cast<HbLabel*>(document()->findWidget(QString("maptilePreferenceWidget"))); |
696 } |
755 } |
697 else if( addressType == CntMapTileService::AddressHome ) |
756 else if( addressType == MapTileService::AddressHome ) |
698 { |
757 { |
699 maptileLabel = static_cast<HbLabel*>(document()->findWidget(QString("maptileHomeWidget"))); |
758 maptileLabel = static_cast<HbLabel*>(document()->findWidget(QString("maptileHomeWidget"))); |
700 } |
759 } |
701 else if( addressType == CntMapTileService::AddressWork ) |
760 else if( addressType == MapTileService::AddressWork ) |
702 { |
761 { |
703 maptileLabel = static_cast<HbLabel*>(document()->findWidget(QString("maptileWorkWidget"))); |
762 maptileLabel = static_cast<HbLabel*>(document()->findWidget(QString("maptileWorkWidget"))); |
704 } |
763 } |
705 |
764 |
706 return maptileLabel; |
765 return maptileLabel; |
942 */ |
1010 */ |
943 void CntContactCardViewPrivate::onItemActivated() |
1011 void CntContactCardViewPrivate::onItemActivated() |
944 { |
1012 { |
945 CntContactCardDetailItem *item = qobject_cast<CntContactCardDetailItem*>(sender()); |
1013 CntContactCardDetailItem *item = qobject_cast<CntContactCardDetailItem*>(sender()); |
946 int index = item->index(); |
1014 int index = item->index(); |
|
1015 CntContactCardDataItem& dataItem = *mDataContainer->dataItem(index); |
947 QString action = mDataContainer->dataItem(index)->action(); |
1016 QString action = mDataContainer->dataItem(index)->action(); |
948 // Check if action is internal |
1017 CntUiContactCardExtension* extension = dataItem.contactCardExtension(); |
949 QList<QContactActionDescriptor> actionDescriptors = QContactAction::actionDescriptors(action, "symbian", 1); |
1018 if (!extension) |
950 if (0 < actionDescriptors.count()) |
1019 { |
951 { |
1020 //It's not an extension action. |
952 // These actions are considered internal(vendor=symbian and version=1) |
1021 // Check if action is internal |
953 executeAction(*mContact, mDataContainer->dataItem(index)->detail(), action, item); |
1022 QList<QContactActionDescriptor> actionDescriptors = QContactAction::actionDescriptors(action, "symbian", 1); |
954 } |
1023 if (0 < actionDescriptors.count()) |
955 else |
1024 { |
956 { |
1025 // These actions are considered internal(vendor=symbian and version=1) |
957 //Handle dynamic actions differently |
1026 executeAction(*mContact, dataItem.detail(), action, item); |
958 executeDynamicAction(*mContact, mDataContainer->dataItem(index)->detail(), mDataContainer->dataItem(index)->actionDescriptor()); |
1027 } |
|
1028 else |
|
1029 { |
|
1030 //Handle dynamic actions differently |
|
1031 executeDynamicAction(*mContact, dataItem.detail(), dataItem.actionDescriptor()); |
|
1032 } |
|
1033 } else { |
|
1034 // The action is from an extension |
|
1035 int indexWithinPlugin = dataItem.contactCardExtensionActionIndex(); |
|
1036 extension->handleShortPress(indexWithinPlugin); |
959 } |
1037 } |
960 } |
1038 } |
961 |
1039 |
962 /*! |
1040 /*! |
963 Execute the call / message / email action |
1041 Execute the call / message / email action |