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 { |
71 } |
72 } |
72 |
73 |
73 return -1; |
74 return -1; |
74 } |
75 } |
75 |
76 |
|
77 bool HbInputModeHandlerPrivate::isPunctuationKey(const Qt::Key key, const HbKeyboardType keypad) |
|
78 { |
|
79 // Currently, Punctuation key is present only for For ITUT Keypad (i.e. Key_1 is is the punctuation key) |
|
80 if ( (!HbInputUtils::isQwertyKeyboard(keypad)) && (Qt::Key_1 == key) ) { |
|
81 return true; |
|
82 } |
|
83 return false; |
|
84 } |
|
85 |
76 void HbInputModeHandlerPrivate::getAndFilterCharactersBoundToKey(QString &allowedChars, HbKeyboardType type, \ |
86 void HbInputModeHandlerPrivate::getAndFilterCharactersBoundToKey(QString &allowedChars, HbKeyboardType type, \ |
77 int key, HbModifiers modifiers) |
87 int key, HbModifiers modifiers) |
78 { |
88 { |
79 allowedChars.clear(); |
89 allowedChars.clear(); |
80 HbInputLanguage language = mInputMethod->inputState().language(); |
90 HbInputLanguage language = mInputMethod->inputState().language(); |
81 |
91 |
82 if (!mKeymap) { |
92 if (!mKeymap) { |
83 mKeymap = HbKeymapFactory::instance()->keymap(language); |
93 mKeymap = HbKeymapFactory::instance()->keymap(language); |
84 } |
94 } |
85 const HbMappedKey* mappedKey = mKeymap->keyForKeycode(type, key); |
95 const HbMappedKey* mappedKey = mKeymap->keyForKeycode(type, key); |
86 if (!mappedKey) { |
96 if (!mappedKey) { |
87 return; |
97 return; |
88 } |
98 } |
89 QString chars = mappedKey->characters(modifiers); |
99 QString chars = mappedKey->characters(modifiers); |
90 // 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 |
91 for (int i = 0; i < chars.length(); i++) { |
101 for (int i = 0; i < chars.length(); i++) { |
92 if (chars.at(i) >= '0' && chars.at(i) <= '9') { |
102 if (chars.at(i) >= '0' && chars.at(i) <= '9') { |
93 chars = chars.replace(chars.at(i), HbInputUtils::findFirstNumberCharacterBoundToKey(mappedKey, |
103 chars = chars.replace(chars.at(i), HbInputUtils::findFirstNumberCharacterBoundToKey(mappedKey, |
94 language, HbInputUtils::inputDigitType(language))); |
104 language, HbInputUtils::inputDigitType(language))); |
95 } |
105 } |
96 } |
106 } |
97 // 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. |
98 // 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. |
99 HbInputFocusObject *focusedObject = mInputMethod->focusObject(); |
109 HbInputFocusObject *focusedObject = mInputMethod->focusObject(); |
100 if(focusedObject) { |
110 if(focusedObject) { |
101 focusedObject->filterStringWithEditorFilter(chars,allowedChars); |
111 focusedObject->filterStringWithEditorFilter(chars,allowedChars); |
261 HbInputLanguage language = d->mInputMethod->inputState().language(); |
271 HbInputLanguage language = d->mInputMethod->inputState().language(); |
262 // This is long key press number shortcut functionality. |
272 // This is long key press number shortcut functionality. |
263 if (!d->mKeymap) { |
273 if (!d->mKeymap) { |
264 d->mKeymap = HbKeymapFactory::instance()->keymap(language); |
274 d->mKeymap = HbKeymapFactory::instance()->keymap(language); |
265 } |
275 } |
266 bool isNumericEditor = d->mInputMethod->focusObject()->editorInterface().isNumericEditor(); |
276 bool isNumericEditor = d->mInputMethod->focusObject()->editorInterface().isNumericEditor(); |
267 HbInputDigitType digitType = HbInputUtils::inputDigitType(language); |
277 HbInputDigitType digitType = HbInputUtils::inputDigitType(language); |
268 if (isNumericEditor) { |
278 if (isNumericEditor) { |
269 QLocale::Language systemLanguage = QLocale::system().language(); |
279 QLocale::Language systemLanguage = QLocale::system().language(); |
270 if (language.language() != systemLanguage) { |
280 if (language.language() != systemLanguage) { |
271 digitType = HbDigitTypeLatin; |
281 digitType = HbDigitTypeLatin; |
272 } |
282 } |
273 } |
283 } |
274 QChar numChr = HbInputUtils::findFirstNumberCharacterBoundToKey( |
284 QChar numChr = HbInputUtils::findFirstNumberCharacterBoundToKey( |
275 d->mKeymap->keyForKeycode(type, key), language, digitType); |
285 d->mKeymap->keyForKeycode(type, key), language, digitType); |
276 // when a number is to be entered, it should commit |
286 // when a number is to be entered, it should commit |
277 // the previous string and then append the number to the string |
287 // the previous string and then append the number to the string |
278 if (numChr != 0) { |
288 if (numChr != 0) { |
279 commitAndAppendString(numChr); |
289 commitAndAppendString(numChr); |
280 } |
290 } |
281 } |
291 } |
287 QChar HbInputModeHandler::getNthCharacterInKey(int &index, int key, HbKeyboardType type) |
297 QChar HbInputModeHandler::getNthCharacterInKey(int &index, int key, HbKeyboardType type) |
288 { |
298 { |
289 Q_D(HbInputModeHandler); |
299 Q_D(HbInputModeHandler); |
290 HbModifiers modifiers = 0; |
300 HbModifiers modifiers = 0; |
291 int textCase = d->mInputMethod->inputState().textCase(); |
301 int textCase = d->mInputMethod->inputState().textCase(); |
292 if (type != HbKeyboardSctPortrait && (textCase == HbTextCaseUpper || textCase == HbTextCaseAutomatic)) { |
302 if ( (type != HbKeyboardSctPortrait && type != HbKeyboardSctUrl && type != HbKeyboardSctEmail) && |
|
303 (textCase == HbTextCaseUpper || textCase == HbTextCaseAutomatic)) { |
293 modifiers |= HbModifierShiftPressed; |
304 modifiers |= HbModifierShiftPressed; |
294 } |
305 } |
295 |
306 |
296 QString allowedChars; |
307 QString allowedChars; |
297 getAndFilterCharactersBoundToKey(allowedChars,type,key,modifiers); |
308 getAndFilterCharactersBoundToKey(allowedChars,type,key,modifiers); |