47 void HbInputModeHandlerPrivate::init() |
47 void HbInputModeHandlerPrivate::init() |
48 { |
48 { |
49 Q_Q(HbInputModeHandler); |
49 Q_Q(HbInputModeHandler); |
50 mTimer = new QTimer(q); |
50 mTimer = new QTimer(q); |
51 q->connect(mTimer, SIGNAL(timeout()), q, SLOT(_q_timeout())); |
51 q->connect(mTimer, SIGNAL(timeout()), q, SLOT(_q_timeout())); |
|
52 mTimer->setSingleShot(true); |
52 } |
53 } |
53 |
54 |
54 // A virtual timeout function mode handlers should implement this slot. |
55 // A virtual timeout function mode handlers should implement this slot. |
55 void HbInputModeHandlerPrivate::_q_timeout() |
56 void HbInputModeHandlerPrivate::_q_timeout() |
56 { |
57 { |
85 void HbInputModeHandlerPrivate::getAndFilterCharactersBoundToKey(QString &allowedChars, HbKeyboardType type, \ |
86 void HbInputModeHandlerPrivate::getAndFilterCharactersBoundToKey(QString &allowedChars, HbKeyboardType type, \ |
86 int key, HbModifiers modifiers) |
87 int key, HbModifiers modifiers) |
87 { |
88 { |
88 allowedChars.clear(); |
89 allowedChars.clear(); |
89 HbInputLanguage language = mInputMethod->inputState().language(); |
90 HbInputLanguage language = mInputMethod->inputState().language(); |
90 |
91 |
91 if (!mKeymap) { |
92 if (!mKeymap) { |
92 mKeymap = HbKeymapFactory::instance()->keymap(language); |
93 mKeymap = HbKeymapFactory::instance()->keymap(language); |
93 } |
94 } |
94 const HbMappedKey* mappedKey = mKeymap->keyForKeycode(type, key); |
95 const HbMappedKey* mappedKey = mKeymap->keyForKeycode(type, key); |
95 if (!mappedKey) { |
96 if (!mappedKey) { |
96 return; |
97 return; |
97 } |
98 } |
98 QString chars = mappedKey->characters(modifiers); |
99 QString chars = mappedKey->characters(modifiers); |
99 // check whether current input language supports native digits. if yes, replace latin digits with native digits |
100 // check whether current input language supports native digits. if yes, replace latin digits with native digits |
100 for (int i = 0; i < chars.length(); i++) { |
101 for (int i = 0; i < chars.length(); i++) { |
101 if (chars.at(i) >= '0' && chars.at(i) <= '9') { |
102 if (chars.at(i) >= '0' && chars.at(i) <= '9') { |
102 chars = chars.replace(chars.at(i), HbInputUtils::findFirstNumberCharacterBoundToKey(mappedKey, |
103 chars = chars.replace(chars.at(i), HbInputUtils::findFirstNumberCharacterBoundToKey(mappedKey, |
103 language, HbInputUtils::inputDigitType(language))); |
104 language, HbInputUtils::inputDigitType(language))); |
104 } |
105 } |
105 } |
106 } |
106 // We need to see which of the characters in keyData are allowed to the editor. |
107 // We need to see which of the characters in keyData are allowed to the editor. |
107 // this looks like expensive operation, need to find out a better way/place to do it. |
108 // this looks like expensive operation, need to find out a better way/place to do it. |
108 HbInputFocusObject *focusedObject = mInputMethod->focusObject(); |
109 HbInputFocusObject *focusedObject = mInputMethod->focusObject(); |
109 if(focusedObject) { |
110 if(focusedObject) { |
110 focusedObject->filterStringWithEditorFilter(chars,allowedChars); |
111 focusedObject->filterStringWithEditorFilter(chars,allowedChars); |
270 HbInputLanguage language = d->mInputMethod->inputState().language(); |
271 HbInputLanguage language = d->mInputMethod->inputState().language(); |
271 // This is long key press number shortcut functionality. |
272 // This is long key press number shortcut functionality. |
272 if (!d->mKeymap) { |
273 if (!d->mKeymap) { |
273 d->mKeymap = HbKeymapFactory::instance()->keymap(language); |
274 d->mKeymap = HbKeymapFactory::instance()->keymap(language); |
274 } |
275 } |
275 bool isNumericEditor = d->mInputMethod->focusObject()->editorInterface().isNumericEditor(); |
276 bool isNumericEditor = d->mInputMethod->focusObject()->editorInterface().isNumericEditor(); |
276 HbInputDigitType digitType = HbInputUtils::inputDigitType(language); |
277 HbInputDigitType digitType = HbInputUtils::inputDigitType(language); |
277 if (isNumericEditor) { |
278 if (isNumericEditor) { |
278 QLocale::Language systemLanguage = QLocale::system().language(); |
279 QLocale::Language systemLanguage = QLocale::system().language(); |
279 if (language.language() != systemLanguage) { |
280 if (language.language() != systemLanguage) { |
280 digitType = HbDigitTypeLatin; |
281 digitType = HbDigitTypeLatin; |
281 } |
282 } |
282 } |
283 } |
283 QChar numChr = HbInputUtils::findFirstNumberCharacterBoundToKey( |
284 QChar numChr = HbInputUtils::findFirstNumberCharacterBoundToKey( |
284 d->mKeymap->keyForKeycode(type, key), language, digitType); |
285 d->mKeymap->keyForKeycode(type, key), language, digitType); |
285 // when a number is to be entered, it should commit |
286 // when a number is to be entered, it should commit |
286 // the previous string and then append the number to the string |
287 // the previous string and then append the number to the string |
287 if (numChr != 0) { |
288 if (numChr != 0) { |
288 commitAndAppendString(numChr); |
289 commitAndAppendString(numChr); |
289 } |
290 } |
290 } |
291 } |