119 |
116 |
120 if ( mView->navigationAction() != mSoftkey) { |
117 if ( mView->navigationAction() != mSoftkey) { |
121 mView->setNavigationAction(mSoftkey); |
118 mView->setNavigationAction(mSoftkey); |
122 } |
119 } |
123 |
120 |
124 QContact selectedContact; |
|
125 if ( mId == groupEditorView ) |
121 if ( mId == groupEditorView ) |
126 { |
122 { |
127 selectedContact = aArgs.value(ESelectedGroupContact).value<QContact>(); |
123 mContact = aArgs.value(ESelectedGroupContact).value<QContact>(); |
128 connect( mDataForm, SIGNAL(itemShown(const QModelIndex&)), this, SLOT(handleItemShown(const QModelIndex&)) ); |
124 connect( mDataForm, SIGNAL(itemShown(const QModelIndex&)), this, SLOT(handleItemShown(const QModelIndex&)) ); |
129 } |
125 } |
130 else |
126 else |
131 { |
127 { |
132 selectedContact = aArgs.value(ESelectedContact).value<QContact>(); |
128 mContact = aArgs.value(ESelectedContact).value<QContact>(); |
133 connect( mDataForm, SIGNAL(itemShown(const QModelIndex&)), this, SLOT(handleItemShown(const QModelIndex&)) ); |
129 connect( mDataForm, SIGNAL(itemShown(const QModelIndex&)), this, SLOT(handleItemShown(const QModelIndex&)) ); |
134 } |
130 } |
135 |
131 |
136 QContactManager& cm = mEngine->contactManager(SYMBIAN_BACKEND); |
132 QContactManager& cm = mEngine->contactManager(SYMBIAN_BACKEND); |
137 connect(&cm, SIGNAL(contactsRemoved(const QList<QContactLocalId>&)), |
133 connect(&cm, SIGNAL(contactsRemoved(const QList<QContactLocalId>&)), |
138 this, SLOT(contactDeletedFromOtherSource(const QList<QContactLocalId>&))); |
134 this, SLOT(contactDeletedFromOtherSource(const QList<QContactLocalId>&))); |
139 |
135 |
140 mEditorFactory->setupEditorView(*this, selectedContact); |
136 mEditorFactory->setupEditorView(*this, mContact); |
141 |
|
142 QString myCard = mArgs.value( EMyCard ).toString(); |
|
143 QContactLocalId localId = selectedContact.localId(); |
|
144 QContactLocalId selfContactId = cm.selfContactId(); |
|
145 bool isMyCard = ( localId == selfContactId && localId != 0 ) || !myCard.isEmpty(); |
|
146 |
|
147 if (isMyCard) |
|
148 { |
|
149 mSaveManager = new CntSaveManager(CntSaveManager::EMyCard); |
|
150 } |
|
151 else if ( mId == groupEditorView ) |
|
152 { |
|
153 mSaveManager = new CntSaveManager(CntSaveManager::EGroup); |
|
154 } |
|
155 else |
|
156 { |
|
157 mSaveManager = new CntSaveManager(); |
|
158 } |
|
159 |
|
160 mDataForm->setItemRecycling(true); |
137 mDataForm->setItemRecycling(true); |
161 |
138 |
162 // add new field if required |
139 // add new field if required |
163 if ( aArgs.value(ESelectedAction).toString() == CNT_ADD_ACTION ) |
140 if ( aArgs.value(ESelectedAction).toString() == CNT_ADD_ACTION ) |
164 { |
141 { |
171 mDataForm->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded); |
148 mDataForm->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded); |
172 mDataForm->setScrollingStyle(HbScrollArea::PanWithFollowOn); |
149 mDataForm->setScrollingStyle(HbScrollArea::PanWithFollowOn); |
173 mDataForm->verticalScrollBar()->setInteractive(true); |
150 mDataForm->verticalScrollBar()->setInteractive(true); |
174 |
151 |
175 mVirtualKeyboard = new HbShrinkingVkbHost(mView); |
152 mVirtualKeyboard = new HbShrinkingVkbHost(mView); |
176 |
|
177 connect(mVirtualKeyboard, SIGNAL(keypadOpened()), this, SLOT(handleKeypadOpen())); |
|
178 connect(mVirtualKeyboard, SIGNAL(keypadClosed()), this, SLOT(handleKeypadClosed())); |
|
179 } |
153 } |
180 |
154 |
181 void CntDetailEditor::deactivate() |
155 void CntDetailEditor::deactivate() |
182 { |
156 { |
183 QContactManager& mgr = mEngine->contactManager(SYMBIAN_BACKEND); |
157 QContactManager& mgr = mEngine->contactManager(SYMBIAN_BACKEND); |
184 if( mId == groupEditorView) { |
|
185 mgr.saveContact( mDataFormModel->contact() ); |
|
186 } |
|
187 |
158 |
188 disconnect(&mgr, SIGNAL(contactsRemoved(const QList<QContactLocalId>&)), |
159 disconnect(&mgr, SIGNAL(contactsRemoved(const QList<QContactLocalId>&)), |
189 this, SLOT(contactDeletedFromOtherSource(const QList<QContactLocalId>&))); |
160 this, SLOT(contactDeletedFromOtherSource(const QList<QContactLocalId>&))); |
|
161 |
|
162 delete mVirtualKeyboard; |
|
163 mVirtualKeyboard = NULL; |
190 } |
164 } |
191 |
165 |
192 bool CntDetailEditor::isDefault() const |
166 bool CntDetailEditor::isDefault() const |
193 { |
167 { |
194 return false; |
168 return false; |
307 if (name.isEmpty()) |
281 if (name.isEmpty()) |
308 { |
282 { |
309 name = hbTrId("txt_phob_list_unnamed"); |
283 name = hbTrId("txt_phob_list_unnamed"); |
310 } |
284 } |
311 |
285 |
312 CntSaveManager::CntSaveResult result = mSaveManager->saveContact(mDataFormModel->contact(), &mgr); |
286 QString myCard = mArgs.value( EMyCard ).toString(); |
313 |
287 QContactLocalId localId = mContact.localId(); |
314 if (mId != groupEditorView) |
288 QContactLocalId selfContactId = mgr.selfContactId(); |
315 { |
289 bool isMyCard = ( localId == selfContactId && localId != 0 ) || !myCard.isEmpty(); |
|
290 |
|
291 CntSaveManager::CntSaveResult result; |
|
292 CntSaveManager& saveMgr = mEngine->saveManager(); |
|
293 if (isMyCard) { |
|
294 result = saveMgr.saveMyCard( mDataFormModel->contact(), &mgr ); |
|
295 } |
|
296 else if ( mId == groupEditorView ) { |
|
297 result = saveMgr.saveGroup( mDataFormModel->contact(), &mgr ); |
|
298 } |
|
299 else { |
|
300 result = saveMgr.saveContact( mDataFormModel->contact(), &mgr ); |
|
301 } |
|
302 |
|
303 if (mId != groupEditorView) { |
316 switch (result) |
304 switch (result) |
317 { |
305 { |
318 case CntSaveManager::ESaved: |
306 case CntSaveManager::ESaved: |
319 HbDeviceNotificationDialog::notification(QString(),HbParameterLengthLimiter(hbTrId("txt_phob_dpophead_contact_1_saved")).arg(name)); |
307 HbDeviceNotificationDialog::notification(QString(),HbParameterLengthLimiter("txt_phob_dpophead_contact_1_saved").arg(name)); |
320 break; |
308 break; |
321 case CntSaveManager::EUpdated: |
309 case CntSaveManager::EUpdated: |
322 HbDeviceNotificationDialog::notification(QString(),HbParameterLengthLimiter(hbTrId("txt_phob_dpophead_contacts_1_updated")).arg(name)); |
310 HbDeviceNotificationDialog::notification(QString(),HbParameterLengthLimiter("txt_phob_dpophead_contacts_1_updated").arg(name)); |
323 break; |
311 break; |
324 case CntSaveManager::EFailed: |
312 case CntSaveManager::EFailed: |
325 HbDeviceNotificationDialog::notification(QString(),hbTrId("SAVING FAILED!")); |
313 HbDeviceNotificationDialog::notification(QString(),hbTrId("SAVING FAILED!")); |
326 break; |
314 break; |
327 case CntSaveManager::EDeleted: |
315 case CntSaveManager::EDeleted: |