OpenCoverage

qlineedit.cpp

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

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9