phonebookui/Phonebook2/UIControls/src/CPbk2ContactEditorDlgImpl.cpp
branchRCL_3
changeset 11 2828b4d142c0
parent 9 0d28c1c5b6dd
child 12 4ae315f230bc
equal deleted inserted replaced
9:0d28c1c5b6dd 11:2828b4d142c0
   841 // CPbk2ContactEditorDlgImpl::SetInitialCurrentLine
   841 // CPbk2ContactEditorDlgImpl::SetInitialCurrentLine
   842 // --------------------------------------------------------------------------
   842 // --------------------------------------------------------------------------
   843 //
   843 //
   844 void CPbk2ContactEditorDlgImpl::SetInitialCurrentLine()
   844 void CPbk2ContactEditorDlgImpl::SetInitialCurrentLine()
   845     {
   845     {
   846     TRAPD( err, ActivateFirstPageL() );
       
   847     if(err)
       
   848         {
       
   849         return;
       
   850         }
       
   851 
       
   852     TInt focusedIndex = 0;
   846     TInt focusedIndex = 0;
   853     if ( iParams.iFocusedContactField )
   847     if ( iParams.iFocusedContactField )
   854         {
   848         {
   855         const TInt count = iUiFieldArray->Count();
   849         const TInt count = iUiFieldArray->Count();
   856         for (TInt i = 0; i < count; ++i)
   850         for (TInt i = 0; i < count; ++i)
  3377         CPbk2ContactEditorArrayItem* aCurrentField,
  3371         CPbk2ContactEditorArrayItem* aCurrentField,
  3378 		const TKeyEvent& aKeyEvent, 
  3372 		const TKeyEvent& aKeyEvent, 
  3379 		TEventCode aType )
  3373 		TEventCode aType )
  3380     {
  3374     {
  3381     MPbk2ContactEditorField* editorField = aCurrentField->ContactEditorField();
  3375     MPbk2ContactEditorField* editorField = aCurrentField->ContactEditorField();
  3382     MVPbkStoreContactField& contactField = editorField->ContactField();
  3376     if ( editorField )
  3383     TVPbkFieldStorageType dataType = contactField.FieldData().DataType();
  3377         {
  3384     
  3378         MVPbkStoreContactField& contactField = editorField->ContactField();
  3385     if ( EVPbkFieldStorageTypeText == dataType )
  3379         TVPbkFieldStorageType dataType = contactField.FieldData().DataType();
  3386         {
       
  3387         const MVPbkContactFieldTextData& textData = 
       
  3388             MVPbkContactFieldTextData::Cast(contactField.FieldData());
       
  3389         TInt maxSize = textData.MaxLength();
       
  3390         
  3380         
  3391         if ( KVPbkUnlimitedFieldLength != maxSize &&
  3381         if ( EVPbkFieldStorageTypeText == dataType )
  3392                 IsCheckPointEvent( aKeyEvent, aType ) )
  3382             {
  3393             {
  3383             const MVPbkContactFieldTextData& textData = 
  3394             CEikEdwin* ctrl = editorField->Control();
  3384                 MVPbkContactFieldTextData::Cast(contactField.FieldData());
  3395             HBufC* textBuf = ctrl->GetTextInHBufL();
  3385             TInt maxSize = textData.MaxLength();
  3396             
  3386             
  3397             if ( textBuf )
  3387             if ( KVPbkUnlimitedFieldLength != maxSize &&
  3398                 {
  3388                     IsCheckPointEvent( aKeyEvent, aType ) )
  3399                 TInt maxLen = maxSize;
  3389                 {
  3400                 if ( IsUnicodeL( *textBuf ) )
  3390                 CEikEdwin* ctrl = editorField->Control();
       
  3391                 HBufC* textBuf = ctrl->GetTextInHBufL();
       
  3392                 
       
  3393                 if ( textBuf )
  3401                     {
  3394                     {
  3402                     maxLen = maxSize / KTwoBytes - KExtraByte;
  3395                     CleanupStack::PushL( textBuf );
  3403                     }
  3396                     TInt maxLen = maxSize;
  3404                 if ( ctrl->MaxLength() != maxLen && textBuf->Length() <= maxLen )
  3397                     if ( IsUnicodeL( *textBuf ) )
  3405                     {
  3398                         {
  3406                     ctrl->SetMaxLength( maxLen );
  3399                         maxLen = maxSize / KTwoBytes - KExtraByte;
       
  3400                         }
       
  3401                     if ( ctrl->MaxLength() != maxLen && textBuf->Length() <= maxLen )
       
  3402                         {
       
  3403                         ctrl->SetMaxLength( maxLen );
       
  3404                         }
       
  3405                     CleanupStack::PopAndDestroy( textBuf );
  3407                     }
  3406                     }
  3408                 }
  3407                 }
  3409             }
  3408             }
  3410         }
  3409         }
  3411     }
  3410     }