Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "qplatforminputcontext.h" | - |
43 | #include <qguiapplication.h> | - |
44 | #include <QRect> | - |
45 | #include "private/qkeymapper_p.h" | - |
46 | #include <qpa/qplatforminputcontext_p.h> | - |
47 | | - |
48 | QT_BEGIN_NAMESPACE | - |
49 | | - |
50 | /*! | - |
51 | \class QPlatformInputContext | - |
52 | \since 5.0 | - |
53 | \internal | - |
54 | \preliminary | - |
55 | \ingroup qpa | - |
56 | \brief The QPlatformInputContext class abstracts the input method dependent data and composing state. | - |
57 | | - |
58 | An input method is responsible for inputting complex text that cannot | - |
59 | be inputted via simple keymap. It converts a sequence of input | - |
60 | events (typically key events) into a text string through the input | - |
61 | method specific converting process. The class of the processes are | - |
62 | widely ranging from simple finite state machine to complex text | - |
63 | translator that pools a whole paragraph of a text with text | - |
64 | editing capability to perform grammar and semantic analysis. | - |
65 | | - |
66 | To abstract such different input method specific intermediate | - |
67 | information, Qt offers the QPlatformInputContext as base class. The | - |
68 | concept is well known as 'input context' in the input method | - |
69 | domain. An input context is created for a text widget in response | - |
70 | to a demand. It is ensured that an input context is prepared for | - |
71 | an input method before input to a text widget. | - |
72 | | - |
73 | QPlatformInputContext provides an interface the actual input methods | - |
74 | can derive from by reimplementing methods. | - |
75 | | - |
76 | \sa QInputMethod | - |
77 | */ | - |
78 | | - |
79 | /*! | - |
80 | \internal | - |
81 | */ | - |
82 | QPlatformInputContext::QPlatformInputContext() | - |
83 | : QObject(*(new QPlatformInputContextPrivate)) | - |
84 | { | - |
85 | } executed: } Execution Count:581 | 581 |
86 | | - |
87 | /*! | - |
88 | \internal | - |
89 | */ | - |
90 | QPlatformInputContext::~QPlatformInputContext() | - |
91 | { | - |
92 | } | - |
93 | | - |
94 | /*! | - |
95 | Returns input context validity. Deriving implementations should return true. | - |
96 | */ | - |
97 | bool QPlatformInputContext::isValid() const | - |
98 | { | - |
99 | return false; never executed: return false; | 0 |
100 | } | - |
101 | | - |
102 | /*! | - |
103 | Method to be called when input method needs to be reset. Called by QInputMethod::reset(). | - |
104 | No further QInputMethodEvents should be sent as response. | - |
105 | */ | - |
106 | void QPlatformInputContext::reset() | - |
107 | { | - |
108 | } | - |
109 | | - |
110 | void QPlatformInputContext::commit() | - |
111 | { | - |
112 | } | - |
113 | | - |
114 | /*! | - |
115 | Notification on editor updates. Called by QInputMethod::update(). | - |
116 | */ | - |
117 | void QPlatformInputContext::update(Qt::InputMethodQueries) | - |
118 | { | - |
119 | } | - |
120 | | - |
121 | /*! | - |
122 | Called when when the word currently being composed in input item is tapped by | - |
123 | the user. Input methods often use this information to offer more word | - |
124 | suggestions to the user. | - |
125 | */ | - |
126 | void QPlatformInputContext::invokeAction(QInputMethod::Action action, int cursorPosition) | - |
127 | { | - |
128 | Q_UNUSED(cursorPosition) never executed (the execution status of this line is deduced): (void)cursorPosition; | - |
129 | // Default behavior for simple ephemeral input contexts. Some | - |
130 | // complex input contexts should not be reset here. | - |
131 | if (action == QInputMethod::Click) never evaluated: action == QInputMethod::Click | 0 |
132 | reset(); | 0 |
133 | } | 0 |
134 | | - |
135 | /*! | - |
136 | This function can be reimplemented to filter input events. | - |
137 | Return true if the event has been consumed. Otherwise, the unfiltered event will | - |
138 | be forwarded to widgets as ordinary way. Although the input events have accept() | - |
139 | and ignore() methods, leave it untouched. | - |
140 | */ | - |
141 | bool QPlatformInputContext::filterEvent(const QEvent *event) | - |
142 | { | - |
143 | Q_UNUSED(event) never executed (the execution status of this line is deduced): (void)event; | - |
144 | return false; never executed: return false; | 0 |
145 | } | - |
146 | | - |
147 | /*! | - |
148 | This function can be reimplemented to return virtual keyboard rectangle in currently active | - |
149 | window coordinates. Default implementation returns invalid rectangle. | - |
150 | */ | - |
151 | QRectF QPlatformInputContext::keyboardRect() const | - |
152 | { | - |
153 | return QRectF(); never executed: return QRectF(); | 0 |
154 | } | - |
155 | | - |
156 | /*! | - |
157 | Active QPlatformInputContext is responsible for providing keyboardRectangle property to QInputMethod. | - |
158 | In addition of providing the value in keyboardRect function, it also needs to call this emit | - |
159 | function whenever the property changes. | - |
160 | */ | - |
161 | void QPlatformInputContext::emitKeyboardRectChanged() | - |
162 | { | - |
163 | emit qApp->inputMethod()->keyboardRectangleChanged(); executed (the execution status of this line is deduced): (static_cast<QGuiApplication *>(QCoreApplication::instance()))->inputMethod()->keyboardRectangleChanged(); | - |
164 | } executed: } Execution Count:1 | 1 |
165 | | - |
166 | /*! | - |
167 | This function can be reimplemented to return true whenever input method is animating | - |
168 | shown or hidden. Default implementation returns false. | - |
169 | */ | - |
170 | bool QPlatformInputContext::isAnimating() const | - |
171 | { | - |
172 | return false; never executed: return false; | 0 |
173 | } | - |
174 | | - |
175 | /*! | - |
176 | Active QPlatformInputContext is responsible for providing animating property to QInputMethod. | - |
177 | In addition of providing the value in isAnimation function, it also needs to call this emit | - |
178 | function whenever the property changes. | - |
179 | */ | - |
180 | void QPlatformInputContext::emitAnimatingChanged() | - |
181 | { | - |
182 | emit qApp->inputMethod()->animatingChanged(); executed (the execution status of this line is deduced): (static_cast<QGuiApplication *>(QCoreApplication::instance()))->inputMethod()->animatingChanged(); | - |
183 | } executed: } Execution Count:1 | 1 |
184 | | - |
185 | /*! | - |
186 | Request to show input panel. | - |
187 | */ | - |
188 | void QPlatformInputContext::showInputPanel() | - |
189 | { | - |
190 | } | - |
191 | | - |
192 | /*! | - |
193 | Request to hide input panel. | - |
194 | */ | - |
195 | void QPlatformInputContext::hideInputPanel() | - |
196 | { | - |
197 | } | - |
198 | | - |
199 | /*! | - |
200 | Returns input panel visibility status. Default implementation returns false. | - |
201 | */ | - |
202 | bool QPlatformInputContext::isInputPanelVisible() const | - |
203 | { | - |
204 | return false; never executed: return false; | 0 |
205 | } | - |
206 | | - |
207 | /*! | - |
208 | Active QPlatformInputContext is responsible for providing visible property to QInputMethod. | - |
209 | In addition of providing the value in isInputPanelVisible function, it also needs to call this emit | - |
210 | function whenever the property changes. | - |
211 | */ | - |
212 | void QPlatformInputContext::emitInputPanelVisibleChanged() | - |
213 | { | - |
214 | emit qApp->inputMethod()->visibleChanged(); never executed (the execution status of this line is deduced): (static_cast<QGuiApplication *>(QCoreApplication::instance()))->inputMethod()->visibleChanged(); | - |
215 | } | 0 |
216 | | - |
217 | QLocale QPlatformInputContext::locale() const | - |
218 | { | - |
219 | return qt_keymapper_private()->keyboardInputLocale; never executed: return qt_keymapper_private()->keyboardInputLocale; | 0 |
220 | } | - |
221 | | - |
222 | void QPlatformInputContext::emitLocaleChanged() | - |
223 | { | - |
224 | emit qApp->inputMethod()->localeChanged(); never executed (the execution status of this line is deduced): (static_cast<QGuiApplication *>(QCoreApplication::instance()))->inputMethod()->localeChanged(); | - |
225 | } | 0 |
226 | | - |
227 | Qt::LayoutDirection QPlatformInputContext::inputDirection() const | - |
228 | { | - |
229 | return qt_keymapper_private()->keyboardInputDirection; never executed: return qt_keymapper_private()->keyboardInputDirection; | 0 |
230 | } | - |
231 | | - |
232 | void QPlatformInputContext::emitInputDirectionChanged(Qt::LayoutDirection newDirection) | - |
233 | { | - |
234 | emit qApp->inputMethod()->inputDirectionChanged(newDirection); never executed (the execution status of this line is deduced): (static_cast<QGuiApplication *>(QCoreApplication::instance()))->inputMethod()->inputDirectionChanged(newDirection); | - |
235 | } | 0 |
236 | | - |
237 | /*! | - |
238 | This virtual method gets called to notify updated focus to \a object. | - |
239 | \warning Input methods must not call this function directly. | - |
240 | */ | - |
241 | void QPlatformInputContext::setFocusObject(QObject *object) | - |
242 | { | - |
243 | Q_UNUSED(object) never executed (the execution status of this line is deduced): (void)object; | - |
244 | } | 0 |
245 | | - |
246 | /*! | - |
247 | Returns true if current focus object supports input method events. | - |
248 | */ | - |
249 | bool QPlatformInputContext::inputMethodAccepted() const | - |
250 | { | - |
251 | return QPlatformInputContextPrivate::s_inputMethodAccepted; executed: return QPlatformInputContextPrivate::s_inputMethodAccepted; Execution Count:2 | 2 |
252 | } | - |
253 | | - |
254 | bool QPlatformInputContextPrivate::s_inputMethodAccepted = false; | - |
255 | | - |
256 | void QPlatformInputContextPrivate::setInputMethodAccepted(bool accepted) | - |
257 | { | - |
258 | QPlatformInputContextPrivate::s_inputMethodAccepted = accepted; executed (the execution status of this line is deduced): QPlatformInputContextPrivate::s_inputMethodAccepted = accepted; | - |
259 | } executed: } Execution Count:22603 | 22603 |
260 | | - |
261 | | - |
262 | QT_END_NAMESPACE | - |
263 | | - |
| | |