347 { |
339 { |
348 mShowTail = true; |
340 mShowTail = true; |
349 mShowTooltip = true; |
341 mShowTooltip = true; |
350 // A backspace in predictive means updating the engine for the delete key press |
342 // A backspace in predictive means updating the engine for the delete key press |
351 // and get the new candidate list from the engine. |
343 // and get the new candidate list from the engine. |
352 if ((mEngine->inputLength() >= 1) || selectWord()) { |
344 if ( mEngine->inputLength() >= 1 ) { |
353 //Only autocomplition part should be deleted when autocompliton part is enable and user pressed a delete key |
345 //Only autocomplition part should be deleted when autocompliton part is enable and user pressed a delete key |
354 //To prevent showing autocompletion part while deleting the characters using backspace key |
346 //To prevent showing autocompletion part while deleting the characters using backspace key |
355 mShowTail = false; |
347 mShowTail = false; |
356 mShowTooltip = false; |
348 mShowTooltip = false; |
357 //The assumption here is that with deletion of a character we always |
349 //The assumption here is that with deletion of a character we always |
358 //can go on with prediction. This is because when we delete a key press |
350 //can go on with prediction. This is because when we delete a key press |
359 //we actually reduce ambiguity in the engine and hence we should have |
351 //we actually reduce ambiguity in the engine and hence we should have |
360 //some word getting predicted as a result to that. |
352 //some word getting predicted as a result to that. |
361 mCanContinuePrediction = true; |
353 mCanContinuePrediction = true; |
362 if (true == mExactPopupLaunched) { |
354 |
363 QString exactWord = mCandidates->at(0); |
355 if(false == mTailShowing && true == mExactPopupLaunched) { |
364 mEngine->setWord(exactWord); |
356 mEngine->deleteKeyPress(); |
365 mCandidates->clear(); |
357 mEngine->updateCandidates(mBestGuessLocation); |
366 mCandidates->append(exactWord); |
358 } |
|
359 if (true == mExactPopupLaunched) { |
367 mBestGuessLocation = 0 ; |
360 mBestGuessLocation = 0 ; |
368 } |
|
369 if(false == mTailShowing && true == mExactPopupLaunched) { |
|
370 mEngine->deleteKeyPress(); |
|
371 } |
361 } |
372 //When there is a deletion of key press, no need to update the candidate list |
362 //When there is a deletion of key press, no need to update the candidate list |
373 //This is because deletion should not cause reprediction. |
363 //This is because deletion should not cause reprediction. |
374 if(mCandidates->count() && (mCandidates->count()>mBestGuessLocation) && false == mTailShowing && false == mExactPopupLaunched) { |
364 if(mCandidates->count() && (mCandidates->count()>mBestGuessLocation) && false == mTailShowing && false == mExactPopupLaunched) { |
375 QString currentWord = mCandidates->at(mBestGuessLocation); |
365 QString currentWord = mCandidates->at(mBestGuessLocation); |
386 (*mCandidates)[mBestGuessLocation] = currentWord; |
376 (*mCandidates)[mBestGuessLocation] = currentWord; |
387 } else { |
377 } else { |
388 commit(QString(""),false); |
378 commit(QString(""),false); |
389 } |
379 } |
390 |
380 |
391 } else if(!mCandidates->count()) { |
381 } else if(!mCandidates->count() && mEngine->inputLength() >= 1) { |
392 mCandidates->append(mEngine->currentWord()); |
382 //If Input length greater or equal to one then Append the current word to candidate |
|
383 mCandidates->append(mEngine->currentWord()); |
393 } |
384 } |
394 // update the editor with the new preedit text. |
385 // update the editor with the new preedit text. |
395 updateEditor(); |
386 updateEditor(); |
396 return; |
387 return; |
397 } |
388 } else { |
398 |
389 // we come here if their is no data in engine. |
399 HbInputFocusObject* focusedObject = 0; |
390 // once the word is committed, we can not bring it back to inline edit. |
400 focusedObject = mInputMethod->focusObject(); |
391 // so if the engine does not have any data, we just send backspace event to the editor. |
401 if (!focusedObject) { |
392 Q_Q(HbInputPredictionQwertyHandler); |
|
393 QKeyEvent event = QKeyEvent(QEvent::KeyPress, Qt::Key_Backspace, Qt::NoModifier); |
|
394 q->sendAndUpdate(event); |
|
395 event = QKeyEvent(QEvent::KeyRelease, Qt::Key_Backspace, Qt::NoModifier); |
|
396 q->sendAndUpdate(event); |
402 return; |
397 return; |
403 } |
398 } |
404 |
|
405 if ((focusedObject->inputMethodQuery(Qt::ImCursorPosition).toInt() >= 0) || focusedObject->preEditString().length()) { |
|
406 QList<QInputMethodEvent::Attribute> list; |
|
407 QInputMethodEvent event(QString(), list); |
|
408 event.setCommitString(QString(), -1, 1); |
|
409 commit(event); |
|
410 } |
|
411 } |
399 } |
412 |
400 |
413 //EOF |
401 //EOF |