src/hbplugins/inputmethods/common/hbinputpredictionhandler.cpp
changeset 28 b7da29130b0e
parent 23 e6ad4ef83b23
child 30 80e4d18b72f5
equal deleted inserted replaced
23:e6ad4ef83b23 28:b7da29130b0e
    39 #include "../touchinput/virtualqwerty.h"
    39 #include "../touchinput/virtualqwerty.h"
    40 
    40 
    41 #include "hbinputpredictionhandler_p.h"
    41 #include "hbinputpredictionhandler_p.h"
    42 #include "hbinputabstractbase.h"
    42 #include "hbinputabstractbase.h"
    43 
    43 
    44 static const qreal HbDeltaHeight = 3.0;
       
    45 
       
    46 HbInputPredictionHandlerPrivate::HbInputPredictionHandlerPrivate()
    44 HbInputPredictionHandlerPrivate::HbInputPredictionHandlerPrivate()
    47     :mEngine(0),
    45     :mEngine(0),
    48     mCandidates(0),
    46     mCandidates(0),
    49     mBestGuessLocation(0),
    47     mBestGuessLocation(0),
    50     mShowTail(true),
    48     mShowTail(true),
    58 HbInputPredictionHandlerPrivate::~HbInputPredictionHandlerPrivate()
    56 HbInputPredictionHandlerPrivate::~HbInputPredictionHandlerPrivate()
    59 {
    57 {
    60     if (mCandidates) {
    58     if (mCandidates) {
    61         delete mCandidates;
    59         delete mCandidates;
    62         mCandidates = 0;
    60         mCandidates = 0;
       
    61     }
       
    62     if (mSpellQueryDialog) {
       
    63         mSpellQueryDialog->deleteLater();
    63     }
    64     }
    64 }
    65 }
    65 
    66 
    66 void HbInputPredictionHandlerPrivate::deleteOneCharacter()
    67 void HbInputPredictionHandlerPrivate::deleteOneCharacter()
    67 {
    68 {
   797         delete d->mSpellQueryDialog;
   798         delete d->mSpellQueryDialog;
   798         d->mSpellQueryDialog =0;
   799         d->mSpellQueryDialog =0;
   799     }
   800     }
   800     if(!d->mSpellQueryDialog) {
   801     if(!d->mSpellQueryDialog) {
   801         d->mSpellQueryDialog = new HbInputSpellQuery(d->mInputMethod,this); 
   802         d->mSpellQueryDialog = new HbInputSpellQuery(d->mInputMethod,this); 
   802         d->mSpellQueryDialog->setParent(this);
       
   803     }
   803     }
   804 
   804 
   805     QString string;
   805     QString string;
   806     if(d->mCandidates && (*(d->mCandidates)).size() >= d->mBestGuessLocation + 1) {
   806     if(d->mCandidates && (*(d->mCandidates)).size() >= d->mBestGuessLocation + 1) {
   807         string = (*(d->mCandidates))[d->mBestGuessLocation].left(d->mEngine->inputLength());
   807         string = (*(d->mCandidates))[d->mBestGuessLocation].left(d->mEngine->inputLength());
   839     newFocusObject->setFocus();
   839     newFocusObject->setFocus();
   840     HbAbstractEdit *abstractEdit = qobject_cast<HbAbstractEdit*>(savedFocusObject);
   840     HbAbstractEdit *abstractEdit = qobject_cast<HbAbstractEdit*>(savedFocusObject);
   841     if(abstractEdit) {
   841     if(abstractEdit) {
   842         abstractEdit->setCursorPosition(abstractEdit->cursorPosition());
   842         abstractEdit->setCursorPosition(abstractEdit->cursorPosition());
   843     }
   843     }
       
   844     if(HbInputMethod::activeInputMethod()->isFocusLocked()) {
       
   845         HbInputMethod::activeInputMethod()->unlockFocus();
   844     HbInputMethod::activeInputMethod()->setFocusObject(newFocusObject);
   846     HbInputMethod::activeInputMethod()->setFocusObject(newFocusObject);
       
   847         HbInputMethod::activeInputMethod()->lockFocus();
       
   848     } else {
       
   849         HbInputMethod::activeInputMethod()->setFocusObject(newFocusObject);
       
   850     }
   845 
   851 
   846     if (closeReason == HbInputSpellQuery::HbOkPressed) {
   852     if (closeReason == HbInputSpellQuery::HbOkPressed) {
   847         d->commit(string,true);
   853         d->commit(string,true);
   848     } else if(closeReason == HbInputSpellQuery::HbCancelPressed) {
   854     } else if(closeReason == HbInputSpellQuery::HbCancelPressed) {
   849         //update the editor with pre-edit text
   855         //update the editor with pre-edit text