branch | GCC_SURGE |
changeset 15 | f378acbc9cfb |
parent 6 | c3690ec91ef8 |
child 21 | 4633027730f5 |
child 34 | ed14f46c0e55 |
9:730c025d4b77 | 15:f378acbc9cfb |
---|---|
25 |
25 |
26 #include "hbinputkeymap.h" |
26 #include "hbinputkeymap.h" |
27 |
27 |
28 #include <QChar> |
28 #include <QChar> |
29 #include <QString> |
29 #include <QString> |
30 #include <QStringList> |
30 #include <QStringList> |
31 |
31 |
32 const int DeadKeyTable[14] = {0x060, 0x0B4, 0x05E, 0x0A8, 0x022, 0x2C7, 0x2D8, 0x0B0, 0x2DB, 0x2DD, 0x07E, 0x0B8, 0x201A, 0x0B7}; |
32 const int DeadKeyTable[14] = {0x060, 0x0B4, 0x05E, 0x0A8, 0x022, 0x2C7, 0x2D8, 0x0B0, 0x2DB, 0x2DD, 0x07E, 0x0B8, 0x201A, 0x0B7}; |
33 |
33 |
34 const int DeadKeyCombineTable[59][3] = { |
34 const int DeadKeyCombineTable[59][3] = { |
35 {0x060, 0x061, 0x0e0}, |
35 {0x060, 0x061, 0x0e0}, |
36 {0x060, 0x065, 0x0e8}, |
36 {0x060, 0x065, 0x0e8}, |
37 {0x060, 0x069, 0x0ec}, |
37 {0x060, 0x069, 0x0ec}, |
38 {0x060, 0x06F, 0x0f2}, |
38 {0x060, 0x06F, 0x0f2}, |
39 {0x060, 0x075, 0x0f9}, |
39 {0x060, 0x075, 0x0f9}, |
40 |
40 |
41 {0x0b4, 0x061, 0x0e1}, |
41 {0x0b4, 0x061, 0x0e1}, |
42 {0x0b4, 0x065, 0x0e9}, |
42 {0x0b4, 0x065, 0x0e9}, |
43 {0x0b4, 0x069, 0x0ed}, |
43 {0x0b4, 0x069, 0x0ed}, |
44 {0x0b4, 0x06F, 0x0f3}, |
44 {0x0b4, 0x06F, 0x0f3}, |
45 {0x0b4, 0x075, 0x0fa}, |
45 {0x0b4, 0x075, 0x0fa}, |
55 {0x05e, 0x061, 0x0e2}, |
55 {0x05e, 0x061, 0x0e2}, |
56 {0x05e, 0x065, 0x0ea}, |
56 {0x05e, 0x065, 0x0ea}, |
57 {0x05e, 0x069, 0x0ee}, |
57 {0x05e, 0x069, 0x0ee}, |
58 {0x05e, 0x06F, 0x0f4}, |
58 {0x05e, 0x06F, 0x0f4}, |
59 {0x05e, 0x075, 0x0fb}, |
59 {0x05e, 0x075, 0x0fb}, |
60 |
60 |
61 {0x0a8, 0x061, 0x0e4}, |
61 {0x0a8, 0x061, 0x0e4}, |
62 {0x0a8, 0x065, 0x0eb}, |
62 {0x0a8, 0x065, 0x0eb}, |
63 {0x0a8, 0x069, 0x0ef}, |
63 {0x0a8, 0x069, 0x0ef}, |
64 {0x0a8, 0x06F, 0x0f6}, |
64 {0x0a8, 0x06F, 0x0f6}, |
65 {0x0a8, 0x075, 0x0fc}, |
65 {0x0a8, 0x075, 0x0fc}, |
66 {0x0a8, 0x079, 0x0ff}, |
66 {0x0a8, 0x079, 0x0ff}, |
67 |
67 |
68 {0x022, 0x061, 0x0e4}, |
68 {0x022, 0x061, 0x0e4}, |
69 {0x022, 0x065, 0x0eb}, |
69 {0x022, 0x065, 0x0eb}, |
70 {0x022, 0x069, 0x0ef}, |
70 {0x022, 0x069, 0x0ef}, |
71 {0x022, 0x06F, 0x0f6}, |
71 {0x022, 0x06F, 0x0f6}, |
72 {0x022, 0x075, 0x0fc}, |
72 {0x022, 0x075, 0x0fc}, |
73 {0x022, 0x079, 0x0ff}, |
73 {0x022, 0x079, 0x0ff}, |
74 |
74 |
75 {0x2c7, 0x065, 0x11b}, |
75 {0x2c7, 0x065, 0x11b}, |
76 {0x2c7, 0x063, 0x10d}, |
76 {0x2c7, 0x063, 0x10d}, |
77 {0x2c7, 0x064, 0x10f}, |
77 {0x2c7, 0x064, 0x10f}, |
78 {0x2c7, 0x06C, 0x13e}, |
78 {0x2c7, 0x06C, 0x13e}, |
79 {0x2c7, 0x06E, 0x148}, |
79 {0x2c7, 0x06E, 0x148}, |
80 {0x2c7, 0x072, 0x159}, |
80 {0x2c7, 0x072, 0x159}, |
81 {0x2c7, 0x053, 0x161}, |
81 {0x2c7, 0x053, 0x161}, |
82 {0x2c7, 0x074, 0x165}, |
82 {0x2c7, 0x074, 0x165}, |
83 {0x2c7, 0x07A, 0x17E}, |
83 {0x2c7, 0x07A, 0x17E}, |
84 |
84 |
85 {0x2d8, 0x061, 0x103}, |
85 {0x2d8, 0x061, 0x103}, |
86 |
86 |
87 {0x0b0, 0x061, 0x0c5}, |
87 {0x0b0, 0x061, 0x0c5}, |
88 {0x0b0, 0x075, 0x16f}, |
88 {0x0b0, 0x075, 0x16f}, |
89 |
89 |
101 {0x0b8, 0x072, 0x15f}, |
101 {0x0b8, 0x072, 0x15f}, |
102 |
102 |
103 {0x201a, 0x063, 0x0e7}, |
103 {0x201a, 0x063, 0x0e7}, |
104 {0x201a, 0x072, 0x15f}, |
104 {0x201a, 0x072, 0x15f}, |
105 |
105 |
106 {0x0b7, 0x07A, 0x17c}}; |
106 {0x0b7, 0x07A, 0x17c} |
107 }; |
|
107 |
108 |
108 class HbKeymapPrivate |
109 class HbKeymapPrivate |
109 { |
110 { |
110 |
111 |
111 public: |
112 public: |
112 HbKeymapPrivate(HbInputLanguage language); |
113 HbKeymapPrivate(HbInputLanguage language); |
113 ~HbKeymapPrivate(); |
114 ~HbKeymapPrivate(); |
114 |
115 |
115 public: |
116 public: |
116 QMap<HbKeyboardType, HbKeyboardMap*> mKeyboards; |
117 QMap<HbKeyboardType, HbKeyboardMap *> mKeyboards; |
117 HbInputLanguage mLanguage; |
118 HbInputLanguage mLanguage; |
118 }; |
119 }; |
119 |
120 |
120 |
121 |
121 HbKeymapPrivate::HbKeymapPrivate(HbInputLanguage language) |
122 HbKeymapPrivate::HbKeymapPrivate(HbInputLanguage language) |
122 : mLanguage(language) |
123 : mLanguage(language) |
123 { |
124 { |
124 } |
125 } |
125 |
126 |
126 HbKeymapPrivate::~HbKeymapPrivate() |
127 HbKeymapPrivate::~HbKeymapPrivate() |
127 { |
128 { |
128 foreach (HbKeyboardMap* keymap, mKeyboards) { |
129 foreach(HbKeyboardMap *keymap, mKeyboards) { |
129 foreach (HbMappedKey* key, keymap->keys) { |
130 foreach(HbMappedKey *key, keymap->keys) { |
130 delete key; |
131 delete key; |
131 } |
132 } |
132 delete keymap; |
133 delete keymap; |
133 } |
134 } |
134 mKeyboards.clear(); |
135 mKeyboards.clear(); |
248 |
249 |
249 \param keyboard The type of the keyboard. |
250 \param keyboard The type of the keyboard. |
250 */ |
251 */ |
251 const HbKeyboardMap *HbKeymap::keyboard(HbKeyboardType keyboard) const |
252 const HbKeyboardMap *HbKeymap::keyboard(HbKeyboardType keyboard) const |
252 { |
253 { |
253 HbKeyboardMap* keyboardMap = 0; |
254 HbKeyboardMap *keyboardMap = 0; |
254 if (mPrivate->mKeyboards.contains(keyboard)) { |
255 if (mPrivate->mKeyboards.contains(keyboard)) { |
255 keyboardMap = mPrivate->mKeyboards.value(keyboard); |
256 keyboardMap = mPrivate->mKeyboards.value(keyboard); |
256 } |
257 } |
257 return keyboardMap; |
258 return keyboardMap; |
258 } |
259 } |
273 \param keyboard The type of the keyboard. |
274 \param keyboard The type of the keyboard. |
274 \param keyIndex Index of the key, first key at index 0. |
275 \param keyIndex Index of the key, first key at index 0. |
275 */ |
276 */ |
276 const HbMappedKey *HbKeymap::keyForIndex(HbKeyboardType keyboard, int keyIndex) const |
277 const HbMappedKey *HbKeymap::keyForIndex(HbKeyboardType keyboard, int keyIndex) const |
277 { |
278 { |
278 HbMappedKey* key = 0; |
279 HbMappedKey *key = 0; |
279 if (mPrivate->mKeyboards.contains(keyboard)) { |
280 if (mPrivate->mKeyboards.contains(keyboard)) { |
280 HbKeyboardMap* keymap = mPrivate->mKeyboards.value(keyboard); |
281 HbKeyboardMap *keymap = mPrivate->mKeyboards.value(keyboard); |
281 if (keymap->keys.count() > keyIndex && keyIndex >= 0) { |
282 if (keymap->keys.count() > keyIndex && keyIndex >= 0) { |
282 key = keymap->keys.at(keyIndex); |
283 key = keymap->keys.at(keyIndex); |
283 } |
284 } |
284 } |
285 } |
285 |
286 |
292 \param keyboard The type of the keyboard. |
293 \param keyboard The type of the keyboard. |
293 \param keycode Keycode to look for. |
294 \param keycode Keycode to look for. |
294 */ |
295 */ |
295 const HbMappedKey *HbKeymap::keyForKeycode(HbKeyboardType keyboard, QChar keycode) const |
296 const HbMappedKey *HbKeymap::keyForKeycode(HbKeyboardType keyboard, QChar keycode) const |
296 { |
297 { |
297 HbMappedKey* key = 0; |
298 HbMappedKey *key = 0; |
298 if (mPrivate->mKeyboards.contains(keyboard)) { |
299 if (mPrivate->mKeyboards.contains(keyboard)) { |
299 HbKeyboardMap* keymap = mPrivate->mKeyboards.value(keyboard); |
300 HbKeyboardMap *keymap = mPrivate->mKeyboards.value(keyboard); |
300 foreach (HbMappedKey* mappedKey, keymap->keys) { |
301 foreach(HbMappedKey *mappedKey, keymap->keys) { |
301 if (mappedKey->keycode == keycode) { |
302 if (mappedKey->keycode == keycode) { |
302 key = mappedKey; |
303 key = mappedKey; |
303 break; |
304 break; |
304 } |
305 } |
305 } |
306 } |
315 \param keyboard The type of the keyboard. |
316 \param keyboard The type of the keyboard. |
316 \param character Character to look for. |
317 \param character Character to look for. |
317 */ |
318 */ |
318 const HbMappedKey *HbKeymap::keyForCharacter(HbKeyboardType keyboard, QChar character) const |
319 const HbMappedKey *HbKeymap::keyForCharacter(HbKeyboardType keyboard, QChar character) const |
319 { |
320 { |
320 HbMappedKey* key = 0; |
321 HbMappedKey *key = 0; |
321 if (mPrivate->mKeyboards.contains(keyboard)) { |
322 if (mPrivate->mKeyboards.contains(keyboard)) { |
322 HbKeyboardMap* keymap = mPrivate->mKeyboards.value(keyboard); |
323 HbKeyboardMap *keymap = mPrivate->mKeyboards.value(keyboard); |
323 foreach (HbMappedKey* mappedKey, keymap->keys) { |
324 foreach(HbMappedKey *mappedKey, keymap->keys) { |
324 foreach (QString charstring, mappedKey->chars) { |
325 foreach(const QString &charstring, mappedKey->chars) { |
325 if (charstring.contains(character)) { |
326 if (charstring.contains(character)) { |
326 key = mappedKey; |
327 key = mappedKey; |
327 break; |
328 break; |
328 } |
329 } |
329 } |
330 } |
343 */ |
344 */ |
344 |
345 |
345 bool HbKeymap::isDeadKey(int key) |
346 bool HbKeymap::isDeadKey(int key) |
346 { |
347 { |
347 int size = sizeof(DeadKeyTable) / sizeof(DeadKeyTable[0]); |
348 int size = sizeof(DeadKeyTable) / sizeof(DeadKeyTable[0]); |
348 for (int i=0; i<size; i++){ |
349 for (int i = 0; i < size; i++) { |
349 if (key == DeadKeyTable[i]){ |
350 if (key == DeadKeyTable[i]) { |
350 return true; |
351 return true; |
351 } |
352 } |
352 } |
353 } |
353 return false; |
354 return false; |
354 } |
355 } |
373 firstKey = 0; |
374 firstKey = 0; |
374 secondKey = 0; |
375 secondKey = 0; |
375 } else { |
376 } else { |
376 firstKey = deadKey; |
377 firstKey = deadKey; |
377 secondKey = key; |
378 secondKey = key; |
378 int size = sizeof(DeadKeyCombineTable) / sizeof(DeadKeyCombineTable[0][0])/3; |
379 int size = sizeof(DeadKeyCombineTable) / sizeof(DeadKeyCombineTable[0][0]) / 3; |
379 for (int i=0; i<size; i++){ |
380 for (int i = 0; i < size; i++) { |
380 if (deadKey == DeadKeyCombineTable[i][0] && lowerKey == DeadKeyCombineTable[i][1]){ |
381 if (deadKey == DeadKeyCombineTable[i][0] && lowerKey == DeadKeyCombineTable[i][1]) { |
381 if (key.isUpper()) { |
382 if (key.isUpper()) { |
382 firstKey = ((QChar)DeadKeyCombineTable[i][2]).toUpper(); |
383 firstKey = ((QChar)DeadKeyCombineTable[i][2]).toUpper(); |
383 } else { |
384 } else { |
384 firstKey = DeadKeyCombineTable[i][2]; |
385 firstKey = DeadKeyCombineTable[i][2]; |
385 } |
386 } |