92 #include <barsread.h> |
92 #include <barsread.h> |
93 #include <aknnotewrappers.h> |
93 #include <aknnotewrappers.h> |
94 #include <hlplch.h> |
94 #include <hlplch.h> |
95 #include <aknnavide.h> |
95 #include <aknnavide.h> |
96 #include <akninputblock.h> |
96 #include <akninputblock.h> |
|
97 #include <charconv.h> |
97 |
98 |
98 /// Unnamed namespace for local definitions |
99 /// Unnamed namespace for local definitions |
99 namespace { |
100 namespace { |
100 |
101 |
101 const TInt KEditorNameFormatFlags = MPbk2ContactNameFormatter::EUseSeparator; |
102 const TInt KEditorNameFormatFlags = MPbk2ContactNameFormatter::EUseSeparator; |
|
103 const TInt KTwoBytes = 2; |
|
104 const TInt KExtraByte = 1; |
102 |
105 |
103 #ifdef _DEBUG |
106 #ifdef _DEBUG |
104 enum TPanicCode |
107 enum TPanicCode |
105 { |
108 { |
106 EHandleControlStateChangeL_NullField = 1, |
109 EHandleControlStateChangeL_NullField = 1, |
483 const TPointerEvent& aPointerEvent ) |
488 const TPointerEvent& aPointerEvent ) |
484 { |
489 { |
485 //Here we can prevent recursive execution of ExecuteBaseCommandL if needed |
490 //Here we can prevent recursive execution of ExecuteBaseCommandL if needed |
486 //as touch events are handled in it too. So it may case multiple callbacks to here if |
491 //as touch events are handled in it too. So it may case multiple callbacks to here if |
487 //user repeats the same pointer event very quickly using options menu. |
492 //user repeats the same pointer event very quickly using options menu. |
488 // if(!iCommandPending) //seems that this check is not needed |
493 // This check is needed, otherwise, when touch quickly on Address field and |
|
494 // quickly on Image field in the Editor Dialog, the address editor will be |
|
495 // opened, but touch input can not open in any of its editors. |
|
496 if(!iCommandPending) |
489 { |
497 { |
490 CAknForm::HandlePointerEventL( aPointerEvent ); |
498 CAknForm::HandlePointerEventL( aPointerEvent ); |
491 } |
499 } |
492 } |
500 } |
493 |
501 |
1777 // -------------------------------------------------------------------------- |
1787 // -------------------------------------------------------------------------- |
1778 // |
1788 // |
1779 void CPbk2ContactEditorDlgImpl::DeleteControl(TInt aControlId) |
1789 void CPbk2ContactEditorDlgImpl::DeleteControl(TInt aControlId) |
1780 { |
1790 { |
1781 DeleteLine( aControlId ); |
1791 DeleteLine( aControlId ); |
|
1792 TRAP_IGNORE( UpdateTitleL() ); |
1782 } |
1793 } |
1783 |
1794 |
1784 // -------------------------------------------------------------------------- |
1795 // -------------------------------------------------------------------------- |
1785 // CPbk2ContactEditorDlgImpl::TryChangeFocusL |
1796 // CPbk2ContactEditorDlgImpl::TryChangeFocusL |
1786 // -------------------------------------------------------------------------- |
1797 // -------------------------------------------------------------------------- |
3251 iWaitFinish = new (ELeave) CActiveSchedulerWait(); |
3262 iWaitFinish = new (ELeave) CActiveSchedulerWait(); |
3252 iWaitFinish->Start(); |
3263 iWaitFinish->Start(); |
3253 } |
3264 } |
3254 } |
3265 } |
3255 |
3266 |
|
3267 // -------------------------------------------------------------------------- |
|
3268 // CPbk2ContactEditorDlgImpl::IsUnicodeL |
|
3269 // -------------------------------------------------------------------------- |
|
3270 // |
|
3271 TBool CPbk2ContactEditorDlgImpl::IsUnicodeL( const TDesC& aText ) |
|
3272 { |
|
3273 if ( !iConverter ) |
|
3274 { |
|
3275 iConverter = CCnvCharacterSetConverter::NewLC(); |
|
3276 CleanupStack::Pop(); |
|
3277 RFs& fs = Phonebook2::Pbk2AppUi()-> |
|
3278 ApplicationServices().ContactManager().FsSession(); |
|
3279 iConverter->PrepareToConvertToOrFromL( KCharacterSetIdentifierSms7Bit, fs ); |
|
3280 } |
|
3281 |
|
3282 TBool isUnicode( EFalse ); |
|
3283 TInt unconvertedCount(0); |
|
3284 HBufC8* convertedText = HBufC8::NewLC( aText.Length()*KTwoBytes ); |
|
3285 TPtr8 convertedTextPtr = convertedText->Des(); |
|
3286 |
|
3287 iConverter->ConvertFromUnicode( convertedTextPtr, aText, unconvertedCount ); |
|
3288 |
|
3289 // If any characters were not converted or if the converted text is longer |
|
3290 // than the original the text must be unicode |
|
3291 if( unconvertedCount > 0 || |
|
3292 aText.Length() < convertedText->Length() ) |
|
3293 { |
|
3294 isUnicode = ETrue; |
|
3295 } |
|
3296 |
|
3297 CleanupStack::PopAndDestroy( convertedText ); |
|
3298 return isUnicode; |
|
3299 } |
|
3300 |
|
3301 // -------------------------------------------------------------------------- |
|
3302 // CPbk2ContactEditorDlgImpl::IsCheckPointEvent |
|
3303 // -------------------------------------------------------------------------- |
|
3304 // |
|
3305 TBool CPbk2ContactEditorDlgImpl::IsCheckPointEvent( |
|
3306 const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
3307 { |
|
3308 TBool check = EFalse; |
|
3309 if ( EEventKeyDown == aType ) |
|
3310 { |
|
3311 // Don't handle 'EStdKeyBackspace', 'EStdKeyHash' and those between |
|
3312 // 'EStdKeyPrintScreen' and 'EStdKeyScrollLock'. |
|
3313 // If the definition of standard scancode is changed, the scope here needs to |
|
3314 // be examined again. |
|
3315 if ( ( EStdKeyPrintScreen > aKeyEvent.iScanCode || EStdKeyScrollLock < aKeyEvent.iScanCode ) && |
|
3316 EStdKeyBackspace != aKeyEvent.iScanCode && |
|
3317 EStdKeyHash != aKeyEvent.iScanCode ) |
|
3318 { |
|
3319 check = ETrue; |
|
3320 } |
|
3321 } |
|
3322 else if ( EEventKey == aType && EStdKeyNull == aKeyEvent.iScanCode ) |
|
3323 { |
|
3324 check = ETrue; |
|
3325 } |
|
3326 |
|
3327 return check; |
|
3328 } |
|
3329 |
|
3330 // -------------------------------------------------------------------------- |
|
3331 // CPbk2ContactEditorDlgImpl::CheckCurrentFieldTextL |
|
3332 // -------------------------------------------------------------------------- |
|
3333 // |
|
3334 void CPbk2ContactEditorDlgImpl::CheckCurrentFieldTextL( |
|
3335 CPbk2ContactEditorArrayItem* aCurrentField, |
|
3336 const TKeyEvent& aKeyEvent, |
|
3337 TEventCode aType ) |
|
3338 { |
|
3339 MPbk2ContactEditorField* editorField = aCurrentField->ContactEditorField(); |
|
3340 MVPbkStoreContactField& contactField = editorField->ContactField(); |
|
3341 TVPbkFieldStorageType dataType = contactField.FieldData().DataType(); |
|
3342 |
|
3343 if ( EVPbkFieldStorageTypeText == dataType ) |
|
3344 { |
|
3345 const MVPbkContactFieldTextData& textData = |
|
3346 MVPbkContactFieldTextData::Cast(contactField.FieldData()); |
|
3347 TInt maxSize = textData.MaxLength(); |
|
3348 |
|
3349 if ( KVPbkUnlimitedFieldLength != maxSize && |
|
3350 IsCheckPointEvent( aKeyEvent, aType ) ) |
|
3351 { |
|
3352 CEikEdwin* ctrl = editorField->Control(); |
|
3353 HBufC* textBuf = ctrl->GetTextInHBufL(); |
|
3354 |
|
3355 if ( textBuf ) |
|
3356 { |
|
3357 TInt maxLen = maxSize; |
|
3358 if ( IsUnicodeL( *textBuf ) ) |
|
3359 { |
|
3360 maxLen = maxSize / KTwoBytes - KExtraByte; |
|
3361 } |
|
3362 if ( ctrl->MaxLength() != maxLen && textBuf->Length() <= maxLen ) |
|
3363 { |
|
3364 ctrl->SetMaxLength( maxLen ); |
|
3365 } |
|
3366 } |
|
3367 } |
|
3368 } |
|
3369 } |
|
3370 |
3256 // End of File |
3371 // End of File |