widgets/qlineedit.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9 -
10 -
11 -
12 -
13 -
14 -
15 -
16 -
17 -
18void QLineEdit::initStyleOption(QStyleOptionFrame *option) const -
19{ -
20 if (!option)
partially evaluated: !option
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18752
0-18752
21 return;
never executed: 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
TRUEFALSE
yes
Evaluation Count:2423
yes
Evaluation Count:16329
2423-16329
27 : 0; -
28 option->midLineWidth = 0; -
29 option->state |= QStyle::State_Sunken; -
30 if (d->control->isReadOnly())
evaluated: d->control->isReadOnly()
TRUEFALSE
yes
Evaluation Count:48
yes
Evaluation Count:18704
48-18704
31 option->state |= QStyle::State_ReadOnly;
executed: option->state |= QStyle::State_ReadOnly;
Execution Count:48
48
32 -
33 -
34 -
35 -
36 option->features = QStyleOptionFrame::None; -
37}
executed: }
Execution Count:18752
18752
38QLineEdit::QLineEdit(QWidget* parent) -
39 : QWidget(*new QLineEditPrivate, parent,0) -
40{ -
41 QLineEditPrivate * const d = d_func(); -
42 d->init(QString()); -
43}
executed: }
Execution Count:801
801
44QLineEdit::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:13
13
50 -
51 -
52 -
53 -
54 -
55 -
56 -
57QLineEdit::~QLineEdit() -
58{ -
59} -
60QString QLineEdit::text() const -
61{ -
62 const QLineEditPrivate * const d = d_func(); -
63 return d->control->text();
executed: return d->control->text();
Execution Count:36210
36210
64} -
65 -
66void QLineEdit::setText(const QString& text) -
67{ -
68 QLineEditPrivate * const d = d_func(); -
69 d->control->setText(text); -
70}
executed: }
Execution Count:4602
4602
71QString QLineEdit::placeholderText() const -
72{ -
73 const QLineEditPrivate * const d = d_func(); -
74 return d->placeholderText;
never executed: return d->placeholderText;
0
75} -
76 -
77void 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 }
never executed: }
0
85}
never executed: }
0
86QString QLineEdit::displayText() const -
87{ -
88 const QLineEditPrivate * const d = d_func(); -
89 return d->control->displayText();
executed: return d->control->displayText();
Execution Count:5010
5010
90} -
91int QLineEdit::maxLength() const -
92{ -
93 const QLineEditPrivate * const d = d_func(); -
94 return d->control->maxLength();
executed: return d->control->maxLength();
Execution Count:3
3
95} -
96 -
97void QLineEdit::setMaxLength(int maxLength) -
98{ -
99 QLineEditPrivate * const d = d_func(); -
100 d->control->setMaxLength(maxLength); -
101}
executed: }
Execution Count:2
2
102bool QLineEdit::hasFrame() const -
103{ -
104 const QLineEditPrivate * const d = d_func(); -
105 return d->frame;
executed: return d->frame;
Execution Count:19
19
106} -
107 -
108 -
109void QLineEdit::setFrame(bool enable) -
110{ -
111 QLineEditPrivate * const d = d_func(); -
112 d->frame = enable; -
113 update(); -
114 updateGeometry(); -
115}
executed: }
Execution Count:545
545
116QLineEdit::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:5
5
120} -
121 -
122void QLineEdit::setEchoMode(EchoMode mode) -
123{ -
124 QLineEditPrivate * const d = d_func(); -
125 if (mode == (EchoMode)d->control->echoMode())
partially evaluated: mode == (EchoMode)d->control->echoMode()
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
126 return;
executed: return;
Execution Count:6
6
127 Qt::InputMethodHints imHints = inputMethodHints(); -
128 if (mode == Password || mode == NoEcho) {
never evaluated: mode == Password
never evaluated: mode == NoEcho
0
129 imHints |= Qt::ImhHiddenText; -
130 } else {
never executed: }
0
131 imHints &= ~Qt::ImhHiddenText; -
132 }
never executed: }
0
133 if (mode != Normal) {
never evaluated: mode != Normal
0
134 imHints |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData); -
135 } else {
never executed: }
0
136 imHints &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData); -
137 }
never executed: }
0
138 setInputMethodHints(imHints); -
139 d->control->setEchoMode(mode); -
140 update(); -
141 -
142 -
143 -
144 -
145}
never executed: }
0
146const QValidator * QLineEdit::validator() const -
147{ -
148 const QLineEditPrivate * const d = d_func(); -
149 return d->control->validator();
executed: return d->control->validator();
Execution Count:349
349
150} -
151void QLineEdit::setValidator(const QValidator *v) -
152{ -
153 QLineEditPrivate * const d = d_func(); -
154 d->control->setValidator(v); -
155}
executed: }
Execution Count:700
700
156void QLineEdit::setCompleter(QCompleter *c) -
157{ -
158 QLineEditPrivate * const d = d_func(); -
159 if (c == d->control->completer())
partially evaluated: c == d->control->completer()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:275
0-275
160 return;
never executed: return;
0
161 if (d->control->completer()) {
evaluated: d->control->completer()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:273
2-273
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
TRUEFALSE
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
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:275
0-275
169 return;
never executed: return;
0
170 if (c->widget() == 0)
evaluated: c->widget() == 0
TRUEFALSE
yes
Evaluation Count:273
yes
Evaluation Count:2
2-273
171 c->setWidget(this);
executed: c->setWidget(this);
Execution Count:273
273
172 if (hasFocus()) {
partially evaluated: hasFocus()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:275
0-275
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 }
never executed: }
0
178}
executed: }
Execution Count:275
275
179 -
180 -
181 -
182 -
183 -
184 -
185QCompleter *QLineEdit::completer() const -
186{ -
187 const QLineEditPrivate * const d = d_func(); -
188 return d->control->completer();
executed: return d->control->completer();
Execution Count:592
592
189} -
190QSize 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). 751
204 expandedTo(QApplication::globalStrut()), this));
executed: return (style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(w, h). expandedTo(QApplication::globalStrut()), this));
Execution Count:751
751
205} -
206QSize 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). 241
217 expandedTo(QApplication::globalStrut()), this));
executed: return (style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(w, h). expandedTo(QApplication::globalStrut()), this));
Execution Count:241
241
218} -
219int QLineEdit::cursorPosition() const -
220{ -
221 const QLineEditPrivate * const d = d_func(); -
222 return d->control->cursorPosition();
executed: return d->control->cursorPosition();
Execution Count:7646
7646
223} -
224 -
225void QLineEdit::setCursorPosition(int pos) -
226{ -
227 QLineEditPrivate * const d = d_func(); -
228 d->control->setCursorPosition(pos); -
229}
executed: }
Execution Count:2245
2245
230 -
231 -
232 -
233 -
234 -
235int 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} -
240Qt::Alignment QLineEdit::alignment() const -
241{ -
242 const QLineEditPrivate * const d = d_func(); -
243 return QFlag(d->alignment);
executed: return QFlag(d->alignment);
Execution Count:1
1
244} -
245 -
246void QLineEdit::setAlignment(Qt::Alignment alignment) -
247{ -
248 QLineEditPrivate * const d = d_func(); -
249 d->alignment = alignment; -
250 update(); -
251}
executed: }
Execution Count:3
3
252void QLineEdit::cursorForward(bool mark, int steps) -
253{ -
254 QLineEditPrivate * const d = d_func(); -
255 d->control->cursorForward(mark, steps); -
256}
never executed: }
0
257void QLineEdit::cursorBackward(bool mark, int steps) -
258{ -
259 cursorForward(mark, -steps); -
260}
never executed: }
0
261 -
262 -
263 -
264 -
265 -
266 -
267 -
268void QLineEdit::cursorWordForward(bool mark) -
269{ -
270 QLineEditPrivate * const d = d_func(); -
271 d->control->cursorWordForward(mark); -
272}
never executed: }
0
273void QLineEdit::cursorWordBackward(bool mark) -
274{ -
275 QLineEditPrivate * const d = d_func(); -
276 d->control->cursorWordBackward(mark); -
277}
never executed: }
0
278void QLineEdit::backspace() -
279{ -
280 QLineEditPrivate * const d = d_func(); -
281 d->control->backspace(); -
282}
never executed: }
0
283void QLineEdit::del() -
284{ -
285 QLineEditPrivate * const d = d_func(); -
286 d->control->del(); -
287}
never executed: }
0
288void QLineEdit::home(bool mark) -
289{ -
290 QLineEditPrivate * const d = d_func(); -
291 d->control->home(mark); -
292}
never executed: }
0
293void QLineEdit::end(bool mark) -
294{ -
295 QLineEditPrivate * const d = d_func(); -
296 d->control->end(mark); -
297}
never executed: }
0
298bool QLineEdit::isModified() const -
299{ -
300 const QLineEditPrivate * const d = d_func(); -
301 return d->control->isModified();
executed: return d->control->isModified();
Execution Count:2
2
302} -
303 -
304void QLineEdit::setModified(bool modified) -
305{ -
306 QLineEditPrivate * const d = d_func(); -
307 d->control->setModified(modified); -
308}
never executed: }
0
309bool QLineEdit::hasSelectedText() const -
310{ -
311 const QLineEditPrivate * const d = d_func(); -
312 return d->control->hasSelectedText();
executed: return d->control->hasSelectedText();
Execution Count:5995
5995
313} -
314QString QLineEdit::selectedText() const -
315{ -
316 const QLineEditPrivate * const d = d_func(); -
317 return d->control->selectedText();
executed: return d->control->selectedText();
Execution Count:3494
3494
318} -
319int QLineEdit::selectionStart() const -
320{ -
321 const QLineEditPrivate * const d = d_func(); -
322 return d->control->selectionStart();
executed: return d->control->selectionStart();
Execution Count:2473
2473
323} -
324void QLineEdit::setSelection(int start, int length) -
325{ -
326 QLineEditPrivate * const d = d_func(); -
327 if (start < 0 || start > (int)d->control->end()) {
partially evaluated: start < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3931
partially evaluated: start > (int)d->control->end()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3931
0-3931
328 QMessageLogger("widgets/qlineedit.cpp", 902, __PRETTY_FUNCTION__).warning("QLineEdit::setSelection: Invalid start position (%d)", start); -
329 return;
never executed: return;
0
330 } -
331 -
332 d->control->setSelection(start, length); -
333 -
334 if (d->control->hasSelectedText()){
evaluated: d->control->hasSelectedText()
TRUEFALSE
yes
Evaluation Count:3918
yes
Evaluation Count:13
13-3918
335 QStyleOptionFrameV2 opt; -
336 initStyleOption(&opt); -
337 if (!style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, this))
partially evaluated: !style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, this)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3918
0-3918
338 d->setCursorVisible(false);
never executed: d->setCursorVisible(false);
0
339 }
executed: }
Execution Count:3918
3918
340}
executed: }
Execution Count:3931
3931
341bool QLineEdit::isUndoAvailable() const -
342{ -
343 const QLineEditPrivate * const d = d_func(); -
344 return d->control->isUndoAvailable();
executed: return d->control->isUndoAvailable();
Execution Count:7
7
345} -
346bool QLineEdit::isRedoAvailable() const -
347{ -
348 const QLineEditPrivate * const d = d_func(); -
349 return d->control->isRedoAvailable();
executed: return d->control->isRedoAvailable();
Execution Count:4
4
350} -
351bool QLineEdit::dragEnabled() const -
352{ -
353 const QLineEditPrivate * const d = d_func(); -
354 return d->dragEnabled;
never executed: return d->dragEnabled;
0
355} -
356 -
357void QLineEdit::setDragEnabled(bool b) -
358{ -
359 QLineEditPrivate * const d = d_func(); -
360 d->dragEnabled = b; -
361}
never executed: }
0
362Qt::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 -
368void QLineEdit::setCursorMoveStyle(Qt::CursorMoveStyle style) -
369{ -
370 QLineEditPrivate * const d = d_func(); -
371 d->control->setCursorMoveStyle(style); -
372}
never executed: }
0
373bool QLineEdit::hasAcceptableInput() const -
374{ -
375 const QLineEditPrivate * const d = d_func(); -
376 return d->control->hasAcceptableInput();
executed: return d->control->hasAcceptableInput();
Execution Count:1727
1727
377} -
378void 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}
never executed: }
0
388 -
389 -
390 -
391 -
392 -
393 -
394 -
395void QLineEdit::setTextMargins(const QMargins &margins) -
396{ -
397 setTextMargins(margins.left(), margins.top(), margins.right(), margins.bottom()); -
398}
never executed: }
0
399 -
400 -
401 -
402 -
403 -
404 -
405 -
406void QLineEdit::getTextMargins(int *left, int *top, int *right, int *bottom) const -
407{ -
408 const QLineEditPrivate * const d = d_func(); -
409 if (left)
partially evaluated: left
TRUEFALSE
yes
Evaluation Count:49
no
Evaluation Count:0
0-49
410 *left = d->leftTextMargin;
executed: *left = d->leftTextMargin;
Execution Count:49
49
411 if (top)
partially evaluated: top
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:49
0-49
412 *top = d->topTextMargin;
never executed: *top = d->topTextMargin;
0
413 if (right)
partially evaluated: right
TRUEFALSE
yes
Evaluation Count:49
no
Evaluation Count:0
0-49
414 *right = d->rightTextMargin;
executed: *right = d->rightTextMargin;
Execution Count:49
49
415 if (bottom)
partially evaluated: bottom
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:49
0-49
416 *bottom = d->bottomTextMargin;
never executed: *bottom = d->bottomTextMargin;
0
417}
executed: }
Execution Count:49
49
418 -
419 -
420 -
421 -
422 -
423 -
424 -
425QMargins 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} -
430QString QLineEdit::inputMask() const -
431{ -
432 const QLineEditPrivate * const d = d_func(); -
433 return d->control->inputMask();
executed: return d->control->inputMask();
Execution Count:4
4
434} -
435 -
436void QLineEdit::setInputMask(const QString &inputMask) -
437{ -
438 QLineEditPrivate * const d = d_func(); -
439 d->control->setInputMask(inputMask); -
440}
executed: }
Execution Count:2
2
441void QLineEdit::selectAll() -
442{ -
443 QLineEditPrivate * const d = d_func(); -
444 d->control->selectAll(); -
445}
executed: }
Execution Count:236
236
446 -
447 -
448 -
449 -
450 -
451 -
452 -
453void QLineEdit::deselect() -
454{ -
455 QLineEditPrivate * const d = d_func(); -
456 d->control->deselect(); -
457}
executed: }
Execution Count:177
177
458void QLineEdit::insert(const QString &newText) -
459{ -
460 -
461 QLineEditPrivate * const d = d_func(); -
462 d->control->insert(newText); -
463}
executed: }
Execution Count:35
35
464 -
465 -
466 -
467 -
468 -
469 -
470void QLineEdit::clear() -
471{ -
472 QLineEditPrivate * const d = d_func(); -
473 d->resetInputMethod(); -
474 d->control->clear(); -
475}
executed: }
Execution Count:3
3
476 -
477 -
478 -
479 -
480 -
481 -
482void QLineEdit::undo() -
483{ -
484 QLineEditPrivate * const d = d_func(); -
485 d->resetInputMethod(); -
486 d->control->undo(); -
487}
never executed: }
0
488 -
489 -
490 -
491 -
492void QLineEdit::redo() -
493{ -
494 QLineEditPrivate * const d = d_func(); -
495 d->resetInputMethod(); -
496 d->control->redo(); -
497}
never executed: }
0
498bool QLineEdit::isReadOnly() const -
499{ -
500 const QLineEditPrivate * const d = d_func(); -
501 return d->control->isReadOnly();
executed: return d->control->isReadOnly();
Execution Count:13
13
502} -
503 -
504void QLineEdit::setReadOnly(bool enable) -
505{ -
506 QLineEditPrivate * const d = d_func(); -
507 if (d->control->isReadOnly() != enable) {
partially evaluated: d->control->isReadOnly() != enable
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-13
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:13
13
516}
executed: }
Execution Count:13
13
517void QLineEdit::cut() -
518{ -
519 if (hasSelectedText()) {
never evaluated: hasSelectedText()
0
520 copy(); -
521 del(); -
522 }
never executed: }
0
523}
never executed: }
0
524void QLineEdit::copy() const -
525{ -
526 const QLineEditPrivate * const d = d_func(); -
527 d->control->copy(); -
528}
never executed: }
0
529void QLineEdit::paste() -
530{ -
531 QLineEditPrivate * const d = d_func(); -
532 d->control->paste(); -
533}
never executed: }
0
534 -
535 -
536 -
537 -
538 -
539bool QLineEdit::event(QEvent * e) -
540{ -
541 QLineEditPrivate * const d = d_func(); -
542 if (e->type() == QEvent::Timer) {
partially evaluated: e->type() == QEvent::Timer
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15997
0-15997
543 -
544 int timerId = ((QTimerEvent*)e)->timerId(); -
545 if (false) {
never evaluated: false
0
546 -
547 } else if (timerId == d->dndTimer.timerId()) {
never evaluated: timerId == d->dndTimer.timerId()
never executed: }
0
548 d->drag(); -
549 -
550 }
never executed: }
0
551 else if (timerId == d->tripleClickTimer.timerId())
never evaluated: timerId == d->tripleClickTimer.timerId()
0
552 d->tripleClickTimer.stop();
never executed: d->tripleClickTimer.stop();
0
553 } else if (e->type() == QEvent::ContextMenu) {
partially evaluated: e->type() == QEvent::ContextMenu
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15997
0-15997
554 -
555 if (d->control->composeMode())
never evaluated: d->control->composeMode()
0
556 return true;
never executed: return true;
0
557 -
558 -
559 } else if (e->type() == QEvent::WindowActivate) {
evaluated: e->type() == QEvent::WindowActivate
TRUEFALSE
yes
Evaluation Count:176
yes
Evaluation Count:15821
never executed: }
0-15821
560 QTimer::singleShot(0, this, "1""_q_handleWindowActivate()"); -
561 -
562 } else if (e->type() == QEvent::ShortcutOverride) {
evaluated: e->type() == QEvent::ShortcutOverride
TRUEFALSE
yes
Evaluation Count:2539
yes
Evaluation Count:13282
executed: }
Execution Count:176
176-13282
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
TRUEFALSE
yes
Evaluation Count:2414
yes
Evaluation Count:10868
executed: }
Execution Count:2539
2414-10868
567 d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime()); -
568 } else if (e->type() == QEvent::Show) {
evaluated: e->type() == QEvent::Show
TRUEFALSE
yes
Evaluation Count:421
yes
Evaluation Count:10447
executed: }
Execution Count:2414
421-10447
569 -
570 if (hasFocus()) {
evaluated: hasFocus()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:419
2-419
571 d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime()); -
572 QStyleOptionFrameV2 opt; -
573 initStyleOption(&opt); -
574 if ((!hasSelectedText() && d->control->preeditAreaText().isEmpty())
partially evaluated: !hasSelectedText()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: d->control->preeditAreaText().isEmpty()
TRUEFALSE
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:421
421
579 return QWidget::event(e);
executed: return QWidget::event(e);
Execution Count:15997
15997
580} -
581 -
582 -
583 -
584void 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)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
591 return;
never executed: return;
0
592 if (e->button() == Qt::RightButton)
partially evaluated: e->button() == Qt::RightButton
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
593 return;
never executed: return;
0
594 if (d->tripleClickTimer.isActive() && (e->pos() - d->tripleClick).manhattanLength() <
partially evaluated: d->tripleClickTimer.isActive()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
595 QApplication::startDragDistance()) {
never evaluated: (e->pos() - d->tripleClick).manhattanLength() < QApplication::startDragDistance()
0
596 selectAll(); -
597 return;
never executed: 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
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: d->dragEnabled
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
never evaluated: d->control->echoMode() == Normal
0-1
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
never executed: }
0
607 -
608 { -
609 d->control->moveCursor(cursor, mark); -
610 }
executed: }
Execution Count:1
1
611} -
612 -
613 -
614 -
615void QLineEdit::mouseMoveEvent(QMouseEvent * e) -
616{ -
617 QLineEditPrivate * const d = d_func(); -
618 -
619 if (e->buttons() & Qt::LeftButton) {
partially evaluated: e->buttons() & Qt::LeftButton
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
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
never executed: }
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 {
never executed: }
0
634 d->control->moveCursor(d->xToPos(e->pos().x()), true); -
635 }
never executed: }
0
636 } -
637 } -
638 -
639 d->sendMouseEventToInputContext(e); -
640}
executed: }
Execution Count:3
3
641 -
642 -
643 -
644void QLineEdit::mouseReleaseEvent(QMouseEvent* e) -
645{ -
646 QLineEditPrivate * const d = d_func(); -
647 if (d->sendMouseEventToInputContext(e))
partially evaluated: d->sendMouseEventToInputContext(e)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
648 return;
never executed: return;
0
649 -
650 if (e->button() == Qt::LeftButton) {
partially evaluated: e->button() == Qt::LeftButton
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
651 if (d->dndTimer.isActive()) {
partially evaluated: d->dndTimer.isActive()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
652 d->dndTimer.stop(); -
653 deselect(); -
654 return;
never executed: return;
0
655 } -
656 }
executed: }
Execution Count:1
1
657 -
658 -
659 if (QApplication::clipboard()->supportsSelection()) {
partially evaluated: QApplication::clipboard()->supportsSelection()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
660 if (e->button() == Qt::LeftButton) {
partially evaluated: e->button() == Qt::LeftButton
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
661 d->control->copy(QClipboard::Selection); -
662 } else if (!d->control->isReadOnly() && e->button() == Qt::MidButton) {
executed: }
Execution Count:1
never evaluated: !d->control->isReadOnly()
never evaluated: e->button() == Qt::MidButton
0-1
663 deselect(); -
664 insert(QApplication::clipboard()->text(QClipboard::Selection)); -
665 }
never executed: }
0
666 } -
667 -
668 -
669 if (!isReadOnly() && rect().contains(e->pos()))
partially evaluated: !isReadOnly()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: rect().contains(e->pos())
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
670 d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus);
executed: d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus);
Execution Count:1
1
671 d->clickCausedFocus = 0; -
672}
executed: }
Execution Count:1
1
673 -
674 -
675 -
676void QLineEdit::mouseDoubleClickEvent(QMouseEvent* e) -
677{ -
678 QLineEditPrivate * const d = d_func(); -
679 -
680 if (e->button() == Qt::LeftButton) {
partially evaluated: e->button() == Qt::LeftButton
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
681 int position = d->xToPos(e->pos().x()); -
682 -
683 -
684 if (d->control->composeMode()) {
partially evaluated: d->control->composeMode()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
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 }
never executed: }
0
707 } -
708 -
709 if (position >= 0)
partially evaluated: position >= 0
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
710 d->control->selectWordAtPos(position);
executed: d->control->selectWordAtPos(position);
Execution Count:1
1
711 -
712 d->tripleClickTimer.start(QApplication::doubleClickInterval(), this); -
713 d->tripleClick = e->pos(); -
714 } else {
executed: }
Execution Count:1
1
715 d->sendMouseEventToInputContext(e); -
716 }
never executed: }
0
717} -
718void QLineEdit::keyPressEvent(QKeyEvent *event) -
719{ -
720 QLineEditPrivate * const d = d_func(); -
721 d->control->processKeyEvent(event); -
722 if (event->isAccepted()) {
evaluated: event->isAccepted()
TRUEFALSE
yes
Evaluation Count:1097
yes
Evaluation Count:81
81-1097
723 if (layoutDirection() != d->control->layoutDirection())
evaluated: layoutDirection() != d->control->layoutDirection()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1096
1-1096
724 setLayoutDirection(d->control->layoutDirection());
executed: setLayoutDirection(d->control->layoutDirection());
Execution Count:1
1
725 d->control->setCursorBlinkPeriod(0); -
726 }
executed: }
Execution Count:1097
1097
727}
executed: }
Execution Count:1178
1178
728 -
729 -
730 -
731 -
732 -
733 -
734QRect QLineEdit::cursorRect() const -
735{ -
736 const QLineEditPrivate * const d = d_func(); -
737 return d->cursorRect();
never executed: return d->cursorRect();
0
738} -
739 -
740 -
741 -
742void QLineEdit::inputMethodEvent(QInputMethodEvent *e) -
743{ -
744 QLineEditPrivate * const d = d_func(); -
745 if (d->control->isReadOnly()) {
never evaluated: d->control->isReadOnly()
0
746 e->ignore(); -
747 return;
never executed: return;
0
748 } -
749 -
750 if (echoMode() == PasswordEchoOnEdit && !d->control->passwordEchoEditing()) {
never evaluated: echoMode() == PasswordEchoOnEdit
never evaluated: !d->control->passwordEchoEditing()
0
751 -
752 -
753 -
754 d->updatePasswordEchoEditing(true); -
755 clear(); -
756 }
never executed: }
0
757 d->control->processInputMethodEvent(e); -
758 -
759 -
760 if (!e->commitString().isEmpty())
never evaluated: !e->commitString().isEmpty()
0
761 d->control->complete(Qt::Key_unknown);
never executed: d->control->complete(Qt::Key_unknown);
0
762 -
763}
never executed: }
0
764 -
765 -
766 -
767QVariant 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();
never executed: return d->cursorRect();
0
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:668
668
792 } -
793}
never executed: }
0
794 -
795 -
796 -
797 -
798void QLineEdit::focusInEvent(QFocusEvent *e) -
799{ -
800 QLineEditPrivate * const d = d_func(); -
801 if (e->reason() == Qt::TabFocusReason ||
evaluated: e->reason() == Qt::TabFocusReason
TRUEFALSE
yes
Evaluation Count:65
yes
Evaluation Count:183
65-183
802 e->reason() == Qt::BacktabFocusReason ||
evaluated: e->reason() == Qt::BacktabFocusReason
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:175
8-175
803 e->reason() == Qt::ShortcutFocusReason) {
evaluated: e->reason() == Qt::ShortcutFocusReason
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:173
2-173
804 if (!d->control->inputMask().isEmpty())
partially evaluated: !d->control->inputMask().isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:75
0-75
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()
TRUEFALSE
yes
Evaluation Count:48
yes
Evaluation Count:27
27-48
807 selectAll();
executed: selectAll();
Execution Count:48
48
808 } else if (e->reason() == Qt::MouseFocusReason) {
evaluated: e->reason() == Qt::MouseFocusReason
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:171
2-171
809 d->clickCausedFocus = 1; -
810 }
executed: }
Execution Count:2
2
811 -
812 -
813 -
814 d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime()); -
815 QStyleOptionFrameV2 opt; -
816 initStyleOption(&opt); -
817 if((!hasSelectedText() && d->control->preeditAreaText().isEmpty())
evaluated: !hasSelectedText()
TRUEFALSE
yes
Evaluation Count:197
yes
Evaluation Count:51
partially evaluated: d->control->preeditAreaText().isEmpty()
TRUEFALSE
yes
Evaluation Count:197
no
Evaluation Count:0
0-197
818 || style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, this))
partially evaluated: style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, this)
TRUEFALSE
yes
Evaluation Count:51
no
Evaluation Count:0
0-51
819 d->setCursorVisible(true);
executed: d->setCursorVisible(true);
Execution Count:248
248
820 if (d->control->completer()) {
evaluated: d->control->completer()
TRUEFALSE
yes
Evaluation Count:47
yes
Evaluation Count:201
47-201
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:47
47
827 -
828 update(); -
829}
executed: }
Execution Count:248
248
830 -
831 -
832 -
833 -
834void QLineEdit::focusOutEvent(QFocusEvent *e) -
835{ -
836 QLineEditPrivate * const d = d_func(); -
837 if (d->control->passwordEchoEditing()) {
partially evaluated: d->control->passwordEchoEditing()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:143
0-143
838 -
839 -
840 d->updatePasswordEchoEditing(false); -
841 }
never executed: }
0
842 -
843 Qt::FocusReason reason = e->reason(); -
844 if (reason != Qt::ActiveWindowFocusReason &&
evaluated: reason != Qt::ActiveWindowFocusReason
TRUEFALSE
yes
Evaluation Count:71
yes
Evaluation Count:72
71-72
845 reason != Qt::PopupFocusReason)
evaluated: reason != Qt::PopupFocusReason
TRUEFALSE
yes
Evaluation Count:70
yes
Evaluation Count:1
1-70
846 deselect();
executed: deselect();
Execution Count:70
70
847 -
848 d->setCursorVisible(false); -
849 d->control->setCursorBlinkPeriod(0); -
850 -
851 -
852 -
853 -
854 if (reason != Qt::PopupFocusReason
evaluated: reason != Qt::PopupFocusReason
TRUEFALSE
yes
Evaluation Count:142
yes
Evaluation Count:1
1-142
855 || !(QApplication::activePopupWidget() && QApplication::activePopupWidget()->parentWidget() == this)) {
partially evaluated: QApplication::activePopupWidget()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: QApplication::activePopupWidget()->parentWidget() == this
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
856 if (hasAcceptableInput() || d->control->fixup())
partially evaluated: hasAcceptableInput()
TRUEFALSE
yes
Evaluation Count:143
no
Evaluation Count:0
never evaluated: d->control->fixup()
0-143
857 editingFinished();
executed: editingFinished();
Execution Count:143
143
858 }
executed: }
Execution Count:143
143
859 if (d->control->completer()) {
evaluated: d->control->completer()
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:126
17-126
860 QObject::disconnect(d->control->completer(), 0, this, 0); -
861 }
executed: }
Execution Count:17
17
862 -
863 update(); -
864}
executed: }
Execution Count:143
143
865 -
866 -
867 -
868void 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;
never executed: break;
0
892 case Qt::AlignTop: -
893 d->vscroll = r.y() + d->verticalMargin; -
894 break;
never executed: break;
0
895 default: -
896 -
897 d->vscroll = r.y() + (r.height() - fm.height() + 1) / 2; -
898 break;
executed: break;
Execution Count:366
366
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()
TRUEFALSE
yes
Evaluation Count:107
yes
Evaluation Count:259
107-259
906 if (!hasFocus() && !d->placeholderText.isEmpty()) {
evaluated: !hasFocus()
TRUEFALSE
yes
Evaluation Count:56
yes
Evaluation Count:51
partially evaluated: !d->placeholderText.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:56
0-56
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;
never executed: return;
0
916 } -
917 }
executed: }
Execution Count:107
107
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()
TRUEFALSE
yes
Evaluation Count:318
yes
Evaluation Count:48
48-318
929 -
930 switch (va & ~(Qt::AlignAbsolute|Qt::AlignVertical_Mask)) { -
931 case Qt::AlignRight: -
932 d->hscroll = widthUsed - lineRect.width() + 1; -
933 break;
never executed: break;
0
934 case Qt::AlignHCenter: -
935 d->hscroll = (widthUsed - lineRect.width()) / 2; -
936 break;
executed: break;
Execution Count:2
2
937 default: -
938 -
939 d->hscroll = 0; -
940 break;
executed: break;
Execution Count:316
316
941 } -
942 d->hscroll -= minLB; -
943 } else if (cix - d->hscroll >= lineRect.width()) {
executed: }
Execution Count:318
evaluated: cix - d->hscroll >= lineRect.width()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:43
5-318
944 -
945 d->hscroll = cix - lineRect.width() + 1; -
946 } else if (cix - d->hscroll < 0 && d->hscroll < widthUsed) {
executed: }
Execution Count:5
partially evaluated: cix - d->hscroll < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:43
never evaluated: d->hscroll < widthUsed
0-43
947 -
948 d->hscroll = cix; -
949 } else if (widthUsed - d->hscroll < lineRect.width()) {
never executed: }
partially evaluated: widthUsed - d->hscroll < lineRect.width()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:43
0-43
950 -
951 -
952 d->hscroll = widthUsed - lineRect.width() + 1; -
953 } else {
never executed: }
0
954 -
955 d->hscroll = qMax(0, d->hscroll); -
956 }
executed: }
Execution Count:43
43
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())
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:364
2-364
964 cssStyle->styleSheetPalette(this, &panel, &pal); -
965 }
executed: }
Execution Count:2
2
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()
TRUEFALSE
yes
Evaluation Count:37
yes
Evaluation Count:329
evaluated: d->cursorVisible
TRUEFALSE
yes
Evaluation Count:152
yes
Evaluation Count:177
partially evaluated: !d->control->inputMask().isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:152
never evaluated: !d->control->isReadOnly()
0-329
975 flags |= QWidgetLineControl::DrawSelections; -
976 -
977 if (d->control->palette() != pal
partially evaluated: d->control->palette() != pal
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:37
0-37
978 || d->control->palette().currentColorGroup() != pal.currentColorGroup())
evaluated: d->control->palette().currentColorGroup() != pal.currentColorGroup()
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:26
11-26
979 d->control->setPalette(pal);
executed: d->control->setPalette(pal);
Execution Count:11
11
980 }
executed: }
Execution Count:37
37
981 -
982 -
983 -
984 -
985 if (d->cursorVisible && !d->control->isReadOnly())
evaluated: d->cursorVisible
TRUEFALSE
yes
Evaluation Count:188
yes
Evaluation Count:178
evaluated: !d->control->isReadOnly()
TRUEFALSE
yes
Evaluation Count:184
yes
Evaluation Count:4
4-188
986 flags |= QWidgetLineControl::DrawCursor;
executed: flags |= QWidgetLineControl::DrawCursor;
Execution Count:184
184
987 -
988 d->control->setCursorWidth(style()->pixelMetric(QStyle::PM_TextCursorWidth)); -
989 d->control->draw(&p, topLeft, r, flags); -
990 -
991}
executed: }
Execution Count:366
366
992 -
993 -
994 -
995 -
996 -
997void 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 }
never executed: }
0
1006}
never executed: }
0
1007 -
1008 -
1009void QLineEdit::dragEnterEvent(QDragEnterEvent * e) -
1010{ -
1011 QLineEdit::dragMoveEvent(e); -
1012}
never executed: }
0
1013 -
1014 -
1015void 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 }
never executed: }
0
1022}
never executed: }
0
1023 -
1024 -
1025void 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 }
never executed: }
0
1052 } -
1053 } else {
never executed: }
0
1054 e->ignore(); -
1055 update(); -
1056 }
never executed: }
0
1057} -
1058void QLineEdit::contextMenuEvent(QContextMenuEvent *event) -
1059{ -
1060 if (QMenu *menu = createStandardContextMenu()) {
never evaluated: QMenu *menu = createStandardContextMenu()
0
1061 menu->setAttribute(Qt::WA_DeleteOnClose); -
1062 menu->popup(event->globalPos()); -
1063 }
never executed: }
0
1064}
never executed: }
0
1065 -
1066 -
1067 -
1068 -
1069 -
1070 -
1071 -
1072QMenu *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()) {
never evaluated: !isReadOnly()
0
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 }
never executed: }
0
1090 -
1091 -
1092 if (!isReadOnly()) {
never evaluated: !isReadOnly()
0
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 }
never executed: }
0
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()) {
never evaluated: !isReadOnly()
0
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 }
never executed: }
0
1109 -
1110 -
1111 if (!isReadOnly()) {
never evaluated: !isReadOnly()
0
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 }
never executed: }
0
1116 -
1117 if (!popup->isEmpty())
never evaluated: !popup->isEmpty()
0
1118 popup->addSeparator();
never executed: popup->addSeparator();
0
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()) {
never evaluated: !d->control->isReadOnly()
never evaluated: (static_cast<QApplication *>(QCoreApplication::instance()))->styleHints()->useRtlExtensions()
0
1126 popup->addSeparator(); -
1127 QUnicodeControlCharacterMenu *ctrlCharacterMenu = new QUnicodeControlCharacterMenu(this, popup); -
1128 popup->addMenu(ctrlCharacterMenu); -
1129 }
never executed: }
0
1130 return popup;
never executed: return popup;
0
1131} -
1132 -
1133 -
1134 -
1135void 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))
never evaluated: !palette().isEqual(QPalette::Active, QPalette::Inactive)
0
1142 update();
never executed: update();
0
1143 break;
never executed: break;
0
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:15
15
1155 default: -
1156 break;
executed: break;
Execution Count:1789
1789
1157 } -
1158 QWidget::changeEvent(ev); -
1159}
executed: }
Execution Count:1902
1902
1160 -
1161 -
1162 -
1163 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial