src/hbplugins/inputmethods/touchinput/hbinputprediction12keyhandler.cpp
changeset 6 c3690ec91ef8
parent 5 627c4a0fd0e7
child 7 923ff622b8b9
equal deleted inserted replaced
5:627c4a0fd0e7 6:c3690ec91ef8
    42 #include "hbinputprediction12keyhandler.h"
    42 #include "hbinputprediction12keyhandler.h"
    43 #include "hbinputpredictionhandler_p.h"
    43 #include "hbinputpredictionhandler_p.h"
    44 #include "hbinputabstractbase.h"
    44 #include "hbinputabstractbase.h"
    45 #include "hbinputprediction12keyhandler_p.h"
    45 #include "hbinputprediction12keyhandler_p.h"
    46 
    46 
    47 #define HbDeltaHeight 3.0
    47 static const qreal HbDeltaHeight = 3.0;
    48 #define MAXUDBWORDSIZE 64
    48 static const qint16 MAXUDBWORDSIZE = 64;
    49 
    49 
    50 HbInputPrediction12KeyHandlerPrivate::HbInputPrediction12KeyHandlerPrivate()
    50 HbInputPrediction12KeyHandlerPrivate::HbInputPrediction12KeyHandlerPrivate()
    51 :mLastKey(0),
    51 :mLastKey(0),
    52 mButtonDown(false),
    52 mButtonDown(false),
    53 mCurrentChar(0),
    53 mCurrentChar(0),
    82     int buttonId = keyEvent->key();
    82     int buttonId = keyEvent->key();
    83 
    83 
    84     if (keyEvent->isAutoRepeat() && mLastKey == buttonId) {
    84     if (keyEvent->isAutoRepeat() && mLastKey == buttonId) {
    85         if (buttonId == HbInputButton::ButtonKeyCodeAsterisk) {
    85         if (buttonId == HbInputButton::ButtonKeyCodeAsterisk) {
    86             //Remove the "?" mark if present
    86             //Remove the "?" mark if present
    87             chopQMarkAndUpdateEditor();
    87             if (!mCanContinuePrediction) {
    88             q->actionHandler(HbInputModeHandler::HbInputModeActionCommit);
    88                 chopQMarkAndUpdateEditor();
    89             mInputMethod->selectSpecialCharacterTableMode();
    89             }	
       
    90             mInputMethod->switchMode(buttonId);
    90             mLongPressHappened = true;
    91             mLongPressHappened = true;
    91         } else if (buttonId == HbInputButton::ButtonKeyCodeShift) {
    92         } else if (buttonId == HbInputButton::ButtonKeyCodeShift) {
    92             mInputMethod->switchMode(HbInputButton::ButtonKeyCodeShift);
    93             mInputMethod->switchMode(HbInputButton::ButtonKeyCodeShift);
    93             mLongPressHappened = true;
    94             mLongPressHappened = true;
    94         } else if (buttonId == HbInputButton::ButtonKeyCodeSymbol) {
    95         } else if (buttonId == HbInputButton::ButtonKeyCodeSymbol) {
   118             return true;
   119             return true;
   119         }
   120         }
   120     }
   121     }
   121 
   122 
   122     if (buttonId == HbInputButton::ButtonKeyCodeShift) {
   123     if (buttonId == HbInputButton::ButtonKeyCodeShift) {
   123         // if we get a second consequtive shift key press, 
   124         // if we get a second consecutive shift key press, 
   124         // we want to handle it in buttonRelease
   125         // we want to handle it in buttonRelease
   125         if (mTimer->isActive() && (mLastKey == buttonId)){
   126         if (mTimer->isActive() && (mLastKey == buttonId)){
   126             mShiftKeyDoubleTap = true;
   127             mShiftKeyDoubleTap = true;
   127         }
   128         }
   128     }
   129     }
   147 
   148 
   148     // since button is released we can set buttonDown back to false.
   149     // since button is released we can set buttonDown back to false.
   149     mButtonDown = false;
   150     mButtonDown = false;
   150     int buttonId = keyEvent->key(); 
   151     int buttonId = keyEvent->key(); 
   151 
   152 
       
   153 	// short key press of character keys should not be handled when "?" is displayed
       
   154     if (!mCanContinuePrediction && !mLongPressHappened &&
       
   155 		buttonId >= Qt::Key_1 && buttonId <= Qt::Key_9) {
       
   156         return false;
       
   157     }	
   152     // Sym key is handled in this class it self, so not passing it to 
   158     // Sym key is handled in this class it self, so not passing it to 
   153     // the base mode handlers.	
   159     // the base mode handlers.	
   154     if (buttonId == HbInputButton::ButtonKeyCodeSymbol ||
   160     if (buttonId == HbInputButton::ButtonKeyCodeSymbol ||
   155         buttonId == HbInputButton::ButtonKeyCodeAlphabet) {
   161         buttonId == HbInputButton::ButtonKeyCodeAlphabet) {
   156         //Remove the "?" mark if present
   162         //Remove the "?" mark if present
   168         if(!mCanContinuePrediction && (*mCandidates)[mBestGuessLocation].endsWith('?')) {			
   174         if(!mCanContinuePrediction && (*mCandidates)[mBestGuessLocation].endsWith('?')) {			
   169             //Remove the "?" mark
   175             //Remove the "?" mark
   170             (*mCandidates)[mBestGuessLocation].chop(1);
   176             (*mCandidates)[mBestGuessLocation].chop(1);
   171             updateEditor();
   177             updateEditor();
   172             q->launchSpellQueryDialog();
   178             q->launchSpellQueryDialog();
   173             mCanContinuePrediction = true;
       
   174         } else {
   179         } else {
   175             mInputMethod->starKeySelected();
   180             mInputMethod->starKeySelected();
   176         }
   181         }
   177         return true;
   182         return true;
   178     }
   183     }
   211                 }
   216                 }
   212             }
   217             }
   213         }
   218         }
   214         return true;
   219         return true;
   215     }
   220     }
   216 
   221 	// ButtonKeyCodeSettings should not be propagated to the engine
       
   222     if(buttonId == HbInputButton::ButtonKeyCodeSettings) {
       
   223         return true;
       
   224     }
   217     if (buttonId != HbInputButton::ButtonKeyCodeDelete &&
   225     if (buttonId != HbInputButton::ButtonKeyCodeDelete &&
   218         mInputMethod->currentKeyboardType() == HbKeyboardSctPortrait) {
   226         mInputMethod->currentKeyboardType() == HbKeyboardSctPortrait) {
   219         q->sctCharacterSelected(QChar(buttonId));
   227         q->sctCharacterSelected(QChar(buttonId));
   220         return true;
   228         return true;
   221     }
   229     }