fep/aknfep/src/AknFepUiInputStateCandidateChinesePhrase.cpp
branchRCL_3
changeset 3 f5a1e66df979
parent 0 eb1f2e154e89
equal deleted inserted replaced
0:eb1f2e154e89 3:f5a1e66df979
    38 #include "aknfepzhuyinkeyhandlerinterface.h"
    38 #include "aknfepzhuyinkeyhandlerinterface.h"
    39 #include <PtiUserDicEntry.h>
    39 #include <PtiUserDicEntry.h>
    40 
    40 
    41 const TInt KMaxBufLen = 100;
    41 const TInt KMaxBufLen = 100;
    42 const TInt KInputPhraseMaxLength = 7;
    42 const TInt KInputPhraseMaxLength = 7;
       
    43 const TInt KMaxPinYinSpellLength = 7;//max pinyin length for one chinese Zi
    43 
    44 
    44 _LIT( KMaxPhraseNote,"\x8BCD\x7EC4\x6700\x957F\x4E3A\x4E03\x5B57" );
    45 _LIT( KMaxPhraseNote,"\x8BCD\x7EC4\x6700\x957F\x4E3A\x4E03\x5B57" );
    45 ///////////////////
    46 ///////////////////
    46 // Candidate state
    47 // Candidate state
    47 ///////////////////
    48 ///////////////////
    79     
    80     
    80     CDesCArrayFlat* zhuyinSymbols = uiContainer->PinyinPopupWindow()->ZhuyinSymbols();
    81     CDesCArrayFlat* zhuyinSymbols = uiContainer->PinyinPopupWindow()->ZhuyinSymbols();
    81     CDesCArrayFlat* chineseDisped = uiContainer->PinyinPopupWindow()->ChineseCharsDisped();
    82     CDesCArrayFlat* chineseDisped = uiContainer->PinyinPopupWindow()->ChineseCharsDisped();
    82     CDesCArrayFlat* zhuyinSymbolsForChinese = uiContainer->PinyinPopupWindow()->ZhuyinSymbolsForChineseCharsDisped();
    83     CDesCArrayFlat* zhuyinSymbolsForChinese = uiContainer->PinyinPopupWindow()->ZhuyinSymbolsForChineseCharsDisped();
    83     CDesCArrayFlat* candidateList = uiContainer->CandidatePane()->CandidateArray();
    84     CDesCArrayFlat* candidateList = uiContainer->CandidatePane()->CandidateArray();
       
    85     
    84     MZhuyinKeyHandler* zhuyinKeyHandler = iOwner->ZhuyinKeyHandler();
    86     MZhuyinKeyHandler* zhuyinKeyHandler = iOwner->ZhuyinKeyHandler();
    85     
    87     
    86     TInt index = MapKeyToIndex(aKey);
    88     TInt index = MapKeyToIndex(aKey);
    87     
    89     
    88     if(aKey == EKeyBackspace)
    90     if(aKey == EKeyBackspace)
    99         }
   101         }
   100     
   102     
   101     if ( aLength == EShortKeyPress && ( candidatePane->SelectIndex(index,EFalse) 
   103     if ( aLength == EShortKeyPress && ( candidatePane->SelectIndex(index,EFalse) 
   102         || aKey == EKeyOK || aKey ==  EKeyCBA1 ))
   104         || aKey == EKeyOK || aKey ==  EKeyCBA1 ))
   103         {
   105         {
   104         TPtrC text = candidatePane->CurrentPhraseCandidate();
   106         TPtrC text = candidatePane->CurrentPhraseCandidate();//current selected in candidates
   105         if ( text.Length() == 0 )
   107         if ( text.Length() == 0 )
   106             {
   108             {
   107             return ETrue;
   109             return ETrue;
   108             }
   110             }
   109         TBuf<KMaxBufLen> pinyinshown = UIContainer()->PinyinPopupWindow()->GetEEPContent();
   111         TBuf<KMaxBufLen> pinyinshown = UIContainer()->PinyinPopupWindow()->GetEEPContent();//current selected spelling
   110         TInt count = TZhuyinSymbolsMethods::GetChineseCount(pinyinshown);
   112         TInt count = TZhuyinSymbolsMethods::GetChineseCount(pinyinshown);//zhuyin group num
   111         if ( count > text.Length() )
   113         if ( count > text.Length() )
   112             {
   114             {
   113             fepMan->PhraseCreation(ETrue);
   115             fepMan->PhraseCreation(ETrue);
   114             }
   116             }
   115         if ( fepMan->IsPhraseCreation( ) )
   117         if ( fepMan->IsPhraseCreation( ) )
   124                 {
   126                 {
   125                 TBuf<KMaxBufLen> commitbuf;
   127                 TBuf<KMaxBufLen> commitbuf;
   126                 TZhuyinSymbolsMethods::Convert2Des(chineseDisped, commitbuf);
   128                 TZhuyinSymbolsMethods::Convert2Des(chineseDisped, commitbuf);
   127                 fepMan->NewTextL(commitbuf);
   129                 fepMan->NewTextL(commitbuf);
   128                 fepMan->CommitInlineEditL();
   130                 fepMan->CommitInlineEditL();
   129                 AddPhraseToDB(commitbuf);
   131 
       
   132 				//we pass zhuyin-spelling to db together with phrase.
       
   133                 //chineseDisped is created phrase
       
   134                 //zhuyinSymbolsForChinese is spelling
       
   135 				TBuf<(1+KMaxPinYinSpellLength)*KInputPhraseMaxLength> phraseCreatedWithZhuYin;//(Zi+zhuyin)* max_Zi
       
   136 				phraseCreatedWithZhuYin.FillZ();
       
   137 				for (TInt i = 0; i < chineseDisped->Count(); i++)
       
   138 					{
       
   139 					TPtrC ptrZi = chineseDisped->MdcaPoint(i);
       
   140 					phraseCreatedWithZhuYin.Append(ptrZi);
       
   141 					
       
   142 					TPtrC ptrZhuYin = zhuyinSymbolsForChinese->MdcaPoint(i);
       
   143 					phraseCreatedWithZhuYin.Append(ptrZhuYin);
       
   144 					
       
   145 					TInt zeroTail = (1+KMaxPinYinSpellLength)-(ptrZi.Length()+ptrZhuYin.Length());
       
   146 					phraseCreatedWithZhuYin.AppendFill(0,zeroTail);
       
   147 					
       
   148 					}
       
   149 				
       
   150                 AddPhraseToDB(phraseCreatedWithZhuYin);
   130                 if ( chineseDisped->Count() < KInputPhraseMaxLength ||
   151                 if ( chineseDisped->Count() < KInputPhraseMaxLength ||
   131                     zhuyinSymbols->Count() == 0 )
   152                     zhuyinSymbols->Count() == 0 )
   132                     {
   153                     {
   133                     iOwner->FepMan()->TryCloseUiL();
   154                     iOwner->FepMan()->TryCloseUiL();
   134                     }
   155                     }
   146                 editPane->SetCursorIndexOfKeystroke( 0 );
   167                 editPane->SetCursorIndexOfKeystroke( 0 );
   147                 if ( changeState )
   168                 if ( changeState )
   148                     {
   169                     {
   149                     for ( TInt i = 0; i < candidateList->Count(); i++ )
   170                     for ( TInt i = 0; i < candidateList->Count(); i++ )
   150                         {
   171                         {
   151                         if ( TZhuyinSymbolsMethods::IsZhuyinSymbol( 
   172                         if ( TZhuyinSymbolsMethods::IsZhuyinSymbol( //0x3105~0x3129 is zhuyin symbol,not include tone
   152                             candidateList->MdcaPoint( i ) ) )
   173                             candidateList->MdcaPoint( i ) ) )
   153                             {
   174                             {
   154                             candidateList->Delete( i, 1 );
   175                             candidateList->Delete( i, 1 );
   155                             break;
   176                             break;
   156                             }
   177                             }