20 #include "cntdocumentloader.h" |
20 #include "cntdocumentloader.h" |
21 #include "cntdetailpopup.h" |
21 #include "cntdetailpopup.h" |
22 #include "cnteditviewheadingitem.h" |
22 #include "cnteditviewheadingitem.h" |
23 #include "cntimagelabel.h" |
23 #include "cntimagelabel.h" |
24 |
24 |
|
25 #include <qtcontacts.h> |
25 #include <hbdocumentloader.h> |
26 #include <hbdocumentloader.h> |
26 #include <thumbnailmanager_qt.h> |
27 #include <thumbnailmanager_qt.h> |
27 #include <hbabstractviewitem.h> |
28 #include <hbabstractviewitem.h> |
28 #include <hbmessagebox.h> |
29 #include <hbmessagebox.h> |
29 #include <hbgroupbox.h> |
30 #include <hbgroupbox.h> |
62 mHeading = static_cast<CntEditViewHeadingItem*>( mDocument->findWidget("editViewHeading") ); |
63 mHeading = static_cast<CntEditViewHeadingItem*>( mDocument->findWidget("editViewHeading") ); |
63 mImageLabel = static_cast<CntImageLabel*>(mDocument->findWidget("editViewImage")); |
64 mImageLabel = static_cast<CntImageLabel*>(mDocument->findWidget("editViewImage")); |
64 |
65 |
65 mSoftkey = new HbAction(Hb::BackNaviAction, mView); |
66 mSoftkey = new HbAction(Hb::BackNaviAction, mView); |
66 mDiscard = static_cast<HbAction*>( mDocument->findObject("cnt:discard") ); |
67 mDiscard = static_cast<HbAction*>( mDocument->findObject("cnt:discard") ); |
|
68 mDiscard->setParent(mView); |
|
69 |
67 mSave = static_cast<HbAction*>( mDocument->findObject("cnt:savecontact") ); |
70 mSave = static_cast<HbAction*>( mDocument->findObject("cnt:savecontact") ); |
|
71 mSave->setParent(mView); |
|
72 |
68 mDelete = static_cast<HbAction*>( mDocument->findObject("cnt:deletecontact") ); |
73 mDelete = static_cast<HbAction*>( mDocument->findObject("cnt:deletecontact") ); |
|
74 mDelete->setParent(mView); |
69 |
75 |
70 HbAction* add = static_cast<HbAction*>( mDocument->findObject("cnt:adddetail_options") ); |
76 HbAction* add = static_cast<HbAction*>( mDocument->findObject("cnt:adddetail_options") ); |
|
77 add->setParent(mView); |
71 |
78 |
72 connect( add, SIGNAL(triggered()), this, SLOT(addDetailItem()) ); |
79 connect( add, SIGNAL(triggered()), this, SLOT(addDetailItem()) ); |
73 connect( mDelete, SIGNAL(triggered()), this, SLOT(deleteContact()) ); |
80 connect( mDelete, SIGNAL(triggered()), this, SLOT(deleteContact()) ); |
74 connect( mDiscard, SIGNAL(triggered()), this, SLOT(discardChanges()) ); |
81 connect( mDiscard, SIGNAL(triggered()), this, SLOT(discardChanges()) ); |
75 connect( mSave, SIGNAL(triggered()), this, SLOT(saveChanges()) ); |
82 connect( mSave, SIGNAL(triggered()), this, SLOT(saveChanges()) ); |
124 setOrientation(window->orientation()); |
130 setOrientation(window->orientation()); |
125 } |
131 } |
126 |
132 |
127 QString myCard = mArgs.value( EMyCard ).toString(); |
133 QString myCard = mArgs.value( EMyCard ).toString(); |
128 QString selectedAction = mArgs.value( ESelectedAction ).toString(); |
134 QString selectedAction = mArgs.value( ESelectedAction ).toString(); |
129 |
|
130 QVariant contact = aArgs.value( ESelectedContact ); |
135 QVariant contact = aArgs.value( ESelectedContact ); |
131 mContact = new QContact( contact.value<QContact>() ); |
136 setSelectedContact( contact.value<QContact>() ); |
|
137 |
132 QContactLocalId localId = mContact->localId(); |
138 QContactLocalId localId = mContact->localId(); |
133 |
|
134 QContactManager* cm = mMgr->contactManager(SYMBIAN_BACKEND); |
139 QContactManager* cm = mMgr->contactManager(SYMBIAN_BACKEND); |
135 QContactLocalId selfContactId = cm->selfContactId(); |
140 QContactLocalId selfContactId = cm->selfContactId(); |
136 mIsMyCard = ( localId == selfContactId && localId != 0 ) || myCard == "myCard"; |
141 mIsMyCard = ( localId == selfContactId && localId != 0 ) || myCard == "myCard"; |
|
142 |
|
143 if ( mHeading ) |
|
144 mHeading->setDetails( mContact, mIsMyCard ); |
137 |
145 |
138 // if "MyCard", set slightly different heading and options menu |
146 // if "MyCard", set slightly different heading and options menu |
139 if ( mIsMyCard ) |
147 if ( mIsMyCard ) |
140 { |
148 { |
141 mSave->setText(hbTrId("txt_phob_opt_save_my_card")); |
149 mSave->setText(hbTrId("txt_phob_opt_save_my_card")); |
164 { |
172 { |
165 mDiscard->setEnabled( false ); |
173 mDiscard->setEnabled( false ); |
166 mSave->setEnabled( false ); |
174 mSave->setEnabled( false ); |
167 } |
175 } |
168 |
176 |
169 mHeading->setDetails( mContact ); |
|
170 mModel = new CntEditViewListModel( mContact ); |
|
171 mListView->setModel( mModel ); |
|
172 |
|
173 mThumbnailManager = new ThumbnailManager(this); |
177 mThumbnailManager = new ThumbnailManager(this); |
174 mThumbnailManager->setMode(ThumbnailManager::Default); |
178 mThumbnailManager->setMode(ThumbnailManager::Default); |
175 mThumbnailManager->setQualityPreference(ThumbnailManager::OptimizeForQuality); |
179 mThumbnailManager->setQualityPreference(ThumbnailManager::OptimizeForQuality); |
176 mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailLarge); |
180 mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailLarge); |
177 |
181 |
333 else |
337 else |
334 { |
338 { |
335 QContactManager* cm = mMgr->contactManager( SYMBIAN_BACKEND ); |
339 QContactManager* cm = mMgr->contactManager( SYMBIAN_BACKEND ); |
336 QString name = cm->synthesizedDisplayLabel( *mContact ); |
340 QString name = cm->synthesizedDisplayLabel( *mContact ); |
337 HbMessageBox::question(HbParameterLengthLimiter(hbTrId("txt_phob_info_delete_1")).arg(name), this, SLOT(handleDeleteContact(HbAction*)), |
341 HbMessageBox::question(HbParameterLengthLimiter(hbTrId("txt_phob_info_delete_1")).arg(name), this, SLOT(handleDeleteContact(HbAction*)), |
338 hbTrId("txt_phob_button_delete"), hbTrId("txt_common_button_cancel")); |
342 hbTrId("txt_common_button_delete"), hbTrId("txt_common_button_cancel")); |
339 } |
343 } |
340 } |
344 } |
341 |
345 |
342 void CntEditViewPrivate::handleDeleteContact(HbAction *action) |
346 void CntEditViewPrivate::handleDeleteContact(HbAction *action) |
343 { |
347 { |
390 mgr->setSelfContactId( mContact->localId() ); |
394 mgr->setSelfContactId( mContact->localId() ); |
391 } |
395 } |
392 |
396 |
393 QString name = mgr->synthesizedDisplayLabel( *mContact ); |
397 QString name = mgr->synthesizedDisplayLabel( *mContact ); |
394 |
398 |
|
399 emit contactUpdated(success); |
|
400 |
395 if ( success ) |
401 if ( success ) |
396 { |
402 { |
397 HbDeviceNotificationDialog notificationDialog; |
403 HbDeviceNotificationDialog::notification(QString(),HbParameterLengthLimiter(hbTrId("txt_phob_dpophead_contact_1_saved")).arg(name)); |
398 notificationDialog.setTitle(HbParameterLengthLimiter(hbTrId("txt_phob_dpophead_contact_1_saved")).arg(name)); |
|
399 notificationDialog.show(); |
|
400 } |
404 } |
401 else |
405 else |
402 { |
406 { |
403 //TODO: localization is missing |
407 //TODO: localization is missing |
404 HbDeviceNotificationDialog notificationDialog; |
408 HbDeviceNotificationDialog::notification(QString(),qtTrId("SAVING FAILED!")); |
405 notificationDialog.setTitle(qtTrId("SAVING FAILED!")); |
|
406 notificationDialog.show(); |
|
407 } |
409 } |
408 |
|
409 emit contactUpdated(success); |
|
410 |
410 |
411 QVariant var; |
411 QVariant var; |
412 var.setValue(*mContact); |
412 var.setValue(*mContact); |
413 mArgs.insert(ESelectedContact, var); |
413 mArgs.insert(ESelectedContact, var); |
414 } |
414 } |
429 { |
429 { |
430 bool success = mgr->saveContact(mContact); |
430 bool success = mgr->saveContact(mContact); |
431 |
431 |
432 QString name = mgr->synthesizedDisplayLabel( *mContact ); |
432 QString name = mgr->synthesizedDisplayLabel( *mContact ); |
433 |
433 |
|
434 emit contactUpdated( success ); |
|
435 |
434 if ( success ) |
436 if ( success ) |
435 { |
437 { |
436 HbDeviceNotificationDialog notificationDialog; |
438 HbDeviceNotificationDialog::notification(QString(),HbParameterLengthLimiter(hbTrId("txt_phob_dpophead_contacts_1_updated")).arg(name)); |
437 notificationDialog.setTitle(HbParameterLengthLimiter(hbTrId("txt_phob_dpophead_contacts_1_updated")).arg(name)); |
|
438 notificationDialog.show(); |
|
439 } |
439 } |
440 else |
440 else |
441 { |
441 { |
442 //TODO: localization is missing |
442 //TODO: localization is missing |
443 HbDeviceNotificationDialog notificationDialog; |
443 HbDeviceNotificationDialog::notification(QString(),qtTrId("SAVING FAILED!")); |
444 notificationDialog.setTitle(qtTrId("SAVING FAILED!")); |
|
445 notificationDialog.show(); |
|
446 } |
444 } |
447 |
|
448 emit contactUpdated( success ); |
|
449 |
445 |
450 QVariant var; |
446 QVariant var; |
451 var.setValue(*mContact); |
447 var.setValue(*mContact); |
452 mArgs.insert(ESelectedContact, var); |
448 mArgs.insert(ESelectedContact, var); |
453 } |
449 } |
626 { |
622 { |
627 mModel->removeItem( aDetail, aIndex ); |
623 mModel->removeItem( aDetail, aIndex ); |
628 mSave->setEnabled( true ); |
624 mSave->setEnabled( true ); |
629 mDiscard->setEnabled( true ); |
625 mDiscard->setEnabled( true ); |
630 } |
626 } |
|
627 |
|
628 void CntEditViewPrivate::setSelectedContact( QContact aContact ) |
|
629 { |
|
630 if ( mContact ) |
|
631 { |
|
632 delete mContact; |
|
633 mContact = NULL; |
|
634 } |
|
635 mContact = new QContact( aContact ); |
|
636 |
|
637 if ( mModel ) |
|
638 { |
|
639 delete mModel; |
|
640 mModel = NULL; |
|
641 } |
|
642 mModel = new CntEditViewListModel( mContact ); |
|
643 |
|
644 if ( mListView ) |
|
645 mListView->setModel( mModel ); |
|
646 } |
631 // End of File |
647 // End of File |
632 |
648 |