|
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 "hbinputnumerichandler_p.h" |
|
26 #include "hbinputabstractbase.h" |
|
27 |
|
28 HbInputNumericHandlerPrivate::HbInputNumericHandlerPrivate() |
|
29 { |
|
30 } |
|
31 |
|
32 HbInputNumericHandlerPrivate::~HbInputNumericHandlerPrivate() |
|
33 { |
|
34 } |
|
35 |
|
36 HbInputNumericHandler::HbInputNumericHandler(HbInputNumericHandlerPrivate &dd, HbInputAbstractMethod* inputMethod) |
|
37 :HbInputModeHandler(dd, inputMethod) |
|
38 { |
|
39 Q_D(HbInputNumericHandler); |
|
40 d->q_ptr = this; |
|
41 } |
|
42 |
|
43 |
|
44 HbInputNumericHandler::~HbInputNumericHandler() |
|
45 { |
|
46 } |
|
47 |
|
48 /*! |
|
49 This function handles different keyevents. |
|
50 */ |
|
51 bool HbInputNumericHandler::filterEvent(const QKeyEvent *event) |
|
52 { |
|
53 bool ret = true; |
|
54 switch (event->key()) { |
|
55 case Qt::Key_Backspace: |
|
56 case Qt::Key_Delete: { |
|
57 QKeyEvent keyEvent(QEvent::KeyPress, Qt::Key_Backspace, Qt::NoModifier); |
|
58 sendAndUpdate(keyEvent); |
|
59 // return false since the event is sent forward |
|
60 ret = false; |
|
61 break; |
|
62 } |
|
63 case Qt::Key_Return: |
|
64 case Qt::Key_Enter: |
|
65 case Qt::Key_Space: |
|
66 case Qt::Key_Period: |
|
67 case Qt::Key_Comma: { |
|
68 QChar qc(event->key()); |
|
69 if (qc == Qt::Key_Enter || qc == Qt::Key_Return) { |
|
70 qc = QChar('\n'); // Editor expects normal line feed. |
|
71 } |
|
72 commitAndUpdate(qc); |
|
73 break; |
|
74 } |
|
75 default: |
|
76 ret = HbInputModeHandler::filterEvent(event); |
|
77 break; |
|
78 } |
|
79 return ret; |
|
80 } |
|
81 |
|
82 /*! |
|
83 Action handler |
|
84 */ |
|
85 bool HbInputNumericHandler::actionHandler(HbInputModeAction action) |
|
86 { |
|
87 return HbInputModeHandler::actionHandler(action); |
|
88 } |
|
89 |
|
90 //EOF |