|
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 "hbinputnumerichandler_p.h" |
|
29 #include "HbHardwareInputNumericQwertyHandler.h" |
|
30 #include "hbinputabstractbase.h" |
|
31 |
|
32 class HbHardwareInputNumericQwertyHandlerPrivate: public HbInputNumericHandlerPrivate |
|
33 { |
|
34 Q_DECLARE_PUBLIC(HbHardwareInputNumericQwertyHandler) |
|
35 public: |
|
36 HbHardwareInputNumericQwertyHandlerPrivate(); |
|
37 ~HbHardwareInputNumericQwertyHandlerPrivate(); |
|
38 |
|
39 void init(); |
|
40 |
|
41 // button related operations. |
|
42 bool buttonPressed(const QKeyEvent *event); |
|
43 bool buttonReleased(const QKeyEvent *event); |
|
44 }; |
|
45 |
|
46 HbHardwareInputNumericQwertyHandlerPrivate::HbHardwareInputNumericQwertyHandlerPrivate() |
|
47 { |
|
48 } |
|
49 |
|
50 HbHardwareInputNumericQwertyHandlerPrivate::~HbHardwareInputNumericQwertyHandlerPrivate() |
|
51 { |
|
52 } |
|
53 |
|
54 bool HbHardwareInputNumericQwertyHandlerPrivate::buttonPressed(const QKeyEvent * event) |
|
55 { |
|
56 Q_UNUSED(event); |
|
57 return true; |
|
58 } |
|
59 |
|
60 bool HbHardwareInputNumericQwertyHandlerPrivate::buttonReleased(const QKeyEvent *event) |
|
61 { |
|
62 Q_Q(HbHardwareInputNumericQwertyHandler); |
|
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 //TODO |
|
77 HbInputFocusObject *focusObject = 0; |
|
78 focusObject = mInputMethod->focusObject(); |
|
79 if (!focusObject) { |
|
80 qDebug("HbHardwareInputNumericQwertyHandler::buttonReleased : no focused editor widget!"); |
|
81 return false; |
|
82 } |
|
83 int currentTextCase = focusObject->editorInterface().textCase(); |
|
84 QChar newChar = QChar(buttonId); |
|
85 if (currentTextCase == HbTextCaseLower) { |
|
86 newChar = newChar.toLower(); |
|
87 } else { |
|
88 newChar = newChar.toUpper(); |
|
89 } |
|
90 q->commitAndUpdate(newChar); |
|
91 return true; |
|
92 } |
|
93 |
|
94 HbHardwareInputNumericQwertyHandler::HbHardwareInputNumericQwertyHandler(HbInputAbstractMethod* inputMethod) |
|
95 :HbInputNumericHandler(* new HbHardwareInputNumericQwertyHandlerPrivate, inputMethod) |
|
96 { |
|
97 Q_D(HbHardwareInputNumericQwertyHandler); |
|
98 d->q_ptr = this; |
|
99 } |
|
100 |
|
101 |
|
102 /*! |
|
103 This function lists different input modes. |
|
104 */ |
|
105 void HbHardwareInputNumericQwertyHandler::listInputModes(QVector<HbInputModeProperties>& modes) const |
|
106 { |
|
107 HbInputModeProperties binding; |
|
108 binding.iMode = HbInputModeNumeric; |
|
109 binding.iKeyboard = HbKeyboardQwerty4x10; |
|
110 |
|
111 QVector<int> languages; |
|
112 HbKeyMapFactory::instance()->listLanguages(languages); |
|
113 foreach (int languageCode, languages) { |
|
114 binding.iLanguage = (QLocale::Language)languageCode; |
|
115 modes.push_back(binding); |
|
116 } |
|
117 } |
|
118 |
|
119 HbHardwareInputNumericQwertyHandler::~HbHardwareInputNumericQwertyHandler() |
|
120 { |
|
121 } |
|
122 |
|
123 /*! |
|
124 filterEvent function key handling. |
|
125 */ |
|
126 bool HbHardwareInputNumericQwertyHandler::filterEvent(const QKeyEvent* event) |
|
127 { |
|
128 Q_D(HbHardwareInputNumericQwertyHandler); |
|
129 |
|
130 if (event->type() == QEvent::KeyRelease) { |
|
131 return d->buttonReleased(event); |
|
132 } else { |
|
133 return d->buttonPressed(event); |
|
134 } |
|
135 } |
|
136 |
|
137 /*! |
|
138 Action handler |
|
139 */ |
|
140 bool HbHardwareInputNumericQwertyHandler::actionHandler(HbInputModeAction action) |
|
141 { |
|
142 return HbInputNumericHandler::actionHandler(action); |
|
143 } |
|
144 |
|
145 //EOF |
|
146 |