32 /*! |
32 /*! |
33 Constructor, initialize member variables. |
33 Constructor, initialize member variables. |
34 \a viewManager is the parent that creates this view. \a parent is a pointer to parent QGraphicsItem (by default this is 0) |
34 \a viewManager is the parent that creates this view. \a parent is a pointer to parent QGraphicsItem (by default this is 0) |
35 */ |
35 */ |
36 CntServiceAssignContactCardView::CntServiceAssignContactCardView( CntAbstractServiceProvider& aServiceProvider ) : |
36 CntServiceAssignContactCardView::CntServiceAssignContactCardView( CntAbstractServiceProvider& aServiceProvider ) : |
37 CntContactCardView(), |
37 CntContactCardView(true), |
38 mProvider( aServiceProvider ) |
38 mProvider( aServiceProvider ) |
39 { |
39 { |
40 CNT_ENTRY |
40 CNT_ENTRY |
41 connect(this, SIGNAL(backPressed()), this, SLOT(doCloseView())); |
41 connect(this, SIGNAL(backPressed()), this, SLOT(doCloseView())); |
42 connect(this, SIGNAL(viewActivated(CntAbstractViewManager*, QContactDetail)), this, SLOT(doViewActivated(CntAbstractViewManager*,QContactDetail))); |
42 connect(this, SIGNAL(viewActivated(CntAbstractViewManager*, const CntViewParameters)), this, SLOT(doViewActivated(CntAbstractViewManager*,const CntViewParameters))); |
43 |
43 connect(this, SIGNAL(addToContacts()), this, SLOT(addToContacts())); |
44 addActionsToToolBar(); |
|
45 CNT_EXIT |
44 CNT_EXIT |
46 } |
45 } |
47 |
46 |
48 /*! |
47 /*! |
49 Destructor |
48 Destructor |
53 CNT_ENTRY |
52 CNT_ENTRY |
54 CNT_EXIT |
53 CNT_EXIT |
55 } |
54 } |
56 |
55 |
57 /*! |
56 /*! |
58 Add actions to the toolbar |
|
59 */ |
|
60 void CntServiceAssignContactCardView::addActionsToToolBar() |
|
61 { |
|
62 CNT_ENTRY |
|
63 view()->toolBar()->clearActions(); |
|
64 HbAction* addToContact = view()->toolBar()->addAction("txt_phob_button_add_to_contacts"); |
|
65 connect(addToContact, SIGNAL(triggered()), this, SLOT(addToContacts())); |
|
66 CNT_EXIT |
|
67 } |
|
68 |
|
69 /*! |
|
70 Opens the Add to Contacts popup |
57 Opens the Add to Contacts popup |
71 */ |
58 */ |
72 void CntServiceAssignContactCardView::addToContacts() |
59 void CntServiceAssignContactCardView::addToContacts() |
73 { |
60 { |
74 CNT_ENTRY |
61 CNT_ENTRY |
75 HbDialog *popup = new HbDialog(); |
62 |
|
63 HbDialog* popup = new HbDialog(); |
76 popup->setDismissPolicy(HbDialog::NoDismiss); |
64 popup->setDismissPolicy(HbDialog::NoDismiss); |
77 popup->setHeadingWidget(new HbLabel(hbTrId("txt_phob_title_add_to_contacts"), popup)); |
65 popup->setHeadingWidget( |
|
66 new HbLabel(hbTrId("txt_phob_title_add_to_contacts"), popup)); |
78 popup->setAttribute(Qt::WA_DeleteOnClose); |
67 popup->setAttribute(Qt::WA_DeleteOnClose); |
|
68 popup->setTimeout( HbPopup::NoTimeout ); |
|
69 popup->addAction( |
|
70 new HbAction(hbTrId("txt_common_button_cancel"), popup)); |
79 |
71 |
80 HbWidget *buttonWidget = new HbWidget(popup); |
72 HbWidget* buttonWidget = new HbWidget(popup); |
81 QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical); |
73 QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical); |
82 HbPushButton *addButton = new HbPushButton(hbTrId("txt_missing_list_save_as_a_new_contact"), buttonWidget); |
74 |
|
75 HbPushButton* addButton = new HbPushButton(buttonWidget); |
|
76 addButton->setStretched(true); |
|
77 addButton->setText(hbTrId("txt_phob_button_save_as_a_new_contact")); |
|
78 HbIcon plusIcon("qtg_mono_plus"); |
|
79 addButton->setIcon(plusIcon); |
|
80 connect(addButton, SIGNAL(clicked()), popup, SLOT(close())); |
83 connect(addButton, SIGNAL(clicked()), this, SLOT(saveNew())); |
81 connect(addButton, SIGNAL(clicked()), this, SLOT(saveNew())); |
84 HbPushButton *updateButton = new HbPushButton(hbTrId("txt_missing_list_update_existing_contact"), buttonWidget); |
82 |
|
83 HbPushButton* updateButton = new HbPushButton(buttonWidget); |
|
84 updateButton->setStretched(true); |
|
85 updateButton->setText(hbTrId("txt_phob_button_update_existing_contact")); |
|
86 updateButton->setIcon(plusIcon); |
|
87 connect(updateButton, SIGNAL(clicked()), popup, SLOT(close())); |
85 connect(updateButton, SIGNAL(clicked()), this, SLOT(updateExisting())); |
88 connect(updateButton, SIGNAL(clicked()), this, SLOT(updateExisting())); |
|
89 |
86 layout->addItem(addButton); |
90 layout->addItem(addButton); |
87 layout->addItem(updateButton); |
91 layout->addItem(updateButton); |
|
92 |
88 buttonWidget->setLayout(layout); |
93 buttonWidget->setLayout(layout); |
89 popup->setContentWidget(buttonWidget); |
94 popup->setContentWidget(buttonWidget); |
|
95 |
|
96 popup->open(); |
90 |
97 |
91 popup->setSecondaryAction(new HbAction(hbTrId("txt_common_button_cancel"), popup)); |
|
92 CNT_EXIT |
98 CNT_EXIT |
93 } |
99 } |
94 |
100 |
95 /*! |
101 /*! |
96 Create a new contact with the detail |
102 Create a new contact with the detail |
98 void CntServiceAssignContactCardView::saveNew() |
104 void CntServiceAssignContactCardView::saveNew() |
99 { |
105 { |
100 CNT_ENTRY |
106 CNT_ENTRY |
101 CntViewParameters viewParameters; |
107 CntViewParameters viewParameters; |
102 viewParameters.insert(EViewId, serviceEditView); |
108 viewParameters.insert(EViewId, serviceEditView); |
|
109 QContactName contactName = mContact.detail<QContactName>(); |
|
110 mContact.removeDetail(&contactName); |
103 QVariant var; |
111 QVariant var; |
104 var.setValue(mContact); |
112 var.setValue(mContact); |
105 viewParameters.insert(ESelectedContact, var); |
113 viewParameters.insert(ESelectedContact, var); |
106 mViewManager->changeView(viewParameters); |
114 mViewManager->changeView(viewParameters); |
107 CNT_EXIT |
115 CNT_EXIT |