30 #include <CPbk2PresentationContact.h> |
30 #include <CPbk2PresentationContact.h> |
31 #include <CPbk2FieldPropertyArray.h> |
31 #include <CPbk2FieldPropertyArray.h> |
32 #include <CPbk2PresentationContactFieldCollection.h> |
32 #include <CPbk2PresentationContactFieldCollection.h> |
33 #include <Pbk2Commands.rsg> |
33 #include <Pbk2Commands.rsg> |
34 #include <Pbk2CmdExtRes.rsg> |
34 #include <Pbk2CmdExtRes.rsg> |
35 |
35 #include <MVPbkContactFieldUriData.h> |
|
36 #include <Pbk2AddressTools.h> |
36 |
37 |
37 #include <txtetext.h> // CPlainText |
38 #include <txtetext.h> // CPlainText |
38 #include <baclipb.h> // CClipboard |
39 #include <baclipb.h> // CClipboard |
39 #include <StringLoader.h> |
40 #include <StringLoader.h> |
40 #include <aknnotewrappers.h> // CAknInformationNote |
41 #include <aknnotewrappers.h> // CAknInformationNote |
186 // Construct a plain text from the detail |
187 // Construct a plain text from the detail |
187 const TInt KBeginning = 0; |
188 const TInt KBeginning = 0; |
188 // Fetch field from current UI control |
189 // Fetch field from current UI control |
189 const MVPbkBaseContactField* field = iUiControl->FocusedField(); |
190 const MVPbkBaseContactField* field = iUiControl->FocusedField(); |
190 TPtrC detail; |
191 TPtrC detail; |
|
192 RBuf addText; |
191 TVPbkFieldStorageType fieldType = field->FieldData().DataType(); |
193 TVPbkFieldStorageType fieldType = field->FieldData().DataType(); |
192 |
194 |
193 switch(fieldType) |
195 switch(fieldType) |
194 { |
196 { |
195 case EVPbkFieldStorageTypeText: |
197 case EVPbkFieldStorageTypeText: |
196 { |
198 { |
197 detail.Set(MVPbkContactFieldTextData::Cast(field->FieldData()).Text()); |
199 const MVPbkFieldType* vPbkFieldType = field->BestMatchingFieldType(); |
|
200 TPbk2FieldGroupId groupId = Pbk2AddressTools::MapVPbkFieldTypeToAddressGroupId( vPbkFieldType ); |
|
201 if( groupId == EPbk2FieldGroupIdHomeAddress || |
|
202 groupId == EPbk2FieldGroupIdCompanyAddress || |
|
203 groupId == EPbk2FieldGroupIdPostalAddress ) //the focused field belongs to Address |
|
204 { |
|
205 MVPbkStoreContact* vPbkStoreContact = const_cast<MVPbkStoreContact*>( iUiControl->FocusedStoreContact() ); |
|
206 //address view is empty |
|
207 if( Pbk2AddressTools::IsAddressPreviewEmptyL(*vPbkStoreContact, groupId) ) |
|
208 { |
|
209 detail.Set( KNullDesC() ); //KNullDesC will be copied to clipboard |
|
210 } |
|
211 else //address view is not empty |
|
212 { |
|
213 Pbk2AddressTools::GetAddressPreviewLC(*vPbkStoreContact, groupId, addText); |
|
214 detail.Set( addText ); |
|
215 } |
|
216 } |
|
217 else //the focused field doesn't belong to Address |
|
218 { |
|
219 detail.Set(MVPbkContactFieldTextData::Cast(field->FieldData()).Text()); |
|
220 } |
198 break; |
221 break; |
199 } |
222 } |
200 case EVPbkFieldStorageTypeDateTime: |
223 case EVPbkFieldStorageTypeDateTime: |
201 { |
224 { |
202 TLocale locale; |
225 TLocale locale; |
227 iAppServices->ContactManager().FsSession()); |
250 iAppServices->ContactManager().FsSession()); |
228 plainText->CopyToStoreL(cb->Store(), cb->StreamDictionary(), |
251 plainText->CopyToStoreL(cb->Store(), cb->StreamDictionary(), |
229 KBeginning, plainText->DocumentLength()); |
252 KBeginning, plainText->DocumentLength()); |
230 cb->CommitL(); |
253 cb->CommitL(); |
231 |
254 |
232 CleanupStack::PopAndDestroy(2); // cb, plainText |
255 CleanupStack::PopAndDestroy(2); // cb, plainText |
|
256 if( addText.Length() ) |
|
257 { |
|
258 CleanupStack::PopAndDestroy(&addText); |
|
259 } |
233 |
260 |
234 // Show a note |
261 // Show a note |
235 HBufC* prompt = StringLoader::LoadLC(R_QTN_CCA_INFO_NOTE_COPIED_TO_CLIPBOARD); |
262 HBufC* prompt = StringLoader::LoadLC(R_QTN_CCA_INFO_NOTE_COPIED_TO_CLIPBOARD); |
236 CAknInformationNote* dlg = new(ELeave) CAknInformationNote(ETrue); |
263 CAknInformationNote* dlg = new(ELeave) CAknInformationNote(ETrue); |
237 dlg->ExecuteLD(*prompt); |
264 dlg->ExecuteLD(*prompt); |