30 |
31 |
31 /*! |
32 /*! |
32 Constructor, initialize member variables. |
33 Constructor, initialize member variables. |
33 \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) |
34 */ |
35 */ |
35 CntServiceAssignContactCardView::CntServiceAssignContactCardView(CntServiceHandler *aServiceHandler) : |
36 CntServiceAssignContactCardView::CntServiceAssignContactCardView( CntAbstractServiceProvider& aServiceProvider ) : |
36 CntContactCardView(), |
37 CntContactCardView(true), |
37 mServiceHandler(aServiceHandler) |
38 mProvider( aServiceProvider ) |
38 { |
39 { |
|
40 CNT_ENTRY |
39 connect(this, SIGNAL(backPressed()), this, SLOT(doCloseView())); |
41 connect(this, SIGNAL(backPressed()), this, SLOT(doCloseView())); |
40 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))); |
41 |
43 connect(this, SIGNAL(addToContacts()), this, SLOT(addToContacts())); |
42 addActionsToToolBar(); |
44 CNT_EXIT |
43 } |
45 } |
44 |
46 |
45 /*! |
47 /*! |
46 Destructor |
48 Destructor |
47 */ |
49 */ |
48 CntServiceAssignContactCardView::~CntServiceAssignContactCardView() |
50 CntServiceAssignContactCardView::~CntServiceAssignContactCardView() |
49 { |
51 { |
50 |
52 CNT_ENTRY |
51 } |
53 CNT_EXIT |
52 |
|
53 /*! |
|
54 Add actions to the toolbar |
|
55 */ |
|
56 void CntServiceAssignContactCardView::addActionsToToolBar() |
|
57 { |
|
58 view()->toolBar()->clearActions(); |
|
59 HbAction* addToContact = view()->toolBar()->addAction("txt_phob_button_add_to_contacts"); |
|
60 connect(addToContact, SIGNAL(triggered()), this, SLOT(addToContacts())); |
|
61 } |
54 } |
62 |
55 |
63 /*! |
56 /*! |
64 Opens the Add to Contacts popup |
57 Opens the Add to Contacts popup |
65 */ |
58 */ |
66 void CntServiceAssignContactCardView::addToContacts() |
59 void CntServiceAssignContactCardView::addToContacts() |
67 { |
60 { |
68 HbDialog *popup = new HbDialog(); |
61 CNT_ENTRY |
|
62 |
|
63 HbDialog* popup = new HbDialog(); |
69 popup->setDismissPolicy(HbDialog::NoDismiss); |
64 popup->setDismissPolicy(HbDialog::NoDismiss); |
70 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)); |
71 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)); |
72 |
71 |
73 HbWidget *buttonWidget = new HbWidget(popup); |
72 HbWidget* buttonWidget = new HbWidget(popup); |
74 QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical); |
73 QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical); |
75 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())); |
76 connect(addButton, SIGNAL(clicked()), this, SLOT(saveNew())); |
81 connect(addButton, SIGNAL(clicked()), this, SLOT(saveNew())); |
77 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())); |
78 connect(updateButton, SIGNAL(clicked()), this, SLOT(updateExisting())); |
88 connect(updateButton, SIGNAL(clicked()), this, SLOT(updateExisting())); |
|
89 |
79 layout->addItem(addButton); |
90 layout->addItem(addButton); |
80 layout->addItem(updateButton); |
91 layout->addItem(updateButton); |
|
92 |
81 buttonWidget->setLayout(layout); |
93 buttonWidget->setLayout(layout); |
82 popup->setContentWidget(buttonWidget); |
94 popup->setContentWidget(buttonWidget); |
|
95 |
|
96 popup->open(); |
83 |
97 |
84 popup->setSecondaryAction(new HbAction(hbTrId("txt_common_button_cancel"), popup)); |
98 CNT_EXIT |
85 } |
99 } |
86 |
100 |
87 /*! |
101 /*! |
88 Create a new contact with the detail |
102 Create a new contact with the detail |
89 */ |
103 */ |
90 void CntServiceAssignContactCardView::saveNew() |
104 void CntServiceAssignContactCardView::saveNew() |
91 { |
105 { |
|
106 CNT_ENTRY |
92 CntViewParameters viewParameters; |
107 CntViewParameters viewParameters; |
93 viewParameters.insert(EViewId, serviceEditView); |
108 viewParameters.insert(EViewId, serviceEditView); |
|
109 QContactName contactName = mContact.detail<QContactName>(); |
|
110 mContact.removeDetail(&contactName); |
94 QVariant var; |
111 QVariant var; |
95 var.setValue(mContact); |
112 var.setValue(mContact); |
96 viewParameters.insert(ESelectedContact, var); |
113 viewParameters.insert(ESelectedContact, var); |
97 mViewManager->changeView(viewParameters); |
114 mViewManager->changeView(viewParameters); |
|
115 CNT_EXIT |
98 } |
116 } |
99 |
117 |
100 /*! |
118 /*! |
101 Update an existing contact with the detail |
119 Update an existing contact with the detail |
102 */ |
120 */ |
103 void CntServiceAssignContactCardView::updateExisting() |
121 void CntServiceAssignContactCardView::updateExisting() |
104 { |
122 { |
|
123 CNT_ENTRY |
105 CntViewParameters viewParameters; |
124 CntViewParameters viewParameters; |
106 viewParameters.insert(EViewId, serviceContactSelectionView); |
125 viewParameters.insert(EViewId, serviceContactSelectionView); |
107 QVariant var; |
126 QVariant var; |
108 var.setValue(mDetail); |
127 var.setValue(mDetail); |
109 viewParameters.insert(ESelectedDetail, var); |
128 viewParameters.insert(ESelectedDetail, var); |
110 mViewManager->changeView(viewParameters); |
129 mViewManager->changeView(viewParameters); |
|
130 CNT_EXIT |
111 } |
131 } |
112 |
132 |
113 /*! |
133 /*! |
114 Called after the view has been activated |
134 Called after the view has been activated |
115 */ |
135 */ |
116 void CntServiceAssignContactCardView::doViewActivated(CntAbstractViewManager* aMgr, const CntViewParameters aArgs) |
136 void CntServiceAssignContactCardView::doViewActivated(CntAbstractViewManager* aMgr, const CntViewParameters aArgs) |
117 { |
137 { |
|
138 CNT_ENTRY |
118 mViewManager = aMgr; |
139 mViewManager = aMgr; |
119 mContact = aArgs.value(ESelectedContact).value<QContact>(); |
140 mContact = aArgs.value(ESelectedContact).value<QContact>(); |
120 mDetail = aArgs.value(ESelectedDetail).value<QContactDetail>(); |
141 mDetail = aArgs.value(ESelectedDetail).value<QContactDetail>(); |
|
142 CNT_EXIT |
121 } |
143 } |
122 |
144 |
123 /*! |
145 /*! |
124 Close the view (quits the service as well) |
146 Close the view (quits the service as well) |
125 */ |
147 */ |
126 void CntServiceAssignContactCardView::doCloseView() |
148 void CntServiceAssignContactCardView::doCloseView() |
127 { |
149 { |
|
150 CNT_ENTRY |
128 qApp->quit(); |
151 qApp->quit(); |
|
152 CNT_EXIT |
129 } |
153 } |
130 |
154 |
131 // end of file |
155 // end of file |