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 "qlineedit.h" | - |
43 | #include "qlineedit_p.h" | - |
44 | | - |
45 | #ifndef QT_NO_LINEEDIT | - |
46 | #include "qaction.h" | - |
47 | #include "qapplication.h" | - |
48 | #include "qclipboard.h" | - |
49 | #include "qdrag.h" | - |
50 | #include "qdrawutil.h" | - |
51 | #include "qevent.h" | - |
52 | #include "qfontmetrics.h" | - |
53 | #include "qstylehints.h" | - |
54 | #include "qmenu.h" | - |
55 | #include "qpainter.h" | - |
56 | #include "qpixmap.h" | - |
57 | #include "qpointer.h" | - |
58 | #include "qstringlist.h" | - |
59 | #include "qstyle.h" | - |
60 | #include "qstyleoption.h" | - |
61 | #include "qtimer.h" | - |
62 | #include "qvalidator.h" | - |
63 | #include "qvariant.h" | - |
64 | #include "qvector.h" | - |
65 | #include "qwhatsthis.h" | - |
66 | #include "qdebug.h" | - |
67 | #include "qtextedit.h" | - |
68 | #include <private/qtextedit_p.h> | - |
69 | #ifndef QT_NO_ACCESSIBILITY | - |
70 | #include "qaccessible.h" | - |
71 | #endif | - |
72 | #include "qabstractitemview.h" | - |
73 | #include "private/qstylesheetstyle_p.h" | - |
74 | | - |
75 | #ifndef QT_NO_SHORTCUT | - |
76 | #include "private/qapplication_p.h" | - |
77 | #include "private/qshortcutmap_p.h" | - |
78 | #include "qkeysequence.h" | - |
79 | #define ACCEL_KEY(k) (!qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? \ | - |
80 | QLatin1Char('\t') + QKeySequence(k).toString(QKeySequence::NativeText) : QString()) | - |
81 | #else | - |
82 | #define ACCEL_KEY(k) QString() | - |
83 | #endif | - |
84 | | - |
85 | #include <limits.h> | - |
86 | #ifdef DrawText | - |
87 | #undef DrawText | - |
88 | #endif | - |
89 | | - |
90 | QT_BEGIN_NAMESPACE | - |
91 | | - |
92 | #ifdef Q_WS_MAC | - |
93 | extern void qt_mac_secure_keyboard(bool); //qapplication_mac.cpp | - |
94 | #endif | - |
95 | | - |
96 | /*! | - |
97 | Initialize \a option with the values from this QLineEdit. This method | - |
98 | is useful for subclasses when they need a QStyleOptionFrame or QStyleOptionFrameV2, but don't want | - |
99 | to fill in all the information themselves. This function will check the version | - |
100 | of the QStyleOptionFrame and fill in the additional values for a | - |
101 | QStyleOptionFrameV2. | - |
102 | | - |
103 | \sa QStyleOption::initFrom() | - |
104 | */ | - |
105 | void QLineEdit::initStyleOption(QStyleOptionFrame *option) const | - |
106 | { | - |
107 | if (!option) partially evaluated: !option no Evaluation Count:0 | yes Evaluation Count:22491 |
| 0-22491 |
108 | return; | 0 |
109 | | - |
110 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
111 | option->initFrom(this); executed (the execution status of this line is deduced): option->initFrom(this); | - |
112 | option->rect = contentsRect(); executed (the execution status of this line is deduced): option->rect = contentsRect(); | - |
113 | option->lineWidth = d->frame ? style()->pixelMetric(QStyle::PM_DefaultFrameWidth, option, this) evaluated: d->frame yes Evaluation Count:5721 | yes Evaluation Count:16770 |
| 5721-16770 |
114 | : 0; executed (the execution status of this line is deduced): : 0; | - |
115 | option->midLineWidth = 0; executed (the execution status of this line is deduced): option->midLineWidth = 0; | - |
116 | option->state |= QStyle::State_Sunken; executed (the execution status of this line is deduced): option->state |= QStyle::State_Sunken; | - |
117 | if (d->control->isReadOnly()) evaluated: d->control->isReadOnly() yes Evaluation Count:64 | yes Evaluation Count:22427 |
| 64-22427 |
118 | option->state |= QStyle::State_ReadOnly; executed: option->state |= QStyle::State_ReadOnly; Execution Count:64 | 64 |
119 | #ifdef QT_KEYPAD_NAVIGATION | - |
120 | if (hasEditFocus()) | - |
121 | option->state |= QStyle::State_HasEditFocus; | - |
122 | #endif | - |
123 | option->features = QStyleOptionFrame::None; executed (the execution status of this line is deduced): option->features = QStyleOptionFrame::None; | - |
124 | } executed: } Execution Count:22491 | 22491 |
125 | | - |
126 | /*! | - |
127 | \class QLineEdit | - |
128 | \brief The QLineEdit widget is a one-line text editor. | - |
129 | | - |
130 | \ingroup basicwidgets | - |
131 | \inmodule QtWidgets | - |
132 | | - |
133 | A line edit allows the user to enter and edit a single line of | - |
134 | plain text with a useful collection of editing functions, | - |
135 | including undo and redo, cut and paste, and drag and drop. | - |
136 | | - |
137 | By changing the echoMode() of a line edit, it can also be used as | - |
138 | a "write-only" field, for inputs such as passwords. | - |
139 | | - |
140 | The length of the text can be constrained to maxLength(). The text | - |
141 | can be arbitrarily constrained using a validator() or an | - |
142 | inputMask(), or both. When switching between a validator and an input mask | - |
143 | on the same line edit, it is best to clear the validator or input mask to | - |
144 | prevent undefined behavior. | - |
145 | | - |
146 | | - |
147 | A related class is QTextEdit which allows multi-line, rich text | - |
148 | editing. | - |
149 | | - |
150 | You can change the text with setText() or insert(). The text is | - |
151 | retrieved with text(); the displayed text (which may be different, | - |
152 | see \l{EchoMode}) is retrieved with displayText(). Text can be | - |
153 | selected with setSelection() or selectAll(), and the selection can | - |
154 | be cut(), copy()ied and paste()d. The text can be aligned with | - |
155 | setAlignment(). | - |
156 | | - |
157 | When the text changes the textChanged() signal is emitted; when | - |
158 | the text changes other than by calling setText() the textEdited() | - |
159 | signal is emitted; when the cursor is moved the | - |
160 | cursorPositionChanged() signal is emitted; and when the Return or | - |
161 | Enter key is pressed the returnPressed() signal is emitted. | - |
162 | | - |
163 | When editing is finished, either because the line edit lost focus | - |
164 | or Return/Enter is pressed the editingFinished() signal is | - |
165 | emitted. | - |
166 | | - |
167 | Note that if there is a validator set on the line edit, the | - |
168 | returnPressed()/editingFinished() signals will only be emitted if | - |
169 | the validator returns QValidator::Acceptable. | - |
170 | | - |
171 | By default, QLineEdits have a frame as specified by platform | - |
172 | style guides; you can turn it off by calling | - |
173 | setFrame(false). | - |
174 | | - |
175 | The default key bindings are described below. The line edit also | - |
176 | provides a context menu (usually invoked by a right mouse click) | - |
177 | that presents some of these editing options. | - |
178 | \target desc | - |
179 | \table | - |
180 | \header \li Keypress \li Action | - |
181 | \row \li Left Arrow \li Moves the cursor one character to the left. | - |
182 | \row \li Shift+Left Arrow \li Moves and selects text one character to the left. | - |
183 | \row \li Right Arrow \li Moves the cursor one character to the right. | - |
184 | \row \li Shift+Right Arrow \li Moves and selects text one character to the right. | - |
185 | \row \li Home \li Moves the cursor to the beginning of the line. | - |
186 | \row \li End \li Moves the cursor to the end of the line. | - |
187 | \row \li Backspace \li Deletes the character to the left of the cursor. | - |
188 | \row \li Ctrl+Backspace \li Deletes the word to the left of the cursor. | - |
189 | \row \li Delete \li Deletes the character to the right of the cursor. | - |
190 | \row \li Ctrl+Delete \li Deletes the word to the right of the cursor. | - |
191 | \row \li Ctrl+A \li Select all. | - |
192 | \row \li Ctrl+C \li Copies the selected text to the clipboard. | - |
193 | \row \li Ctrl+Insert \li Copies the selected text to the clipboard. | - |
194 | \row \li Ctrl+K \li Deletes to the end of the line. | - |
195 | \row \li Ctrl+V \li Pastes the clipboard text into line edit. | - |
196 | \row \li Shift+Insert \li Pastes the clipboard text into line edit. | - |
197 | \row \li Ctrl+X \li Deletes the selected text and copies it to the clipboard. | - |
198 | \row \li Shift+Delete \li Deletes the selected text and copies it to the clipboard. | - |
199 | \row \li Ctrl+Z \li Undoes the last operation. | - |
200 | \row \li Ctrl+Y \li Redoes the last undone operation. | - |
201 | \endtable | - |
202 | | - |
203 | Any other key sequence that represents a valid character, will | - |
204 | cause the character to be inserted into the line edit. | - |
205 | | - |
206 | \table 100% | - |
207 | \row \li \inlineimage macintosh-lineedit.png Screenshot of a Macintosh style line edit | - |
208 | \li A line edit shown in the \l{Macintosh Style Widget Gallery}{Macintosh widget style}. | - |
209 | \row \li \inlineimage windowsvista-lineedit.png Screenshot of a Windows Vista style line edit | - |
210 | \li A line edit shown in the \l{Windows Vista Style Widget Gallery}{Windows Vista widget style}. | - |
211 | \row \li \inlineimage fusion-lineedit.png Screenshot of a Fusion style line edit | - |
212 | \li A line edit shown in the \l{Fusion Style Widget Gallery}{Fusion widget style}. | - |
213 | \endtable | - |
214 | | - |
215 | \sa QTextEdit, QLabel, QComboBox, {fowler}{GUI Design Handbook: Field, Entry}, {Line Edits Example} | - |
216 | */ | - |
217 | | - |
218 | | - |
219 | /*! | - |
220 | \fn void QLineEdit::textChanged(const QString &text) | - |
221 | | - |
222 | This signal is emitted whenever the text changes. The \a text | - |
223 | argument is the new text. | - |
224 | | - |
225 | Unlike textEdited(), this signal is also emitted when the text is | - |
226 | changed programmatically, for example, by calling setText(). | - |
227 | */ | - |
228 | | - |
229 | /*! | - |
230 | \fn void QLineEdit::textEdited(const QString &text) | - |
231 | | - |
232 | This signal is emitted whenever the text is edited. The \a text | - |
233 | argument is the new text. | - |
234 | | - |
235 | Unlike textChanged(), this signal is not emitted when the text is | - |
236 | changed programmatically, for example, by calling setText(). | - |
237 | */ | - |
238 | | - |
239 | /*! | - |
240 | \fn void QLineEdit::cursorPositionChanged(int old, int new) | - |
241 | | - |
242 | This signal is emitted whenever the cursor moves. The previous | - |
243 | position is given by \a old, and the new position by \a new. | - |
244 | | - |
245 | \sa setCursorPosition(), cursorPosition() | - |
246 | */ | - |
247 | | - |
248 | /*! | - |
249 | \fn void QLineEdit::selectionChanged() | - |
250 | | - |
251 | This signal is emitted whenever the selection changes. | - |
252 | | - |
253 | \sa hasSelectedText(), selectedText() | - |
254 | */ | - |
255 | | - |
256 | /*! | - |
257 | Constructs a line edit with no text. | - |
258 | | - |
259 | The maximum text length is set to 32767 characters. | - |
260 | | - |
261 | The \a parent argument is sent to the QWidget constructor. | - |
262 | | - |
263 | \sa setText(), setMaxLength() | - |
264 | */ | - |
265 | QLineEdit::QLineEdit(QWidget* parent) | - |
266 | : QWidget(*new QLineEditPrivate, parent,0) | - |
267 | { | - |
268 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
269 | d->init(QString()); executed (the execution status of this line is deduced): d->init(QString()); | - |
270 | } executed: } Execution Count:1058 | 1058 |
271 | | - |
272 | /*! | - |
273 | Constructs a line edit containing the text \a contents. | - |
274 | | - |
275 | The cursor position is set to the end of the line and the maximum | - |
276 | text length to 32767 characters. | - |
277 | | - |
278 | The \a parent and argument is sent to the QWidget | - |
279 | constructor. | - |
280 | | - |
281 | \sa text(), setMaxLength() | - |
282 | */ | - |
283 | QLineEdit::QLineEdit(const QString& contents, QWidget* parent) | - |
284 | : QWidget(*new QLineEditPrivate, parent, 0) | - |
285 | { | - |
286 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
287 | d->init(contents); executed (the execution status of this line is deduced): d->init(contents); | - |
288 | } executed: } Execution Count:19 | 19 |
289 | | - |
290 | | - |
291 | | - |
292 | /*! | - |
293 | Destroys the line edit. | - |
294 | */ | - |
295 | | - |
296 | QLineEdit::~QLineEdit() | - |
297 | { | - |
298 | } | - |
299 | | - |
300 | | - |
301 | /*! | - |
302 | \property QLineEdit::text | - |
303 | \brief the line edit's text | - |
304 | | - |
305 | Setting this property clears the selection, clears the undo/redo | - |
306 | history, moves the cursor to the end of the line and resets the | - |
307 | \l modified property to false. The text is not validated when | - |
308 | inserted with setText(). | - |
309 | | - |
310 | The text is truncated to maxLength() length. | - |
311 | | - |
312 | By default, this property contains an empty string. | - |
313 | | - |
314 | \sa insert(), clear() | - |
315 | */ | - |
316 | QString QLineEdit::text() const | - |
317 | { | - |
318 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
319 | return d->control->text(); executed: return d->control->text(); Execution Count:37525 | 37525 |
320 | } | - |
321 | | - |
322 | void QLineEdit::setText(const QString& text) | - |
323 | { | - |
324 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
325 | d->control->setText(text); executed (the execution status of this line is deduced): d->control->setText(text); | - |
326 | } executed: } Execution Count:5444 | 5444 |
327 | | - |
328 | /*! | - |
329 | \since 4.7 | - |
330 | | - |
331 | \property QLineEdit::placeholderText | - |
332 | \brief the line edit's placeholder text | - |
333 | | - |
334 | Setting this property makes the line edit display a grayed-out | - |
335 | placeholder text as long as the text() is empty and the widget doesn't | - |
336 | have focus. | - |
337 | | - |
338 | By default, this property contains an empty string. | - |
339 | | - |
340 | \sa text() | - |
341 | */ | - |
342 | QString QLineEdit::placeholderText() const | - |
343 | { | - |
344 | Q_D(const QLineEdit); never executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
345 | return d->placeholderText; never executed: return d->placeholderText; | 0 |
346 | } | - |
347 | | - |
348 | void QLineEdit::setPlaceholderText(const QString& placeholderText) | - |
349 | { | - |
350 | Q_D(QLineEdit); never executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
351 | if (d->placeholderText != placeholderText) { never evaluated: d->placeholderText != placeholderText | 0 |
352 | d->placeholderText = placeholderText; never executed (the execution status of this line is deduced): d->placeholderText = placeholderText; | - |
353 | if (!hasFocus()) never evaluated: !hasFocus() | 0 |
354 | update(); never executed: update(); | 0 |
355 | } | 0 |
356 | } | 0 |
357 | | - |
358 | /*! | - |
359 | \property QLineEdit::displayText | - |
360 | \brief the displayed text | - |
361 | | - |
362 | If \l echoMode is \l Normal this returns the same as text(); if | - |
363 | \l EchoMode is \l Password or \l PasswordEchoOnEdit it returns a string of asterisks | - |
364 | text().length() characters long, e.g. "******"; if \l EchoMode is | - |
365 | \l NoEcho returns an empty string, "". | - |
366 | | - |
367 | By default, this property contains an empty string. | - |
368 | | - |
369 | \sa setEchoMode(), text(), EchoMode | - |
370 | */ | - |
371 | | - |
372 | QString QLineEdit::displayText() const | - |
373 | { | - |
374 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
375 | return d->control->displayText(); executed: return d->control->displayText(); Execution Count:5420 | 5420 |
376 | } | - |
377 | | - |
378 | | - |
379 | /*! | - |
380 | \property QLineEdit::maxLength | - |
381 | \brief the maximum permitted length of the text | - |
382 | | - |
383 | If the text is too long, it is truncated at the limit. | - |
384 | | - |
385 | If truncation occurs any selected text will be unselected, the | - |
386 | cursor position is set to 0 and the first part of the string is | - |
387 | shown. | - |
388 | | - |
389 | If the line edit has an input mask, the mask defines the maximum | - |
390 | string length. | - |
391 | | - |
392 | By default, this property contains a value of 32767. | - |
393 | | - |
394 | \sa inputMask | - |
395 | */ | - |
396 | | - |
397 | int QLineEdit::maxLength() const | - |
398 | { | - |
399 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
400 | return d->control->maxLength(); executed: return d->control->maxLength(); Execution Count:33 | 33 |
401 | } | - |
402 | | - |
403 | void QLineEdit::setMaxLength(int maxLength) | - |
404 | { | - |
405 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
406 | d->control->setMaxLength(maxLength); executed (the execution status of this line is deduced): d->control->setMaxLength(maxLength); | - |
407 | } executed: } Execution Count:358 | 358 |
408 | | - |
409 | /*! | - |
410 | \property QLineEdit::frame | - |
411 | \brief whether the line edit draws itself with a frame | - |
412 | | - |
413 | If enabled (the default) the line edit draws itself inside a | - |
414 | frame, otherwise the line edit draws itself without any frame. | - |
415 | */ | - |
416 | bool QLineEdit::hasFrame() const | - |
417 | { | - |
418 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
419 | return d->frame; executed: return d->frame; Execution Count:51 | 51 |
420 | } | - |
421 | | - |
422 | | - |
423 | void QLineEdit::setFrame(bool enable) | - |
424 | { | - |
425 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
426 | d->frame = enable; executed (the execution status of this line is deduced): d->frame = enable; | - |
427 | update(); executed (the execution status of this line is deduced): update(); | - |
428 | updateGeometry(); executed (the execution status of this line is deduced): updateGeometry(); | - |
429 | } executed: } Execution Count:961 | 961 |
430 | | - |
431 | | - |
432 | /*! | - |
433 | \enum QLineEdit::EchoMode | - |
434 | | - |
435 | This enum type describes how a line edit should display its | - |
436 | contents. | - |
437 | | - |
438 | \value Normal Display characters as they are entered. This is the | - |
439 | default. | - |
440 | \value NoEcho Do not display anything. This may be appropriate | - |
441 | for passwords where even the length of the | - |
442 | password should be kept secret. | - |
443 | \value Password Display asterisks instead of the characters | - |
444 | actually entered. | - |
445 | \value PasswordEchoOnEdit Display characters as they are entered | - |
446 | while editing otherwise display asterisks. | - |
447 | | - |
448 | \sa setEchoMode(), echoMode() | - |
449 | */ | - |
450 | | - |
451 | | - |
452 | /*! | - |
453 | \property QLineEdit::echoMode | - |
454 | \brief the line edit's echo mode | - |
455 | | - |
456 | The echo mode determines how the text entered in the line edit is | - |
457 | displayed (or echoed) to the user. | - |
458 | | - |
459 | The most common setting is \l Normal, in which the text entered by the | - |
460 | user is displayed verbatim, but QLineEdit also supports modes that allow | - |
461 | the entered text to be suppressed or obscured: these include \l NoEcho, | - |
462 | \l Password and \l PasswordEchoOnEdit. | - |
463 | | - |
464 | The widget's display and the ability to copy or drag the text is | - |
465 | affected by this setting. | - |
466 | | - |
467 | By default, this property is set to \l Normal. | - |
468 | | - |
469 | \sa EchoMode, displayText() | - |
470 | */ | - |
471 | | - |
472 | QLineEdit::EchoMode QLineEdit::echoMode() const | - |
473 | { | - |
474 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
475 | return (EchoMode) d->control->echoMode(); executed: return (EchoMode) d->control->echoMode(); Execution Count:178 | 178 |
476 | } | - |
477 | | - |
478 | void QLineEdit::setEchoMode(EchoMode mode) | - |
479 | { | - |
480 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
481 | if (mode == (EchoMode)d->control->echoMode()) evaluated: mode == (EchoMode)d->control->echoMode() yes Evaluation Count:315 | yes Evaluation Count:65 |
| 65-315 |
482 | return; executed: return; Execution Count:315 | 315 |
483 | Qt::InputMethodHints imHints = inputMethodHints(); executed (the execution status of this line is deduced): Qt::InputMethodHints imHints = inputMethodHints(); | - |
484 | if (mode == Password || mode == NoEcho) { evaluated: mode == Password yes Evaluation Count:14 | yes Evaluation Count:51 |
evaluated: mode == NoEcho yes Evaluation Count:14 | yes Evaluation Count:37 |
| 14-51 |
485 | imHints |= Qt::ImhHiddenText; executed (the execution status of this line is deduced): imHints |= Qt::ImhHiddenText; | - |
486 | } else { executed: } Execution Count:28 | 28 |
487 | imHints &= ~Qt::ImhHiddenText; executed (the execution status of this line is deduced): imHints &= ~Qt::ImhHiddenText; | - |
488 | } executed: } Execution Count:37 | 37 |
489 | if (mode != Normal) { evaluated: mode != Normal yes Evaluation Count:34 | yes Evaluation Count:31 |
| 31-34 |
490 | imHints |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData); executed (the execution status of this line is deduced): imHints |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData); | - |
491 | } else { executed: } Execution Count:34 | 34 |
492 | imHints &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData); executed (the execution status of this line is deduced): imHints &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData); | - |
493 | } executed: } Execution Count:31 | 31 |
494 | setInputMethodHints(imHints); executed (the execution status of this line is deduced): setInputMethodHints(imHints); | - |
495 | d->control->setEchoMode(mode); executed (the execution status of this line is deduced): d->control->setEchoMode(mode); | - |
496 | update(); executed (the execution status of this line is deduced): update(); | - |
497 | #ifdef Q_WS_MAC | - |
498 | if (hasFocus()) | - |
499 | qt_mac_secure_keyboard(mode == Password || mode == NoEcho); | - |
500 | #endif | - |
501 | } executed: } Execution Count:65 | 65 |
502 | | - |
503 | | - |
504 | #ifndef QT_NO_VALIDATOR | - |
505 | /*! | - |
506 | Returns a pointer to the current input validator, or 0 if no | - |
507 | validator has been set. | - |
508 | | - |
509 | \sa setValidator() | - |
510 | */ | - |
511 | | - |
512 | const QValidator * QLineEdit::validator() const | - |
513 | { | - |
514 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
515 | return d->control->validator(); executed: return d->control->validator(); Execution Count:403 | 403 |
516 | } | - |
517 | | - |
518 | /*! | - |
519 | Sets this line edit to only accept input that the validator, \a v, | - |
520 | will accept. This allows you to place any arbitrary constraints on | - |
521 | the text which may be entered. | - |
522 | | - |
523 | If \a v == 0, setValidator() removes the current input validator. | - |
524 | The initial setting is to have no input validator (i.e. any input | - |
525 | is accepted up to maxLength()). | - |
526 | | - |
527 | \sa validator(), QIntValidator, QDoubleValidator, QRegExpValidator | - |
528 | */ | - |
529 | | - |
530 | void QLineEdit::setValidator(const QValidator *v) | - |
531 | { | - |
532 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
533 | d->control->setValidator(v); executed (the execution status of this line is deduced): d->control->setValidator(v); | - |
534 | } executed: } Execution Count:1154 | 1154 |
535 | #endif // QT_NO_VALIDATOR | - |
536 | | - |
537 | #ifndef QT_NO_COMPLETER | - |
538 | /*! | - |
539 | \since 4.2 | - |
540 | | - |
541 | Sets this line edit to provide auto completions from the completer, \a c. | - |
542 | The completion mode is set using QCompleter::setCompletionMode(). | - |
543 | | - |
544 | To use a QCompleter with a QValidator or QLineEdit::inputMask, you need to | - |
545 | ensure that the model provided to QCompleter contains valid entries. You can | - |
546 | use the QSortFilterProxyModel to ensure that the QCompleter's model contains | - |
547 | only valid entries. | - |
548 | | - |
549 | If \a c == 0, setCompleter() removes the current completer, effectively | - |
550 | disabling auto completion. | - |
551 | | - |
552 | \sa QCompleter | - |
553 | */ | - |
554 | void QLineEdit::setCompleter(QCompleter *c) | - |
555 | { | - |
556 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
557 | if (c == d->control->completer()) partially evaluated: c == d->control->completer() no Evaluation Count:0 | yes Evaluation Count:357 |
| 0-357 |
558 | return; | 0 |
559 | if (d->control->completer()) { evaluated: d->control->completer() yes Evaluation Count:2 | yes Evaluation Count:355 |
| 2-355 |
560 | disconnect(d->control->completer(), 0, this, 0); executed (the execution status of this line is deduced): disconnect(d->control->completer(), 0, this, 0); | - |
561 | d->control->completer()->setWidget(0); executed (the execution status of this line is deduced): d->control->completer()->setWidget(0); | - |
562 | if (d->control->completer()->parent() == this) partially evaluated: d->control->completer()->parent() == this yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
563 | delete d->control->completer(); executed: delete d->control->completer(); Execution Count:2 | 2 |
564 | } executed: } Execution Count:2 | 2 |
565 | d->control->setCompleter(c); executed (the execution status of this line is deduced): d->control->setCompleter(c); | - |
566 | if (!c) partially evaluated: !c no Evaluation Count:0 | yes Evaluation Count:357 |
| 0-357 |
567 | return; | 0 |
568 | if (c->widget() == 0) evaluated: c->widget() == 0 yes Evaluation Count:355 | yes Evaluation Count:2 |
| 2-355 |
569 | c->setWidget(this); executed: c->setWidget(this); Execution Count:355 | 355 |
570 | if (hasFocus()) { evaluated: hasFocus() yes Evaluation Count:1 | yes Evaluation Count:356 |
| 1-356 |
571 | QObject::connect(d->control->completer(), SIGNAL(activated(QString)), executed (the execution status of this line is deduced): QObject::connect(d->control->completer(), "2""activated(QString)", | - |
572 | this, SLOT(setText(QString))); executed (the execution status of this line is deduced): this, "1""setText(QString)"); | - |
573 | QObject::connect(d->control->completer(), SIGNAL(highlighted(QString)), executed (the execution status of this line is deduced): QObject::connect(d->control->completer(), "2""highlighted(QString)", | - |
574 | this, SLOT(_q_completionHighlighted(QString))); executed (the execution status of this line is deduced): this, "1""_q_completionHighlighted(QString)"); | - |
575 | } executed: } Execution Count:1 | 1 |
576 | } executed: } Execution Count:357 | 357 |
577 | | - |
578 | /*! | - |
579 | \since 4.2 | - |
580 | | - |
581 | Returns the current QCompleter that provides completions. | - |
582 | */ | - |
583 | QCompleter *QLineEdit::completer() const | - |
584 | { | - |
585 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
586 | return d->control->completer(); executed: return d->control->completer(); Execution Count:657 | 657 |
587 | } | - |
588 | | - |
589 | #endif // QT_NO_COMPLETER | - |
590 | | - |
591 | /*! | - |
592 | Returns a recommended size for the widget. | - |
593 | | - |
594 | The width returned, in pixels, is usually enough for about 15 to | - |
595 | 20 characters. | - |
596 | */ | - |
597 | | - |
598 | QSize QLineEdit::sizeHint() const | - |
599 | { | - |
600 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
601 | ensurePolished(); executed (the execution status of this line is deduced): ensurePolished(); | - |
602 | QFontMetrics fm(font()); executed (the execution status of this line is deduced): QFontMetrics fm(font()); | - |
603 | int h = qMax(fm.height(), 14) + 2*d->verticalMargin executed (the execution status of this line is deduced): int h = qMax(fm.height(), 14) + 2*d->verticalMargin | - |
604 | + d->topTextMargin + d->bottomTextMargin executed (the execution status of this line is deduced): + d->topTextMargin + d->bottomTextMargin | - |
605 | + d->topmargin + d->bottommargin; executed (the execution status of this line is deduced): + d->topmargin + d->bottommargin; | - |
606 | int w = fm.width(QLatin1Char('x')) * 17 + 2*d->horizontalMargin executed (the execution status of this line is deduced): int w = fm.width(QLatin1Char('x')) * 17 + 2*d->horizontalMargin | - |
607 | + d->leftTextMargin + d->rightTextMargin executed (the execution status of this line is deduced): + d->leftTextMargin + d->rightTextMargin | - |
608 | + d->leftmargin + d->rightmargin; // "some" executed (the execution status of this line is deduced): + d->leftmargin + d->rightmargin; | - |
609 | QStyleOptionFrameV2 opt; executed (the execution status of this line is deduced): QStyleOptionFrameV2 opt; | - |
610 | initStyleOption(&opt); executed (the execution status of this line is deduced): initStyleOption(&opt); | - |
611 | return (style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(w, h). executed: return (style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(w, h). expandedTo(QApplication::globalStrut()), this)); Execution Count:1078 | 1078 |
612 | expandedTo(QApplication::globalStrut()), this)); executed: return (style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(w, h). expandedTo(QApplication::globalStrut()), this)); Execution Count:1078 | 1078 |
613 | } | - |
614 | | - |
615 | | - |
616 | /*! | - |
617 | Returns a minimum size for the line edit. | - |
618 | | - |
619 | The width returned is enough for at least one character. | - |
620 | */ | - |
621 | | - |
622 | QSize QLineEdit::minimumSizeHint() const | - |
623 | { | - |
624 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
625 | ensurePolished(); executed (the execution status of this line is deduced): ensurePolished(); | - |
626 | QFontMetrics fm = fontMetrics(); executed (the execution status of this line is deduced): QFontMetrics fm = fontMetrics(); | - |
627 | int h = fm.height() + qMax(2*d->verticalMargin, fm.leading()) executed (the execution status of this line is deduced): int h = fm.height() + qMax(2*d->verticalMargin, fm.leading()) | - |
628 | + d->topmargin + d->bottommargin; executed (the execution status of this line is deduced): + d->topmargin + d->bottommargin; | - |
629 | int w = fm.maxWidth() + d->leftmargin + d->rightmargin; executed (the execution status of this line is deduced): int w = fm.maxWidth() + d->leftmargin + d->rightmargin; | - |
630 | QStyleOptionFrameV2 opt; executed (the execution status of this line is deduced): QStyleOptionFrameV2 opt; | - |
631 | initStyleOption(&opt); executed (the execution status of this line is deduced): initStyleOption(&opt); | - |
632 | return (style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(w, h). executed: return (style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(w, h). expandedTo(QApplication::globalStrut()), this)); Execution Count:359 | 359 |
633 | expandedTo(QApplication::globalStrut()), this)); executed: return (style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(w, h). expandedTo(QApplication::globalStrut()), this)); Execution Count:359 | 359 |
634 | } | - |
635 | | - |
636 | | - |
637 | /*! | - |
638 | \property QLineEdit::cursorPosition | - |
639 | \brief the current cursor position for this line edit | - |
640 | | - |
641 | Setting the cursor position causes a repaint when appropriate. | - |
642 | | - |
643 | By default, this property contains a value of 0. | - |
644 | */ | - |
645 | | - |
646 | int QLineEdit::cursorPosition() const | - |
647 | { | - |
648 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
649 | return d->control->cursorPosition(); executed: return d->control->cursorPosition(); Execution Count:8250 | 8250 |
650 | } | - |
651 | | - |
652 | void QLineEdit::setCursorPosition(int pos) | - |
653 | { | - |
654 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
655 | d->control->setCursorPosition(pos); executed (the execution status of this line is deduced): d->control->setCursorPosition(pos); | - |
656 | } executed: } Execution Count:2377 | 2377 |
657 | | - |
658 | /*! | - |
659 | Returns the cursor position under the point \a pos. | - |
660 | */ | - |
661 | // ### What should this do if the point is outside of contentsRect? Currently returns 0. | - |
662 | int QLineEdit::cursorPositionAt(const QPoint &pos) | - |
663 | { | - |
664 | Q_D(QLineEdit); never executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
665 | return d->xToPos(pos.x()); never executed: return d->xToPos(pos.x()); | 0 |
666 | } | - |
667 | | - |
668 | | - |
669 | | - |
670 | /*! | - |
671 | \property QLineEdit::alignment | - |
672 | \brief the alignment of the line edit | - |
673 | | - |
674 | Both horizontal and vertical alignment is allowed here, Qt::AlignJustify | - |
675 | will map to Qt::AlignLeft. | - |
676 | | - |
677 | By default, this property contains a combination of Qt::AlignLeft and Qt::AlignVCenter. | - |
678 | | - |
679 | \sa Qt::Alignment | - |
680 | */ | - |
681 | | - |
682 | Qt::Alignment QLineEdit::alignment() const | - |
683 | { | - |
684 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
685 | return QFlag(d->alignment); executed: return QFlag(d->alignment); Execution Count:7 | 7 |
686 | } | - |
687 | | - |
688 | void QLineEdit::setAlignment(Qt::Alignment alignment) | - |
689 | { | - |
690 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
691 | d->alignment = alignment; executed (the execution status of this line is deduced): d->alignment = alignment; | - |
692 | update(); executed (the execution status of this line is deduced): update(); | - |
693 | } executed: } Execution Count:10 | 10 |
694 | | - |
695 | | - |
696 | /*! | - |
697 | Moves the cursor forward \a steps characters. If \a mark is true | - |
698 | each character moved over is added to the selection; if \a mark is | - |
699 | false the selection is cleared. | - |
700 | | - |
701 | \sa cursorBackward() | - |
702 | */ | - |
703 | | - |
704 | void QLineEdit::cursorForward(bool mark, int steps) | - |
705 | { | - |
706 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
707 | d->control->cursorForward(mark, steps); executed (the execution status of this line is deduced): d->control->cursorForward(mark, steps); | - |
708 | } executed: } Execution Count:12 | 12 |
709 | | - |
710 | | - |
711 | /*! | - |
712 | Moves the cursor back \a steps characters. If \a mark is true each | - |
713 | character moved over is added to the selection; if \a mark is | - |
714 | false the selection is cleared. | - |
715 | | - |
716 | \sa cursorForward() | - |
717 | */ | - |
718 | void QLineEdit::cursorBackward(bool mark, int steps) | - |
719 | { | - |
720 | cursorForward(mark, -steps); executed (the execution status of this line is deduced): cursorForward(mark, -steps); | - |
721 | } executed: } Execution Count:5 | 5 |
722 | | - |
723 | /*! | - |
724 | Moves the cursor one word forward. If \a mark is true, the word is | - |
725 | also selected. | - |
726 | | - |
727 | \sa cursorWordBackward() | - |
728 | */ | - |
729 | void QLineEdit::cursorWordForward(bool mark) | - |
730 | { | - |
731 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
732 | d->control->cursorWordForward(mark); executed (the execution status of this line is deduced): d->control->cursorWordForward(mark); | - |
733 | } executed: } Execution Count:3 | 3 |
734 | | - |
735 | /*! | - |
736 | Moves the cursor one word backward. If \a mark is true, the word | - |
737 | is also selected. | - |
738 | | - |
739 | \sa cursorWordForward() | - |
740 | */ | - |
741 | | - |
742 | void QLineEdit::cursorWordBackward(bool mark) | - |
743 | { | - |
744 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
745 | d->control->cursorWordBackward(mark); executed (the execution status of this line is deduced): d->control->cursorWordBackward(mark); | - |
746 | } executed: } Execution Count:6 | 6 |
747 | | - |
748 | | - |
749 | /*! | - |
750 | If no text is selected, deletes the character to the left of the | - |
751 | text cursor and moves the cursor one position to the left. If any | - |
752 | text is selected, the cursor is moved to the beginning of the | - |
753 | selected text and the selected text is deleted. | - |
754 | | - |
755 | \sa del() | - |
756 | */ | - |
757 | void QLineEdit::backspace() | - |
758 | { | - |
759 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
760 | d->control->backspace(); executed (the execution status of this line is deduced): d->control->backspace(); | - |
761 | } executed: } Execution Count:8 | 8 |
762 | | - |
763 | /*! | - |
764 | If no text is selected, deletes the character to the right of the | - |
765 | text cursor. If any text is selected, the cursor is moved to the | - |
766 | beginning of the selected text and the selected text is deleted. | - |
767 | | - |
768 | \sa backspace() | - |
769 | */ | - |
770 | | - |
771 | void QLineEdit::del() | - |
772 | { | - |
773 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
774 | d->control->del(); executed (the execution status of this line is deduced): d->control->del(); | - |
775 | } executed: } Execution Count:6 | 6 |
776 | | - |
777 | /*! | - |
778 | Moves the text cursor to the beginning of the line unless it is | - |
779 | already there. If \a mark is true, text is selected towards the | - |
780 | first position; otherwise, any selected text is unselected if the | - |
781 | cursor is moved. | - |
782 | | - |
783 | \sa end() | - |
784 | */ | - |
785 | | - |
786 | void QLineEdit::home(bool mark) | - |
787 | { | - |
788 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
789 | d->control->home(mark); executed (the execution status of this line is deduced): d->control->home(mark); | - |
790 | } executed: } Execution Count:6 | 6 |
791 | | - |
792 | /*! | - |
793 | Moves the text cursor to the end of the line unless it is already | - |
794 | there. If \a mark is true, text is selected towards the last | - |
795 | position; otherwise, any selected text is unselected if the cursor | - |
796 | is moved. | - |
797 | | - |
798 | \sa home() | - |
799 | */ | - |
800 | | - |
801 | void QLineEdit::end(bool mark) | - |
802 | { | - |
803 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
804 | d->control->end(mark); executed (the execution status of this line is deduced): d->control->end(mark); | - |
805 | } executed: } Execution Count:6 | 6 |
806 | | - |
807 | | - |
808 | /*! | - |
809 | \property QLineEdit::modified | - |
810 | \brief whether the line edit's contents has been modified by the user | - |
811 | | - |
812 | The modified flag is never read by QLineEdit; it has a default value | - |
813 | of false and is changed to true whenever the user changes the line | - |
814 | edit's contents. | - |
815 | | - |
816 | This is useful for things that need to provide a default value but | - |
817 | do not start out knowing what the default should be (perhaps it | - |
818 | depends on other fields on the form). Start the line edit without | - |
819 | the best default, and when the default is known, if modified() | - |
820 | returns false (the user hasn't entered any text), insert the | - |
821 | default value. | - |
822 | | - |
823 | Calling setText() resets the modified flag to false. | - |
824 | */ | - |
825 | | - |
826 | bool QLineEdit::isModified() const | - |
827 | { | - |
828 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
829 | return d->control->isModified(); executed: return d->control->isModified(); Execution Count:26 | 26 |
830 | } | - |
831 | | - |
832 | void QLineEdit::setModified(bool modified) | - |
833 | { | - |
834 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
835 | d->control->setModified(modified); executed (the execution status of this line is deduced): d->control->setModified(modified); | - |
836 | } executed: } Execution Count:2 | 2 |
837 | | - |
838 | /*! | - |
839 | \property QLineEdit::hasSelectedText | - |
840 | \brief whether there is any text selected | - |
841 | | - |
842 | hasSelectedText() returns true if some or all of the text has been | - |
843 | selected by the user; otherwise returns false. | - |
844 | | - |
845 | By default, this property is false. | - |
846 | | - |
847 | \sa selectedText() | - |
848 | */ | - |
849 | | - |
850 | | - |
851 | bool QLineEdit::hasSelectedText() const | - |
852 | { | - |
853 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
854 | return d->control->hasSelectedText(); executed: return d->control->hasSelectedText(); Execution Count:6293 | 6293 |
855 | } | - |
856 | | - |
857 | /*! | - |
858 | \property QLineEdit::selectedText | - |
859 | \brief the selected text | - |
860 | | - |
861 | If there is no selected text this property's value is | - |
862 | an empty string. | - |
863 | | - |
864 | By default, this property contains an empty string. | - |
865 | | - |
866 | \sa hasSelectedText() | - |
867 | */ | - |
868 | | - |
869 | QString QLineEdit::selectedText() const | - |
870 | { | - |
871 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
872 | return d->control->selectedText(); executed: return d->control->selectedText(); Execution Count:3613 | 3613 |
873 | } | - |
874 | | - |
875 | /*! | - |
876 | selectionStart() returns the index of the first selected character in the | - |
877 | line edit or -1 if no text is selected. | - |
878 | | - |
879 | \sa selectedText() | - |
880 | */ | - |
881 | | - |
882 | int QLineEdit::selectionStart() const | - |
883 | { | - |
884 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
885 | return d->control->selectionStart(); executed: return d->control->selectionStart(); Execution Count:2480 | 2480 |
886 | } | - |
887 | | - |
888 | | - |
889 | | - |
890 | | - |
891 | /*! | - |
892 | Selects text from position \a start and for \a length characters. | - |
893 | Negative lengths are allowed. | - |
894 | | - |
895 | \sa deselect(), selectAll(), selectedText() | - |
896 | */ | - |
897 | | - |
898 | void QLineEdit::setSelection(int start, int length) | - |
899 | { | - |
900 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
901 | if (start < 0 || start > (int)d->control->end()) { evaluated: start < 0 yes Evaluation Count:2 | yes Evaluation Count:3985 |
partially evaluated: start > (int)d->control->end() no Evaluation Count:0 | yes Evaluation Count:3985 |
| 0-3985 |
902 | qWarning("QLineEdit::setSelection: Invalid start position (%d)", start); executed (the execution status of this line is deduced): QMessageLogger("widgets/qlineedit.cpp", 902, __PRETTY_FUNCTION__).warning("QLineEdit::setSelection: Invalid start position (%d)", start); | - |
903 | return; executed: return; Execution Count:2 | 2 |
904 | } | - |
905 | | - |
906 | d->control->setSelection(start, length); executed (the execution status of this line is deduced): d->control->setSelection(start, length); | - |
907 | | - |
908 | if (d->control->hasSelectedText()){ evaluated: d->control->hasSelectedText() yes Evaluation Count:3970 | yes Evaluation Count:15 |
| 15-3970 |
909 | QStyleOptionFrameV2 opt; executed (the execution status of this line is deduced): QStyleOptionFrameV2 opt; | - |
910 | initStyleOption(&opt); executed (the execution status of this line is deduced): initStyleOption(&opt); | - |
911 | if (!style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, this)) partially evaluated: !style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, this) no Evaluation Count:0 | yes Evaluation Count:3970 |
| 0-3970 |
912 | d->setCursorVisible(false); never executed: d->setCursorVisible(false); | 0 |
913 | } executed: } Execution Count:3970 | 3970 |
914 | } executed: } Execution Count:3985 | 3985 |
915 | | - |
916 | | - |
917 | /*! | - |
918 | \property QLineEdit::undoAvailable | - |
919 | \brief whether undo is available | - |
920 | | - |
921 | Undo becomes available once the user has modified the text in the line edit. | - |
922 | | - |
923 | By default, this property is false. | - |
924 | */ | - |
925 | | - |
926 | bool QLineEdit::isUndoAvailable() const | - |
927 | { | - |
928 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
929 | return d->control->isUndoAvailable(); executed: return d->control->isUndoAvailable(); Execution Count:59 | 59 |
930 | } | - |
931 | | - |
932 | /*! | - |
933 | \property QLineEdit::redoAvailable | - |
934 | \brief whether redo is available | - |
935 | | - |
936 | Redo becomes available once the user has performed one or more undo operations | - |
937 | on text in the line edit. | - |
938 | | - |
939 | By default, this property is false. | - |
940 | */ | - |
941 | | - |
942 | bool QLineEdit::isRedoAvailable() const | - |
943 | { | - |
944 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
945 | return d->control->isRedoAvailable(); executed: return d->control->isRedoAvailable(); Execution Count:26 | 26 |
946 | } | - |
947 | | - |
948 | /*! | - |
949 | \property QLineEdit::dragEnabled | - |
950 | \brief whether the lineedit starts a drag if the user presses and | - |
951 | moves the mouse on some selected text | - |
952 | | - |
953 | Dragging is disabled by default. | - |
954 | */ | - |
955 | | - |
956 | bool QLineEdit::dragEnabled() const | - |
957 | { | - |
958 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
959 | return d->dragEnabled; executed: return d->dragEnabled; Execution Count:2 | 2 |
960 | } | - |
961 | | - |
962 | void QLineEdit::setDragEnabled(bool b) | - |
963 | { | - |
964 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
965 | d->dragEnabled = b; executed (the execution status of this line is deduced): d->dragEnabled = b; | - |
966 | } executed: } Execution Count:323 | 323 |
967 | | - |
968 | | - |
969 | /*! | - |
970 | \property QLineEdit::cursorMoveStyle | - |
971 | \brief the movement style of cursor in this line edit | - |
972 | \since 4.8 | - |
973 | | - |
974 | When this property is set to Qt::VisualMoveStyle, the line edit will use visual | - |
975 | movement style. Pressing the left arrow key will always cause the cursor to move | - |
976 | left, regardless of the text's writing direction. The same behavior applies to | - |
977 | right arrow key. | - |
978 | | - |
979 | When the property is Qt::LogicalMoveStyle (the default), within a LTR text block, | - |
980 | increase cursor position when pressing left arrow key, decrease cursor position | - |
981 | when pressing the right arrow key. If the text block is right to left, the opposite | - |
982 | behavior applies. | - |
983 | */ | - |
984 | | - |
985 | Qt::CursorMoveStyle QLineEdit::cursorMoveStyle() const | - |
986 | { | - |
987 | Q_D(const QLineEdit); never executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
988 | return d->control->cursorMoveStyle(); never executed: return d->control->cursorMoveStyle(); | 0 |
989 | } | - |
990 | | - |
991 | void QLineEdit::setCursorMoveStyle(Qt::CursorMoveStyle style) | - |
992 | { | - |
993 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
994 | d->control->setCursorMoveStyle(style); executed (the execution status of this line is deduced): d->control->setCursorMoveStyle(style); | - |
995 | } executed: } Execution Count:16 | 16 |
996 | | - |
997 | /*! | - |
998 | \property QLineEdit::acceptableInput | - |
999 | \brief whether the input satisfies the inputMask and the | - |
1000 | validator. | - |
1001 | | - |
1002 | By default, this property is true. | - |
1003 | | - |
1004 | \sa setInputMask(), setValidator() | - |
1005 | */ | - |
1006 | bool QLineEdit::hasAcceptableInput() const | - |
1007 | { | - |
1008 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
1009 | return d->control->hasAcceptableInput(); executed: return d->control->hasAcceptableInput(); Execution Count:2285 | 2285 |
1010 | } | - |
1011 | | - |
1012 | /*! | - |
1013 | Sets the margins around the text inside the frame to have the | - |
1014 | sizes \a left, \a top, \a right, and \a bottom. | - |
1015 | \since 4.5 | - |
1016 | | - |
1017 | See also getTextMargins(). | - |
1018 | */ | - |
1019 | void QLineEdit::setTextMargins(int left, int top, int right, int bottom) | - |
1020 | { | - |
1021 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
1022 | d->leftTextMargin = left; executed (the execution status of this line is deduced): d->leftTextMargin = left; | - |
1023 | d->topTextMargin = top; executed (the execution status of this line is deduced): d->topTextMargin = top; | - |
1024 | d->rightTextMargin = right; executed (the execution status of this line is deduced): d->rightTextMargin = right; | - |
1025 | d->bottomTextMargin = bottom; executed (the execution status of this line is deduced): d->bottomTextMargin = bottom; | - |
1026 | updateGeometry(); executed (the execution status of this line is deduced): updateGeometry(); | - |
1027 | update(); executed (the execution status of this line is deduced): update(); | - |
1028 | } executed: } Execution Count:9 | 9 |
1029 | | - |
1030 | /*! | - |
1031 | \since 4.6 | - |
1032 | Sets the \a margins around the text inside the frame. | - |
1033 | | - |
1034 | See also textMargins(). | - |
1035 | */ | - |
1036 | void QLineEdit::setTextMargins(const QMargins &margins) | - |
1037 | { | - |
1038 | setTextMargins(margins.left(), margins.top(), margins.right(), margins.bottom()); never executed (the execution status of this line is deduced): setTextMargins(margins.left(), margins.top(), margins.right(), margins.bottom()); | - |
1039 | } | 0 |
1040 | | - |
1041 | /*! | - |
1042 | Returns the widget's text margins for \a left, \a top, \a right, and \a bottom. | - |
1043 | \since 4.5 | - |
1044 | | - |
1045 | \sa setTextMargins() | - |
1046 | */ | - |
1047 | void QLineEdit::getTextMargins(int *left, int *top, int *right, int *bottom) const | - |
1048 | { | - |
1049 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
1050 | if (left) evaluated: left yes Evaluation Count:94 | yes Evaluation Count:10 |
| 10-94 |
1051 | *left = d->leftTextMargin; executed: *left = d->leftTextMargin; Execution Count:94 | 94 |
1052 | if (top) evaluated: top yes Evaluation Count:19 | yes Evaluation Count:85 |
| 19-85 |
1053 | *top = d->topTextMargin; executed: *top = d->topTextMargin; Execution Count:19 | 19 |
1054 | if (right) evaluated: right yes Evaluation Count:94 | yes Evaluation Count:10 |
| 10-94 |
1055 | *right = d->rightTextMargin; executed: *right = d->rightTextMargin; Execution Count:94 | 94 |
1056 | if (bottom) evaluated: bottom yes Evaluation Count:9 | yes Evaluation Count:95 |
| 9-95 |
1057 | *bottom = d->bottomTextMargin; executed: *bottom = d->bottomTextMargin; Execution Count:9 | 9 |
1058 | } executed: } Execution Count:104 | 104 |
1059 | | - |
1060 | /*! | - |
1061 | \since 4.6 | - |
1062 | Returns the widget's text margins. | - |
1063 | | - |
1064 | \sa setTextMargins() | - |
1065 | */ | - |
1066 | QMargins QLineEdit::textMargins() const | - |
1067 | { | - |
1068 | Q_D(const QLineEdit); never executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
1069 | return QMargins(d->leftTextMargin, d->topTextMargin, d->rightTextMargin, d->bottomTextMargin); never executed: return QMargins(d->leftTextMargin, d->topTextMargin, d->rightTextMargin, d->bottomTextMargin); | 0 |
1070 | } | - |
1071 | | - |
1072 | /*! | - |
1073 | \property QLineEdit::inputMask | - |
1074 | \brief The validation input mask | - |
1075 | | - |
1076 | If no mask is set, inputMask() returns an empty string. | - |
1077 | | - |
1078 | Sets the QLineEdit's validation mask. Validators can be used | - |
1079 | instead of, or in conjunction with masks; see setValidator(). | - |
1080 | | - |
1081 | Unset the mask and return to normal QLineEdit operation by passing | - |
1082 | an empty string (""). | - |
1083 | | - |
1084 | The table below shows the characters that can be used in an input mask. | - |
1085 | A space character, the default character for a blank, is needed for cases | - |
1086 | where a character is \e{permitted but not required}. | - |
1087 | | - |
1088 | \table | - |
1089 | \header \li Character \li Meaning | - |
1090 | \row \li \c A \li ASCII alphabetic character required. A-Z, a-z. | - |
1091 | \row \li \c a \li ASCII alphabetic character permitted but not required. | - |
1092 | \row \li \c N \li ASCII alphanumeric character required. A-Z, a-z, 0-9. | - |
1093 | \row \li \c n \li ASCII alphanumeric character permitted but not required. | - |
1094 | \row \li \c X \li Any character required. | - |
1095 | \row \li \c x \li Any character permitted but not required. | - |
1096 | \row \li \c 9 \li ASCII digit required. 0-9. | - |
1097 | \row \li \c 0 \li ASCII digit permitted but not required. | - |
1098 | \row \li \c D \li ASCII digit required. 1-9. | - |
1099 | \row \li \c d \li ASCII digit permitted but not required (1-9). | - |
1100 | \row \li \c # \li ASCII digit or plus/minus sign permitted but not required. | - |
1101 | \row \li \c H \li Hexadecimal character required. A-F, a-f, 0-9. | - |
1102 | \row \li \c h \li Hexadecimal character permitted but not required. | - |
1103 | \row \li \c B \li Binary character required. 0-1. | - |
1104 | \row \li \c b \li Binary character permitted but not required. | - |
1105 | \row \li \c > \li All following alphabetic characters are uppercased. | - |
1106 | \row \li \c < \li All following alphabetic characters are lowercased. | - |
1107 | \row \li \c ! \li Switch off case conversion. | - |
1108 | \row \li \tt{\\} \li Use \tt{\\} to escape the special | - |
1109 | characters listed above to use them as | - |
1110 | separators. | - |
1111 | \endtable | - |
1112 | | - |
1113 | The mask consists of a string of mask characters and separators, | - |
1114 | optionally followed by a semicolon and the character used for | - |
1115 | blanks. The blank characters are always removed from the text | - |
1116 | after editing. | - |
1117 | | - |
1118 | Examples: | - |
1119 | \table | - |
1120 | \header \li Mask \li Notes | - |
1121 | \row \li \c 000.000.000.000;_ \li IP address; blanks are \c{_}. | - |
1122 | \row \li \c HH:HH:HH:HH:HH:HH;_ \li MAC address | - |
1123 | \row \li \c 0000-00-00 \li ISO Date; blanks are \c space | - |
1124 | \row \li \c >AAAAA-AAAAA-AAAAA-AAAAA-AAAAA;# \li License number; | - |
1125 | blanks are \c - and all (alphabetic) characters are converted to | - |
1126 | uppercase. | - |
1127 | \endtable | - |
1128 | | - |
1129 | To get range control (e.g., for an IP address) use masks together | - |
1130 | with \l{setValidator()}{validators}. | - |
1131 | | - |
1132 | \sa maxLength | - |
1133 | */ | - |
1134 | QString QLineEdit::inputMask() const | - |
1135 | { | - |
1136 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
1137 | return d->control->inputMask(); executed: return d->control->inputMask(); Execution Count:16 | 16 |
1138 | } | - |
1139 | | - |
1140 | void QLineEdit::setInputMask(const QString &inputMask) | - |
1141 | { | - |
1142 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
1143 | d->control->setInputMask(inputMask); executed (the execution status of this line is deduced): d->control->setInputMask(inputMask); | - |
1144 | } executed: } Execution Count:436 | 436 |
1145 | | - |
1146 | /*! | - |
1147 | Selects all the text (i.e. highlights it) and moves the cursor to | - |
1148 | the end. This is useful when a default value has been inserted | - |
1149 | because if the user types before clicking on the widget, the | - |
1150 | selected text will be deleted. | - |
1151 | | - |
1152 | \sa setSelection(), deselect() | - |
1153 | */ | - |
1154 | | - |
1155 | void QLineEdit::selectAll() | - |
1156 | { | - |
1157 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
1158 | d->control->selectAll(); executed (the execution status of this line is deduced): d->control->selectAll(); | - |
1159 | } executed: } Execution Count:389 | 389 |
1160 | | - |
1161 | /*! | - |
1162 | Deselects any selected text. | - |
1163 | | - |
1164 | \sa setSelection(), selectAll() | - |
1165 | */ | - |
1166 | | - |
1167 | void QLineEdit::deselect() | - |
1168 | { | - |
1169 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
1170 | d->control->deselect(); executed (the execution status of this line is deduced): d->control->deselect(); | - |
1171 | } executed: } Execution Count:438 | 438 |
1172 | | - |
1173 | | - |
1174 | /*! | - |
1175 | Deletes any selected text, inserts \a newText, and validates the | - |
1176 | result. If it is valid, it sets it as the new contents of the line | - |
1177 | edit. | - |
1178 | | - |
1179 | \sa setText(), clear() | - |
1180 | */ | - |
1181 | void QLineEdit::insert(const QString &newText) | - |
1182 | { | - |
1183 | // q->resetInputContext(); //#### FIX ME IN QT | - |
1184 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
1185 | d->control->insert(newText); executed (the execution status of this line is deduced): d->control->insert(newText); | - |
1186 | } executed: } Execution Count:139 | 139 |
1187 | | - |
1188 | /*! | - |
1189 | Clears the contents of the line edit. | - |
1190 | | - |
1191 | \sa setText(), insert() | - |
1192 | */ | - |
1193 | void QLineEdit::clear() | - |
1194 | { | - |
1195 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
1196 | d->resetInputMethod(); executed (the execution status of this line is deduced): d->resetInputMethod(); | - |
1197 | d->control->clear(); executed (the execution status of this line is deduced): d->control->clear(); | - |
1198 | } executed: } Execution Count:341 | 341 |
1199 | | - |
1200 | /*! | - |
1201 | Undoes the last operation if undo is \l{QLineEdit::undoAvailable}{available}. Deselects any current | - |
1202 | selection, and updates the selection start to the current cursor | - |
1203 | position. | - |
1204 | */ | - |
1205 | void QLineEdit::undo() | - |
1206 | { | - |
1207 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
1208 | d->resetInputMethod(); executed (the execution status of this line is deduced): d->resetInputMethod(); | - |
1209 | d->control->undo(); executed (the execution status of this line is deduced): d->control->undo(); | - |
1210 | } executed: } Execution Count:58 | 58 |
1211 | | - |
1212 | /*! | - |
1213 | Redoes the last operation if redo is \l{QLineEdit::redoAvailable}{available}. | - |
1214 | */ | - |
1215 | void QLineEdit::redo() | - |
1216 | { | - |
1217 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
1218 | d->resetInputMethod(); executed (the execution status of this line is deduced): d->resetInputMethod(); | - |
1219 | d->control->redo(); executed (the execution status of this line is deduced): d->control->redo(); | - |
1220 | } executed: } Execution Count:14 | 14 |
1221 | | - |
1222 | | - |
1223 | /*! | - |
1224 | \property QLineEdit::readOnly | - |
1225 | \brief whether the line edit is read only. | - |
1226 | | - |
1227 | In read-only mode, the user can still copy the text to the | - |
1228 | clipboard, or drag and drop the text (if echoMode() is \l Normal), | - |
1229 | but cannot edit it. | - |
1230 | | - |
1231 | QLineEdit does not show a cursor in read-only mode. | - |
1232 | | - |
1233 | By default, this property is false. | - |
1234 | | - |
1235 | \sa setEnabled() | - |
1236 | */ | - |
1237 | | - |
1238 | bool QLineEdit::isReadOnly() const | - |
1239 | { | - |
1240 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
1241 | return d->control->isReadOnly(); executed: return d->control->isReadOnly(); Execution Count:56 | 56 |
1242 | } | - |
1243 | | - |
1244 | void QLineEdit::setReadOnly(bool enable) | - |
1245 | { | - |
1246 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
1247 | if (d->control->isReadOnly() != enable) { evaluated: d->control->isReadOnly() != enable yes Evaluation Count:22 | yes Evaluation Count:322 |
| 22-322 |
1248 | d->control->setReadOnly(enable); executed (the execution status of this line is deduced): d->control->setReadOnly(enable); | - |
1249 | setAttribute(Qt::WA_MacShowFocusRect, !enable); executed (the execution status of this line is deduced): setAttribute(Qt::WA_MacShowFocusRect, !enable); | - |
1250 | setAttribute(Qt::WA_InputMethodEnabled, d->shouldEnableInputMethod()); executed (the execution status of this line is deduced): setAttribute(Qt::WA_InputMethodEnabled, d->shouldEnableInputMethod()); | - |
1251 | #ifndef QT_NO_CURSOR | - |
1252 | setCursor(enable ? Qt::ArrowCursor : Qt::IBeamCursor); executed (the execution status of this line is deduced): setCursor(enable ? Qt::ArrowCursor : Qt::IBeamCursor); | - |
1253 | #endif | - |
1254 | update(); executed (the execution status of this line is deduced): update(); | - |
1255 | } executed: } Execution Count:22 | 22 |
1256 | } executed: } Execution Count:344 | 344 |
1257 | | - |
1258 | | - |
1259 | #ifndef QT_NO_CLIPBOARD | - |
1260 | /*! | - |
1261 | Copies the selected text to the clipboard and deletes it, if there | - |
1262 | is any, and if echoMode() is \l Normal. | - |
1263 | | - |
1264 | If the current validator disallows deleting the selected text, | - |
1265 | cut() will copy without deleting. | - |
1266 | | - |
1267 | \sa copy(), paste(), setValidator() | - |
1268 | */ | - |
1269 | | - |
1270 | void QLineEdit::cut() | - |
1271 | { | - |
1272 | if (hasSelectedText()) { partially evaluated: hasSelectedText() yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
1273 | copy(); executed (the execution status of this line is deduced): copy(); | - |
1274 | del(); executed (the execution status of this line is deduced): del(); | - |
1275 | } executed: } Execution Count:4 | 4 |
1276 | } executed: } Execution Count:4 | 4 |
1277 | | - |
1278 | | - |
1279 | /*! | - |
1280 | Copies the selected text to the clipboard, if there is any, and if | - |
1281 | echoMode() is \l Normal. | - |
1282 | | - |
1283 | \sa cut(), paste() | - |
1284 | */ | - |
1285 | | - |
1286 | void QLineEdit::copy() const | - |
1287 | { | - |
1288 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
1289 | d->control->copy(); executed (the execution status of this line is deduced): d->control->copy(); | - |
1290 | } executed: } Execution Count:5 | 5 |
1291 | | - |
1292 | /*! | - |
1293 | Inserts the clipboard's text at the cursor position, deleting any | - |
1294 | selected text, providing the line edit is not \l{QLineEdit::readOnly}{read-only}. | - |
1295 | | - |
1296 | If the end result would not be acceptable to the current | - |
1297 | \l{setValidator()}{validator}, nothing happens. | - |
1298 | | - |
1299 | \sa copy(), cut() | - |
1300 | */ | - |
1301 | | - |
1302 | void QLineEdit::paste() | - |
1303 | { | - |
1304 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
1305 | d->control->paste(); executed (the execution status of this line is deduced): d->control->paste(); | - |
1306 | } executed: } Execution Count:8 | 8 |
1307 | | - |
1308 | #endif // !QT_NO_CLIPBOARD | - |
1309 | | - |
1310 | /*! \reimp | - |
1311 | */ | - |
1312 | bool QLineEdit::event(QEvent * e) | - |
1313 | { | - |
1314 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
1315 | if (e->type() == QEvent::Timer) { evaluated: e->type() == QEvent::Timer yes Evaluation Count:1 | yes Evaluation Count:27283 |
| 1-27283 |
1316 | // should be timerEvent, is here for binary compatibility | - |
1317 | int timerId = ((QTimerEvent*)e)->timerId(); executed (the execution status of this line is deduced): int timerId = ((QTimerEvent*)e)->timerId(); | - |
1318 | if (false) { partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1319 | #ifndef QT_NO_DRAGANDDROP | - |
1320 | } else if (timerId == d->dndTimer.timerId()) { never executed: } partially evaluated: timerId == d->dndTimer.timerId() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1321 | d->drag(); never executed (the execution status of this line is deduced): d->drag(); | - |
1322 | #endif | - |
1323 | } | 0 |
1324 | else if (timerId == d->tripleClickTimer.timerId()) partially evaluated: timerId == d->tripleClickTimer.timerId() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1325 | d->tripleClickTimer.stop(); executed: d->tripleClickTimer.stop(); Execution Count:1 | 1 |
1326 | } else if (e->type() == QEvent::ContextMenu) { evaluated: e->type() == QEvent::ContextMenu yes Evaluation Count:1 | yes Evaluation Count:27282 |
| 1-27282 |
1327 | #ifndef QT_NO_IM | - |
1328 | if (d->control->composeMode()) partially evaluated: d->control->composeMode() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1329 | return true; never executed: return true; | 0 |
1330 | #endif | - |
1331 | //d->separate(); | - |
1332 | } else if (e->type() == QEvent::WindowActivate) { executed: } Execution Count:1 evaluated: e->type() == QEvent::WindowActivate yes Evaluation Count:339 | yes Evaluation Count:26943 |
| 1-26943 |
1333 | QTimer::singleShot(0, this, SLOT(_q_handleWindowActivate())); executed (the execution status of this line is deduced): QTimer::singleShot(0, this, "1""_q_handleWindowActivate()"); | - |
1334 | #ifndef QT_NO_SHORTCUT | - |
1335 | } else if (e->type() == QEvent::ShortcutOverride) { executed: } Execution Count:339 evaluated: e->type() == QEvent::ShortcutOverride yes Evaluation Count:3801 | yes Evaluation Count:23142 |
| 339-23142 |
1336 | QKeyEvent *ke = static_cast<QKeyEvent*>(e); executed (the execution status of this line is deduced): QKeyEvent *ke = static_cast<QKeyEvent*>(e); | - |
1337 | d->control->processShortcutOverrideEvent(ke); executed (the execution status of this line is deduced): d->control->processShortcutOverrideEvent(ke); | - |
1338 | #endif | - |
1339 | } else if (e->type() == QEvent::KeyRelease) { executed: } Execution Count:3801 evaluated: e->type() == QEvent::KeyRelease yes Evaluation Count:3610 | yes Evaluation Count:19532 |
| 3610-19532 |
1340 | d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime()); executed (the execution status of this line is deduced): d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime()); | - |
1341 | } else if (e->type() == QEvent::Show) { executed: } Execution Count:3610 evaluated: e->type() == QEvent::Show yes Evaluation Count:591 | yes Evaluation Count:18941 |
| 591-18941 |
1342 | //In order to get the cursor blinking if QComboBox::setEditable is called when the combobox has focus | - |
1343 | if (hasFocus()) { evaluated: hasFocus() yes Evaluation Count:2 | yes Evaluation Count:589 |
| 2-589 |
1344 | d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime()); executed (the execution status of this line is deduced): d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime()); | - |
1345 | QStyleOptionFrameV2 opt; executed (the execution status of this line is deduced): QStyleOptionFrameV2 opt; | - |
1346 | initStyleOption(&opt); executed (the execution status of this line is deduced): initStyleOption(&opt); | - |
1347 | if ((!hasSelectedText() && d->control->preeditAreaText().isEmpty()) partially evaluated: !hasSelectedText() yes Evaluation Count:2 | no Evaluation Count:0 |
partially evaluated: d->control->preeditAreaText().isEmpty() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
1348 | || style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, this)) never evaluated: style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, this) | 0 |
1349 | d->setCursorVisible(true); executed: d->setCursorVisible(true); Execution Count:2 | 2 |
1350 | } executed: } Execution Count:2 | 2 |
1351 | } executed: } Execution Count:591 | 591 |
1352 | | - |
1353 | #ifdef QT_KEYPAD_NAVIGATION | - |
1354 | if (QApplication::keypadNavigationEnabled()) { | - |
1355 | if (e->type() == QEvent::EnterEditFocus) { | - |
1356 | end(false); | - |
1357 | d->setCursorVisible(true); | - |
1358 | d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime()); | - |
1359 | } else if (e->type() == QEvent::LeaveEditFocus) { | - |
1360 | d->setCursorVisible(false); | - |
1361 | d->control->setCursorBlinkPeriod(0); | - |
1362 | if (d->control->hasAcceptableInput() || d->control->fixup()) | - |
1363 | emit editingFinished(); | - |
1364 | } | - |
1365 | } | - |
1366 | #endif | - |
1367 | return QWidget::event(e); executed: return QWidget::event(e); Execution Count:27284 | 27284 |
1368 | } | - |
1369 | | - |
1370 | /*! \reimp | - |
1371 | */ | - |
1372 | void QLineEdit::mousePressEvent(QMouseEvent* e) | - |
1373 | { | - |
1374 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
1375 | | - |
1376 | d->mousePressPos = e->pos(); executed (the execution status of this line is deduced): d->mousePressPos = e->pos(); | - |
1377 | | - |
1378 | if (d->sendMouseEventToInputContext(e)) partially evaluated: d->sendMouseEventToInputContext(e) no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
1379 | return; | 0 |
1380 | if (e->button() == Qt::RightButton) partially evaluated: e->button() == Qt::RightButton no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
1381 | return; | 0 |
1382 | #ifdef QT_KEYPAD_NAVIGATION | - |
1383 | if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) { | - |
1384 | setEditFocus(true); | - |
1385 | // Get the completion list to pop up. | - |
1386 | if (d->control->completer()) | - |
1387 | d->control->completer()->complete(); | - |
1388 | } | - |
1389 | #endif | - |
1390 | if (d->tripleClickTimer.isActive() && (e->pos() - d->tripleClick).manhattanLength() < partially evaluated: d->tripleClickTimer.isActive() no Evaluation Count:0 | yes Evaluation Count:11 |
never evaluated: (e->pos() - d->tripleClick).manhattanLength() < QApplication::startDragDistance() | 0-11 |
1391 | QApplication::startDragDistance()) { never evaluated: (e->pos() - d->tripleClick).manhattanLength() < QApplication::startDragDistance() | 0 |
1392 | selectAll(); never executed (the execution status of this line is deduced): selectAll(); | - |
1393 | return; | 0 |
1394 | } | - |
1395 | bool mark = e->modifiers() & Qt::ShiftModifier; executed (the execution status of this line is deduced): bool mark = e->modifiers() & Qt::ShiftModifier; | - |
1396 | int cursor = d->xToPos(e->pos().x()); executed (the execution status of this line is deduced): int cursor = d->xToPos(e->pos().x()); | - |
1397 | #ifndef QT_NO_DRAGANDDROP | - |
1398 | if (!mark && d->dragEnabled && d->control->echoMode() == Normal && partially evaluated: !mark yes Evaluation Count:11 | no Evaluation Count:0 |
partially evaluated: d->dragEnabled no Evaluation Count:0 | yes Evaluation Count:11 |
never evaluated: d->control->echoMode() == Normal | 0-11 |
1399 | e->button() == Qt::LeftButton && d->control->inSelection(e->pos().x())) { never evaluated: e->button() == Qt::LeftButton never evaluated: d->control->inSelection(e->pos().x()) | 0 |
1400 | if (!d->dndTimer.isActive()) never evaluated: !d->dndTimer.isActive() | 0 |
1401 | d->dndTimer.start(QApplication::startDragTime(), this); never executed: d->dndTimer.start(QApplication::startDragTime(), this); | 0 |
1402 | } else | 0 |
1403 | #endif | - |
1404 | { | - |
1405 | d->control->moveCursor(cursor, mark); executed (the execution status of this line is deduced): d->control->moveCursor(cursor, mark); | - |
1406 | } executed: } Execution Count:11 | 11 |
1407 | } | - |
1408 | | - |
1409 | /*! \reimp | - |
1410 | */ | - |
1411 | void QLineEdit::mouseMoveEvent(QMouseEvent * e) | - |
1412 | { | - |
1413 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
1414 | | - |
1415 | if (e->buttons() & Qt::LeftButton) { partially evaluated: e->buttons() & Qt::LeftButton no Evaluation Count:0 | yes Evaluation Count:31 |
| 0-31 |
1416 | #ifndef QT_NO_DRAGANDDROP | - |
1417 | if (d->dndTimer.isActive()) { never evaluated: d->dndTimer.isActive() | 0 |
1418 | if ((d->mousePressPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) never evaluated: (d->mousePressPos - e->pos()).manhattanLength() > QApplication::startDragDistance() | 0 |
1419 | d->drag(); never executed: d->drag(); | 0 |
1420 | } else | 0 |
1421 | #endif | - |
1422 | { | - |
1423 | if (d->control->composeMode()) { never evaluated: d->control->composeMode() | 0 |
1424 | int startPos = d->xToPos(d->mousePressPos.x()); never executed (the execution status of this line is deduced): int startPos = d->xToPos(d->mousePressPos.x()); | - |
1425 | int currentPos = d->xToPos(e->pos().x()); never executed (the execution status of this line is deduced): int currentPos = d->xToPos(e->pos().x()); | - |
1426 | if (startPos != currentPos) never evaluated: startPos != currentPos | 0 |
1427 | d->control->setSelection(startPos, currentPos - startPos); never executed: d->control->setSelection(startPos, currentPos - startPos); | 0 |
1428 | | - |
1429 | } else { | 0 |
1430 | d->control->moveCursor(d->xToPos(e->pos().x()), true); never executed (the execution status of this line is deduced): d->control->moveCursor(d->xToPos(e->pos().x()), true); | - |
1431 | } | 0 |
1432 | } | - |
1433 | } | - |
1434 | | - |
1435 | d->sendMouseEventToInputContext(e); executed (the execution status of this line is deduced): d->sendMouseEventToInputContext(e); | - |
1436 | } executed: } Execution Count:31 | 31 |
1437 | | - |
1438 | /*! \reimp | - |
1439 | */ | - |
1440 | void QLineEdit::mouseReleaseEvent(QMouseEvent* e) | - |
1441 | { | - |
1442 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
1443 | if (d->sendMouseEventToInputContext(e)) partially evaluated: d->sendMouseEventToInputContext(e) no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
1444 | return; | 0 |
1445 | #ifndef QT_NO_DRAGANDDROP | - |
1446 | if (e->button() == Qt::LeftButton) { partially evaluated: e->button() == Qt::LeftButton yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-11 |
1447 | if (d->dndTimer.isActive()) { partially evaluated: d->dndTimer.isActive() no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
1448 | d->dndTimer.stop(); never executed (the execution status of this line is deduced): d->dndTimer.stop(); | - |
1449 | deselect(); never executed (the execution status of this line is deduced): deselect(); | - |
1450 | return; | 0 |
1451 | } | - |
1452 | } executed: } Execution Count:11 | 11 |
1453 | #endif | - |
1454 | #ifndef QT_NO_CLIPBOARD | - |
1455 | if (QApplication::clipboard()->supportsSelection()) { partially evaluated: QApplication::clipboard()->supportsSelection() yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-11 |
1456 | if (e->button() == Qt::LeftButton) { partially evaluated: e->button() == Qt::LeftButton yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-11 |
1457 | d->control->copy(QClipboard::Selection); executed (the execution status of this line is deduced): d->control->copy(QClipboard::Selection); | - |
1458 | } else if (!d->control->isReadOnly() && e->button() == Qt::MidButton) { executed: } Execution Count:11 never evaluated: !d->control->isReadOnly() never evaluated: e->button() == Qt::MidButton | 0-11 |
1459 | deselect(); never executed (the execution status of this line is deduced): deselect(); | - |
1460 | insert(QApplication::clipboard()->text(QClipboard::Selection)); never executed (the execution status of this line is deduced): insert(QApplication::clipboard()->text(QClipboard::Selection)); | - |
1461 | } | 0 |
1462 | } | - |
1463 | #endif | - |
1464 | | - |
1465 | if (!isReadOnly() && rect().contains(e->pos())) partially evaluated: !isReadOnly() yes Evaluation Count:11 | no Evaluation Count:0 |
evaluated: rect().contains(e->pos()) yes Evaluation Count:10 | yes Evaluation Count:1 |
| 0-11 |
1466 | d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus); executed: d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus); Execution Count:10 | 10 |
1467 | d->clickCausedFocus = 0; executed (the execution status of this line is deduced): d->clickCausedFocus = 0; | - |
1468 | } executed: } Execution Count:11 | 11 |
1469 | | - |
1470 | /*! \reimp | - |
1471 | */ | - |
1472 | void QLineEdit::mouseDoubleClickEvent(QMouseEvent* e) | - |
1473 | { | - |
1474 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
1475 | | - |
1476 | if (e->button() == Qt::LeftButton) { partially evaluated: e->button() == Qt::LeftButton yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
1477 | int position = d->xToPos(e->pos().x()); executed (the execution status of this line is deduced): int position = d->xToPos(e->pos().x()); | - |
1478 | | - |
1479 | // exit composition mode | - |
1480 | if (d->control->composeMode()) { partially evaluated: d->control->composeMode() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
1481 | int preeditPos = d->control->cursor(); never executed (the execution status of this line is deduced): int preeditPos = d->control->cursor(); | - |
1482 | int posInPreedit = position - d->control->cursor(); never executed (the execution status of this line is deduced): int posInPreedit = position - d->control->cursor(); | - |
1483 | int preeditLength = d->control->preeditAreaText().length(); never executed (the execution status of this line is deduced): int preeditLength = d->control->preeditAreaText().length(); | - |
1484 | bool positionOnPreedit = false; never executed (the execution status of this line is deduced): bool positionOnPreedit = false; | - |
1485 | | - |
1486 | if (posInPreedit >= 0 && posInPreedit <= preeditLength) never evaluated: posInPreedit >= 0 never evaluated: posInPreedit <= preeditLength | 0 |
1487 | positionOnPreedit = true; never executed: positionOnPreedit = true; | 0 |
1488 | | - |
1489 | int textLength = d->control->end(); never executed (the execution status of this line is deduced): int textLength = d->control->end(); | - |
1490 | d->control->commitPreedit(); never executed (the execution status of this line is deduced): d->control->commitPreedit(); | - |
1491 | int sizeChange = d->control->end() - textLength; never executed (the execution status of this line is deduced): int sizeChange = d->control->end() - textLength; | - |
1492 | | - |
1493 | if (positionOnPreedit) { never evaluated: positionOnPreedit | 0 |
1494 | if (sizeChange == 0) never evaluated: sizeChange == 0 | 0 |
1495 | position = -1; // cancel selection, word disappeared never executed: position = -1; | 0 |
1496 | else | - |
1497 | // ensure not selecting after preedit if event happened there | - |
1498 | position = qBound(preeditPos, position, preeditPos + sizeChange); never executed: position = qBound(preeditPos, position, preeditPos + sizeChange); | 0 |
1499 | } else if (position > preeditPos) { never evaluated: position > preeditPos | 0 |
1500 | // adjust positions after former preedit by how much text changed | - |
1501 | position += (sizeChange - preeditLength); never executed (the execution status of this line is deduced): position += (sizeChange - preeditLength); | - |
1502 | } | 0 |
1503 | } | - |
1504 | | - |
1505 | if (position >= 0) partially evaluated: position >= 0 yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
1506 | d->control->selectWordAtPos(position); executed: d->control->selectWordAtPos(position); Execution Count:2 | 2 |
1507 | | - |
1508 | d->tripleClickTimer.start(QApplication::doubleClickInterval(), this); executed (the execution status of this line is deduced): d->tripleClickTimer.start(QApplication::doubleClickInterval(), this); | - |
1509 | d->tripleClick = e->pos(); executed (the execution status of this line is deduced): d->tripleClick = e->pos(); | - |
1510 | } else { executed: } Execution Count:2 | 2 |
1511 | d->sendMouseEventToInputContext(e); never executed (the execution status of this line is deduced): d->sendMouseEventToInputContext(e); | - |
1512 | } | 0 |
1513 | } | - |
1514 | | - |
1515 | /*! | - |
1516 | \fn void QLineEdit::returnPressed() | - |
1517 | | - |
1518 | This signal is emitted when the Return or Enter key is pressed. | - |
1519 | Note that if there is a validator() or inputMask() set on the line | - |
1520 | edit, the returnPressed() signal will only be emitted if the input | - |
1521 | follows the inputMask() and the validator() returns | - |
1522 | QValidator::Acceptable. | - |
1523 | */ | - |
1524 | | - |
1525 | /*! | - |
1526 | \fn void QLineEdit::editingFinished() | - |
1527 | | - |
1528 | This signal is emitted when the Return or Enter key is pressed or | - |
1529 | the line edit loses focus. Note that if there is a validator() or | - |
1530 | inputMask() set on the line edit and enter/return is pressed, the | - |
1531 | editingFinished() signal will only be emitted if the input follows | - |
1532 | the inputMask() and the validator() returns QValidator::Acceptable. | - |
1533 | */ | - |
1534 | | - |
1535 | /*! | - |
1536 | Converts the given key press \a event into a line edit action. | - |
1537 | | - |
1538 | If Return or Enter is pressed and the current text is valid (or | - |
1539 | can be \l{QValidator::fixup()}{made valid} by the | - |
1540 | validator), the signal returnPressed() is emitted. | - |
1541 | | - |
1542 | The default key bindings are listed in the class's detailed | - |
1543 | description. | - |
1544 | */ | - |
1545 | | - |
1546 | void QLineEdit::keyPressEvent(QKeyEvent *event) | - |
1547 | { | - |
1548 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
1549 | #ifdef QT_KEYPAD_NAVIGATION | - |
1550 | bool select = false; | - |
1551 | switch (event->key()) { | - |
1552 | case Qt::Key_Select: | - |
1553 | if (QApplication::keypadNavigationEnabled()) { | - |
1554 | if (hasEditFocus()) { | - |
1555 | setEditFocus(false); | - |
1556 | if (d->control->completer() && d->control->completer()->popup()->isVisible()) | - |
1557 | d->control->completer()->popup()->hide(); | - |
1558 | select = true; | - |
1559 | } | - |
1560 | } | - |
1561 | break; | - |
1562 | case Qt::Key_Back: | - |
1563 | case Qt::Key_No: | - |
1564 | if (!QApplication::keypadNavigationEnabled() || !hasEditFocus()) { | - |
1565 | event->ignore(); | - |
1566 | return; | - |
1567 | } | - |
1568 | break; | - |
1569 | default: | - |
1570 | if (QApplication::keypadNavigationEnabled()) { | - |
1571 | if (!hasEditFocus() && !(event->modifiers() & Qt::ControlModifier)) { | - |
1572 | if (!event->text().isEmpty() && event->text().at(0).isPrint() | - |
1573 | && !isReadOnly()) | - |
1574 | setEditFocus(true); | - |
1575 | else { | - |
1576 | event->ignore(); | - |
1577 | return; | - |
1578 | } | - |
1579 | } | - |
1580 | } | - |
1581 | } | - |
1582 | | - |
1583 | | - |
1584 | | - |
1585 | if (QApplication::keypadNavigationEnabled() && !select && !hasEditFocus()) { | - |
1586 | setEditFocus(true); | - |
1587 | if (event->key() == Qt::Key_Select) | - |
1588 | return; // Just start. No action. | - |
1589 | } | - |
1590 | #endif | - |
1591 | d->control->processKeyEvent(event); executed (the execution status of this line is deduced): d->control->processKeyEvent(event); | - |
1592 | if (event->isAccepted()) { evaluated: event->isAccepted() yes Evaluation Count:2231 | yes Evaluation Count:191 |
| 191-2231 |
1593 | if (layoutDirection() != d->control->layoutDirection()) evaluated: layoutDirection() != d->control->layoutDirection() yes Evaluation Count:9 | yes Evaluation Count:2222 |
| 9-2222 |
1594 | setLayoutDirection(d->control->layoutDirection()); executed: setLayoutDirection(d->control->layoutDirection()); Execution Count:9 | 9 |
1595 | d->control->setCursorBlinkPeriod(0); executed (the execution status of this line is deduced): d->control->setCursorBlinkPeriod(0); | - |
1596 | } executed: } Execution Count:2231 | 2231 |
1597 | } executed: } Execution Count:2422 | 2422 |
1598 | | - |
1599 | /*! | - |
1600 | \since 4.4 | - |
1601 | | - |
1602 | Returns a rectangle that includes the lineedit cursor. | - |
1603 | */ | - |
1604 | QRect QLineEdit::cursorRect() const | - |
1605 | { | - |
1606 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
1607 | return d->cursorRect(); executed: return d->cursorRect(); Execution Count:1 | 1 |
1608 | } | - |
1609 | | - |
1610 | /*! \reimp | - |
1611 | */ | - |
1612 | void QLineEdit::inputMethodEvent(QInputMethodEvent *e) | - |
1613 | { | - |
1614 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
1615 | if (d->control->isReadOnly()) { evaluated: d->control->isReadOnly() yes Evaluation Count:4 | yes Evaluation Count:66 |
| 4-66 |
1616 | e->ignore(); executed (the execution status of this line is deduced): e->ignore(); | - |
1617 | return; executed: return; Execution Count:4 | 4 |
1618 | } | - |
1619 | | - |
1620 | if (echoMode() == PasswordEchoOnEdit && !d->control->passwordEchoEditing()) { evaluated: echoMode() == PasswordEchoOnEdit yes Evaluation Count:1 | yes Evaluation Count:65 |
partially evaluated: !d->control->passwordEchoEditing() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-65 |
1621 | // Clear the edit and reset to normal echo mode while entering input | - |
1622 | // method data; the echo mode switches back when the edit loses focus. | - |
1623 | // ### changes a public property, resets current content. | - |
1624 | d->updatePasswordEchoEditing(true); never executed (the execution status of this line is deduced): d->updatePasswordEchoEditing(true); | - |
1625 | clear(); never executed (the execution status of this line is deduced): clear(); | - |
1626 | } | 0 |
1627 | | - |
1628 | #ifdef QT_KEYPAD_NAVIGATION | - |
1629 | // Focus in if currently in navigation focus on the widget | - |
1630 | // Only focus in on preedits, to allow input methods to | - |
1631 | // commit text as they focus out without interfering with focus | - |
1632 | if (QApplication::keypadNavigationEnabled() | - |
1633 | && hasFocus() && !hasEditFocus() | - |
1634 | && !e->preeditString().isEmpty()) | - |
1635 | setEditFocus(true); | - |
1636 | #endif | - |
1637 | | - |
1638 | d->control->processInputMethodEvent(e); executed (the execution status of this line is deduced): d->control->processInputMethodEvent(e); | - |
1639 | | - |
1640 | #ifndef QT_NO_COMPLETER | - |
1641 | if (!e->commitString().isEmpty()) evaluated: !e->commitString().isEmpty() yes Evaluation Count:25 | yes Evaluation Count:41 |
| 25-41 |
1642 | d->control->complete(Qt::Key_unknown); executed: d->control->complete(Qt::Key_unknown); Execution Count:25 | 25 |
1643 | #endif | - |
1644 | } executed: } Execution Count:66 | 66 |
1645 | | - |
1646 | /*!\reimp | - |
1647 | */ | - |
1648 | QVariant QLineEdit::inputMethodQuery(Qt::InputMethodQuery property) const | - |
1649 | { | - |
1650 | Q_D(const QLineEdit); executed (the execution status of this line is deduced): const QLineEditPrivate * const d = d_func(); | - |
1651 | switch(property) { | - |
1652 | case Qt::ImCursorRectangle: | - |
1653 | return d->cursorRect(); executed: return d->cursorRect(); Execution Count:1 | 1 |
1654 | case Qt::ImFont: | - |
1655 | return font(); never executed: return font(); | 0 |
1656 | case Qt::ImCursorPosition: | - |
1657 | return QVariant(d->control->cursor()); never executed: return QVariant(d->control->cursor()); | 0 |
1658 | case Qt::ImSurroundingText: | - |
1659 | return QVariant(d->control->text()); never executed: return QVariant(d->control->text()); | 0 |
1660 | case Qt::ImCurrentSelection: | - |
1661 | return QVariant(selectedText()); never executed: return QVariant(selectedText()); | 0 |
1662 | case Qt::ImMaximumTextLength: | - |
1663 | return QVariant(maxLength()); never executed: return QVariant(maxLength()); | 0 |
1664 | case Qt::ImAnchorPosition: | - |
1665 | if (d->control->selectionStart() == d->control->selectionEnd()) never evaluated: d->control->selectionStart() == d->control->selectionEnd() | 0 |
1666 | return QVariant(d->control->cursor()); never executed: return QVariant(d->control->cursor()); | 0 |
1667 | else if (d->control->selectionStart() == d->control->cursor()) never evaluated: d->control->selectionStart() == d->control->cursor() | 0 |
1668 | return QVariant(d->control->selectionEnd()); never executed: return QVariant(d->control->selectionEnd()); | 0 |
1669 | else | - |
1670 | return QVariant(d->control->selectionStart()); never executed: return QVariant(d->control->selectionStart()); | 0 |
1671 | default: | - |
1672 | return QWidget::inputMethodQuery(property); executed: return QWidget::inputMethodQuery(property); Execution Count:3436 | 3436 |
1673 | } | - |
1674 | } | 0 |
1675 | | - |
1676 | /*!\reimp | - |
1677 | */ | - |
1678 | | - |
1679 | void QLineEdit::focusInEvent(QFocusEvent *e) | - |
1680 | { | - |
1681 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
1682 | if (e->reason() == Qt::TabFocusReason || evaluated: e->reason() == Qt::TabFocusReason yes Evaluation Count:94 | yes Evaluation Count:377 |
| 94-377 |
1683 | e->reason() == Qt::BacktabFocusReason || evaluated: e->reason() == Qt::BacktabFocusReason yes Evaluation Count:8 | yes Evaluation Count:369 |
| 8-369 |
1684 | e->reason() == Qt::ShortcutFocusReason) { evaluated: e->reason() == Qt::ShortcutFocusReason yes Evaluation Count:2 | yes Evaluation Count:367 |
| 2-367 |
1685 | if (!d->control->inputMask().isEmpty()) partially evaluated: !d->control->inputMask().isEmpty() no Evaluation Count:0 | yes Evaluation Count:104 |
| 0-104 |
1686 | d->control->moveCursor(d->control->nextMaskBlank(0)); never executed: d->control->moveCursor(d->control->nextMaskBlank(0)); | 0 |
1687 | else if (!d->control->hasSelectedText()) evaluated: !d->control->hasSelectedText() yes Evaluation Count:74 | yes Evaluation Count:30 |
| 30-74 |
1688 | selectAll(); executed: selectAll(); Execution Count:74 | 74 |
1689 | } else if (e->reason() == Qt::MouseFocusReason) { evaluated: e->reason() == Qt::MouseFocusReason yes Evaluation Count:4 | yes Evaluation Count:363 |
| 4-363 |
1690 | d->clickCausedFocus = 1; executed (the execution status of this line is deduced): d->clickCausedFocus = 1; | - |
1691 | } executed: } Execution Count:4 | 4 |
1692 | #ifdef QT_KEYPAD_NAVIGATION | - |
1693 | if (!QApplication::keypadNavigationEnabled() || (hasEditFocus() && ( e->reason() == Qt::PopupFocusReason))) { | - |
1694 | #endif | - |
1695 | d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime()); executed (the execution status of this line is deduced): d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime()); | - |
1696 | QStyleOptionFrameV2 opt; executed (the execution status of this line is deduced): QStyleOptionFrameV2 opt; | - |
1697 | initStyleOption(&opt); executed (the execution status of this line is deduced): initStyleOption(&opt); | - |
1698 | if((!hasSelectedText() && d->control->preeditAreaText().isEmpty()) evaluated: !hasSelectedText() yes Evaluation Count:394 | yes Evaluation Count:77 |
partially evaluated: d->control->preeditAreaText().isEmpty() yes Evaluation Count:394 | no Evaluation Count:0 |
| 0-394 |
1699 | || style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, this)) partially evaluated: style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, this) yes Evaluation Count:77 | no Evaluation Count:0 |
| 0-77 |
1700 | d->setCursorVisible(true); executed: d->setCursorVisible(true); Execution Count:471 | 471 |
1701 | #ifdef Q_WS_MAC | - |
1702 | if (d->control->echoMode() == Password || d->control->echoMode() == NoEcho) | - |
1703 | qt_mac_secure_keyboard(true); | - |
1704 | #endif | - |
1705 | #ifdef QT_KEYPAD_NAVIGATION | - |
1706 | d->control->setCancelText(d->control->text()); | - |
1707 | } | - |
1708 | #endif | - |
1709 | #ifndef QT_NO_COMPLETER | - |
1710 | if (d->control->completer()) { evaluated: d->control->completer() yes Evaluation Count:114 | yes Evaluation Count:357 |
| 114-357 |
1711 | d->control->completer()->setWidget(this); executed (the execution status of this line is deduced): d->control->completer()->setWidget(this); | - |
1712 | QObject::connect(d->control->completer(), SIGNAL(activated(QString)), executed (the execution status of this line is deduced): QObject::connect(d->control->completer(), "2""activated(QString)", | - |
1713 | this, SLOT(setText(QString))); executed (the execution status of this line is deduced): this, "1""setText(QString)"); | - |
1714 | QObject::connect(d->control->completer(), SIGNAL(highlighted(QString)), executed (the execution status of this line is deduced): QObject::connect(d->control->completer(), "2""highlighted(QString)", | - |
1715 | this, SLOT(_q_completionHighlighted(QString))); executed (the execution status of this line is deduced): this, "1""_q_completionHighlighted(QString)"); | - |
1716 | } executed: } Execution Count:114 | 114 |
1717 | #endif | - |
1718 | update(); executed (the execution status of this line is deduced): update(); | - |
1719 | } executed: } Execution Count:471 | 471 |
1720 | | - |
1721 | /*!\reimp | - |
1722 | */ | - |
1723 | | - |
1724 | void QLineEdit::focusOutEvent(QFocusEvent *e) | - |
1725 | { | - |
1726 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
1727 | if (d->control->passwordEchoEditing()) { evaluated: d->control->passwordEchoEditing() yes Evaluation Count:2 | yes Evaluation Count:523 |
| 2-523 |
1728 | // Reset the echomode back to PasswordEchoOnEdit when the widget loses | - |
1729 | // focus. | - |
1730 | d->updatePasswordEchoEditing(false); executed (the execution status of this line is deduced): d->updatePasswordEchoEditing(false); | - |
1731 | } executed: } Execution Count:2 | 2 |
1732 | | - |
1733 | Qt::FocusReason reason = e->reason(); executed (the execution status of this line is deduced): Qt::FocusReason reason = e->reason(); | - |
1734 | if (reason != Qt::ActiveWindowFocusReason && evaluated: reason != Qt::ActiveWindowFocusReason yes Evaluation Count:335 | yes Evaluation Count:190 |
| 190-335 |
1735 | reason != Qt::PopupFocusReason) evaluated: reason != Qt::PopupFocusReason yes Evaluation Count:328 | yes Evaluation Count:7 |
| 7-328 |
1736 | deselect(); executed: deselect(); Execution Count:328 | 328 |
1737 | | - |
1738 | d->setCursorVisible(false); executed (the execution status of this line is deduced): d->setCursorVisible(false); | - |
1739 | d->control->setCursorBlinkPeriod(0); executed (the execution status of this line is deduced): d->control->setCursorBlinkPeriod(0); | - |
1740 | #ifdef QT_KEYPAD_NAVIGATION | - |
1741 | // editingFinished() is already emitted on LeaveEditFocus | - |
1742 | if (!QApplication::keypadNavigationEnabled()) | - |
1743 | #endif | - |
1744 | if (reason != Qt::PopupFocusReason evaluated: reason != Qt::PopupFocusReason yes Evaluation Count:518 | yes Evaluation Count:7 |
| 7-518 |
1745 | || !(QApplication::activePopupWidget() && QApplication::activePopupWidget()->parentWidget() == this)) { partially evaluated: QApplication::activePopupWidget() yes Evaluation Count:7 | no Evaluation Count:0 |
evaluated: QApplication::activePopupWidget()->parentWidget() == this yes Evaluation Count:1 | yes Evaluation Count:6 |
| 0-7 |
1746 | if (hasAcceptableInput() || d->control->fixup()) evaluated: hasAcceptableInput() yes Evaluation Count:448 | yes Evaluation Count:76 |
evaluated: d->control->fixup() yes Evaluation Count:1 | yes Evaluation Count:75 |
| 1-448 |
1747 | emit editingFinished(); executed: editingFinished(); Execution Count:449 | 449 |
1748 | } executed: } Execution Count:524 | 524 |
1749 | #ifdef Q_WS_MAC | - |
1750 | if (d->control->echoMode() == Password || d->control->echoMode() == NoEcho) | - |
1751 | qt_mac_secure_keyboard(false); | - |
1752 | #endif | - |
1753 | #ifdef QT_KEYPAD_NAVIGATION | - |
1754 | d->control->setCancelText(QString()); | - |
1755 | #endif | - |
1756 | #ifndef QT_NO_COMPLETER | - |
1757 | if (d->control->completer()) { evaluated: d->control->completer() yes Evaluation Count:49 | yes Evaluation Count:476 |
| 49-476 |
1758 | QObject::disconnect(d->control->completer(), 0, this, 0); executed (the execution status of this line is deduced): QObject::disconnect(d->control->completer(), 0, this, 0); | - |
1759 | } executed: } Execution Count:49 | 49 |
1760 | #endif | - |
1761 | update(); executed (the execution status of this line is deduced): update(); | - |
1762 | } executed: } Execution Count:525 | 525 |
1763 | | - |
1764 | /*!\reimp | - |
1765 | */ | - |
1766 | void QLineEdit::paintEvent(QPaintEvent *) | - |
1767 | { | - |
1768 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
1769 | QPainter p(this); executed (the execution status of this line is deduced): QPainter p(this); | - |
1770 | | - |
1771 | QRect r = rect(); executed (the execution status of this line is deduced): QRect r = rect(); | - |
1772 | QPalette pal = palette(); executed (the execution status of this line is deduced): QPalette pal = palette(); | - |
1773 | | - |
1774 | QStyleOptionFrameV2 panel; executed (the execution status of this line is deduced): QStyleOptionFrameV2 panel; | - |
1775 | initStyleOption(&panel); executed (the execution status of this line is deduced): initStyleOption(&panel); | - |
1776 | style()->drawPrimitive(QStyle::PE_PanelLineEdit, &panel, &p, this); executed (the execution status of this line is deduced): style()->drawPrimitive(QStyle::PE_PanelLineEdit, &panel, &p, this); | - |
1777 | r = style()->subElementRect(QStyle::SE_LineEditContents, &panel, this); executed (the execution status of this line is deduced): r = style()->subElementRect(QStyle::SE_LineEditContents, &panel, this); | - |
1778 | r.setX(r.x() + d->leftTextMargin); executed (the execution status of this line is deduced): r.setX(r.x() + d->leftTextMargin); | - |
1779 | r.setY(r.y() + d->topTextMargin); executed (the execution status of this line is deduced): r.setY(r.y() + d->topTextMargin); | - |
1780 | r.setRight(r.right() - d->rightTextMargin); executed (the execution status of this line is deduced): r.setRight(r.right() - d->rightTextMargin); | - |
1781 | r.setBottom(r.bottom() - d->bottomTextMargin); executed (the execution status of this line is deduced): r.setBottom(r.bottom() - d->bottomTextMargin); | - |
1782 | p.setClipRect(r); executed (the execution status of this line is deduced): p.setClipRect(r); | - |
1783 | | - |
1784 | QFontMetrics fm = fontMetrics(); executed (the execution status of this line is deduced): QFontMetrics fm = fontMetrics(); | - |
1785 | Qt::Alignment va = QStyle::visualAlignment(d->control->layoutDirection(), QFlag(d->alignment)); executed (the execution status of this line is deduced): Qt::Alignment va = QStyle::visualAlignment(d->control->layoutDirection(), QFlag(d->alignment)); | - |
1786 | switch (va & Qt::AlignVertical_Mask) { | - |
1787 | case Qt::AlignBottom: | - |
1788 | d->vscroll = r.y() + r.height() - fm.height() - d->verticalMargin; never executed (the execution status of this line is deduced): d->vscroll = r.y() + r.height() - fm.height() - d->verticalMargin; | - |
1789 | break; | 0 |
1790 | case Qt::AlignTop: | - |
1791 | d->vscroll = r.y() + d->verticalMargin; never executed (the execution status of this line is deduced): d->vscroll = r.y() + d->verticalMargin; | - |
1792 | break; | 0 |
1793 | default: | - |
1794 | //center | - |
1795 | d->vscroll = r.y() + (r.height() - fm.height() + 1) / 2; executed (the execution status of this line is deduced): d->vscroll = r.y() + (r.height() - fm.height() + 1) / 2; | - |
1796 | break; executed: break; Execution Count:762 | 762 |
1797 | } | - |
1798 | QRect lineRect(r.x() + d->horizontalMargin, d->vscroll, r.width() - 2*d->horizontalMargin, fm.height()); executed (the execution status of this line is deduced): QRect lineRect(r.x() + d->horizontalMargin, d->vscroll, r.width() - 2*d->horizontalMargin, fm.height()); | - |
1799 | | - |
1800 | int minLB = qMax(0, -fm.minLeftBearing()); executed (the execution status of this line is deduced): int minLB = qMax(0, -fm.minLeftBearing()); | - |
1801 | int minRB = qMax(0, -fm.minRightBearing()); executed (the execution status of this line is deduced): int minRB = qMax(0, -fm.minRightBearing()); | - |
1802 | | - |
1803 | if (d->control->text().isEmpty()) { evaluated: d->control->text().isEmpty() yes Evaluation Count:439 | yes Evaluation Count:323 |
| 323-439 |
1804 | if (!hasFocus() && !d->placeholderText.isEmpty()) { evaluated: !hasFocus() yes Evaluation Count:218 | yes Evaluation Count:221 |
partially evaluated: !d->placeholderText.isEmpty() no Evaluation Count:0 | yes Evaluation Count:218 |
| 0-221 |
1805 | QColor col = pal.text().color(); never executed (the execution status of this line is deduced): QColor col = pal.text().color(); | - |
1806 | col.setAlpha(128); never executed (the execution status of this line is deduced): col.setAlpha(128); | - |
1807 | QPen oldpen = p.pen(); never executed (the execution status of this line is deduced): QPen oldpen = p.pen(); | - |
1808 | p.setPen(col); never executed (the execution status of this line is deduced): p.setPen(col); | - |
1809 | lineRect.adjust(minLB, 0, 0, 0); never executed (the execution status of this line is deduced): lineRect.adjust(minLB, 0, 0, 0); | - |
1810 | QString elidedText = fm.elidedText(d->placeholderText, Qt::ElideRight, lineRect.width()); never executed (the execution status of this line is deduced): QString elidedText = fm.elidedText(d->placeholderText, Qt::ElideRight, lineRect.width()); | - |
1811 | p.drawText(lineRect, va, elidedText); never executed (the execution status of this line is deduced): p.drawText(lineRect, va, elidedText); | - |
1812 | p.setPen(oldpen); never executed (the execution status of this line is deduced): p.setPen(oldpen); | - |
1813 | return; | 0 |
1814 | } | - |
1815 | } executed: } Execution Count:439 | 439 |
1816 | | - |
1817 | int cix = qRound(d->control->cursorToX()); executed (the execution status of this line is deduced): int cix = qRound(d->control->cursorToX()); | - |
1818 | | - |
1819 | // horizontal scrolling. d->hscroll is the left indent from the beginning | - |
1820 | // of the text line to the left edge of lineRect. we update this value | - |
1821 | // depending on the delta from the last paint event; in effect this means | - |
1822 | // the below code handles all scrolling based on the textline (widthUsed, | - |
1823 | // minLB, minRB), the line edit rect (lineRect) and the cursor position | - |
1824 | // (cix). | - |
1825 | int widthUsed = qRound(d->control->naturalTextWidth()) + 1 + minRB; executed (the execution status of this line is deduced): int widthUsed = qRound(d->control->naturalTextWidth()) + 1 + minRB; | - |
1826 | if ((minLB + widthUsed) <= lineRect.width()) { evaluated: (minLB + widthUsed) <= lineRect.width() yes Evaluation Count:699 | yes Evaluation Count:63 |
| 63-699 |
1827 | // text fits in lineRect; use hscroll for alignment | - |
1828 | switch (va & ~(Qt::AlignAbsolute|Qt::AlignVertical_Mask)) { | - |
1829 | case Qt::AlignRight: | - |
1830 | d->hscroll = widthUsed - lineRect.width() + 1; executed (the execution status of this line is deduced): d->hscroll = widthUsed - lineRect.width() + 1; | - |
1831 | break; executed: break; Execution Count:2 | 2 |
1832 | case Qt::AlignHCenter: | - |
1833 | d->hscroll = (widthUsed - lineRect.width()) / 2; executed (the execution status of this line is deduced): d->hscroll = (widthUsed - lineRect.width()) / 2; | - |
1834 | break; executed: break; Execution Count:32 | 32 |
1835 | default: | - |
1836 | // Left | - |
1837 | d->hscroll = 0; executed (the execution status of this line is deduced): d->hscroll = 0; | - |
1838 | break; executed: break; Execution Count:665 | 665 |
1839 | } | - |
1840 | d->hscroll -= minLB; executed (the execution status of this line is deduced): d->hscroll -= minLB; | - |
1841 | } else if (cix - d->hscroll >= lineRect.width()) { executed: } Execution Count:699 evaluated: cix - d->hscroll >= lineRect.width() yes Evaluation Count:10 | yes Evaluation Count:53 |
| 10-699 |
1842 | // text doesn't fit, cursor is to the right of lineRect (scroll right) | - |
1843 | d->hscroll = cix - lineRect.width() + 1; executed (the execution status of this line is deduced): d->hscroll = cix - lineRect.width() + 1; | - |
1844 | } else if (cix - d->hscroll < 0 && d->hscroll < widthUsed) { executed: } Execution Count:10 partially evaluated: cix - d->hscroll < 0 no Evaluation Count:0 | yes Evaluation Count:53 |
never evaluated: d->hscroll < widthUsed | 0-53 |
1845 | // text doesn't fit, cursor is to the left of lineRect (scroll left) | - |
1846 | d->hscroll = cix; never executed (the execution status of this line is deduced): d->hscroll = cix; | - |
1847 | } else if (widthUsed - d->hscroll < lineRect.width()) { never executed: } partially evaluated: widthUsed - d->hscroll < lineRect.width() no Evaluation Count:0 | yes Evaluation Count:53 |
| 0-53 |
1848 | // text doesn't fit, text document is to the left of lineRect; align | - |
1849 | // right | - |
1850 | d->hscroll = widthUsed - lineRect.width() + 1; never executed (the execution status of this line is deduced): d->hscroll = widthUsed - lineRect.width() + 1; | - |
1851 | } else { | 0 |
1852 | //in case the text is bigger than the lineedit, the hscroll can never be negative | - |
1853 | d->hscroll = qMax(0, d->hscroll); executed (the execution status of this line is deduced): d->hscroll = qMax(0, d->hscroll); | - |
1854 | } executed: } Execution Count:53 | 53 |
1855 | | - |
1856 | // the y offset is there to keep the baseline constant in case we have script changes in the text. | - |
1857 | QPoint topLeft = lineRect.topLeft() - QPoint(d->hscroll, d->control->ascent() - fm.ascent()); executed (the execution status of this line is deduced): QPoint topLeft = lineRect.topLeft() - QPoint(d->hscroll, d->control->ascent() - fm.ascent()); | - |
1858 | | - |
1859 | // draw text, selections and cursors | - |
1860 | #ifndef QT_NO_STYLE_STYLESHEET | - |
1861 | if (QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(style())) { evaluated: QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(style()) yes Evaluation Count:7 | yes Evaluation Count:755 |
| 7-755 |
1862 | cssStyle->styleSheetPalette(this, &panel, &pal); executed (the execution status of this line is deduced): cssStyle->styleSheetPalette(this, &panel, &pal); | - |
1863 | } executed: } Execution Count:7 | 7 |
1864 | #endif | - |
1865 | p.setPen(pal.text().color()); executed (the execution status of this line is deduced): p.setPen(pal.text().color()); | - |
1866 | | - |
1867 | int flags = QWidgetLineControl::DrawText; executed (the execution status of this line is deduced): int flags = QWidgetLineControl::DrawText; | - |
1868 | | - |
1869 | #ifdef QT_KEYPAD_NAVIGATION | - |
1870 | if (!QApplication::keypadNavigationEnabled() || hasEditFocus()) | - |
1871 | #endif | - |
1872 | if (d->control->hasSelectedText() || (d->cursorVisible && !d->control->inputMask().isEmpty() && !d->control->isReadOnly())){ evaluated: d->control->hasSelectedText() yes Evaluation Count:51 | yes Evaluation Count:711 |
evaluated: d->cursorVisible yes Evaluation Count:343 | yes Evaluation Count:368 |
partially evaluated: !d->control->inputMask().isEmpty() no Evaluation Count:0 | yes Evaluation Count:343 |
never evaluated: !d->control->isReadOnly() | 0-711 |
1873 | flags |= QWidgetLineControl::DrawSelections; executed (the execution status of this line is deduced): flags |= QWidgetLineControl::DrawSelections; | - |
1874 | // Palette only used for selections/mask and may not be in sync | - |
1875 | if (d->control->palette() != pal evaluated: d->control->palette() != pal yes Evaluation Count:1 | yes Evaluation Count:50 |
| 1-50 |
1876 | || d->control->palette().currentColorGroup() != pal.currentColorGroup()) evaluated: d->control->palette().currentColorGroup() != pal.currentColorGroup() yes Evaluation Count:17 | yes Evaluation Count:33 |
| 17-33 |
1877 | d->control->setPalette(pal); executed: d->control->setPalette(pal); Execution Count:18 | 18 |
1878 | } executed: } Execution Count:51 | 51 |
1879 | | - |
1880 | // Asian users see an IM selection text as cursor on candidate | - |
1881 | // selection phase of input method, so the ordinary cursor should be | - |
1882 | // invisible if we have a preedit string. | - |
1883 | if (d->cursorVisible && !d->control->isReadOnly()) evaluated: d->cursorVisible yes Evaluation Count:392 | yes Evaluation Count:370 |
evaluated: !d->control->isReadOnly() yes Evaluation Count:386 | yes Evaluation Count:6 |
| 6-392 |
1884 | flags |= QWidgetLineControl::DrawCursor; executed: flags |= QWidgetLineControl::DrawCursor; Execution Count:386 | 386 |
1885 | | - |
1886 | d->control->setCursorWidth(style()->pixelMetric(QStyle::PM_TextCursorWidth)); executed (the execution status of this line is deduced): d->control->setCursorWidth(style()->pixelMetric(QStyle::PM_TextCursorWidth)); | - |
1887 | d->control->draw(&p, topLeft, r, flags); executed (the execution status of this line is deduced): d->control->draw(&p, topLeft, r, flags); | - |
1888 | | - |
1889 | } executed: } Execution Count:762 | 762 |
1890 | | - |
1891 | | - |
1892 | #ifndef QT_NO_DRAGANDDROP | - |
1893 | /*!\reimp | - |
1894 | */ | - |
1895 | void QLineEdit::dragMoveEvent(QDragMoveEvent *e) | - |
1896 | { | - |
1897 | Q_D(QLineEdit); never executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
1898 | if (!d->control->isReadOnly() && e->mimeData()->hasFormat(QLatin1String("text/plain"))) { never evaluated: !d->control->isReadOnly() never evaluated: e->mimeData()->hasFormat(QLatin1String("text/plain")) | 0 |
1899 | e->acceptProposedAction(); never executed (the execution status of this line is deduced): e->acceptProposedAction(); | - |
1900 | d->control->moveCursor(d->xToPos(e->pos().x()), false); never executed (the execution status of this line is deduced): d->control->moveCursor(d->xToPos(e->pos().x()), false); | - |
1901 | d->cursorVisible = true; never executed (the execution status of this line is deduced): d->cursorVisible = true; | - |
1902 | update(); never executed (the execution status of this line is deduced): update(); | - |
1903 | } | 0 |
1904 | } | 0 |
1905 | | - |
1906 | /*!\reimp */ | - |
1907 | void QLineEdit::dragEnterEvent(QDragEnterEvent * e) | - |
1908 | { | - |
1909 | QLineEdit::dragMoveEvent(e); never executed (the execution status of this line is deduced): QLineEdit::dragMoveEvent(e); | - |
1910 | } | 0 |
1911 | | - |
1912 | /*!\reimp */ | - |
1913 | void QLineEdit::dragLeaveEvent(QDragLeaveEvent *) | - |
1914 | { | - |
1915 | Q_D(QLineEdit); never executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
1916 | if (d->cursorVisible) { never evaluated: d->cursorVisible | 0 |
1917 | d->cursorVisible = false; never executed (the execution status of this line is deduced): d->cursorVisible = false; | - |
1918 | update(); never executed (the execution status of this line is deduced): update(); | - |
1919 | } | 0 |
1920 | } | 0 |
1921 | | - |
1922 | /*!\reimp */ | - |
1923 | void QLineEdit::dropEvent(QDropEvent* e) | - |
1924 | { | - |
1925 | Q_D(QLineEdit); never executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
1926 | QString str = e->mimeData()->text(); never executed (the execution status of this line is deduced): QString str = e->mimeData()->text(); | - |
1927 | | - |
1928 | if (!str.isNull() && !d->control->isReadOnly()) { never evaluated: !str.isNull() never evaluated: !d->control->isReadOnly() | 0 |
1929 | if (e->source() == this && e->dropAction() == Qt::CopyAction) never evaluated: e->source() == this never evaluated: e->dropAction() == Qt::CopyAction | 0 |
1930 | deselect(); never executed: deselect(); | 0 |
1931 | int cursorPos = d->xToPos(e->pos().x()); never executed (the execution status of this line is deduced): int cursorPos = d->xToPos(e->pos().x()); | - |
1932 | int selStart = cursorPos; never executed (the execution status of this line is deduced): int selStart = cursorPos; | - |
1933 | int oldSelStart = d->control->selectionStart(); never executed (the execution status of this line is deduced): int oldSelStart = d->control->selectionStart(); | - |
1934 | int oldSelEnd = d->control->selectionEnd(); never executed (the execution status of this line is deduced): int oldSelEnd = d->control->selectionEnd(); | - |
1935 | d->control->moveCursor(cursorPos, false); never executed (the execution status of this line is deduced): d->control->moveCursor(cursorPos, false); | - |
1936 | d->cursorVisible = false; never executed (the execution status of this line is deduced): d->cursorVisible = false; | - |
1937 | e->acceptProposedAction(); never executed (the execution status of this line is deduced): e->acceptProposedAction(); | - |
1938 | insert(str); never executed (the execution status of this line is deduced): insert(str); | - |
1939 | if (e->source() == this) { never evaluated: e->source() == this | 0 |
1940 | if (e->dropAction() == Qt::MoveAction) { never evaluated: e->dropAction() == Qt::MoveAction | 0 |
1941 | if (selStart > oldSelStart && selStart <= oldSelEnd) never evaluated: selStart > oldSelStart never evaluated: selStart <= oldSelEnd | 0 |
1942 | setSelection(oldSelStart, str.length()); never executed: setSelection(oldSelStart, str.length()); | 0 |
1943 | else if (selStart > oldSelEnd) never evaluated: selStart > oldSelEnd | 0 |
1944 | setSelection(selStart - str.length(), str.length()); never executed: setSelection(selStart - str.length(), str.length()); | 0 |
1945 | else | - |
1946 | setSelection(selStart, str.length()); never executed: setSelection(selStart, str.length()); | 0 |
1947 | } else { | - |
1948 | setSelection(selStart, str.length()); never executed (the execution status of this line is deduced): setSelection(selStart, str.length()); | - |
1949 | } | 0 |
1950 | } | - |
1951 | } else { | 0 |
1952 | e->ignore(); never executed (the execution status of this line is deduced): e->ignore(); | - |
1953 | update(); never executed (the execution status of this line is deduced): update(); | - |
1954 | } | 0 |
1955 | } | - |
1956 | | - |
1957 | #endif // QT_NO_DRAGANDDROP | - |
1958 | | - |
1959 | #ifndef QT_NO_CONTEXTMENU | - |
1960 | /*! | - |
1961 | Shows the standard context menu created with | - |
1962 | createStandardContextMenu(). | - |
1963 | | - |
1964 | If you do not want the line edit to have a context menu, you can set | - |
1965 | its \l contextMenuPolicy to Qt::NoContextMenu. If you want to | - |
1966 | customize the context menu, reimplement this function. If you want | - |
1967 | to extend the standard context menu, reimplement this function, call | - |
1968 | createStandardContextMenu() and extend the menu returned. | - |
1969 | | - |
1970 | \snippet code/src_gui_widgets_qlineedit.cpp 0 | - |
1971 | | - |
1972 | The \a event parameter is used to obtain the position where | - |
1973 | the mouse cursor was when the event was generated. | - |
1974 | | - |
1975 | \sa setContextMenuPolicy() | - |
1976 | */ | - |
1977 | void QLineEdit::contextMenuEvent(QContextMenuEvent *event) | - |
1978 | { | - |
1979 | if (QMenu *menu = createStandardContextMenu()) { partially evaluated: QMenu *menu = createStandardContextMenu() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1980 | menu->setAttribute(Qt::WA_DeleteOnClose); executed (the execution status of this line is deduced): menu->setAttribute(Qt::WA_DeleteOnClose); | - |
1981 | menu->popup(event->globalPos()); executed (the execution status of this line is deduced): menu->popup(event->globalPos()); | - |
1982 | } executed: } Execution Count:1 | 1 |
1983 | } executed: } Execution Count:1 | 1 |
1984 | | - |
1985 | /*! This function creates the standard context menu which is shown | - |
1986 | when the user clicks on the line edit with the right mouse | - |
1987 | button. It is called from the default contextMenuEvent() handler. | - |
1988 | The popup menu's ownership is transferred to the caller. | - |
1989 | */ | - |
1990 | | - |
1991 | QMenu *QLineEdit::createStandardContextMenu() | - |
1992 | { | - |
1993 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
1994 | QMenu *popup = new QMenu(this); executed (the execution status of this line is deduced): QMenu *popup = new QMenu(this); | - |
1995 | popup->setObjectName(QLatin1String("qt_edit_menu")); executed (the execution status of this line is deduced): popup->setObjectName(QLatin1String("qt_edit_menu")); | - |
1996 | QAction *action = 0; executed (the execution status of this line is deduced): QAction *action = 0; | - |
1997 | | - |
1998 | if (!isReadOnly()) { partially evaluated: !isReadOnly() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
1999 | action = popup->addAction(QLineEdit::tr("&Undo") + ACCEL_KEY(QKeySequence::Undo)); executed (the execution status of this line is deduced): action = popup->addAction(QLineEdit::tr("&Undo") + (!(static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.hasShortcutForKeySequence(QKeySequence::Undo) ? QLatin1Char('\t') + QKeySequence(QKeySequence::Undo).toString(QKeySequence::NativeText) : QString())); | - |
2000 | action->setEnabled(d->control->isUndoAvailable()); executed (the execution status of this line is deduced): action->setEnabled(d->control->isUndoAvailable()); | - |
2001 | connect(action, SIGNAL(triggered()), SLOT(undo())); executed (the execution status of this line is deduced): connect(action, "2""triggered()", "1""undo()"); | - |
2002 | | - |
2003 | action = popup->addAction(QLineEdit::tr("&Redo") + ACCEL_KEY(QKeySequence::Redo)); executed (the execution status of this line is deduced): action = popup->addAction(QLineEdit::tr("&Redo") + (!(static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.hasShortcutForKeySequence(QKeySequence::Redo) ? QLatin1Char('\t') + QKeySequence(QKeySequence::Redo).toString(QKeySequence::NativeText) : QString())); | - |
2004 | action->setEnabled(d->control->isRedoAvailable()); executed (the execution status of this line is deduced): action->setEnabled(d->control->isRedoAvailable()); | - |
2005 | connect(action, SIGNAL(triggered()), SLOT(redo())); executed (the execution status of this line is deduced): connect(action, "2""triggered()", "1""redo()"); | - |
2006 | | - |
2007 | popup->addSeparator(); executed (the execution status of this line is deduced): popup->addSeparator(); | - |
2008 | } executed: } Execution Count:2 | 2 |
2009 | | - |
2010 | #ifndef QT_NO_CLIPBOARD | - |
2011 | if (!isReadOnly()) { partially evaluated: !isReadOnly() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
2012 | action = popup->addAction(QLineEdit::tr("Cu&t") + ACCEL_KEY(QKeySequence::Cut)); executed (the execution status of this line is deduced): action = popup->addAction(QLineEdit::tr("Cu&t") + (!(static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.hasShortcutForKeySequence(QKeySequence::Cut) ? QLatin1Char('\t') + QKeySequence(QKeySequence::Cut).toString(QKeySequence::NativeText) : QString())); | - |
2013 | action->setEnabled(!d->control->isReadOnly() && d->control->hasSelectedText() executed (the execution status of this line is deduced): action->setEnabled(!d->control->isReadOnly() && d->control->hasSelectedText() | - |
2014 | && d->control->echoMode() == QLineEdit::Normal); executed (the execution status of this line is deduced): && d->control->echoMode() == QLineEdit::Normal); | - |
2015 | connect(action, SIGNAL(triggered()), SLOT(cut())); executed (the execution status of this line is deduced): connect(action, "2""triggered()", "1""cut()"); | - |
2016 | } executed: } Execution Count:2 | 2 |
2017 | | - |
2018 | action = popup->addAction(QLineEdit::tr("&Copy") + ACCEL_KEY(QKeySequence::Copy)); executed (the execution status of this line is deduced): action = popup->addAction(QLineEdit::tr("&Copy") + (!(static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.hasShortcutForKeySequence(QKeySequence::Copy) ? QLatin1Char('\t') + QKeySequence(QKeySequence::Copy).toString(QKeySequence::NativeText) : QString())); | - |
2019 | action->setEnabled(d->control->hasSelectedText() executed (the execution status of this line is deduced): action->setEnabled(d->control->hasSelectedText() | - |
2020 | && d->control->echoMode() == QLineEdit::Normal); executed (the execution status of this line is deduced): && d->control->echoMode() == QLineEdit::Normal); | - |
2021 | connect(action, SIGNAL(triggered()), SLOT(copy())); executed (the execution status of this line is deduced): connect(action, "2""triggered()", "1""copy()"); | - |
2022 | | - |
2023 | if (!isReadOnly()) { partially evaluated: !isReadOnly() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
2024 | action = popup->addAction(QLineEdit::tr("&Paste") + ACCEL_KEY(QKeySequence::Paste)); executed (the execution status of this line is deduced): action = popup->addAction(QLineEdit::tr("&Paste") + (!(static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.hasShortcutForKeySequence(QKeySequence::Paste) ? QLatin1Char('\t') + QKeySequence(QKeySequence::Paste).toString(QKeySequence::NativeText) : QString())); | - |
2025 | action->setEnabled(!d->control->isReadOnly() && !QApplication::clipboard()->text().isEmpty()); executed (the execution status of this line is deduced): action->setEnabled(!d->control->isReadOnly() && !QApplication::clipboard()->text().isEmpty()); | - |
2026 | connect(action, SIGNAL(triggered()), SLOT(paste())); executed (the execution status of this line is deduced): connect(action, "2""triggered()", "1""paste()"); | - |
2027 | } executed: } Execution Count:2 | 2 |
2028 | #endif | - |
2029 | | - |
2030 | if (!isReadOnly()) { partially evaluated: !isReadOnly() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
2031 | action = popup->addAction(QLineEdit::tr("Delete")); executed (the execution status of this line is deduced): action = popup->addAction(QLineEdit::tr("Delete")); | - |
2032 | action->setEnabled(!d->control->isReadOnly() && !d->control->text().isEmpty() && d->control->hasSelectedText()); executed (the execution status of this line is deduced): action->setEnabled(!d->control->isReadOnly() && !d->control->text().isEmpty() && d->control->hasSelectedText()); | - |
2033 | connect(action, SIGNAL(triggered()), d->control, SLOT(_q_deleteSelected())); executed (the execution status of this line is deduced): connect(action, "2""triggered()", d->control, "1""_q_deleteSelected()"); | - |
2034 | } executed: } Execution Count:2 | 2 |
2035 | | - |
2036 | if (!popup->isEmpty()) partially evaluated: !popup->isEmpty() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
2037 | popup->addSeparator(); executed: popup->addSeparator(); Execution Count:2 | 2 |
2038 | | - |
2039 | action = popup->addAction(QLineEdit::tr("Select All") + ACCEL_KEY(QKeySequence::SelectAll)); executed (the execution status of this line is deduced): action = popup->addAction(QLineEdit::tr("Select All") + (!(static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.hasShortcutForKeySequence(QKeySequence::SelectAll) ? QLatin1Char('\t') + QKeySequence(QKeySequence::SelectAll).toString(QKeySequence::NativeText) : QString())); | - |
2040 | action->setEnabled(!d->control->text().isEmpty() && !d->control->allSelected()); executed (the execution status of this line is deduced): action->setEnabled(!d->control->text().isEmpty() && !d->control->allSelected()); | - |
2041 | d->selectAllAction = action; executed (the execution status of this line is deduced): d->selectAllAction = action; | - |
2042 | connect(action, SIGNAL(triggered()), SLOT(selectAll())); executed (the execution status of this line is deduced): connect(action, "2""triggered()", "1""selectAll()"); | - |
2043 | | - |
2044 | if (!d->control->isReadOnly() && qApp->styleHints()->useRtlExtensions()) { partially evaluated: !d->control->isReadOnly() yes Evaluation Count:2 | no Evaluation Count:0 |
partially evaluated: (static_cast<QApplication *>(QCoreApplication::instance()))->styleHints()->useRtlExtensions() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
2045 | popup->addSeparator(); never executed (the execution status of this line is deduced): popup->addSeparator(); | - |
2046 | QUnicodeControlCharacterMenu *ctrlCharacterMenu = new QUnicodeControlCharacterMenu(this, popup); never executed (the execution status of this line is deduced): QUnicodeControlCharacterMenu *ctrlCharacterMenu = new QUnicodeControlCharacterMenu(this, popup); | - |
2047 | popup->addMenu(ctrlCharacterMenu); never executed (the execution status of this line is deduced): popup->addMenu(ctrlCharacterMenu); | - |
2048 | } | 0 |
2049 | return popup; executed: return popup; Execution Count:2 | 2 |
2050 | } | - |
2051 | #endif // QT_NO_CONTEXTMENU | - |
2052 | | - |
2053 | /*! \reimp */ | - |
2054 | void QLineEdit::changeEvent(QEvent *ev) | - |
2055 | { | - |
2056 | Q_D(QLineEdit); executed (the execution status of this line is deduced): QLineEditPrivate * const d = d_func(); | - |
2057 | switch(ev->type()) | - |
2058 | { | - |
2059 | case QEvent::ActivationChange: | - |
2060 | if (!palette().isEqual(QPalette::Active, QPalette::Inactive)) evaluated: !palette().isEqual(QPalette::Active, QPalette::Inactive) yes Evaluation Count:4 | yes Evaluation Count:51 |
| 4-51 |
2061 | update(); executed: update(); Execution Count:4 | 4 |
2062 | break; executed: break; Execution Count:55 | 55 |
2063 | case QEvent::FontChange: | - |
2064 | d->control->setFont(font()); executed (the execution status of this line is deduced): d->control->setFont(font()); | - |
2065 | break; executed: break; Execution Count:98 | 98 |
2066 | case QEvent::StyleChange: | - |
2067 | { | - |
2068 | QStyleOptionFrameV2 opt; executed (the execution status of this line is deduced): QStyleOptionFrameV2 opt; | - |
2069 | initStyleOption(&opt); executed (the execution status of this line is deduced): initStyleOption(&opt); | - |
2070 | d->control->setPasswordCharacter(style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, this)); executed (the execution status of this line is deduced): d->control->setPasswordCharacter(style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, this)); | - |
2071 | } | - |
2072 | update(); executed (the execution status of this line is deduced): update(); | - |
2073 | break; executed: break; Execution Count:19 | 19 |
2074 | default: | - |
2075 | break; executed: break; Execution Count:2336 | 2336 |
2076 | } | - |
2077 | QWidget::changeEvent(ev); executed (the execution status of this line is deduced): QWidget::changeEvent(ev); | - |
2078 | } executed: } Execution Count:2508 | 2508 |
2079 | | - |
2080 | QT_END_NAMESPACE | - |
2081 | | - |
2082 | #include "moc_qlineedit.cpp" | - |
2083 | | - |
2084 | #endif // QT_NO_LINEEDIT | - |
2085 | | - |
| | |