plugins/contacts/symbian/contactsmodel/cntplsql/inc/cqwertykeymap.h
changeset 0 876b1a06bc25
child 5 603d3f8b6302
equal deleted inserted replaced
-1:000000000000 0:876b1a06bc25
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: Class to hold the character to key mappings for a virtual
       
    15 *   qwerty keyboard.
       
    16 */
       
    17 
       
    18 #ifndef __CQWERTYKEYMAP_H__
       
    19 #define __CQWERTYKEYMAP_H__
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "cpcskeymap.h"
       
    23 #include <QMap>
       
    24 
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 
       
    28 // CLASS DECLARATION
       
    29 NONSHARABLE_CLASS(CQwertyKeyMap) : public CPcsKeyMap
       
    30 	{
       
    31 	public: // Enums
       
    32 		enum TQwertyKeyboard
       
    33 			{
       
    34 			// How many keys have mappings in the virtual QWERTY keypad.
       
    35 			// Most languages list 32 keys, some have 36 keys.
       
    36 			// 4x11 keyboard could have 44 keys.
       
    37 			EAmountOfKeysInQwertyKeypad = 44
       
    38 			};
       
    39 
       
    40 		// These values are used to identify each key in the keyboard.
       
    41 		enum TKeyId
       
    42 			{
       
    43 			// first key at index 0 
       
    44 			EKeyQ = 0,
       
    45 			EKeyW,
       
    46 			EKeyE,
       
    47 			EKeyR,
       
    48 			EKeyT,
       
    49 			EKeyY,
       
    50 			EKeyU,
       
    51 			EKeyI,
       
    52 			EKeyO,
       
    53 			EKeyP,
       
    54 
       
    55 			EKeyA, // 10
       
    56 			EKeyS,
       
    57 			EKeyD,
       
    58 			EKeyF,
       
    59 			EKeyG,
       
    60 			EKeyH,
       
    61 			EKeyJ,
       
    62 			EKeyK,
       
    63 			EKeyL,
       
    64 
       
    65 			EKeyZ, // 19
       
    66 			EKeyX,
       
    67 			EKeyC,
       
    68 			EKeyV,
       
    69 			EKeyB,
       
    70 			EKeyN,
       
    71 			EKeyM,
       
    72 			EKeyColon,
       
    73 			EKeyDot,
       
    74 			EKeyDash,	// 28
       
    75 			EKeyAt,
       
    76 			EKeyQuote,
       
    77 			EKeyQuestionMark,
       
    78 
       
    79 			EKey32,
       
    80 			EKey33,
       
    81 			EKey34,
       
    82 			EKey35,
       
    83 			EKey36,
       
    84 			EKey37,
       
    85 			EKey38,
       
    86 			EKey39,
       
    87 			EKey40,
       
    88 			EKey41,
       
    89 			EKey42,
       
    90 			EKey43,
       
    91 
       
    92 			// Value is KBitsInKeyId amount of 1-bits (i.e. 111111 (binary))
       
    93 			KPadCharValue = 0x3f
       
    94 			};
       
    95 
       
    96     public: // Constructors and destructor
       
    97         /**
       
    98          * Two phase construction
       
    99          */
       
   100         static CQwertyKeyMap* NewL();
       
   101         
       
   102         /**
       
   103          * Destructor
       
   104          */
       
   105 		virtual ~CQwertyKeyMap();
       
   106 
       
   107 	public: // From CPcsKeyMap
       
   108 		virtual const QChar ArrayIndexToMappedChar(TInt aArrayIndex) const;
       
   109 #if !defined(USE_ORBIT_KEYMAP)
       
   110 		virtual const QChar UseHardcodedKeyMap(const QChar input) const;
       
   111 #endif
       
   112 
       
   113 	private: // From CPcsKeyMap
       
   114 		virtual TInt ComputeValue(QString aString,
       
   115 								  TBool aUpperLimit,
       
   116 								  QString& aValue) const;
       
   117 
       
   118 	public:
       
   119 #if defined(USE_ORBIT_KEYMAP)
       
   120 		bool IsValidChar(const QChar aChar) const;
       
   121 #endif
       
   122 		TInt MapKeyNameToValue(const QChar aKeyName) const;
       
   123 
       
   124 	private: // Constructors
       
   125         /**
       
   126          * Constructor
       
   127          */
       
   128 		CQwertyKeyMap();
       
   129 		
       
   130 		/**
       
   131 		 * Second phase constructor
       
   132 		 */
       
   133 		void ConstructL();
       
   134 
       
   135 	private: // New functions
       
   136 		void ConstructKeyNameMap();
       
   137 
       
   138     private: // Data
       
   139 		// Mapping between the virtual keys (TKeyId) of the keyboard, and the
       
   140 		// base character of that key (QChar).
       
   141 		//
       
   142 		// TODO: must place QMap's 1st arg the one that used more,
       
   143 		// since reverse lookup (Qmap::key()) is slow
       
   144 		QMap<TKeyId, QChar> iKeyNames;
       
   145 
       
   146 		// List of the valid base characters of the keyboard. Obtained from
       
   147 		// iKeyNames.
       
   148 		QList<QChar> iKeyValues;
       
   149 
       
   150 		// For unit testing
       
   151 		friend class UT_CQwertyKeyMap;
       
   152 	};
       
   153 
       
   154 #endif // __CQWERTYKEYMAP_H__
       
   155 
       
   156 // End of file