71 } |
71 } |
72 |
72 |
73 return -1; |
73 return -1; |
74 } |
74 } |
75 |
75 |
76 void HbInputModeHandlerPrivate::getAndFilterCharactersBoundToKey(QStringList &spellList, Qt::Key key) |
76 void HbInputModeHandlerPrivate::getAndFilterCharactersBoundToKey(QString &allowedChars, HbKeyboardType type, \ |
77 { |
77 int key, HbModifiers modifiers) |
78 HbInputFocusObject *focusObject = mInputMethod->focusObject(); |
78 { |
79 |
79 allowedChars.clear(); |
80 spellList.clear(); |
80 HbInputLanguage language = mInputMethod->inputState().language(); |
81 // Get the functionized character |
81 |
82 const HbMappedKey* mappedKey = mKeymap->keyForKeycode(mInputMethod->inputState().keyboard(), key); |
82 if (!mKeymap) { |
|
83 mKeymap = HbKeymapFactory::instance()->keymap(language); |
|
84 } |
|
85 const HbMappedKey* mappedKey = mKeymap->keyForKeycode(type, key); |
83 if (!mappedKey) { |
86 if (!mappedKey) { |
84 return; |
87 return; |
85 } |
88 } |
86 |
89 QString chars = mappedKey->characters(modifiers); |
87 if (!mappedKey->characters(HbModifierFnPressed).isNull() && focusObject && focusObject->characterAllowedInEditor(mappedKey->characters(HbModifierFnPressed).at(0))) { |
90 // check whether current input language supports native digits. if yes, replace latin digits with native digits |
88 spellList.append(mappedKey->characters(HbModifierFnPressed).at(0)); |
91 for (int i = 0; i < chars.length(); i++) { |
89 } |
92 if (chars.at(i) >= '0' && chars.at(i) <= '9') { |
90 |
93 chars = chars.replace(chars.at(i), HbInputUtils::findFirstNumberCharacterBoundToKey(mappedKey, |
91 // Get the characters mapped to the key. |
94 language, HbInputUtils::inputDigitType(language))); |
92 HbInputState inputState = mInputMethod->inputState(); |
95 } |
93 HbTextCase textCase = inputState.textCase(); |
96 } |
94 HbModifiers modifiers = HbModifierNone; |
97 // We need to see which of the characters in keyData are allowed to the editor. |
95 |
98 // this looks like expensive operation, need to find out a better way/place to do it. |
96 if (textCase == HbTextCaseUpper || textCase == HbTextCaseAutomatic) { |
99 HbInputFocusObject *focusedObject = mInputMethod->focusObject(); |
97 modifiers |= HbModifierShiftPressed; |
100 if(focusedObject) { |
98 } |
101 focusedObject->filterStringWithEditorFilter(chars,allowedChars); |
99 for (int i=0; i < mappedKey->characters(modifiers).length(); i++) { |
102 } |
100 if (focusObject && focusObject->characterAllowedInEditor(mappedKey->characters(modifiers).at(i))) { |
|
101 spellList.append(mappedKey->characters(modifiers).at(i)); |
|
102 } |
|
103 } |
|
104 } |
103 } |
105 |
104 |
106 |
105 |
107 void HbInputModeHandlerPrivate::updateTextCase() |
106 void HbInputModeHandlerPrivate::updateTextCase() |
108 { |
107 { |
291 HbModifiers modifiers = 0; |
290 HbModifiers modifiers = 0; |
292 int textCase = d->mInputMethod->inputState().textCase(); |
291 int textCase = d->mInputMethod->inputState().textCase(); |
293 if (type != HbKeyboardSctPortrait && (textCase == HbTextCaseUpper || textCase == HbTextCaseAutomatic)) { |
292 if (type != HbKeyboardSctPortrait && (textCase == HbTextCaseUpper || textCase == HbTextCaseAutomatic)) { |
294 modifiers |= HbModifierShiftPressed; |
293 modifiers |= HbModifierShiftPressed; |
295 } |
294 } |
296 HbInputLanguage language = d->mInputMethod->inputState().language(); |
295 |
297 |
296 QString allowedChars; |
298 if (!d->mKeymap) { |
297 getAndFilterCharactersBoundToKey(allowedChars,type,key,modifiers); |
299 d->mKeymap = HbKeymapFactory::instance()->keymap(language); |
298 |
300 } |
|
301 const HbMappedKey* mappedKey = d->mKeymap->keyForKeycode(type, key); |
|
302 if (!mappedKey) { |
|
303 return 0; |
|
304 } |
|
305 QString chars = mappedKey->characters(modifiers); |
|
306 // check whether current input language supports native digits. if yes, replace latin digits with native digits |
|
307 for (int i = 0; i < chars.length(); i++) { |
|
308 if (chars.at(i) >= '0' && chars.at(i) <= '9') { |
|
309 chars = chars.replace(chars.at(i), HbInputUtils::findFirstNumberCharacterBoundToKey(mappedKey, |
|
310 language, HbInputUtils::inputDigitType(language))); |
|
311 } |
|
312 } |
|
313 // We need to see which of the characters in keyData are allowed to the editor. |
|
314 // this looks like expensive operation, need to find out a better way/place to do it. |
|
315 QString allowedChars = chars; |
|
316 HbInputFocusObject *focusedObject = d->mInputMethod->focusObject(); |
|
317 if(focusedObject) { |
|
318 focusedObject->filterStringWithEditorFilter(chars,allowedChars); |
|
319 } |
|
320 QChar character = 0; |
299 QChar character = 0; |
321 if (!allowedChars.isNull()) { |
300 if (!allowedChars.isNull()) { |
322 if (index >= allowedChars.length() || index < 0) { |
301 if (index >= allowedChars.length() || index < 0) { |
323 index = 0; |
302 index = 0; |
324 } |
303 } |
325 character = allowedChars.at(index); |
304 character = allowedChars.at(index); |
326 index++; |
305 index++; |
|
306 if (index >= allowedChars.length() || index < 0) { |
|
307 index = 0; |
|
308 } |
327 } |
309 } |
328 return character; |
310 return character; |
329 } |
311 } |
330 |
312 |
331 /*! |
313 /*! |
332 This function gets all the characters bound to a key and filters those character based on the editor. |
314 This function gets all the characters bound to a key and filters those character based on the editor. |
333 */ |
315 */ |
334 void HbInputModeHandler::getAndFilterCharactersBoundToKey(QStringList &spellList, Qt::Key key) |
316 void HbInputModeHandler::getAndFilterCharactersBoundToKey(QString &allowedChars, HbKeyboardType type, \ |
335 { |
317 int key, HbModifiers modifiers) |
336 Q_D(HbInputModeHandler); |
318 { |
337 d->getAndFilterCharactersBoundToKey(spellList, key); |
319 Q_D(HbInputModeHandler); |
|
320 d->getAndFilterCharactersBoundToKey(allowedChars,type,key,modifiers); |
338 } |
321 } |
339 |
322 |
340 /*! |
323 /*! |
341 A virtual function, this should be called from plugin when ever there is mouse event. |
324 A virtual function, this should be called from plugin when ever there is mouse event. |
342 */ |
325 */ |