|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (developer.feedback@nokia.com) |
|
6 ** |
|
7 ** This file is part of the HbPlugins module of the UI Extensions for Mobile. |
|
8 ** |
|
9 ** GNU Lesser General Public License Usage |
|
10 ** This file may be used under the terms of the GNU Lesser General Public |
|
11 ** License version 2.1 as published by the Free Software Foundation and |
|
12 ** appearing in the file LICENSE.LGPL included in the packaging of this file. |
|
13 ** Please review the following information to ensure the GNU Lesser General |
|
14 ** Public License version 2.1 requirements will be met: |
|
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
16 ** |
|
17 ** In addition, as a special exception, Nokia gives you certain additional |
|
18 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
20 ** |
|
21 ** If you have questions regarding the use of this file, please contact |
|
22 ** Nokia at developer.feedback@nokia.com. |
|
23 ** |
|
24 ****************************************************************************/ |
|
25 #include <hbinputmethod.h> |
|
26 #include <hbinputkeymapfactory.h> |
|
27 |
|
28 #include "hbinputnumericqwertyhandler.h" |
|
29 #include "hbinputnumerichandler_p.h" |
|
30 #include "hbinputabstractbase.h" |
|
31 |
|
32 class HbInputNumericQwertyHandlerPrivate: public HbInputNumericHandlerPrivate |
|
33 { |
|
34 Q_DECLARE_PUBLIC(HbInputNumericQwertyHandler) |
|
35 public: |
|
36 HbInputNumericQwertyHandlerPrivate(); |
|
37 ~HbInputNumericQwertyHandlerPrivate(); |
|
38 |
|
39 void init(); |
|
40 |
|
41 // button related operations. |
|
42 bool buttonPressed(const QKeyEvent *event); |
|
43 bool buttonReleased(const QKeyEvent *event); |
|
44 }; |
|
45 |
|
46 HbInputNumericQwertyHandlerPrivate::HbInputNumericQwertyHandlerPrivate() |
|
47 { |
|
48 } |
|
49 |
|
50 HbInputNumericQwertyHandlerPrivate::~HbInputNumericQwertyHandlerPrivate() |
|
51 { |
|
52 } |
|
53 |
|
54 bool HbInputNumericQwertyHandlerPrivate::buttonPressed(const QKeyEvent * event) |
|
55 { |
|
56 Q_UNUSED(event); |
|
57 return false; |
|
58 } |
|
59 |
|
60 bool HbInputNumericQwertyHandlerPrivate::buttonReleased(const QKeyEvent *event) |
|
61 { |
|
62 Q_Q(HbInputNumericQwertyHandler); |
|
63 |
|
64 // let's pass event to the base class. |
|
65 if (q->HbInputNumericHandler::filterEvent(event)) { |
|
66 return true; |
|
67 } |
|
68 |
|
69 int buttonId = event->key(); |
|
70 // currently we shift and control key are not clear as concept. So just ignoring |
|
71 // these buttons. |
|
72 if (buttonId == Qt::Key_Shift || buttonId == Qt::Key_Control) { |
|
73 return false; |
|
74 } |
|
75 |
|
76 // Don't handle this |
|
77 if (buttonId == Qt::Key_Backspace || buttonId == Qt::Key_Delete) { |
|
78 return false; |
|
79 } |
|
80 |
|
81 //TODO |
|
82 HbInputFocusObject *focusObject = 0; |
|
83 focusObject = mInputMethod->focusObject(); |
|
84 if (!focusObject) { |
|
85 qDebug("HbInputNumericQwertyHandler::buttonReleased : no focused editor widget!"); |
|
86 return false; |
|
87 } |
|
88 int currentTextCase = focusObject->editorInterface().textCase(); |
|
89 if (buttonId >= 0) { |
|
90 QChar newChar = QChar(buttonId); |
|
91 if (currentTextCase == HbTextCaseLower) { |
|
92 newChar = newChar.toLower(); |
|
93 } else { |
|
94 newChar = newChar.toUpper(); |
|
95 } |
|
96 q->commitAndUpdate(newChar); |
|
97 return true; |
|
98 } |
|
99 return false; |
|
100 } |
|
101 |
|
102 HbInputNumericQwertyHandler::HbInputNumericQwertyHandler(HbInputAbstractMethod* inputMethod) |
|
103 :HbInputNumericHandler(* new HbInputNumericQwertyHandlerPrivate, inputMethod) |
|
104 { |
|
105 Q_D(HbInputNumericQwertyHandler); |
|
106 d->q_ptr = this; |
|
107 } |
|
108 |
|
109 |
|
110 /*! |
|
111 This function lists different input modes. |
|
112 */ |
|
113 void HbInputNumericQwertyHandler::listInputModes(QVector<HbInputModeProperties>& modes) const |
|
114 { |
|
115 HbInputModeProperties binding; |
|
116 binding.iMode = HbInputModeNumeric; |
|
117 binding.iKeyboard = HbKeyboardVirtualQwerty; |
|
118 |
|
119 QList<HbInputLanguage> languages = HbKeymapFactory::availableLanguages(); |
|
120 foreach (HbInputLanguage language, languages) { |
|
121 binding.iLanguage = language; |
|
122 modes.push_back(binding); |
|
123 } |
|
124 } |
|
125 |
|
126 HbInputNumericQwertyHandler::~HbInputNumericQwertyHandler() |
|
127 { |
|
128 } |
|
129 |
|
130 /*! |
|
131 filterEvent function key handling. |
|
132 */ |
|
133 bool HbInputNumericQwertyHandler::filterEvent(const QKeyEvent* event) |
|
134 { |
|
135 Q_D(HbInputNumericQwertyHandler); |
|
136 |
|
137 if (event->type() == QEvent::KeyRelease) { |
|
138 return d->buttonReleased(event); |
|
139 } else { |
|
140 return d->buttonPressed(event); |
|
141 } |
|
142 } |
|
143 |
|
144 /*! |
|
145 Action handler |
|
146 */ |
|
147 bool HbInputNumericQwertyHandler::actionHandler(HbInputModeAction action) |
|
148 { |
|
149 return HbInputNumericHandler::actionHandler(action); |
|
150 } |
|
151 |
|
152 //EOF |
|
153 |