predictivesearch/PcsAlgorithm/Algorithm2/inc/CPcsKeyMap.h
branchRCL_3
changeset 58 d4f567ce2e7c
parent 21 b3431bff8c19
child 64 c1e8ba0c2b16
equal deleted inserted replaced
57:2666d9724c76 58:d4f567ce2e7c
    16 */
    16 */
    17 
    17 
    18 #ifndef __CPCS_KEY_MAP_ALGORITHM_2_H__
    18 #ifndef __CPCS_KEY_MAP_ALGORITHM_2_H__
    19 #define __CPCS_KEY_MAP_ALGORITHM_2_H__
    19 #define __CPCS_KEY_MAP_ALGORITHM_2_H__
    20 
    20 
    21 // The macro is used for a hack which fix a problem of PtiEngine with Sonja keyboard.
       
    22 // The problem is that J/# key can't returned character code ('J', 'j', '#') 
       
    23 #define HACK_FOR_E72_J_KEY
       
    24 
    21 
    25 // INCLUDES
    22 // INCLUDES
    26 #include <e32base.h>
    23 #include <e32base.h>
    27 #include <PtiEngine.h>
       
    28 #include <PtiKeyMappings.h>
       
    29 #include <AvkonInternalCRKeys.h>
       
    30 #include <e32property.h>
    24 #include <e32property.h>
       
    25 #include <PtiDefs.h>
       
    26 #include "CPcsDefs.h"
    31 
    27 
    32 class CPcsAlgorithm2;
    28 class CPcsAlgorithm2;
    33 class     CPtiEngine;
    29 class CPsQuery;
       
    30 class CPtiEngine;
       
    31 class CPtiKeyMapData;
    34 
    32 
    35 class TKeyMappingData
    33 class TKeyMappingData
    36     {
    34     {
    37 public:
    35 public:
    38     TPtiKey key; // key
    36     TPtiKey iKey; // key
    39     RArray<TInt> iKeyMappingArray; // All the characters mapped to the key
    37     RArray<TInt> iKeyMappingArray; // All the characters mapped to the key
    40     };
    38     };
    41 
    39 
    42 // CLASS DECLARATION
    40 // CLASS DECLARATION
    43 class CPcsKeyMap : public CBase
    41 class CPcsKeyMap : public CBase
    54      * Destructor
    52      * Destructor
    55      */
    53      */
    56     virtual ~CPcsKeyMap();
    54     virtual ~CPcsKeyMap();
    57 
    55 
    58     /**
    56     /**
    59      * Converts the alphanumeric string to numeric string
    57      * Convert functions to get the key string from query and/or chars string
    60      */
    58      */
    61     void GetNumericKeyString(const TDesC& alphaNumericStr, TDes& numericStr);
    59     void GetMixedKeyStringForQueryL(CPsQuery& aSrcQuery, TDes& aDestStr) const;
    62 
    60     void GetMixedKeyStringForDataL(CPsQuery& aSrcQuery, const TDesC& aSrcData, TDes& aDestStr) const;
    63     /**
    61 
    64      * Returns the numeric key id corresponding to a specific character		                          
    62     /**
    65      */
    63      * Returns the numeric key id corresponding to a specific character
    66     TInt KeyForCharacter(const TChar& aChar);
    64      */
       
    65     TPtiKey KeyForCharacter(TText aChar, TKeyboardModes aKbMode) const;
    67 
    66 
    68     /**
    67     /**
    69      * Returns ETrue if this language is supported
    68      * Returns ETrue if this language is supported
    70      */
    69      */
    71     TBool IsLanguageSupportedL(const TUint32 aLanguage);
    70     TBool IsLanguageSupportedL(const TUint32 aLanguage);
    72 
    71 
    73     void ReconstructKeymapL();
    72     void ReconstructKeymapL();
    74     
    73     
    75     /**
    74     /**
    76      * Returns the pool Id for a Character                               
    75      * Returns the pool Id for a key
    77      */
    76      */
    78     TInt PoolIdForCharacter(TChar aChar);
    77     TInt PoolIdForCharacter(TChar aChar, TKeyboardModes aKbMode );
    79     
    78     
    80     /**
    79     /**
    81      * Returns total number of pools                                
    80      * Returns total number of pools
    82      */
    81      */
    83     TInt PoolCount();
    82     TInt PoolCount();
    84 
    83 
       
    84     /**
       
    85      * Returns true if the characters "0" and " " are on the same key
       
    86      */
       
    87     TBool GetSpaceAndZeroOnSameKey( TKeyboardModes aMode );
       
    88 
    85 private:
    89 private:
    86 
    90 
    87     /**
    91     /**
    88      * Constructor
    92      * Constructor
    89      */
    93      */
    93      * Second phase constructor
    97      * Second phase constructor
    94      */
    98      */
    95     void ConstructL(CPcsAlgorithm2* aAlgorithm);
    99     void ConstructL(CPcsAlgorithm2* aAlgorithm);
    96 
   100 
    97     /**
   101     /**
       
   102      * Set flags to indicate if space and zero are on same key.
       
   103      * Keymappings must be constructed before calling this.
       
   104      */
       
   105     void SetSpaceAndZeroOnSameKey();
       
   106     
       
   107     /**
    98      * Helper function to construct keyboard specific mappings
   108      * Helper function to construct keyboard specific mappings
    99      */
   109      */
   100     void ContructForItutKeyboardL(TLanguage aLanguage);
   110     void ConstructForItutKeyboardL();
   101     void ContructForHalfQwertyKeyboardL(TLanguage aLanguage);
   111     void ConstructForQwertyKeyboardL(TPtiKeyboardType aKbType);
   102     void ContructFor4x10QwertyKeyboardL(TLanguage aLanguage);
       
   103 
   112 
   104     /**
   113     /**
   105      * Helper function to populate Itut key mappings
   114      * Helper function to populate Itut key mappings
   106      */
   115      */
   107     void AddKeyMapforItutL(TLanguage aLanguage);
   116     void AddKeyMapforItutL(TLanguage aLanguage);
   108 
   117 
   109     void AddDataForItutKeyboardL(CPtiKeyMappings* aPtiKeyMappings,
   118     void AddDataForItutKeyboardL(CPtiKeyMapData* aPtiKeyMapData,
   110             TPtiKey aKey, TKeyMappingData& aKeyDataList);
   119             TPtiKey aKey, TKeyMappingData& aKeyDataList);
   111     /**
   120     /**
   112      * Helper function to populate 4x10 Qwerty Keyboard  key mappings
   121      * Helper function to populate 4x10 Qwerty Keyboard  key mappings
   113      */
   122      */
   114     void AddKeyMapfor4x10QwertyKeyboardL(TLanguage aLanguage);
   123     void AddKeyMapForQwertyKeyboardL(TLanguage aLanguage, TPtiKeyboardType aKbType);
   115 
   124 
   116     void AddDataFor4x10QwertyKeyboardL(
   125     void AddDataForQwertyKeyboardL(
   117             CPtiQwertyKeyMappings* aPtiKeyMappings, TPtiKey aKey,
   126             CPtiKeyMapData* aPtiKeyMapData, 
       
   127             TPtiKeyboardType aKbType, 
       
   128             TPtiKey aKey,
   118             TKeyMappingData& aKeyDataList);
   129             TKeyMappingData& aKeyDataList);
   119     
   130     
   120 #ifdef HACK_FOR_E72_J_KEY
   131     /**
   121     void AddDataFor4x10QwertyKeyboardE72HackL(); // Hack for E72 (J/# key)
   132      * Create list of PTI keys for the given keyboard type
   122 #endif  // HACK_FOR_E72_J_KEY
   133      */
   123     
   134     void CreateKeyListFromKeyBindingTable( RArray<TPtiKey>& aKeyArray, TPtiKeyboardType aKbType );
   124     /**
       
   125      * Helper function to populate alfQwerty Keyboard key mappings
       
   126      */
       
   127     void AddKeyMapforHalfQwertyKeyboardL(TLanguage aLanguage);
       
   128 
       
   129     void AddDataForHalfQwertyKeyboardL(CPtiHalfQwertyKeyMappings* aPtiKeyMappings,
       
   130             TPtiKey aKey, TKeyMappingData& aKeyDataList);
       
   131 
   135 
   132     void ResetKeyMap();
   136     void ResetKeyMap();
       
   137     
   133     /**
   138     /**
   134      * Function to construct key mappings for a particula language
   139      * Function to construct key mappings for a particula language
   135      * 
   140      * 
   136      */
   141      */
   137     void ConstructKeymapL();
   142     void ConstructKeymapL();
   138     
   143     
   139     /**
   144     /**
   140      * Get the current keyboard type.
   145      * Select keyboard types according to available physical keyboard(s)
   141      * @return current keyboard type.
   146      */
   142      */
   147     void SetupKeyboardTypesL();
   143     TInt CurrentKeyBoardTypeL();
       
   144     
   148     
   145     /**
   149     /**
   146      * 
   150      * 
   147      * Construct keymap by type and language
   151      * Construct keymaps
   148      * @ aKeyboardType, the current keyboard type.
   152      */
   149      * @ aLanguage, the keymap construct language.
   153     void ConstructConcreteKeyMapL();
   150      */
       
   151     void ConstructConcreteKeyMapL( TInt aKeyboardType, TLanguage aLanguage );
       
   152     
   154     
   153     /**
   155     /**
   154      * 
   156      * 
   155      * Add keymap for keyboard by type and language
   157      * Add keymap for keyboard by type and language
   156      * @ aKeyboardType, the current keyboard type.
   158      * @ aKeyboardType, the current keyboard type.
   157      * @ aLanguage, the keymap construct language.
   159      * @ aLanguage, the keymap construct language.
   158      */
   160      */
   159     void AddKeyMapforConcreteKeyboardL( TInt aKeyboardType, TLanguage aLanguage );
   161     void AddKeyMapforConcreteKeyboardL( TLanguage aLanguage );
   160     
   162 
   161     /**
   163     /**
   162      * In case the given character is a Chinese characer, give the first
   164      * In case the given character is a Chinese characer, give the first
   163      * character of it's first spelling using the current spelling mode.
   165      * character of it's first spelling using the current spelling mode.
   164      * Otherwise, the character is returned unmodified.
   166      * Otherwise, the character is returned unmodified.
   165      */
   167      */
   166     TChar FirstCharFromSpellingL( TChar aChar ) const;
   168     TChar FirstCharFromSpellingL( TChar aChar ) const;
   167 
   169     
       
   170     TInt PoolIdForKey(TPtiKey aKey, TKeyboardModes aKbMode) const;
       
   171     
       
   172     /**
       
   173      * Gets predictive keyboard mapping data for given match mode.
       
   174      * @param   aMode      Matching mode for which keymappings are asked. 
       
   175      * @return  Mapping table for the given mode. NULL if asked for non-predictive mode.
       
   176      */
       
   177     const RPointerArray<TKeyMappingData>* KeyMappings( TKeyboardModes aMode ) const;
       
   178 
       
   179     /**
       
   180      * Resolve any ambiguity from the given keyboard mode.
       
   181      * Keyboard mode "predictive default keyboard" will be replaced by 
       
   182      * "ITU-T predictive" or "QWERTY predictive", depending on the configuration
       
   183      * of the device. Predictive keyboard modes, which can't be supported
       
   184      * in this device, are replaced with "non-predictive" mode.
       
   185      */
       
   186     TKeyboardModes ResolveKeyboardMode( TKeyboardModes aKbMode ) const;
       
   187     
       
   188     /**
       
   189      * Get the default charcter for the given key in given keyboard.
       
   190      * The default character is used to construct the compare string for
       
   191      * predictive mode.
       
   192      */
       
   193     TText DefaultCharForKey( TPtiKey aKey, TKeyboardModes aKbMode ) const;
       
   194     
   168 private:
   195 private:
       
   196     /**
       
   197      * PTI engine istance. Owned.
       
   198      */
   169     CPtiEngine* iPtiEngine;
   199     CPtiEngine* iPtiEngine;
   170 
   200 
       
   201     /**
       
   202      * Algorithm instacne pointer. NOT owned.
       
   203      */
   171     CPcsAlgorithm2* iAlgorithm;
   204     CPcsAlgorithm2* iAlgorithm;
       
   205     
   172     /**
   206     /**
   173      * Array to hold the list of languages not supported
   207      * Array to hold the list of languages not supported
   174      */
   208      */
   175     RArray<TLanguage> iLanguageNotSupported;
   209     RArray<TLanguage> iLanguageNotSupported;
   176 
   210 
   177     /**
   211     /**
   178      * Flag to indicate if Phone is Chinese variant 
   212      * Type of keyboard used in ITU-T search mode. Typically this is standard ITU-T
   179      */
   213      * 12-key keypad.
   180     RArray<TPtiKey> iKeysForPoolFormation;
   214      */
   181 
   215     TPtiKeyboardType iItutKeyboardType;
   182     /**
   216 
   183      * Contains all the keys and the characters mapped to each key
   217     /**
   184      * own
   218      * PTI keys of the ITU-T keyboard.
   185      */
   219      */
   186     RPointerArray<TKeyMappingData> iAllKeyMappingsPtrArr;
   220     RArray<TPtiKey> iItutKeys;
   187     
   221 
       
   222     /**
       
   223      * Contains all the ITU-T keys and the characters mapped to each key. Owned.
       
   224      */
       
   225     RPointerArray<TKeyMappingData> iItutKeyMappings;
       
   226 
       
   227     /**
       
   228      * True if "0" and " " are on the same key in the ITU-T mode
       
   229      */
       
   230     TBool iSpaceAndZeroOnSameKeyOnItut;
       
   231     
       
   232     /**
       
   233      * Type of keyboard used in QWERTY search mode. Typically this is either 3x11 or 4x10 QWERTY
       
   234      * or EPtiKeyboardNone if there's no any kind of QWERTY available. This may also be
       
   235      * half-QWERTY.
       
   236      */
       
   237     TPtiKeyboardType iQwertyKeyboardType;
       
   238 
       
   239     /**
       
   240      * PTI keys of the QWERTY keyboard.
       
   241      */
       
   242     RArray<TPtiKey> iQwertyKeys;
       
   243 
       
   244     /**
       
   245      * Contains all the QWERTY keys and the characters mapped to each key. Owned.
       
   246      */
       
   247     RPointerArray<TKeyMappingData> iQwertyKeyMappings;
       
   248     
       
   249     /**
       
   250      * True if "0" and " " are on the same key in the QWERTY mode
       
   251      */
       
   252     TBool iSpaceAndZeroOnSameKeyOnQwerty;
       
   253     
       
   254     /**
       
   255      * Flag to indicate if the default multi-matching mode is ITU-T or QWERTY mode.
       
   256      * ETrue, if ITU-T is defualt and EFalse if QWERTY is default.
       
   257      */
       
   258     TBool iItutIsDefault;
   188     };
   259     };
   189 
   260 
   190 #endif // __CPCS_KEY_MAP_ALGORITHM_2_H__
   261 #endif // __CPCS_KEY_MAP_ALGORITHM_2_H__
   191 
   262 
   192 // End of file
   263 // End of file