131 } |
131 } |
132 break; |
132 break; |
133 case HbInputButton::ButtonKeyCodeSymbol: { // Ctrl/Chr |
133 case HbInputButton::ButtonKeyCodeSymbol: { // Ctrl/Chr |
134 case HbInputButton::ButtonKeyCodeAlphabet: |
134 case HbInputButton::ButtonKeyCodeAlphabet: |
135 mInputMethod->switchSpecialCharacterTable(); |
135 mInputMethod->switchSpecialCharacterTable(); |
|
136 q->HbInputPredictionHandler::actionHandler(HbInputModeHandler::HbInputModeActionSetKeypad); |
136 } |
137 } |
137 break; |
138 break; |
138 case HbInputButton::ButtonKeyCodeSettings: |
139 case HbInputButton::ButtonKeyCodeSettings: |
139 mInputMethod->closeExactWordPopup(); |
140 mInputMethod->closeExactWordPopup(); |
140 break; |
141 break; |
150 // If shift is pressed, the shifted characters have to be input. |
151 // If shift is pressed, the shifted characters have to be input. |
151 if ( HbTextCaseUpper == currentTextCase || HbTextCaseAutomatic == currentTextCase ) { |
152 if ( HbTextCaseUpper == currentTextCase || HbTextCaseAutomatic == currentTextCase ) { |
152 modifiers |= Qt::ShiftModifier; |
153 modifiers |= Qt::ShiftModifier; |
153 } |
154 } |
154 |
155 |
155 if (key != HbInputButton::ButtonKeyCodeDelete && |
|
156 key != HbInputButton::ButtonKeyCodeEnter && |
|
157 mInputMethod->currentKeyboardType() == HbKeyboardSctLandscape) { |
|
158 q->sctCharacterSelected(QChar(key)); |
|
159 return true; |
|
160 } |
|
161 |
156 |
162 // let's pass it to the base class. |
157 // let's pass it to the base class. |
163 ret = q->HbInputPredictionHandler::filterEvent(event); |
158 ret = q->HbInputPredictionHandler::filterEvent(event); |
164 |
159 |
165 mInputMethod->updateState(); |
160 mInputMethod->updateState(); |
251 { |
246 { |
252 Q_D(HbInputPredictionQwertyHandler); |
247 Q_D(HbInputPredictionQwertyHandler); |
253 HbInputModeHandler::commitAndUpdate(string, replaceFrom, replaceLength); |
248 HbInputModeHandler::commitAndUpdate(string, replaceFrom, replaceLength); |
254 d->mInputMethod->closeExactWordPopup(); |
249 d->mInputMethod->closeExactWordPopup(); |
255 d->mExactPopupLaunched = false; |
250 d->mExactPopupLaunched = false; |
256 d->mTailShowing = false; |
|
257 } |
251 } |
258 |
252 |
259 /*! |
253 /*! |
260 this function deletes one character and updates the engine and editor. |
254 this function deletes one character and updates the engine and editor. |
261 */ |
255 */ |
313 return d->mEngine != 0; |
307 return d->mEngine != 0; |
314 } |
308 } |
315 |
309 |
316 void HbInputPredictionQwertyHandlerPrivate::deleteOneCharacter() |
310 void HbInputPredictionQwertyHandlerPrivate::deleteOneCharacter() |
317 { |
311 { |
|
312 if (!mEngine && !mInputMethod->focusObject()) { |
|
313 return; |
|
314 } |
318 mShowTail = true; |
315 mShowTail = true; |
319 mShowTooltip = true; |
316 mShowTooltip = true; |
320 // A backspace in predictive means updating the engine for the delete key press |
317 // A backspace in predictive means updating the engine for the delete key press |
321 // and get the new candidate list from the engine. |
318 // and get the new candidate list from the engine. |
322 if ( mEngine->inputLength() >= 1 ) { |
319 if ( mEngine->inputLength() >= 1 ) { |
327 //The assumption here is that with deletion of a character we always |
324 //The assumption here is that with deletion of a character we always |
328 //can go on with prediction. This is because when we delete a key press |
325 //can go on with prediction. This is because when we delete a key press |
329 //we actually reduce ambiguity in the engine and hence we should have |
326 //we actually reduce ambiguity in the engine and hence we should have |
330 //some word getting predicted as a result to that. |
327 //some word getting predicted as a result to that. |
331 mCanContinuePrediction = true; |
328 mCanContinuePrediction = true; |
332 |
329 |
333 if(false == mTailShowing && true == mExactPopupLaunched) { |
330 int tailLength = mInputMethod->focusObject()->preEditString().length() - mEngine->inputLength(); |
334 mEngine->deleteKeyPress(); |
331 if(tailLength <= 0 && true == mExactPopupLaunched) { |
335 mEngine->updateCandidates(mBestGuessLocation); |
332 mEngine->deleteKeyPress(); |
|
333 mEngine->updateCandidates(mBestGuessLocation); |
336 } |
334 } |
337 |
335 |
338 mBestGuessLocation = 0 ; |
336 mBestGuessLocation = 0; |
339 if(mCandidates->count() && (mCandidates->count()>mBestGuessLocation) && false == mTailShowing && false == mExactPopupLaunched) { |
337 if(mCandidates->count() && (mCandidates->count()>mBestGuessLocation) && tailLength <= 0 && false == mExactPopupLaunched) { |
340 QString currentWord = mCandidates->at(mBestGuessLocation); |
338 QString currentWord = mCandidates->at(mBestGuessLocation); |
341 if(currentWord.length() > mEngine->inputLength()) { |
|
342 //chop off the autocompletion part |
|
343 currentWord = currentWord.left(mEngine->inputLength()); |
|
344 } |
|
345 if(currentWord.length()) { |
339 if(currentWord.length()) { |
346 currentWord.chop(1); |
340 currentWord.chop(1); |
347 mEngine->deleteKeyPress(); |
341 mEngine->deleteKeyPress(); |
348 //We are not supposed to re-construct the candidate list as deletion |
342 //We are not supposed to re-construct the candidate list as deletion |
349 //does not cause reprediction. Also, candidate list construction is the |
343 //does not cause reprediction. Also, candidate list construction is the |
350 //heaviest operation out of all engine operations. |
344 //heaviest operation out of all engine operations. |
351 (*mCandidates)[mBestGuessLocation] = currentWord; |
345 (*mCandidates)[mBestGuessLocation] = currentWord; |
352 } else { |
346 } else { |
353 commit(QString(""),false); |
347 commit(QString(""),false); |
354 } |
348 } |
355 |
349 |
356 } else if(!mCandidates->count() && mEngine->inputLength() >= 1) { |
350 } else if(!mCandidates->count() && mEngine->inputLength() >= 1) { |
357 //If Input length greater or equal to one then Append the current word to candidate |
351 //If Input length greater or equal to one then Append the current word to candidate |
358 mCandidates->append(mEngine->currentWord()); |
352 mCandidates->append(mEngine->currentWord()); |
359 } |
353 } |
360 // update the editor with the new preedit text. |
354 // update the editor with the new preedit text. |
444 } |
438 } |
445 list.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, mEngine->inputLength(), 0, 0)); |
439 list.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, mEngine->inputLength(), 0, 0)); |
446 // the best guess word is sent to the editor |
440 // the best guess word is sent to the editor |
447 QInputMethodEvent event(bestGuessWord, list); |
441 QInputMethodEvent event(bestGuessWord, list); |
448 focusedObject->sendEvent(event); |
442 focusedObject->sendEvent(event); |
449 mTailShowing = true; |
|
450 } else { |
443 } else { |
451 QInputMethodEvent::Attribute textstyle(QInputMethodEvent::TextFormat, 0, mCandidates->at(mPrimaryCandidateIndex).length(), underlined); |
444 QInputMethodEvent::Attribute textstyle(QInputMethodEvent::TextFormat, 0, mCandidates->at(mPrimaryCandidateIndex).length(), underlined); |
452 list.append(textstyle); |
445 list.append(textstyle); |
453 list.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, mCandidates->at(mPrimaryCandidateIndex).length(), 0, 0)); |
446 list.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, mCandidates->at(mPrimaryCandidateIndex).length(), 0, 0)); |
454 QInputMethodEvent event(mCandidates->at(mPrimaryCandidateIndex), list); |
447 QInputMethodEvent event(mCandidates->at(mPrimaryCandidateIndex), list); |
455 focusedObject->sendEvent(event); |
448 focusedObject->sendEvent(event); |
456 mTailShowing = false; |
|
457 } |
449 } |
458 |
450 |
459 if (mShowTooltip && mPrimaryCandidateIndex != mSecondaryCandidateIndex) { |
451 if (mShowTooltip && mPrimaryCandidateIndex != mSecondaryCandidateIndex) { |
460 q->processExactWord(mCandidates->at(mSecondaryCandidateIndex)); |
452 q->processExactWord(mCandidates->at(mSecondaryCandidateIndex)); |
461 } else { |
453 } else { |