Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | | - |
17 | | - |
18 | void QLineEdit::initStyleOption(QStyleOptionFrame *option) const | - |
19 | { | - |
20 | if (!option) partially evaluated: !option no Evaluation Count:0 | yes Evaluation Count:22491 |
| 0-22491 |
21 | return; | 0 |
22 | | - |
23 | const QLineEditPrivate * const d = d_func(); | - |
24 | option->initFrom(this); | - |
25 | option->rect = contentsRect(); | - |
26 | option->lineWidth = d->frame ? style()->pixelMetric(QStyle::PM_DefaultFrameWidth, option, this) evaluated: d->frame yes Evaluation Count:5721 | yes Evaluation Count:16770 |
| 5721-16770 |
27 | : 0; | - |
28 | option->midLineWidth = 0; | - |
29 | option->state |= QStyle::State_Sunken; | - |
30 | if (d->control->isReadOnly()) evaluated: d->control->isReadOnly() yes Evaluation Count:64 | yes Evaluation Count:22427 |
| 64-22427 |
31 | option->state |= QStyle::State_ReadOnly; executed: option->state |= QStyle::State_ReadOnly; Execution Count:64 | 64 |
32 | | - |
33 | | - |
34 | | - |
35 | | - |
36 | option->features = QStyleOptionFrame::None; | - |
37 | } executed: } Execution Count:22491 | 22491 |
38 | QLineEdit::QLineEdit(QWidget* parent) | - |
39 | : QWidget(*new QLineEditPrivate, parent,0) | - |
40 | { | - |
41 | QLineEditPrivate * const d = d_func(); | - |
42 | d->init(QString()); | - |
43 | } executed: } Execution Count:1058 | 1058 |
44 | QLineEdit::QLineEdit(const QString& contents, QWidget* parent) | - |
45 | : QWidget(*new QLineEditPrivate, parent, 0) | - |
46 | { | - |
47 | QLineEditPrivate * const d = d_func(); | - |
48 | d->init(contents); | - |
49 | } executed: } Execution Count:19 | 19 |
50 | | - |
51 | | - |
52 | | - |
53 | | - |
54 | | - |
55 | | - |
56 | | - |
57 | QLineEdit::~QLineEdit() | - |
58 | { | - |
59 | } | - |
60 | QString QLineEdit::text() const | - |
61 | { | - |
62 | const QLineEditPrivate * const d = d_func(); | - |
63 | return d->control->text(); executed: return d->control->text(); Execution Count:37525 | 37525 |
64 | } | - |
65 | | - |
66 | void QLineEdit::setText(const QString& text) | - |
67 | { | - |
68 | QLineEditPrivate * const d = d_func(); | - |
69 | d->control->setText(text); | - |
70 | } executed: } Execution Count:5444 | 5444 |
71 | QString QLineEdit::placeholderText() const | - |
72 | { | - |
73 | const QLineEditPrivate * const d = d_func(); | - |
74 | return d->placeholderText; never executed: return d->placeholderText; | 0 |
75 | } | - |
76 | | - |
77 | void QLineEdit::setPlaceholderText(const QString& placeholderText) | - |
78 | { | - |
79 | QLineEditPrivate * const d = d_func(); | - |
80 | if (d->placeholderText != placeholderText) { never evaluated: d->placeholderText != placeholderText | 0 |
81 | d->placeholderText = placeholderText; | - |
82 | if (!hasFocus()) never evaluated: !hasFocus() | 0 |
83 | update(); never executed: update(); | 0 |
84 | } | 0 |
85 | } | 0 |
86 | QString QLineEdit::displayText() const | - |
87 | { | - |
88 | const QLineEditPrivate * const d = d_func(); | - |
89 | return d->control->displayText(); executed: return d->control->displayText(); Execution Count:5420 | 5420 |
90 | } | - |
91 | int QLineEdit::maxLength() const | - |
92 | { | - |
93 | const QLineEditPrivate * const d = d_func(); | - |
94 | return d->control->maxLength(); executed: return d->control->maxLength(); Execution Count:33 | 33 |
95 | } | - |
96 | | - |
97 | void QLineEdit::setMaxLength(int maxLength) | - |
98 | { | - |
99 | QLineEditPrivate * const d = d_func(); | - |
100 | d->control->setMaxLength(maxLength); | - |
101 | } executed: } Execution Count:358 | 358 |
102 | bool QLineEdit::hasFrame() const | - |
103 | { | - |
104 | const QLineEditPrivate * const d = d_func(); | - |
105 | return d->frame; executed: return d->frame; Execution Count:51 | 51 |
106 | } | - |
107 | | - |
108 | | - |
109 | void QLineEdit::setFrame(bool enable) | - |
110 | { | - |
111 | QLineEditPrivate * const d = d_func(); | - |
112 | d->frame = enable; | - |
113 | update(); | - |
114 | updateGeometry(); | - |
115 | } executed: } Execution Count:961 | 961 |
116 | QLineEdit::EchoMode QLineEdit::echoMode() const | - |
117 | { | - |
118 | const QLineEditPrivate * const d = d_func(); | - |
119 | return (EchoMode) d->control->echoMode(); executed: return (EchoMode) d->control->echoMode(); Execution Count:178 | 178 |
120 | } | - |
121 | | - |
122 | void QLineEdit::setEchoMode(EchoMode mode) | - |
123 | { | - |
124 | QLineEditPrivate * const d = d_func(); | - |
125 | if (mode == (EchoMode)d->control->echoMode()) evaluated: mode == (EchoMode)d->control->echoMode() yes Evaluation Count:315 | yes Evaluation Count:65 |
| 65-315 |
126 | return; executed: return; Execution Count:315 | 315 |
127 | Qt::InputMethodHints imHints = inputMethodHints(); | - |
128 | 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 |
129 | imHints |= Qt::ImhHiddenText; | - |
130 | } else { executed: } Execution Count:28 | 28 |
131 | imHints &= ~Qt::ImhHiddenText; | - |
132 | } executed: } Execution Count:37 | 37 |
133 | if (mode != Normal) { evaluated: mode != Normal yes Evaluation Count:34 | yes Evaluation Count:31 |
| 31-34 |
134 | imHints |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData); | - |
135 | } else { executed: } Execution Count:34 | 34 |
136 | imHints &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData); | - |
137 | } executed: } Execution Count:31 | 31 |
138 | setInputMethodHints(imHints); | - |
139 | d->control->setEchoMode(mode); | - |
140 | update(); | - |
141 | | - |
142 | | - |
143 | | - |
144 | | - |
145 | } executed: } Execution Count:65 | 65 |
146 | const QValidator * QLineEdit::validator() const | - |
147 | { | - |
148 | const QLineEditPrivate * const d = d_func(); | - |
149 | return d->control->validator(); executed: return d->control->validator(); Execution Count:403 | 403 |
150 | } | - |
151 | void QLineEdit::setValidator(const QValidator *v) | - |
152 | { | - |
153 | QLineEditPrivate * const d = d_func(); | - |
154 | d->control->setValidator(v); | - |
155 | } executed: } Execution Count:1154 | 1154 |
156 | void QLineEdit::setCompleter(QCompleter *c) | - |
157 | { | - |
158 | QLineEditPrivate * const d = d_func(); | - |
159 | if (c == d->control->completer()) partially evaluated: c == d->control->completer() no Evaluation Count:0 | yes Evaluation Count:357 |
| 0-357 |
160 | return; | 0 |
161 | if (d->control->completer()) { evaluated: d->control->completer() yes Evaluation Count:2 | yes Evaluation Count:355 |
| 2-355 |
162 | disconnect(d->control->completer(), 0, this, 0); | - |
163 | d->control->completer()->setWidget(0); | - |
164 | if (d->control->completer()->parent() == this) partially evaluated: d->control->completer()->parent() == this yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
165 | delete d->control->completer(); executed: delete d->control->completer(); Execution Count:2 | 2 |
166 | } executed: } Execution Count:2 | 2 |
167 | d->control->setCompleter(c); | - |
168 | if (!c) partially evaluated: !c no Evaluation Count:0 | yes Evaluation Count:357 |
| 0-357 |
169 | return; | 0 |
170 | if (c->widget() == 0) evaluated: c->widget() == 0 yes Evaluation Count:355 | yes Evaluation Count:2 |
| 2-355 |
171 | c->setWidget(this); executed: c->setWidget(this); Execution Count:355 | 355 |
172 | if (hasFocus()) { evaluated: hasFocus() yes Evaluation Count:1 | yes Evaluation Count:356 |
| 1-356 |
173 | QObject::connect(d->control->completer(), "2""activated(QString)", | - |
174 | this, "1""setText(QString)"); | - |
175 | QObject::connect(d->control->completer(), "2""highlighted(QString)", | - |
176 | this, "1""_q_completionHighlighted(QString)"); | - |
177 | } executed: } Execution Count:1 | 1 |
178 | } executed: } Execution Count:357 | 357 |
179 | | - |
180 | | - |
181 | | - |
182 | | - |
183 | | - |
184 | | - |
185 | QCompleter *QLineEdit::completer() const | - |
186 | { | - |
187 | const QLineEditPrivate * const d = d_func(); | - |
188 | return d->control->completer(); executed: return d->control->completer(); Execution Count:657 | 657 |
189 | } | - |
190 | QSize QLineEdit::sizeHint() const | - |
191 | { | - |
192 | const QLineEditPrivate * const d = d_func(); | - |
193 | ensurePolished(); | - |
194 | QFontMetrics fm(font()); | - |
195 | int h = qMax(fm.height(), 14) + 2*d->verticalMargin | - |
196 | + d->topTextMargin + d->bottomTextMargin | - |
197 | + d->topmargin + d->bottommargin; | - |
198 | int w = fm.width(QLatin1Char('x')) * 17 + 2*d->horizontalMargin | - |
199 | + d->leftTextMargin + d->rightTextMargin | - |
200 | + d->leftmargin + d->rightmargin; | - |
201 | QStyleOptionFrameV2 opt; | - |
202 | initStyleOption(&opt); | - |
203 | return (style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(w, h). | 1078 |
204 | expandedTo(QApplication::globalStrut()), this)); executed: return (style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(w, h). expandedTo(QApplication::globalStrut()), this)); Execution Count:1078 | 1078 |
205 | } | - |
206 | QSize QLineEdit::minimumSizeHint() const | - |
207 | { | - |
208 | const QLineEditPrivate * const d = d_func(); | - |
209 | ensurePolished(); | - |
210 | QFontMetrics fm = fontMetrics(); | - |
211 | int h = fm.height() + qMax(2*d->verticalMargin, fm.leading()) | - |
212 | + d->topmargin + d->bottommargin; | - |
213 | int w = fm.maxWidth() + d->leftmargin + d->rightmargin; | - |
214 | QStyleOptionFrameV2 opt; | - |
215 | initStyleOption(&opt); | - |
216 | return (style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(w, h). | 359 |
217 | expandedTo(QApplication::globalStrut()), this)); executed: return (style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(w, h). expandedTo(QApplication::globalStrut()), this)); Execution Count:359 | 359 |
218 | } | - |
219 | int QLineEdit::cursorPosition() const | - |
220 | { | - |
221 | const QLineEditPrivate * const d = d_func(); | - |
222 | return d->control->cursorPosition(); executed: return d->control->cursorPosition(); Execution Count:8250 | 8250 |
223 | } | - |
224 | | - |
225 | void QLineEdit::setCursorPosition(int pos) | - |
226 | { | - |
227 | QLineEditPrivate * const d = d_func(); | - |
228 | d->control->setCursorPosition(pos); | - |
229 | } executed: } Execution Count:2377 | 2377 |
230 | | - |
231 | | - |
232 | | - |
233 | | - |
234 | | - |
235 | int QLineEdit::cursorPositionAt(const QPoint &pos) | - |
236 | { | - |
237 | QLineEditPrivate * const d = d_func(); | - |
238 | return d->xToPos(pos.x()); never executed: return d->xToPos(pos.x()); | 0 |
239 | } | - |
240 | Qt::Alignment QLineEdit::alignment() const | - |
241 | { | - |
242 | const QLineEditPrivate * const d = d_func(); | - |
243 | return QFlag(d->alignment); executed: return QFlag(d->alignment); Execution Count:7 | 7 |
244 | } | - |
245 | | - |
246 | void QLineEdit::setAlignment(Qt::Alignment alignment) | - |
247 | { | - |
248 | QLineEditPrivate * const d = d_func(); | - |
249 | d->alignment = alignment; | - |
250 | update(); | - |
251 | } executed: } Execution Count:10 | 10 |
252 | void QLineEdit::cursorForward(bool mark, int steps) | - |
253 | { | - |
254 | QLineEditPrivate * const d = d_func(); | - |
255 | d->control->cursorForward(mark, steps); | - |
256 | } executed: } Execution Count:12 | 12 |
257 | void QLineEdit::cursorBackward(bool mark, int steps) | - |
258 | { | - |
259 | cursorForward(mark, -steps); | - |
260 | } executed: } Execution Count:5 | 5 |
261 | | - |
262 | | - |
263 | | - |
264 | | - |
265 | | - |
266 | | - |
267 | | - |
268 | void QLineEdit::cursorWordForward(bool mark) | - |
269 | { | - |
270 | QLineEditPrivate * const d = d_func(); | - |
271 | d->control->cursorWordForward(mark); | - |
272 | } executed: } Execution Count:3 | 3 |
273 | void QLineEdit::cursorWordBackward(bool mark) | - |
274 | { | - |
275 | QLineEditPrivate * const d = d_func(); | - |
276 | d->control->cursorWordBackward(mark); | - |
277 | } executed: } Execution Count:6 | 6 |
278 | void QLineEdit::backspace() | - |
279 | { | - |
280 | QLineEditPrivate * const d = d_func(); | - |
281 | d->control->backspace(); | - |
282 | } executed: } Execution Count:8 | 8 |
283 | void QLineEdit::del() | - |
284 | { | - |
285 | QLineEditPrivate * const d = d_func(); | - |
286 | d->control->del(); | - |
287 | } executed: } Execution Count:6 | 6 |
288 | void QLineEdit::home(bool mark) | - |
289 | { | - |
290 | QLineEditPrivate * const d = d_func(); | - |
291 | d->control->home(mark); | - |
292 | } executed: } Execution Count:6 | 6 |
293 | void QLineEdit::end(bool mark) | - |
294 | { | - |
295 | QLineEditPrivate * const d = d_func(); | - |
296 | d->control->end(mark); | - |
297 | } executed: } Execution Count:6 | 6 |
298 | bool QLineEdit::isModified() const | - |
299 | { | - |
300 | const QLineEditPrivate * const d = d_func(); | - |
301 | return d->control->isModified(); executed: return d->control->isModified(); Execution Count:26 | 26 |
302 | } | - |
303 | | - |
304 | void QLineEdit::setModified(bool modified) | - |
305 | { | - |
306 | QLineEditPrivate * const d = d_func(); | - |
307 | d->control->setModified(modified); | - |
308 | } executed: } Execution Count:2 | 2 |
309 | bool QLineEdit::hasSelectedText() const | - |
310 | { | - |
311 | const QLineEditPrivate * const d = d_func(); | - |
312 | return d->control->hasSelectedText(); executed: return d->control->hasSelectedText(); Execution Count:6293 | 6293 |
313 | } | - |
314 | QString QLineEdit::selectedText() const | - |
315 | { | - |
316 | const QLineEditPrivate * const d = d_func(); | - |
317 | return d->control->selectedText(); executed: return d->control->selectedText(); Execution Count:3613 | 3613 |
318 | } | - |
319 | int QLineEdit::selectionStart() const | - |
320 | { | - |
321 | const QLineEditPrivate * const d = d_func(); | - |
322 | return d->control->selectionStart(); executed: return d->control->selectionStart(); Execution Count:2480 | 2480 |
323 | } | - |
324 | void QLineEdit::setSelection(int start, int length) | - |
325 | { | - |
326 | QLineEditPrivate * const d = d_func(); | - |
327 | 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 |
328 | QMessageLogger("widgets/qlineedit.cpp", 902, __PRETTY_FUNCTION__).warning("QLineEdit::setSelection: Invalid start position (%d)", start); | - |
329 | return; executed: return; Execution Count:2 | 2 |
330 | } | - |
331 | | - |
332 | d->control->setSelection(start, length); | - |
333 | | - |
334 | if (d->control->hasSelectedText()){ evaluated: d->control->hasSelectedText() yes Evaluation Count:3970 | yes Evaluation Count:15 |
| 15-3970 |
335 | QStyleOptionFrameV2 opt; | - |
336 | initStyleOption(&opt); | - |
337 | 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 |
338 | d->setCursorVisible(false); never executed: d->setCursorVisible(false); | 0 |
339 | } executed: } Execution Count:3970 | 3970 |
340 | } executed: } Execution Count:3985 | 3985 |
341 | bool QLineEdit::isUndoAvailable() const | - |
342 | { | - |
343 | const QLineEditPrivate * const d = d_func(); | - |
344 | return d->control->isUndoAvailable(); executed: return d->control->isUndoAvailable(); Execution Count:59 | 59 |
345 | } | - |
346 | bool QLineEdit::isRedoAvailable() const | - |
347 | { | - |
348 | const QLineEditPrivate * const d = d_func(); | - |
349 | return d->control->isRedoAvailable(); executed: return d->control->isRedoAvailable(); Execution Count:26 | 26 |
350 | } | - |
351 | bool QLineEdit::dragEnabled() const | - |
352 | { | - |
353 | const QLineEditPrivate * const d = d_func(); | - |
354 | return d->dragEnabled; executed: return d->dragEnabled; Execution Count:2 | 2 |
355 | } | - |
356 | | - |
357 | void QLineEdit::setDragEnabled(bool b) | - |
358 | { | - |
359 | QLineEditPrivate * const d = d_func(); | - |
360 | d->dragEnabled = b; | - |
361 | } executed: } Execution Count:323 | 323 |
362 | Qt::CursorMoveStyle QLineEdit::cursorMoveStyle() const | - |
363 | { | - |
364 | const QLineEditPrivate * const d = d_func(); | - |
365 | return d->control->cursorMoveStyle(); never executed: return d->control->cursorMoveStyle(); | 0 |
366 | } | - |
367 | | - |
368 | void QLineEdit::setCursorMoveStyle(Qt::CursorMoveStyle style) | - |
369 | { | - |
370 | QLineEditPrivate * const d = d_func(); | - |
371 | d->control->setCursorMoveStyle(style); | - |
372 | } executed: } Execution Count:16 | 16 |
373 | bool QLineEdit::hasAcceptableInput() const | - |
374 | { | - |
375 | const QLineEditPrivate * const d = d_func(); | - |
376 | return d->control->hasAcceptableInput(); executed: return d->control->hasAcceptableInput(); Execution Count:2285 | 2285 |
377 | } | - |
378 | void QLineEdit::setTextMargins(int left, int top, int right, int bottom) | - |
379 | { | - |
380 | QLineEditPrivate * const d = d_func(); | - |
381 | d->leftTextMargin = left; | - |
382 | d->topTextMargin = top; | - |
383 | d->rightTextMargin = right; | - |
384 | d->bottomTextMargin = bottom; | - |
385 | updateGeometry(); | - |
386 | update(); | - |
387 | } executed: } Execution Count:9 | 9 |
388 | | - |
389 | | - |
390 | | - |
391 | | - |
392 | | - |
393 | | - |
394 | | - |
395 | void QLineEdit::setTextMargins(const QMargins &margins) | - |
396 | { | - |
397 | setTextMargins(margins.left(), margins.top(), margins.right(), margins.bottom()); | - |
398 | } | 0 |
399 | | - |
400 | | - |
401 | | - |
402 | | - |
403 | | - |
404 | | - |
405 | | - |
406 | void QLineEdit::getTextMargins(int *left, int *top, int *right, int *bottom) const | - |
407 | { | - |
408 | const QLineEditPrivate * const d = d_func(); | - |
409 | if (left) evaluated: left yes Evaluation Count:94 | yes Evaluation Count:10 |
| 10-94 |
410 | *left = d->leftTextMargin; executed: *left = d->leftTextMargin; Execution Count:94 | 94 |
411 | if (top) evaluated: top yes Evaluation Count:19 | yes Evaluation Count:85 |
| 19-85 |
412 | *top = d->topTextMargin; executed: *top = d->topTextMargin; Execution Count:19 | 19 |
413 | if (right) evaluated: right yes Evaluation Count:94 | yes Evaluation Count:10 |
| 10-94 |
414 | *right = d->rightTextMargin; executed: *right = d->rightTextMargin; Execution Count:94 | 94 |
415 | if (bottom) evaluated: bottom yes Evaluation Count:9 | yes Evaluation Count:95 |
| 9-95 |
416 | *bottom = d->bottomTextMargin; executed: *bottom = d->bottomTextMargin; Execution Count:9 | 9 |
417 | } executed: } Execution Count:104 | 104 |
418 | | - |
419 | | - |
420 | | - |
421 | | - |
422 | | - |
423 | | - |
424 | | - |
425 | QMargins QLineEdit::textMargins() const | - |
426 | { | - |
427 | const QLineEditPrivate * const d = d_func(); | - |
428 | return QMargins(d->leftTextMargin, d->topTextMargin, d->rightTextMargin, d->bottomTextMargin); never executed: return QMargins(d->leftTextMargin, d->topTextMargin, d->rightTextMargin, d->bottomTextMargin); | 0 |
429 | } | - |
430 | QString QLineEdit::inputMask() const | - |
431 | { | - |
432 | const QLineEditPrivate * const d = d_func(); | - |
433 | return d->control->inputMask(); executed: return d->control->inputMask(); Execution Count:16 | 16 |
434 | } | - |
435 | | - |
436 | void QLineEdit::setInputMask(const QString &inputMask) | - |
437 | { | - |
438 | QLineEditPrivate * const d = d_func(); | - |
439 | d->control->setInputMask(inputMask); | - |
440 | } executed: } Execution Count:436 | 436 |
441 | void QLineEdit::selectAll() | - |
442 | { | - |
443 | QLineEditPrivate * const d = d_func(); | - |
444 | d->control->selectAll(); | - |
445 | } executed: } Execution Count:389 | 389 |
446 | | - |
447 | | - |
448 | | - |
449 | | - |
450 | | - |
451 | | - |
452 | | - |
453 | void QLineEdit::deselect() | - |
454 | { | - |
455 | QLineEditPrivate * const d = d_func(); | - |
456 | d->control->deselect(); | - |
457 | } executed: } Execution Count:438 | 438 |
458 | void QLineEdit::insert(const QString &newText) | - |
459 | { | - |
460 | | - |
461 | QLineEditPrivate * const d = d_func(); | - |
462 | d->control->insert(newText); | - |
463 | } executed: } Execution Count:139 | 139 |
464 | | - |
465 | | - |
466 | | - |
467 | | - |
468 | | - |
469 | | - |
470 | void QLineEdit::clear() | - |
471 | { | - |
472 | QLineEditPrivate * const d = d_func(); | - |
473 | d->resetInputMethod(); | - |
474 | d->control->clear(); | - |
475 | } executed: } Execution Count:341 | 341 |
476 | | - |
477 | | - |
478 | | - |
479 | | - |
480 | | - |
481 | | - |
482 | void QLineEdit::undo() | - |
483 | { | - |
484 | QLineEditPrivate * const d = d_func(); | - |
485 | d->resetInputMethod(); | - |
486 | d->control->undo(); | - |
487 | } executed: } Execution Count:58 | 58 |
488 | | - |
489 | | - |
490 | | - |
491 | | - |
492 | void QLineEdit::redo() | - |
493 | { | - |
494 | QLineEditPrivate * const d = d_func(); | - |
495 | d->resetInputMethod(); | - |
496 | d->control->redo(); | - |
497 | } executed: } Execution Count:14 | 14 |
498 | bool QLineEdit::isReadOnly() const | - |
499 | { | - |
500 | const QLineEditPrivate * const d = d_func(); | - |
501 | return d->control->isReadOnly(); executed: return d->control->isReadOnly(); Execution Count:56 | 56 |
502 | } | - |
503 | | - |
504 | void QLineEdit::setReadOnly(bool enable) | - |
505 | { | - |
506 | QLineEditPrivate * const d = d_func(); | - |
507 | if (d->control->isReadOnly() != enable) { evaluated: d->control->isReadOnly() != enable yes Evaluation Count:22 | yes Evaluation Count:322 |
| 22-322 |
508 | d->control->setReadOnly(enable); | - |
509 | setAttribute(Qt::WA_MacShowFocusRect, !enable); | - |
510 | setAttribute(Qt::WA_InputMethodEnabled, d->shouldEnableInputMethod()); | - |
511 | | - |
512 | setCursor(enable ? Qt::ArrowCursor : Qt::IBeamCursor); | - |
513 | | - |
514 | update(); | - |
515 | } executed: } Execution Count:22 | 22 |
516 | } executed: } Execution Count:344 | 344 |
517 | void QLineEdit::cut() | - |
518 | { | - |
519 | if (hasSelectedText()) { partially evaluated: hasSelectedText() yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
520 | copy(); | - |
521 | del(); | - |
522 | } executed: } Execution Count:4 | 4 |
523 | } executed: } Execution Count:4 | 4 |
524 | void QLineEdit::copy() const | - |
525 | { | - |
526 | const QLineEditPrivate * const d = d_func(); | - |
527 | d->control->copy(); | - |
528 | } executed: } Execution Count:5 | 5 |
529 | void QLineEdit::paste() | - |
530 | { | - |
531 | QLineEditPrivate * const d = d_func(); | - |
532 | d->control->paste(); | - |
533 | } executed: } Execution Count:8 | 8 |
534 | | - |
535 | | - |
536 | | - |
537 | | - |
538 | | - |
539 | bool QLineEdit::event(QEvent * e) | - |
540 | { | - |
541 | QLineEditPrivate * const d = d_func(); | - |
542 | if (e->type() == QEvent::Timer) { evaluated: e->type() == QEvent::Timer yes Evaluation Count:1 | yes Evaluation Count:27283 |
| 1-27283 |
543 | | - |
544 | int timerId = ((QTimerEvent*)e)->timerId(); | - |
545 | if (false) { partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
546 | | - |
547 | } else if (timerId == d->dndTimer.timerId()) { partially evaluated: timerId == d->dndTimer.timerId() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
548 | d->drag(); | - |
549 | | - |
550 | } | 0 |
551 | else if (timerId == d->tripleClickTimer.timerId()) partially evaluated: timerId == d->tripleClickTimer.timerId() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
552 | d->tripleClickTimer.stop(); executed: d->tripleClickTimer.stop(); Execution Count:1 | 1 |
553 | } else if (e->type() == QEvent::ContextMenu) { evaluated: e->type() == QEvent::ContextMenu yes Evaluation Count:1 | yes Evaluation Count:27282 |
| 1-27282 |
554 | | - |
555 | if (d->control->composeMode()) partially evaluated: d->control->composeMode() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
556 | return true; never executed: return true; | 0 |
557 | | - |
558 | | - |
559 | } else if (e->type() == QEvent::WindowActivate) { evaluated: e->type() == QEvent::WindowActivate yes Evaluation Count:339 | yes Evaluation Count:26943 |
executed: } Execution Count:1 | 1-26943 |
560 | QTimer::singleShot(0, this, "1""_q_handleWindowActivate()"); | - |
561 | | - |
562 | } else if (e->type() == QEvent::ShortcutOverride) { evaluated: e->type() == QEvent::ShortcutOverride yes Evaluation Count:3801 | yes Evaluation Count:23142 |
executed: } Execution Count:339 | 339-23142 |
563 | QKeyEvent *ke = static_cast<QKeyEvent*>(e); | - |
564 | d->control->processShortcutOverrideEvent(ke); | - |
565 | | - |
566 | } else if (e->type() == QEvent::KeyRelease) { evaluated: e->type() == QEvent::KeyRelease yes Evaluation Count:3610 | yes Evaluation Count:19532 |
executed: } Execution Count:3801 | 3610-19532 |
567 | d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime()); | - |
568 | } else if (e->type() == QEvent::Show) { evaluated: e->type() == QEvent::Show yes Evaluation Count:591 | yes Evaluation Count:18941 |
executed: } Execution Count:3610 | 591-18941 |
569 | | - |
570 | if (hasFocus()) { evaluated: hasFocus() yes Evaluation Count:2 | yes Evaluation Count:589 |
| 2-589 |
571 | d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime()); | - |
572 | QStyleOptionFrameV2 opt; | - |
573 | initStyleOption(&opt); | - |
574 | 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 |
575 | || style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, this)) never evaluated: style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, this) | 0 |
576 | d->setCursorVisible(true); executed: d->setCursorVisible(true); Execution Count:2 | 2 |
577 | } executed: } Execution Count:2 | 2 |
578 | } executed: } Execution Count:591 | 591 |
579 | return QWidget::event(e); executed: return QWidget::event(e); Execution Count:27284 | 27284 |
580 | } | - |
581 | | - |
582 | | - |
583 | | - |
584 | void QLineEdit::mousePressEvent(QMouseEvent* e) | - |
585 | { | - |
586 | QLineEditPrivate * const d = d_func(); | - |
587 | | - |
588 | d->mousePressPos = e->pos(); | - |
589 | | - |
590 | if (d->sendMouseEventToInputContext(e)) partially evaluated: d->sendMouseEventToInputContext(e) no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
591 | return; | 0 |
592 | if (e->button() == Qt::RightButton) partially evaluated: e->button() == Qt::RightButton no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
593 | return; | 0 |
594 | if (d->tripleClickTimer.isActive() && (e->pos() - d->tripleClick).manhattanLength() < partially evaluated: d->tripleClickTimer.isActive() no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
595 | QApplication::startDragDistance()) { never evaluated: (e->pos() - d->tripleClick).manhattanLength() < QApplication::startDragDistance() | 0 |
596 | selectAll(); | - |
597 | return; | 0 |
598 | } | - |
599 | bool mark = e->modifiers() & Qt::ShiftModifier; | - |
600 | int cursor = d->xToPos(e->pos().x()); | - |
601 | | - |
602 | 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 |
603 | 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 |
604 | if (!d->dndTimer.isActive()) never evaluated: !d->dndTimer.isActive() | 0 |
605 | d->dndTimer.start(QApplication::startDragTime(), this); never executed: d->dndTimer.start(QApplication::startDragTime(), this); | 0 |
606 | } else | 0 |
607 | | - |
608 | { | - |
609 | d->control->moveCursor(cursor, mark); | - |
610 | } executed: } Execution Count:11 | 11 |
611 | } | - |
612 | | - |
613 | | - |
614 | | - |
615 | void QLineEdit::mouseMoveEvent(QMouseEvent * e) | - |
616 | { | - |
617 | QLineEditPrivate * const d = d_func(); | - |
618 | | - |
619 | if (e->buttons() & Qt::LeftButton) { partially evaluated: e->buttons() & Qt::LeftButton no Evaluation Count:0 | yes Evaluation Count:31 |
| 0-31 |
620 | | - |
621 | if (d->dndTimer.isActive()) { never evaluated: d->dndTimer.isActive() | 0 |
622 | if ((d->mousePressPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) never evaluated: (d->mousePressPos - e->pos()).manhattanLength() > QApplication::startDragDistance() | 0 |
623 | d->drag(); never executed: d->drag(); | 0 |
624 | } else | 0 |
625 | | - |
626 | { | - |
627 | if (d->control->composeMode()) { never evaluated: d->control->composeMode() | 0 |
628 | int startPos = d->xToPos(d->mousePressPos.x()); | - |
629 | int currentPos = d->xToPos(e->pos().x()); | - |
630 | if (startPos != currentPos) never evaluated: startPos != currentPos | 0 |
631 | d->control->setSelection(startPos, currentPos - startPos); never executed: d->control->setSelection(startPos, currentPos - startPos); | 0 |
632 | | - |
633 | } else { | 0 |
634 | d->control->moveCursor(d->xToPos(e->pos().x()), true); | - |
635 | } | 0 |
636 | } | - |
637 | } | - |
638 | | - |
639 | d->sendMouseEventToInputContext(e); | - |
640 | } executed: } Execution Count:31 | 31 |
641 | | - |
642 | | - |
643 | | - |
644 | void QLineEdit::mouseReleaseEvent(QMouseEvent* e) | - |
645 | { | - |
646 | QLineEditPrivate * const d = d_func(); | - |
647 | if (d->sendMouseEventToInputContext(e)) partially evaluated: d->sendMouseEventToInputContext(e) no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
648 | return; | 0 |
649 | | - |
650 | if (e->button() == Qt::LeftButton) { partially evaluated: e->button() == Qt::LeftButton yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-11 |
651 | if (d->dndTimer.isActive()) { partially evaluated: d->dndTimer.isActive() no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
652 | d->dndTimer.stop(); | - |
653 | deselect(); | - |
654 | return; | 0 |
655 | } | - |
656 | } executed: } Execution Count:11 | 11 |
657 | | - |
658 | | - |
659 | if (QApplication::clipboard()->supportsSelection()) { partially evaluated: QApplication::clipboard()->supportsSelection() yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-11 |
660 | if (e->button() == Qt::LeftButton) { partially evaluated: e->button() == Qt::LeftButton yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-11 |
661 | d->control->copy(QClipboard::Selection); | - |
662 | } 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 |
663 | deselect(); | - |
664 | insert(QApplication::clipboard()->text(QClipboard::Selection)); | - |
665 | } | 0 |
666 | } | - |
667 | | - |
668 | | - |
669 | 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 |
670 | d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus); executed: d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus); Execution Count:10 | 10 |
671 | d->clickCausedFocus = 0; | - |
672 | } executed: } Execution Count:11 | 11 |
673 | | - |
674 | | - |
675 | | - |
676 | void QLineEdit::mouseDoubleClickEvent(QMouseEvent* e) | - |
677 | { | - |
678 | QLineEditPrivate * const d = d_func(); | - |
679 | | - |
680 | if (e->button() == Qt::LeftButton) { partially evaluated: e->button() == Qt::LeftButton yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
681 | int position = d->xToPos(e->pos().x()); | - |
682 | | - |
683 | | - |
684 | if (d->control->composeMode()) { partially evaluated: d->control->composeMode() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
685 | int preeditPos = d->control->cursor(); | - |
686 | int posInPreedit = position - d->control->cursor(); | - |
687 | int preeditLength = d->control->preeditAreaText().length(); | - |
688 | bool positionOnPreedit = false; | - |
689 | | - |
690 | if (posInPreedit >= 0 && posInPreedit <= preeditLength) never evaluated: posInPreedit >= 0 never evaluated: posInPreedit <= preeditLength | 0 |
691 | positionOnPreedit = true; never executed: positionOnPreedit = true; | 0 |
692 | | - |
693 | int textLength = d->control->end(); | - |
694 | d->control->commitPreedit(); | - |
695 | int sizeChange = d->control->end() - textLength; | - |
696 | | - |
697 | if (positionOnPreedit) { never evaluated: positionOnPreedit | 0 |
698 | if (sizeChange == 0) never evaluated: sizeChange == 0 | 0 |
699 | position = -1; never executed: position = -1; | 0 |
700 | else | - |
701 | | - |
702 | position = qBound(preeditPos, position, preeditPos + sizeChange); never executed: position = qBound(preeditPos, position, preeditPos + sizeChange); | 0 |
703 | } else if (position > preeditPos) { never evaluated: position > preeditPos | 0 |
704 | | - |
705 | position += (sizeChange - preeditLength); | - |
706 | } | 0 |
707 | } | - |
708 | | - |
709 | if (position >= 0) partially evaluated: position >= 0 yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
710 | d->control->selectWordAtPos(position); executed: d->control->selectWordAtPos(position); Execution Count:2 | 2 |
711 | | - |
712 | d->tripleClickTimer.start(QApplication::doubleClickInterval(), this); | - |
713 | d->tripleClick = e->pos(); | - |
714 | } else { executed: } Execution Count:2 | 2 |
715 | d->sendMouseEventToInputContext(e); | - |
716 | } | 0 |
717 | } | - |
718 | void QLineEdit::keyPressEvent(QKeyEvent *event) | - |
719 | { | - |
720 | QLineEditPrivate * const d = d_func(); | - |
721 | d->control->processKeyEvent(event); | - |
722 | if (event->isAccepted()) { evaluated: event->isAccepted() yes Evaluation Count:2231 | yes Evaluation Count:191 |
| 191-2231 |
723 | if (layoutDirection() != d->control->layoutDirection()) evaluated: layoutDirection() != d->control->layoutDirection() yes Evaluation Count:9 | yes Evaluation Count:2222 |
| 9-2222 |
724 | setLayoutDirection(d->control->layoutDirection()); executed: setLayoutDirection(d->control->layoutDirection()); Execution Count:9 | 9 |
725 | d->control->setCursorBlinkPeriod(0); | - |
726 | } executed: } Execution Count:2231 | 2231 |
727 | } executed: } Execution Count:2422 | 2422 |
728 | | - |
729 | | - |
730 | | - |
731 | | - |
732 | | - |
733 | | - |
734 | QRect QLineEdit::cursorRect() const | - |
735 | { | - |
736 | const QLineEditPrivate * const d = d_func(); | - |
737 | return d->cursorRect(); executed: return d->cursorRect(); Execution Count:1 | 1 |
738 | } | - |
739 | | - |
740 | | - |
741 | | - |
742 | void QLineEdit::inputMethodEvent(QInputMethodEvent *e) | - |
743 | { | - |
744 | QLineEditPrivate * const d = d_func(); | - |
745 | if (d->control->isReadOnly()) { evaluated: d->control->isReadOnly() yes Evaluation Count:4 | yes Evaluation Count:66 |
| 4-66 |
746 | e->ignore(); | - |
747 | return; executed: return; Execution Count:4 | 4 |
748 | } | - |
749 | | - |
750 | 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 |
751 | | - |
752 | | - |
753 | | - |
754 | d->updatePasswordEchoEditing(true); | - |
755 | clear(); | - |
756 | } | 0 |
757 | d->control->processInputMethodEvent(e); | - |
758 | | - |
759 | | - |
760 | if (!e->commitString().isEmpty()) evaluated: !e->commitString().isEmpty() yes Evaluation Count:25 | yes Evaluation Count:41 |
| 25-41 |
761 | d->control->complete(Qt::Key_unknown); executed: d->control->complete(Qt::Key_unknown); Execution Count:25 | 25 |
762 | | - |
763 | } executed: } Execution Count:66 | 66 |
764 | | - |
765 | | - |
766 | | - |
767 | QVariant QLineEdit::inputMethodQuery(Qt::InputMethodQuery property) const | - |
768 | { | - |
769 | const QLineEditPrivate * const d = d_func(); | - |
770 | switch(property) { | - |
771 | case Qt::ImCursorRectangle: | - |
772 | return d->cursorRect(); executed: return d->cursorRect(); Execution Count:1 | 1 |
773 | case Qt::ImFont: | - |
774 | return font(); never executed: return font(); | 0 |
775 | case Qt::ImCursorPosition: | - |
776 | return QVariant(d->control->cursor()); never executed: return QVariant(d->control->cursor()); | 0 |
777 | case Qt::ImSurroundingText: | - |
778 | return QVariant(d->control->text()); never executed: return QVariant(d->control->text()); | 0 |
779 | case Qt::ImCurrentSelection: | - |
780 | return QVariant(selectedText()); never executed: return QVariant(selectedText()); | 0 |
781 | case Qt::ImMaximumTextLength: | - |
782 | return QVariant(maxLength()); never executed: return QVariant(maxLength()); | 0 |
783 | case Qt::ImAnchorPosition: | - |
784 | if (d->control->selectionStart() == d->control->selectionEnd()) never evaluated: d->control->selectionStart() == d->control->selectionEnd() | 0 |
785 | return QVariant(d->control->cursor()); never executed: return QVariant(d->control->cursor()); | 0 |
786 | else if (d->control->selectionStart() == d->control->cursor()) never evaluated: d->control->selectionStart() == d->control->cursor() | 0 |
787 | return QVariant(d->control->selectionEnd()); never executed: return QVariant(d->control->selectionEnd()); | 0 |
788 | else | - |
789 | return QVariant(d->control->selectionStart()); never executed: return QVariant(d->control->selectionStart()); | 0 |
790 | default: | - |
791 | return QWidget::inputMethodQuery(property); executed: return QWidget::inputMethodQuery(property); Execution Count:3436 | 3436 |
792 | } | - |
793 | } | 0 |
794 | | - |
795 | | - |
796 | | - |
797 | | - |
798 | void QLineEdit::focusInEvent(QFocusEvent *e) | - |
799 | { | - |
800 | QLineEditPrivate * const d = d_func(); | - |
801 | if (e->reason() == Qt::TabFocusReason || evaluated: e->reason() == Qt::TabFocusReason yes Evaluation Count:94 | yes Evaluation Count:377 |
| 94-377 |
802 | e->reason() == Qt::BacktabFocusReason || evaluated: e->reason() == Qt::BacktabFocusReason yes Evaluation Count:8 | yes Evaluation Count:369 |
| 8-369 |
803 | e->reason() == Qt::ShortcutFocusReason) { evaluated: e->reason() == Qt::ShortcutFocusReason yes Evaluation Count:2 | yes Evaluation Count:367 |
| 2-367 |
804 | if (!d->control->inputMask().isEmpty()) partially evaluated: !d->control->inputMask().isEmpty() no Evaluation Count:0 | yes Evaluation Count:104 |
| 0-104 |
805 | d->control->moveCursor(d->control->nextMaskBlank(0)); never executed: d->control->moveCursor(d->control->nextMaskBlank(0)); | 0 |
806 | else if (!d->control->hasSelectedText()) evaluated: !d->control->hasSelectedText() yes Evaluation Count:74 | yes Evaluation Count:30 |
| 30-74 |
807 | selectAll(); executed: selectAll(); Execution Count:74 | 74 |
808 | } else if (e->reason() == Qt::MouseFocusReason) { evaluated: e->reason() == Qt::MouseFocusReason yes Evaluation Count:4 | yes Evaluation Count:363 |
| 4-363 |
809 | d->clickCausedFocus = 1; | - |
810 | } executed: } Execution Count:4 | 4 |
811 | | - |
812 | | - |
813 | | - |
814 | d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime()); | - |
815 | QStyleOptionFrameV2 opt; | - |
816 | initStyleOption(&opt); | - |
817 | 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 |
818 | || 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 |
819 | d->setCursorVisible(true); executed: d->setCursorVisible(true); Execution Count:471 | 471 |
820 | if (d->control->completer()) { evaluated: d->control->completer() yes Evaluation Count:114 | yes Evaluation Count:357 |
| 114-357 |
821 | d->control->completer()->setWidget(this); | - |
822 | QObject::connect(d->control->completer(), "2""activated(QString)", | - |
823 | this, "1""setText(QString)"); | - |
824 | QObject::connect(d->control->completer(), "2""highlighted(QString)", | - |
825 | this, "1""_q_completionHighlighted(QString)"); | - |
826 | } executed: } Execution Count:114 | 114 |
827 | | - |
828 | update(); | - |
829 | } executed: } Execution Count:471 | 471 |
830 | | - |
831 | | - |
832 | | - |
833 | | - |
834 | void QLineEdit::focusOutEvent(QFocusEvent *e) | - |
835 | { | - |
836 | QLineEditPrivate * const d = d_func(); | - |
837 | if (d->control->passwordEchoEditing()) { evaluated: d->control->passwordEchoEditing() yes Evaluation Count:2 | yes Evaluation Count:523 |
| 2-523 |
838 | | - |
839 | | - |
840 | d->updatePasswordEchoEditing(false); | - |
841 | } executed: } Execution Count:2 | 2 |
842 | | - |
843 | Qt::FocusReason reason = e->reason(); | - |
844 | if (reason != Qt::ActiveWindowFocusReason && evaluated: reason != Qt::ActiveWindowFocusReason yes Evaluation Count:335 | yes Evaluation Count:190 |
| 190-335 |
845 | reason != Qt::PopupFocusReason) evaluated: reason != Qt::PopupFocusReason yes Evaluation Count:328 | yes Evaluation Count:7 |
| 7-328 |
846 | deselect(); executed: deselect(); Execution Count:328 | 328 |
847 | | - |
848 | d->setCursorVisible(false); | - |
849 | d->control->setCursorBlinkPeriod(0); | - |
850 | | - |
851 | | - |
852 | | - |
853 | | - |
854 | if (reason != Qt::PopupFocusReason evaluated: reason != Qt::PopupFocusReason yes Evaluation Count:518 | yes Evaluation Count:7 |
| 7-518 |
855 | || !(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 |
856 | 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 |
857 | editingFinished(); executed: editingFinished(); Execution Count:449 | 449 |
858 | } executed: } Execution Count:524 | 524 |
859 | if (d->control->completer()) { evaluated: d->control->completer() yes Evaluation Count:49 | yes Evaluation Count:476 |
| 49-476 |
860 | QObject::disconnect(d->control->completer(), 0, this, 0); | - |
861 | } executed: } Execution Count:49 | 49 |
862 | | - |
863 | update(); | - |
864 | } executed: } Execution Count:525 | 525 |
865 | | - |
866 | | - |
867 | | - |
868 | void QLineEdit::paintEvent(QPaintEvent *) | - |
869 | { | - |
870 | QLineEditPrivate * const d = d_func(); | - |
871 | QPainter p(this); | - |
872 | | - |
873 | QRect r = rect(); | - |
874 | QPalette pal = palette(); | - |
875 | | - |
876 | QStyleOptionFrameV2 panel; | - |
877 | initStyleOption(&panel); | - |
878 | style()->drawPrimitive(QStyle::PE_PanelLineEdit, &panel, &p, this); | - |
879 | r = style()->subElementRect(QStyle::SE_LineEditContents, &panel, this); | - |
880 | r.setX(r.x() + d->leftTextMargin); | - |
881 | r.setY(r.y() + d->topTextMargin); | - |
882 | r.setRight(r.right() - d->rightTextMargin); | - |
883 | r.setBottom(r.bottom() - d->bottomTextMargin); | - |
884 | p.setClipRect(r); | - |
885 | | - |
886 | QFontMetrics fm = fontMetrics(); | - |
887 | Qt::Alignment va = QStyle::visualAlignment(d->control->layoutDirection(), QFlag(d->alignment)); | - |
888 | switch (va & Qt::AlignVertical_Mask) { | - |
889 | case Qt::AlignBottom: | - |
890 | d->vscroll = r.y() + r.height() - fm.height() - d->verticalMargin; | - |
891 | break; | 0 |
892 | case Qt::AlignTop: | - |
893 | d->vscroll = r.y() + d->verticalMargin; | - |
894 | break; | 0 |
895 | default: | - |
896 | | - |
897 | d->vscroll = r.y() + (r.height() - fm.height() + 1) / 2; | - |
898 | break; executed: break; Execution Count:762 | 762 |
899 | } | - |
900 | QRect lineRect(r.x() + d->horizontalMargin, d->vscroll, r.width() - 2*d->horizontalMargin, fm.height()); | - |
901 | | - |
902 | int minLB = qMax(0, -fm.minLeftBearing()); | - |
903 | int minRB = qMax(0, -fm.minRightBearing()); | - |
904 | | - |
905 | if (d->control->text().isEmpty()) { evaluated: d->control->text().isEmpty() yes Evaluation Count:439 | yes Evaluation Count:323 |
| 323-439 |
906 | 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 |
907 | QColor col = pal.text().color(); | - |
908 | col.setAlpha(128); | - |
909 | QPen oldpen = p.pen(); | - |
910 | p.setPen(col); | - |
911 | lineRect.adjust(minLB, 0, 0, 0); | - |
912 | QString elidedText = fm.elidedText(d->placeholderText, Qt::ElideRight, lineRect.width()); | - |
913 | p.drawText(lineRect, va, elidedText); | - |
914 | p.setPen(oldpen); | - |
915 | return; | 0 |
916 | } | - |
917 | } executed: } Execution Count:439 | 439 |
918 | | - |
919 | int cix = qRound(d->control->cursorToX()); | - |
920 | | - |
921 | | - |
922 | | - |
923 | | - |
924 | | - |
925 | | - |
926 | | - |
927 | int widthUsed = qRound(d->control->naturalTextWidth()) + 1 + minRB; | - |
928 | if ((minLB + widthUsed) <= lineRect.width()) { evaluated: (minLB + widthUsed) <= lineRect.width() yes Evaluation Count:699 | yes Evaluation Count:63 |
| 63-699 |
929 | | - |
930 | switch (va & ~(Qt::AlignAbsolute|Qt::AlignVertical_Mask)) { | - |
931 | case Qt::AlignRight: | - |
932 | d->hscroll = widthUsed - lineRect.width() + 1; | - |
933 | break; executed: break; Execution Count:2 | 2 |
934 | case Qt::AlignHCenter: | - |
935 | d->hscroll = (widthUsed - lineRect.width()) / 2; | - |
936 | break; executed: break; Execution Count:32 | 32 |
937 | default: | - |
938 | | - |
939 | d->hscroll = 0; | - |
940 | break; executed: break; Execution Count:665 | 665 |
941 | } | - |
942 | d->hscroll -= minLB; | - |
943 | } 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 |
944 | | - |
945 | d->hscroll = cix - lineRect.width() + 1; | - |
946 | } 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 |
947 | | - |
948 | d->hscroll = cix; | - |
949 | } else if (widthUsed - d->hscroll < lineRect.width()) { partially evaluated: widthUsed - d->hscroll < lineRect.width() no Evaluation Count:0 | yes Evaluation Count:53 |
| 0-53 |
950 | | - |
951 | | - |
952 | d->hscroll = widthUsed - lineRect.width() + 1; | - |
953 | } else { | 0 |
954 | | - |
955 | d->hscroll = qMax(0, d->hscroll); | - |
956 | } executed: } Execution Count:53 | 53 |
957 | | - |
958 | | - |
959 | QPoint topLeft = lineRect.topLeft() - QPoint(d->hscroll, d->control->ascent() - fm.ascent()); | - |
960 | | - |
961 | | - |
962 | | - |
963 | if (QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(style())) { evaluated: QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(style()) yes Evaluation Count:7 | yes Evaluation Count:755 |
| 7-755 |
964 | cssStyle->styleSheetPalette(this, &panel, &pal); | - |
965 | } executed: } Execution Count:7 | 7 |
966 | | - |
967 | p.setPen(pal.text().color()); | - |
968 | | - |
969 | int flags = QWidgetLineControl::DrawText; | - |
970 | | - |
971 | | - |
972 | | - |
973 | | - |
974 | 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 |
975 | flags |= QWidgetLineControl::DrawSelections; | - |
976 | | - |
977 | if (d->control->palette() != pal evaluated: d->control->palette() != pal yes Evaluation Count:1 | yes Evaluation Count:50 |
| 1-50 |
978 | || d->control->palette().currentColorGroup() != pal.currentColorGroup()) evaluated: d->control->palette().currentColorGroup() != pal.currentColorGroup() yes Evaluation Count:17 | yes Evaluation Count:33 |
| 17-33 |
979 | d->control->setPalette(pal); executed: d->control->setPalette(pal); Execution Count:18 | 18 |
980 | } executed: } Execution Count:51 | 51 |
981 | | - |
982 | | - |
983 | | - |
984 | | - |
985 | 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 |
986 | flags |= QWidgetLineControl::DrawCursor; executed: flags |= QWidgetLineControl::DrawCursor; Execution Count:386 | 386 |
987 | | - |
988 | d->control->setCursorWidth(style()->pixelMetric(QStyle::PM_TextCursorWidth)); | - |
989 | d->control->draw(&p, topLeft, r, flags); | - |
990 | | - |
991 | } executed: } Execution Count:762 | 762 |
992 | | - |
993 | | - |
994 | | - |
995 | | - |
996 | | - |
997 | void QLineEdit::dragMoveEvent(QDragMoveEvent *e) | - |
998 | { | - |
999 | QLineEditPrivate * const d = d_func(); | - |
1000 | if (!d->control->isReadOnly() && e->mimeData()->hasFormat(QLatin1String("text/plain"))) { never evaluated: !d->control->isReadOnly() never evaluated: e->mimeData()->hasFormat(QLatin1String("text/plain")) | 0 |
1001 | e->acceptProposedAction(); | - |
1002 | d->control->moveCursor(d->xToPos(e->pos().x()), false); | - |
1003 | d->cursorVisible = true; | - |
1004 | update(); | - |
1005 | } | 0 |
1006 | } | 0 |
1007 | | - |
1008 | | - |
1009 | void QLineEdit::dragEnterEvent(QDragEnterEvent * e) | - |
1010 | { | - |
1011 | QLineEdit::dragMoveEvent(e); | - |
1012 | } | 0 |
1013 | | - |
1014 | | - |
1015 | void QLineEdit::dragLeaveEvent(QDragLeaveEvent *) | - |
1016 | { | - |
1017 | QLineEditPrivate * const d = d_func(); | - |
1018 | if (d->cursorVisible) { never evaluated: d->cursorVisible | 0 |
1019 | d->cursorVisible = false; | - |
1020 | update(); | - |
1021 | } | 0 |
1022 | } | 0 |
1023 | | - |
1024 | | - |
1025 | void QLineEdit::dropEvent(QDropEvent* e) | - |
1026 | { | - |
1027 | QLineEditPrivate * const d = d_func(); | - |
1028 | QString str = e->mimeData()->text(); | - |
1029 | | - |
1030 | if (!str.isNull() && !d->control->isReadOnly()) { never evaluated: !str.isNull() never evaluated: !d->control->isReadOnly() | 0 |
1031 | if (e->source() == this && e->dropAction() == Qt::CopyAction) never evaluated: e->source() == this never evaluated: e->dropAction() == Qt::CopyAction | 0 |
1032 | deselect(); never executed: deselect(); | 0 |
1033 | int cursorPos = d->xToPos(e->pos().x()); | - |
1034 | int selStart = cursorPos; | - |
1035 | int oldSelStart = d->control->selectionStart(); | - |
1036 | int oldSelEnd = d->control->selectionEnd(); | - |
1037 | d->control->moveCursor(cursorPos, false); | - |
1038 | d->cursorVisible = false; | - |
1039 | e->acceptProposedAction(); | - |
1040 | insert(str); | - |
1041 | if (e->source() == this) { never evaluated: e->source() == this | 0 |
1042 | if (e->dropAction() == Qt::MoveAction) { never evaluated: e->dropAction() == Qt::MoveAction | 0 |
1043 | if (selStart > oldSelStart && selStart <= oldSelEnd) never evaluated: selStart > oldSelStart never evaluated: selStart <= oldSelEnd | 0 |
1044 | setSelection(oldSelStart, str.length()); never executed: setSelection(oldSelStart, str.length()); | 0 |
1045 | else if (selStart > oldSelEnd) never evaluated: selStart > oldSelEnd | 0 |
1046 | setSelection(selStart - str.length(), str.length()); never executed: setSelection(selStart - str.length(), str.length()); | 0 |
1047 | else | - |
1048 | setSelection(selStart, str.length()); never executed: setSelection(selStart, str.length()); | 0 |
1049 | } else { | - |
1050 | setSelection(selStart, str.length()); | - |
1051 | } | 0 |
1052 | } | - |
1053 | } else { | 0 |
1054 | e->ignore(); | - |
1055 | update(); | - |
1056 | } | 0 |
1057 | } | - |
1058 | void QLineEdit::contextMenuEvent(QContextMenuEvent *event) | - |
1059 | { | - |
1060 | if (QMenu *menu = createStandardContextMenu()) { partially evaluated: QMenu *menu = createStandardContextMenu() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1061 | menu->setAttribute(Qt::WA_DeleteOnClose); | - |
1062 | menu->popup(event->globalPos()); | - |
1063 | } executed: } Execution Count:1 | 1 |
1064 | } executed: } Execution Count:1 | 1 |
1065 | | - |
1066 | | - |
1067 | | - |
1068 | | - |
1069 | | - |
1070 | | - |
1071 | | - |
1072 | QMenu *QLineEdit::createStandardContextMenu() | - |
1073 | { | - |
1074 | QLineEditPrivate * const d = d_func(); | - |
1075 | QMenu *popup = new QMenu(this); | - |
1076 | popup->setObjectName(QLatin1String("qt_edit_menu")); | - |
1077 | QAction *action = 0; | - |
1078 | | - |
1079 | if (!isReadOnly()) { partially evaluated: !isReadOnly() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
1080 | 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())); | - |
1081 | action->setEnabled(d->control->isUndoAvailable()); | - |
1082 | connect(action, "2""triggered()", "1""undo()"); | - |
1083 | | - |
1084 | 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())); | - |
1085 | action->setEnabled(d->control->isRedoAvailable()); | - |
1086 | connect(action, "2""triggered()", "1""redo()"); | - |
1087 | | - |
1088 | popup->addSeparator(); | - |
1089 | } executed: } Execution Count:2 | 2 |
1090 | | - |
1091 | | - |
1092 | if (!isReadOnly()) { partially evaluated: !isReadOnly() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
1093 | 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())); | - |
1094 | action->setEnabled(!d->control->isReadOnly() && d->control->hasSelectedText() | - |
1095 | && d->control->echoMode() == QLineEdit::Normal); | - |
1096 | connect(action, "2""triggered()", "1""cut()"); | - |
1097 | } executed: } Execution Count:2 | 2 |
1098 | | - |
1099 | 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())); | - |
1100 | action->setEnabled(d->control->hasSelectedText() | - |
1101 | && d->control->echoMode() == QLineEdit::Normal); | - |
1102 | connect(action, "2""triggered()", "1""copy()"); | - |
1103 | | - |
1104 | if (!isReadOnly()) { partially evaluated: !isReadOnly() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
1105 | 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())); | - |
1106 | action->setEnabled(!d->control->isReadOnly() && !QApplication::clipboard()->text().isEmpty()); | - |
1107 | connect(action, "2""triggered()", "1""paste()"); | - |
1108 | } executed: } Execution Count:2 | 2 |
1109 | | - |
1110 | | - |
1111 | if (!isReadOnly()) { partially evaluated: !isReadOnly() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
1112 | action = popup->addAction(QLineEdit::tr("Delete")); | - |
1113 | action->setEnabled(!d->control->isReadOnly() && !d->control->text().isEmpty() && d->control->hasSelectedText()); | - |
1114 | connect(action, "2""triggered()", d->control, "1""_q_deleteSelected()"); | - |
1115 | } executed: } Execution Count:2 | 2 |
1116 | | - |
1117 | if (!popup->isEmpty()) partially evaluated: !popup->isEmpty() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
1118 | popup->addSeparator(); executed: popup->addSeparator(); Execution Count:2 | 2 |
1119 | | - |
1120 | 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())); | - |
1121 | action->setEnabled(!d->control->text().isEmpty() && !d->control->allSelected()); | - |
1122 | d->selectAllAction = action; | - |
1123 | connect(action, "2""triggered()", "1""selectAll()"); | - |
1124 | | - |
1125 | if (!d->control->isReadOnly() && (static_cast<QApplication *>(QCoreApplication::instance()))->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 |
1126 | popup->addSeparator(); | - |
1127 | QUnicodeControlCharacterMenu *ctrlCharacterMenu = new QUnicodeControlCharacterMenu(this, popup); | - |
1128 | popup->addMenu(ctrlCharacterMenu); | - |
1129 | } | 0 |
1130 | return popup; executed: return popup; Execution Count:2 | 2 |
1131 | } | - |
1132 | | - |
1133 | | - |
1134 | | - |
1135 | void QLineEdit::changeEvent(QEvent *ev) | - |
1136 | { | - |
1137 | QLineEditPrivate * const d = d_func(); | - |
1138 | switch(ev->type()) | - |
1139 | { | - |
1140 | case QEvent::ActivationChange: | - |
1141 | if (!palette().isEqual(QPalette::Active, QPalette::Inactive)) evaluated: !palette().isEqual(QPalette::Active, QPalette::Inactive) yes Evaluation Count:4 | yes Evaluation Count:51 |
| 4-51 |
1142 | update(); executed: update(); Execution Count:4 | 4 |
1143 | break; executed: break; Execution Count:55 | 55 |
1144 | case QEvent::FontChange: | - |
1145 | d->control->setFont(font()); | - |
1146 | break; executed: break; Execution Count:98 | 98 |
1147 | case QEvent::StyleChange: | - |
1148 | { | - |
1149 | QStyleOptionFrameV2 opt; | - |
1150 | initStyleOption(&opt); | - |
1151 | d->control->setPasswordCharacter(style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, this)); | - |
1152 | } | - |
1153 | update(); | - |
1154 | break; executed: break; Execution Count:19 | 19 |
1155 | default: | - |
1156 | break; executed: break; Execution Count:2336 | 2336 |
1157 | } | - |
1158 | QWidget::changeEvent(ev); | - |
1159 | } executed: } Execution Count:2508 | 2508 |
1160 | | - |
1161 | | - |
1162 | | - |
1163 | | - |
| | |