diff -r 81f8547efd4f -r e8e3147d53eb predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsKeyMap.h --- a/predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsKeyMap.h Fri Mar 12 15:41:25 2010 +0200 +++ b/predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsKeyMap.h Mon Mar 15 12:39:26 2010 +0200 @@ -20,12 +20,15 @@ // INCLUDES #include -#include -#include +#include #include #include +#include class CPsQuery; +class CPtiEngine; +class CPtiCoreLanguage; + class TKeyMappingData { @@ -70,34 +73,29 @@ */ virtual ~CPcsKeyMap(); - /** - * Convert functions to get the key string from query and/or chars string - */ - void GetMixedKeyStringForQueryL(CPsQuery& aSrcQuery, TDes& aDestStr); - void GetMixedKeyStringForDataL(CPsQuery& aSrcQuery, const TDesC& aSrcData, TDes& aDestStr); - - /** - * Returns true if the character is mapped to the key - */ - TBool CharacterForKeyMappingExists(TKeyMappingData& aKeyMap, const TUint aIntChar); + static TBool IsModePredictive( TKeyboardModes aKbMode ); -#ifdef _DEBUG - /** - * Check potential error conditions for KeyForCharacterMultiMatch - */ - void CheckPotentialErrorConditions(RArray& aPoolIndexArr, const TChar& aChar); -#endif // _DEBUG + /** + * Convert functions to get the key string from query and/or chars string + */ + void GetMixedKeyStringForQueryL(CPsQuery& aSrcQuery, TDes& aDestStr) const; + void GetMixedKeyStringForDataL(CPsQuery& aSrcQuery, const TDesC& aSrcData, TDes& aDestStr) const; + + /** + * Returns true if the character is mapped to the key + */ + TBool CharacterForKeyMappingExists(TKeyMappingData& aKeyMap, TUint aIntChar) const; /** * Returns the numeric key id corresponding to a specific character * Considers possible multiple matches for some phone variants */ - TPtiKey KeyForCharacterMultiMatch(const TChar& aChar); + TPtiKey KeyForCharacterMultiMatch( const TChar& aChar, TKeyboardModes aKbMode ) const; /** * Returns true if the characters "0" and " " are on the same key */ - TBool GetSpaceAndZeroOnSameKey(); + TBool GetSpaceAndZeroOnSameKey( TKeyboardModes aKbMode ); /** * Returns true if this language is supported @@ -105,14 +103,9 @@ TBool IsLanguageSupported(TInt aLang); /** - * Returns the pool Id for a key - */ - TInt PoolIdForKey(const TPtiKey aKey); - - /** * Returns the pool Id for a character */ - TInt PoolIdForCharacter(const TChar& aChar); + TInt PoolIdForCharacter(const TChar& aChar, TKeyboardModes aKbMode); /** * Returns total number of pools @@ -132,47 +125,94 @@ void ConstructL(); /** - * Helper functions to get Key Mappings and Key Mappings Data depending - * on keyboard type + * Select keyboard types according to available physical keyboard(s) */ - MPtiKeyMappings* GetKeyboardKeyMapping(CPtiCoreLanguage& aCurrLanguage); - CPtiKeyMapData* GetKeyMapData(CPtiCoreLanguage& aCurrLanguage); + void SetupKeyboardTypesL(); /** - * Helper functions to construct Key List for different keyboards + * Returns the pool Id for a key */ - void AppendEntryWithFakeKeyToKeyList(); - void CreateKeyListFromITUTHardcodedKeys(); - void CreateKeyListFromKeyBindingTable( CPtiEngine* aPtiEngine ); - void CreateKeyListL( CPtiEngine* aPtiEngine ); + TInt PoolIdForKey(const TPtiKey aKey, TKeyboardModes aKbMode); /** * Helper function to construct Key Mappings */ - void CreateKeyMappingL(); + void CreateKeyMappingL( TKeyboardModes aKbMode ); + + /** + * Create list of PTI keys for the given keyboard type + */ + void CreateKeyListFromKeyBindingTable( RArray& aKeyArray, TPtiKeyboardType aKbType, CPtiEngine* aPtiEngine ); + + /** + * Add a non-existing key ID in the end of given array + */ + void AppendEntryWithFakeKeyToKeyList( RArray& aKeyArray ); /** * Helper functions to populate Keyboard Key Mappings (Characters for - * all Keys) for the Active Language + * all Keys) for the given Language */ - void AddKeyMappingForActiveLanguageL(CPtiEngine* aPtiEngine, TLanguage aLanguage); - void GetCharactersForKey(MPtiKeyMappings& aPtiKeyMappings, + void AddKeyMappingForLanguageL( CPtiEngine* aPtiEngine, + TLanguage aLanguage, + TPtiKeyboardType aKbType, + const RArray& aPtiKeys, + RPointerArray& aResultMapping ); + void GetCharactersForKey( CPtiCoreLanguage& aPtiLanguage, + TPtiKeyboardType aKbType, + TPtiKey aKey, + TPtiTextCase aTextCase, + TDes& aResult ); + void AddCharactersToKey( CPtiCoreLanguage& aPtiLanguage, + TPtiKeyboardType aKbType, TPtiKey aKey, TPtiTextCase aTextCase, - TDes& aResult); - void AddCharactersToKey(MPtiKeyMappings& aPtiKeyMappings, - TPtiKey aKey, - TPtiTextCase aTextCase, - TKeyMappingData& aKeyDataList, - RArray& aKeyMapLang, - TBool& aIsSingleCharForKey, - TUint& aSingleChar); + TKeyMappingData& aKeyDataList, + RArray& aKeyMapLang, + TBool& aIsSingleCharForKey, + TUint& aSingleChar ); /** * Sets attribute to true if the characters "0" and " " are on the same key */ void SetSpaceAndZeroOnSameKey(); + /** + * Gets predictive keyboard mapping data for given match mode. + * @param aKbMode Matching mode for which data is asked. + * @param aPtiKeys On return, will point to the array of PtiKeys for the given mode. + * @param aKeyMappings On return, will point to key mapping array for the given mode. + * @param aKbType On return, will hold the keyboard type for the given mode. + */ + void GetPredictiveKeyboardData( TKeyboardModes aKbMode, + RArray*& aPtiKeys, + RPointerArray*& aKeyMappings, + TPtiKeyboardType& aKbType ); + /** + * Constant overload of the GetPredictiveKeyboardData function. + */ + void GetPredictiveKeyboardData( TKeyboardModes aKbMode, + const RArray*& aPtiKeys, + const RPointerArray*& aKeyMappings, + TPtiKeyboardType& aKbType ) const; + + /** + * Resolve keyboard mode to "ITU-T predictive" or "QWERTY predictive". + */ + TKeyboardModes ResolveKeyboardMode( TKeyboardModes aKbMode, + TKeyboardModes aKbModeToResolve ) const; + + +#ifdef _DEBUG + /** + * Check potential error conditions for KeyForCharacterMultiMatch + */ + void CheckPotentialErrorConditions(const RArray& aPoolIndexArr, + const TChar& aChar, + const RArray& aPtiKeys, + const RPointerArray& aKeyMappings) const; +#endif // _DEBUG + private: /** @@ -186,24 +226,54 @@ TLanguage iUILanguage; /** - * Flag to indicate if Phone is Chinese variant + * Type of keyboard used in ITU-T search mode. Typically this is + * standard ITU-T 12-key keypad. + */ + TPtiKeyboardType iItutKeyboardType; + + /** + * Type of keyboard used in QWERTY search mode. Typically this is either + * 3x11 or 4x10 QWERTY or EPtiKeyboardNone if there's no any kind of + * QWERTY available. This may also be half-QWERTY. */ - RArray iKeysArr; + TPtiKeyboardType iQwertyKeyboardType; + + /** + * Type of keyboard used in Default Preditive search mode. This will + * point to ITU-T or QWERTY keypad. + */ + TKeyboardModes iPredictiveDefaultKeyboardMode; + + /** + * Pti keys of ITU-T mode + */ + RArray iItutKeys; /** - * Contains all the keys and the characters mapped to each key own + * Pti keys of QWERTY mode */ - RPointerArray iKeyMapPtrArr; + RArray iQwertyKeys; + + /** + * Contains all the keys and the characters mapped to each key in ITU-T mode. Owned. + */ + RPointerArray iItutKeyMaps; /** - * Type of keyboard for example, half-qwerty, 4x10 qwerty etc + * Contains all the keys and the characters mapped to each key in QWERTY mode. Owned. */ - TPtiKeyboardType iKeyboardType; + RPointerArray iQwertyKeyMaps; + + /** + * True if "0" and " " are on the same key in the ITU-T mode + */ + TBool iSpaceAndZeroOnSameKeyOnItut; /** - * True if "0" and " " are on the same key + * True if "0" and " " are on the same key in the QWERTY mode */ - TBool iSpaceAndZeroOnSameKey; + TBool iSpaceAndZeroOnSameKeyOnQwerty; + }; #endif // __CPCS_KEY_MAP_H__