fep/aknfep/src/aknfepuiinputminiqwertypinyinphrasebase.cpp
branchRCL_3
changeset 3 f5a1e66df979
parent 0 eb1f2e154e89
child 7 6defe5d1bd39
equal deleted inserted replaced
0:eb1f2e154e89 3:f5a1e66df979
    45 #include "aknfepuiinputminiqwertypinyinphrasebase.h"
    45 #include "aknfepuiinputminiqwertypinyinphrasebase.h"
    46 
    46 
    47 // Constant definition
    47 // Constant definition
    48 const TInt KMaxPhraseCount = 50;
    48 const TInt KMaxPhraseCount = 50;
    49 const TInt KMaxPhraseCreationCount = 7;
    49 const TInt KMaxPhraseCreationCount = 7;
       
    50 const TInt KMaxSpellLength = 7;//max pinyin length for one chinese Zi
    50 const TInt KMaxKeystrokeCount = 31;
    51 const TInt KMaxKeystrokeCount = 31;
    51 const TInt KInvalidToneMark = -1;
    52 const TInt KInvalidToneMark = -1;
    52 const TUint16 KAutoDLT = 0x002E;
    53 const TUint16 KAutoDLT = 0x002E;
    53 const TUint16 KManualDLT = 0x0027;
    54 const TUint16 KManualDLT = 0x0027;
    54 const TUint16 KPYa = 0x0061;
    55 const TUint16 KPYa = 0x0061;
  1569     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
  1570     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
  1570     MAknFepUICtrlEditPane* editpane = UIContainer()->EditPaneWindow();
  1571     MAknFepUICtrlEditPane* editpane = UIContainer()->EditPaneWindow();
  1571     CDesCArrayFlat* showkeyStoke = editpane->ShowKeystrokeArray();
  1572     CDesCArrayFlat* showkeyStoke = editpane->ShowKeystrokeArray();
  1572     CDesCArrayFlat* keyStoke = editpane->KeystrokeArray();
  1573     CDesCArrayFlat* keyStoke = editpane->KeystrokeArray();
  1573     CDesCArrayFlat* phraseArray = editpane->PhraseArray();
  1574     CDesCArrayFlat* phraseArray = editpane->PhraseArray();
  1574     CDesCArrayFlat* phraseShowKeyStroke =
  1575     CDesCArrayFlat* phraseShowKeyStroke = editpane->PhraseShowKeyStrokeArray();
  1575             editpane->PhraseShowKeyStrokeArray();
       
  1576     TBuf<KMaxKeystrokeCount> buf;
  1576     TBuf<KMaxKeystrokeCount> buf;
  1577     TBuf<1> autoDLT;
  1577     TBuf<1> autoDLT;
  1578     autoDLT.Append(KAutoDLT);
  1578     autoDLT.Append(KAutoDLT);
  1579 
  1579 
  1580     if (phraseArray->Count() == 0)
  1580     if (phraseArray->Count() == 0)
  1599             buf.Append(ptr);
  1599             buf.Append(ptr);
  1600             keyStoke->Delete( 0);
  1600             keyStoke->Delete( 0);
  1601             }
  1601             }
  1602         delCount++;
  1602         delCount++;
  1603         }
  1603         }
  1604 
  1604     
       
  1605 	for (TInt j = 0; j < delCount; j++)
       
  1606 		{
       
  1607 		showkeyStoke->Delete( 0);
       
  1608 		}
       
  1609 	phraseShowKeyStroke->AppendL(buf);
       
  1610 	
  1605     TInt phraseCount = phraseArray->Count();
  1611     TInt phraseCount = phraseArray->Count();
  1606     if (phraseCount > KMaxPhraseCreationCount)
  1612     if (phraseCount > KMaxPhraseCreationCount)
  1607         {
  1613         {
  1608         phraseCount = KMaxPhraseCreationCount;
  1614         phraseCount = KMaxPhraseCreationCount;
  1609         }
  1615         }
  1610 
  1616 
  1611     if (keyStoke->Count() == 0 || phraseCount == KMaxPhraseCreationCount)
  1617     if (keyStoke->Count() == 0 || phraseCount == KMaxPhraseCreationCount)
  1612         {
  1618         {
  1613         TBuf<KMaxPhraseCreationCount> phraseCreated;
  1619 		//here,we pass pinyin-spelling to db together with phrase.
  1614         for (TInt ii = 0; ii < phraseCount; ++ii)
  1620 		TBuf<KMaxPhraseCreationCount> phraseCreated;
  1615             {
  1621 		phraseCreated.FillZ();
  1616             phraseCreated.Append(phraseArray->MdcaPoint(ii) );
  1622 		TBuf<(1+KMaxSpellLength)*KMaxPhraseCreationCount> phraseCreatedWithPinYin;//(Zi+pinyin)* max_Zi
  1617             }
  1623 		phraseCreatedWithPinYin.FillZ();
  1618         fepMan->NewTextL(phraseCreated);
  1624 		for (TInt ii = 0; ii < phraseCount; ++ii)
  1619         fepMan->CommitInlineEditL();
  1625 			{
  1620         iOwner->PtiEngine()->SetPredictiveChineseChar(phraseCreated);
  1626 			TPtrC ptrZi = phraseArray->MdcaPoint(ii);
  1621         AddPhraseToDB(phraseCreated);
  1627 			phraseCreatedWithPinYin.Append(ptrZi);
  1622         return EFalse;
  1628 			phraseCreated.Append(ptrZi);
  1623         }
  1629 			
  1624 
  1630 			TPtrC ptrPinYin = phraseShowKeyStroke->MdcaPoint(ii);//it mabe include KManualDLT,but no matter
  1625     for (TInt j = 0; j < delCount; j++)
  1631 			phraseCreatedWithPinYin.Append(ptrPinYin);
  1626         {
  1632 			
  1627         showkeyStoke->Delete( 0);
  1633 			TInt zeroTail = (1+KMaxSpellLength)-(ptrZi.Length()+ptrPinYin.Length());
  1628         }
  1634 			phraseCreatedWithPinYin.AppendFill(0,zeroTail);
  1629     phraseShowKeyStroke->AppendL(buf);
  1635 			
       
  1636 			}
       
  1637 		fepMan->NewTextL(phraseCreated);
       
  1638 		fepMan->CommitInlineEditL();
       
  1639 		iOwner->PtiEngine()->SetPredictiveChineseChar(phraseCreated);
       
  1640 		AddPhraseToDB(phraseCreatedWithPinYin);
       
  1641 		return EFalse;
       
  1642         }
       
  1643 
       
  1644     
  1630 
  1645 
  1631     editpane->SetCursorIndexOfKeystroke( 0);
  1646     editpane->SetCursorIndexOfKeystroke( 0);
  1632     editpane->DisableCursor();
  1647     editpane->DisableCursor();
  1633     editpane->SetPhraseCreationFlag(ETrue);
  1648     editpane->SetPhraseCreationFlag(ETrue);
  1634     return ETrue;
  1649     return ETrue;