--- a/src/hbplugins/inputmethods/hardwareinput/hbhardwareinputbasic12keyhandler.cpp Mon Oct 04 17:49:30 2010 +0300
+++ b/src/hbplugins/inputmethods/hardwareinput/hbhardwareinputbasic12keyhandler.cpp Mon Oct 18 18:23:13 2010 +0300
@@ -35,24 +35,24 @@
class HbHardwareInputBasic12KeyHandlerPrivate: public HbInputBasicHandlerPrivate
{
- Q_DECLARE_PUBLIC(HbHardwareInputBasic12KeyHandler)
+ Q_DECLARE_PUBLIC(HbHardwareInputBasic12KeyHandler)
public:
- HbHardwareInputBasic12KeyHandlerPrivate();
- ~HbHardwareInputBasic12KeyHandlerPrivate();
+ HbHardwareInputBasic12KeyHandlerPrivate();
+ ~HbHardwareInputBasic12KeyHandlerPrivate();
- void handleAlphaEvent(int buttonId);
- bool keyPressed(const QKeyEvent *keyEvent);
- bool keyReleased(const QKeyEvent *keyEvent);
- bool actionHandler(HbInputModeHandler::HbInputModeAction action);
+ void handleAlphaEvent(int buttonId);
+ bool keyPressed(const QKeyEvent *keyEvent);
+ bool keyReleased(const QKeyEvent *keyEvent);
+ bool actionHandler(HbInputModeHandler::HbInputModeAction action);
- void _q_timeout();
+ void _q_timeout();
public:
- int mLastKey;
- QChar mCurrentChar;
- int mNumChr;
- bool mButtonDown;
- HbInputFocusObject *mCurrentlyFocused;
+ int mLastKey;
+ QChar mCurrentChar;
+ int mNumChr;
+ bool mButtonDown;
+ HbInputFocusObject *mCurrentlyFocused;
};
HbHardwareInputBasic12KeyHandlerPrivate::HbHardwareInputBasic12KeyHandlerPrivate()
@@ -71,92 +71,92 @@
// handles the key press events. It starts a multitap timer as well.
void HbHardwareInputBasic12KeyHandlerPrivate::handleAlphaEvent(int buttonId)
{
- Q_Q(HbHardwareInputBasic12KeyHandler);
- HbInputFocusObject *focusObject = 0;
- focusObject = mInputMethod->focusObject();
- if (!focusObject) {
- return;
- }
+ Q_Q(HbHardwareInputBasic12KeyHandler);
+ HbInputFocusObject *focusObject = 0;
+ focusObject = mInputMethod->focusObject();
+ if (!focusObject) {
+ return;
+ }
- mCurrentChar = q->getNthCharacterInKey(mNumChr, buttonId);
+ mCurrentChar = q->getNthCharacterInKey(mNumChr, buttonId);
- if (mCurrentChar != 0) {
- QString str;
- str += mCurrentChar;
+ if (mCurrentChar != 0) {
+ QString str;
+ str += mCurrentChar;
- QList<QInputMethodEvent::Attribute> list;
- QInputMethodEvent event(str, list);
- focusObject->sendEvent(event);
- mTimer->start(HbMultiTapTimerTimeout);
- }
+ QList<QInputMethodEvent::Attribute> list;
+ QInputMethodEvent event(str, list);
+ focusObject->sendEvent(event);
+ mTimer->start(HbMultiTapTimerTimeout);
+ }
}
bool HbHardwareInputBasic12KeyHandlerPrivate::keyPressed(const QKeyEvent *keyEvent)
{
- Q_Q(HbHardwareInputBasic12KeyHandler);
- HbInputFocusObject *focusObject = 0;
- focusObject = mInputMethod->focusObject();
- if (!focusObject) {
- return false;
- }
+ Q_Q(HbHardwareInputBasic12KeyHandler);
+ HbInputFocusObject *focusObject = 0;
+ focusObject = mInputMethod->focusObject();
+ if (!focusObject) {
+ return false;
+ }
- int buttonId = keyEvent->key();
-
+ int buttonId = keyEvent->key();
+
- if( mLastKey != buttonId) {
- mLastKey = buttonId;
- if(mTimer->isActive()) {
- mTimer->stop();
- mNumChr = 0;
- if (isEnterCharacter(mCurrentChar)) {
- focusObject->sendPreEditString(QString("")); // Make sure the enter character is cleared.
- mCurrentChar = QChar('\n'); // Convert enter character to line feed.
- }
+ if( mLastKey != buttonId) {
+ mLastKey = buttonId;
+ if(mTimer->isActive()) {
+ mTimer->stop();
+ mNumChr = 0;
+ if (isEnterCharacter(mCurrentChar)) {
+ focusObject->sendPreEditString(QString("")); // Make sure the enter character is cleared.
+ mCurrentChar = QChar('\n'); // Convert enter character to line feed.
+ }
- if(mCurrentChar != 0) {
- focusObject->filterAndCommitCharacter(mCurrentChar);
- }
- // For QLineEdit it works fine. For HbLineEdit, need to set the state
- // to lower by calling activateState().
- // This is needed for the scenario - When automatic text case is true
- // click a button and before the multitap timer expires click on
- // another button.
- mInputMethod->updateState();
+ if(mCurrentChar != 0) {
+ focusObject->filterAndCommitCharacter(mCurrentChar);
+ }
+ // For QLineEdit it works fine. For HbLineEdit, need to set the state
+ // to lower by calling activateState().
+ // This is needed for the scenario - When automatic text case is true
+ // click a button and before the multitap timer expires click on
+ // another button.
+ mInputMethod->updateState();
refreshAutoCompleter();
- }
- }
+ }
+ }
- if (buttonId == Qt::Key_Return) {
- mLastKey = buttonId;
- return true;
- } else if (buttonId == Qt::Key_Shift) {
- // For single key press, change the text input case. If the second shift key press is
- // received within long key press time out interval, then activate the next state
- if (mTimer->isActive() && (mLastKey == buttonId)){
- mTimer->stop();
+ if (buttonId == Qt::Key_Return) {
+ mLastKey = buttonId;
+ return true;
+ } else if (buttonId == Qt::Key_Shift) {
+ // For single key press, change the text input case. If the second shift key press is
+ // received within long key press time out interval, then activate the next state
+ if (mTimer->isActive() && (mLastKey == buttonId)){
+ mTimer->stop();
HbInputState rootState;
mInputMethod->editorRootState(rootState);
mInputMethod->activateState(rootState);
- } else {
- updateTextCase();
- mTimer->start(HbLongPressTimerTimeout);
- }
- mCurrentChar = 0;
- mButtonDown = true;
- mCurrentChar = 0;
- return true;
- }
- // Let's see if we can get the handler for this button in the base class.
- if (q->HbInputBasicHandler::filterEvent(keyEvent)) {
- return true;
- }
+ } else {
+ updateTextCase();
+ mTimer->start(HbLongPressTimerTimeout);
+ }
+ mCurrentChar = 0;
+ mButtonDown = true;
+ mCurrentChar = 0;
+ return true;
+ }
+ // Let's see if we can get the handler for this button in the base class.
+ if (q->HbInputBasicHandler::filterEvent(keyEvent)) {
+ return true;
+ }
- mLastKey = buttonId;
- mButtonDown = true;
+ mLastKey = buttonId;
+ mButtonDown = true;
- handleAlphaEvent(buttonId);
- return true;
+ handleAlphaEvent(buttonId);
+ return true;
}
/*!
@@ -165,146 +165,146 @@
*/
bool HbHardwareInputBasic12KeyHandlerPrivate::keyReleased(const QKeyEvent *keyEvent)
{
- Q_Q(HbHardwareInputBasic12KeyHandler);
- mButtonDown = false;
- int buttonId = keyEvent->key();
+ Q_Q(HbHardwareInputBasic12KeyHandler);
+ mButtonDown = false;
+ int buttonId = keyEvent->key();
- if (buttonId == Qt::Key_Asterisk) {
- //Same asterisk key is used for launching candidate list (long key press)
- //and also for SCT. So, do not launch SCT if candidate list is already launched.
- mInputMethod->switchMode(buttonId);
- return true;
- } else if (buttonId == Qt::Key_Delete) {
- QKeyEvent keyEvent(QEvent::KeyRelease, Qt::Key_Backspace, Qt::NoModifier);
- q->sendAndUpdate(keyEvent);
- return true;
- }
+ if (buttonId == Qt::Key_Asterisk) {
+ //Same asterisk key is used for launching candidate list (long key press)
+ //and also for SCT. So, do not launch SCT if candidate list is already launched.
+ mInputMethod->switchMode(buttonId);
+ return true;
+ } else if (buttonId == Qt::Key_Delete) {
+ QKeyEvent keyEvent(QEvent::KeyRelease, Qt::Key_Backspace, Qt::NoModifier);
+ q->sendAndUpdate(keyEvent);
+ return true;
+ }
- return false;
+ return false;
}
void HbHardwareInputBasic12KeyHandlerPrivate::_q_timeout()
{
- Q_Q(HbHardwareInputBasic12KeyHandler);
- mTimer->stop();
- mNumChr = 0;
+ Q_Q(HbHardwareInputBasic12KeyHandler);
+ mTimer->stop();
+ mNumChr = 0;
- HbInputFocusObject *focusedObject = 0;
- focusedObject = mInputMethod->focusObject();
- if (!focusedObject) {
- qDebug("HbHardwareInputBasic12KeyHandler::timeout focusObject == 0");
- return;
- }
+ HbInputFocusObject *focusedObject = 0;
+ focusedObject = mInputMethod->focusObject();
+ if (!focusedObject) {
+ qDebug("HbHardwareInputBasic12KeyHandler::timeout focusObject == 0");
+ return;
+ }
- if (isEnterCharacter(mCurrentChar)) {
- focusedObject->sendPreEditString(QString("")); // Make sure the enter character is cleared.
- mCurrentChar = QChar('\n'); // Convert enter character to line feed.
- }
+ if (isEnterCharacter(mCurrentChar)) {
+ focusedObject->sendPreEditString(QString("")); // Make sure the enter character is cleared.
+ mCurrentChar = QChar('\n'); // Convert enter character to line feed.
+ }
- //Long key press number key is applicable to all keys
- if (mButtonDown) {
- //switch to numeric mode for long key press of Hash key
- if (mLastKey == Qt::Key_Shift){
- updateTextCase();
- mInputMethod->switchMode(Qt::Key_Shift);
- }else {
- q->commitFirstMappedNumber(mLastKey);
- }
- } else if(mLastKey != Qt::Key_Shift){
- if (!focusedObject->characterAllowedInEditor(mCurrentChar)) {
- focusedObject->sendCommitString(QString());
- } else {
- if ( mCurrentChar != 0){
- QString curString;
- curString.append(mCurrentChar);
- focusedObject->sendCommitString(curString);
- }
- mInputMethod->updateState();
- // pass this character to autocompleter.
+ //Long key press number key is applicable to all keys
+ if (mButtonDown) {
+ //switch to numeric mode for long key press of Hash key
+ if (mLastKey == Qt::Key_Shift){
+ updateTextCase();
+ mInputMethod->switchMode(Qt::Key_Shift);
+ }else {
+ q->commitFirstMappedNumber(mLastKey);
+ }
+ } else if(mLastKey != Qt::Key_Shift){
+ if (!focusedObject->characterAllowedInEditor(mCurrentChar)) {
+ focusedObject->sendCommitString(QString());
+ } else {
+ if ( mCurrentChar != 0){
+ QString curString;
+ curString.append(mCurrentChar);
+ focusedObject->sendCommitString(curString);
+ }
+ mInputMethod->updateState();
+ // pass this character to autocompleter.
refreshAutoCompleter();
- }
- }
- return;
+ }
+ }
+ return;
}
bool HbHardwareInputBasic12KeyHandlerPrivate::actionHandler(HbInputModeHandler::HbInputModeAction action)
{
- HbInputFocusObject *focusObject = 0;
- focusObject = mInputMethod->focusObject();
- if (!focusObject) {
- return false;
- }
+ HbInputFocusObject *focusObject = 0;
+ focusObject = mInputMethod->focusObject();
+ if (!focusObject) {
+ return false;
+ }
- bool ret = true;
- switch (action) {
+ bool ret = true;
+ switch (action) {
case HbInputModeHandler::HbInputModeActionReset:
- mLastKey = 0;
- mNumChr = 0;
- if (mTimer->isActive()) {
- mTimer->stop();
- }
- break;
+ mLastKey = 0;
+ mNumChr = 0;
+ if (mTimer->isActive()) {
+ mTimer->stop();
+ }
+ break;
case HbInputModeHandler::HbInputModeActionDeleteAndCommit:{
- mTimer->stop();
- QString empty;
- if(mInputMethod) {
- //In case of the sct the character is already committed
- //We need to remove the committed character.
- QList<QInputMethodEvent::Attribute> list;
- QInputMethodEvent event(QString(), list);
- event.setCommitString(empty, -1, 1);
- focusObject->sendEvent(event);
- } else {
- // Close event was originated from a button press, remove the uncommitted character.
- focusObject->sendCommitString(empty);
- }
- }
- break;
+ mTimer->stop();
+ QString empty;
+ if(mInputMethod) {
+ //In case of the sct the character is already committed
+ //We need to remove the committed character.
+ QList<QInputMethodEvent::Attribute> list;
+ QInputMethodEvent event(QString(), list);
+ event.setCommitString(empty, -1, 1);
+ focusObject->sendEvent(event);
+ } else {
+ // Close event was originated from a button press, remove the uncommitted character.
+ focusObject->sendCommitString(empty);
+ }
+ }
+ break;
case HbInputModeHandler::HbInputModeActionFocusRecieved:
- mTimer->stop();
- mNumChr = 0;
- if (mCurrentlyFocused != focusObject) {
- mCurrentlyFocused = focusObject;
- if (mAutoCompleter) {
- mAutoCompleter->commit();
- }
- }
- // set up auto completer
- setUpAutoCompleter();
- break;
+ mTimer->stop();
+ mNumChr = 0;
+ if (mCurrentlyFocused != focusObject) {
+ mCurrentlyFocused = focusObject;
+ if (mAutoCompleter) {
+ mAutoCompleter->commit();
+ }
+ }
+ // set up auto completer
+ setUpAutoCompleter();
+ break;
case HbInputModeHandler::HbInputModeActionCommit:
case HbInputModeHandler::HbInputModeActionFocusLost:
- if (mTimer->isActive()) {
- mTimer->stop();
- if (mCurrentChar != 0) {
- if (isEnterCharacter(mCurrentChar)) {
- focusObject->sendPreEditString(QString("")); // Make sure the enter character is cleared.
- mCurrentChar = QChar('\n'); // Convert enter character to line feed.
- }
- focusObject->filterAndCommitCharacter(mCurrentChar);
- mCurrentChar = 0;
- }
- mLastKey = 0;
- mNumChr = 0;
- mInputMethod->updateState();
- }
- break;
+ if (mTimer->isActive()) {
+ mTimer->stop();
+ if (mCurrentChar != 0) {
+ if (isEnterCharacter(mCurrentChar)) {
+ focusObject->sendPreEditString(QString("")); // Make sure the enter character is cleared.
+ mCurrentChar = QChar('\n'); // Convert enter character to line feed.
+ }
+ focusObject->filterAndCommitCharacter(mCurrentChar);
+ mCurrentChar = 0;
+ }
+ mLastKey = 0;
+ mNumChr = 0;
+ mInputMethod->updateState();
+ }
+ break;
default: {
- ret = false;
- }
- break;
- };
+ ret = false;
+ }
+ break;
+ };
- return ret;
+ return ret;
}
HbHardwareInputBasic12KeyHandler::HbHardwareInputBasic12KeyHandler(HbInputAbstractMethod* inputMethod)
:HbInputBasicHandler( *new HbHardwareInputBasic12KeyHandlerPrivate, inputMethod)
{
- Q_D(HbHardwareInputBasic12KeyHandler);
- d->q_ptr = this;
+ Q_D(HbHardwareInputBasic12KeyHandler);
+ d->q_ptr = this;
}
HbHardwareInputBasic12KeyHandler::~HbHardwareInputBasic12KeyHandler()
@@ -316,16 +316,16 @@
*/
bool HbHardwareInputBasic12KeyHandler::filterEvent(const QKeyEvent * event)
{
- Q_D(HbHardwareInputBasic12KeyHandler);
+ Q_D(HbHardwareInputBasic12KeyHandler);
- if (event->isAutoRepeat()) {
- // Ignore all repeat events after first repeat event
- return true;
- } else if (event->type() == QEvent::KeyRelease) {
- return d->keyReleased(event);
- } else {
- return d->keyPressed(event);
- }
+ if (event->isAutoRepeat()) {
+ // Ignore all repeat events after first repeat event
+ return true;
+ } else if (event->type() == QEvent::KeyRelease) {
+ return d->keyReleased(event);
+ } else {
+ return d->keyPressed(event);
+ }
}
/*!
@@ -333,8 +333,8 @@
*/
bool HbHardwareInputBasic12KeyHandler::isComposing() const
{
- Q_D(const HbHardwareInputBasic12KeyHandler);
- return d->mTimer->isActive();
+ Q_D(const HbHardwareInputBasic12KeyHandler);
+ return d->mTimer->isActive();
}
/*!
@@ -342,11 +342,11 @@
*/
bool HbHardwareInputBasic12KeyHandler::actionHandler(HbInputModeAction action)
{
- Q_D(HbHardwareInputBasic12KeyHandler);
- if (!d->actionHandler(action)) {
- // no action taken so let's pass it to the base class.
- return HbInputBasicHandler::actionHandler(action);
- }
- return false;
+ Q_D(HbHardwareInputBasic12KeyHandler);
+ if (!d->actionHandler(action)) {
+ // no action taken so let's pass it to the base class.
+ return HbInputBasicHandler::actionHandler(action);
+ }
+ return false;
}
// EOF