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)-
21 return;-
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)-
27 : 0;-
28 option->midLineWidth = 0;-
29 option->state |= QStyle::State_Sunken;-
30 if (d->control->isReadOnly())-
31 option->state |= QStyle::State_ReadOnly;-
32-
33-
34-
35-
36 option->features = QStyleOptionFrame::None;-
37}-
38QLineEdit::QLineEdit(QWidget* parent)-
39 : QWidget(*new QLineEditPrivate, parent,0)-
40{-
41 QLineEditPrivate * const d = d_func();-
42 d->init(QString());-
43}-
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}-
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();-
64}-
65-
66void QLineEdit::setText(const QString& text)-
67{-
68 QLineEditPrivate * const d = d_func();-
69 d->control->setText(text);-
70}-
71QString QLineEdit::placeholderText() const-
72{-
73 const QLineEditPrivate * const d = d_func();-
74 return d->placeholderText;-
75}-
76-
77void QLineEdit::setPlaceholderText(const QString& placeholderText)-
78{-
79 QLineEditPrivate * const d = d_func();-
80 if (d->placeholderText != placeholderText) {-
81 d->placeholderText = placeholderText;-
82 if (d->shouldShowPlaceholderText())-
83 update();-
84 }-
85}-
86QString QLineEdit::displayText() const-
87{-
88 const QLineEditPrivate * const d = d_func();-
89 return d->control->displayText();-
90}-
91int QLineEdit::maxLength() const-
92{-
93 const QLineEditPrivate * const d = d_func();-
94 return d->control->maxLength();-
95}-
96-
97void QLineEdit::setMaxLength(int maxLength)-
98{-
99 QLineEditPrivate * const d = d_func();-
100 d->control->setMaxLength(maxLength);-
101}-
102bool QLineEdit::hasFrame() const-
103{-
104 const QLineEditPrivate * const d = d_func();-
105 return d->frame;-
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}-
113QAction *QLineEdit::addAction(const QIcon &icon, ActionPosition position)-
114{-
115 QAction *result = new QAction(icon, QString(), this);-
116 addAction(result, position);-
117 return result;-
118}-
119static const char clearButtonActionNameC[] = "_q_qlineeditclearaction";-
120-
121void QLineEdit::setClearButtonEnabled(bool enable)-
122{-
123 QLineEditPrivate * const d = d_func();-
124 if (enable == isClearButtonEnabled())-
125 return;-
126 if (enable) {-
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 } else {-
132 QAction *clearAction = findChild<QAction *>(QLatin1String(clearButtonActionNameC));-
133 ((!(clearAction)) ? qt_assert("clearAction",__FILE__,492498) : qt_noop());-
134 d->removeAction(clearAction);-
135 delete clearAction;-
136 }-
137}-
138-
139bool QLineEdit::isClearButtonEnabled() const-
140{-
141 return findChild<QAction *>(QLatin1String(clearButtonActionNameC));-
142}-
143-
144void QLineEdit::setFrame(bool enable)-
145{-
146 QLineEditPrivate * const d = d_func();-
147 d->frame = enable;-
148 update();-
149 updateGeometry();-
150}-
151QLineEdit::EchoMode QLineEdit::echoMode() const-
152{-
153 const QLineEditPrivate * const d = d_func();-
154 return (EchoMode) d->control->echoMode();-
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 ifimHints.setFlag(Qt::ImhHiddenText, mode == Password || mode == NoEcho) {-
imHints |= Qt::ImhHiddenText;
} else {);
164 imHints&= ~.setFlag(Qt::ImhHiddenText;-
}
if (ImhNoAutoUppercase, mode != Normal) {);
165 imHints|=.setFlag(Qt::ImhNoAutoUppercase |Qt::ImhNoPredictiveText| Qt::ImhSensitiveData, mode != Normal);-
166 } else {imHints&= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText |.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 d->control->validator();-
179}-
180void QLineEdit::setValidator(const QValidator *v)-
181{-
182 QLineEditPrivate * const d = d_func();-
183 d->control->setValidator(v);-
184}-
185void QLineEdit::setCompleter(QCompleter *c)-
186{-
187 QLineEditPrivate * const d = d_func();-
188 if (c == d->control->completer())-
189 return;-
190 if (d->control->completer()) {-
191 disconnect(d->control->completer(), 0, this, 0);-
192 d->control->completer()->setWidget(0);-
193 if (d->control->completer()->parent() == this)-
194 delete d->control->completer();-
195 }-
196 d->control->setCompleter(c);-
197 if (!c)-
198 return;-
199 if (c->widget() == 0)-
200 c->setWidget(this);-
201 if (hasFocus()) {-
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 }-
207}-
208-
209-
210-
211-
212-
213-
214QCompleter *QLineEdit::completer() const-
215{-
216 const QLineEditPrivate * const d = d_func();-
217 return d->control->completer();-
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 (style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(w, h).-
233 expandedTo(QApplication::globalStrut()), this));-
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 (style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(w, h).-
249 expandedTo(QApplication::globalStrut()), this));-
250}-
251int QLineEdit::cursorPosition() const-
252{-
253 const QLineEditPrivate * const d = d_func();-
254 return d->control->cursorPosition();-
255}-
256-
257void QLineEdit::setCursorPosition(int pos)-
258{-
259 QLineEditPrivate * const d = d_func();-
260 d->control->setCursorPosition(pos);-
261}-
262-
263-
264-
265-
266-
267int QLineEdit::cursorPositionAt(const QPoint &pos)-
268{-
269 QLineEditPrivate * const d = d_func();-
270 return d->xToPos(pos.x());-
271}-
272Qt::Alignment QLineEdit::alignment() const-
273{-
274 const QLineEditPrivate * const d = d_func();-
275 return QFlag(d->alignment);-
276}-
277-
278void QLineEdit::setAlignment(Qt::Alignment alignment)-
279{-
280 QLineEditPrivate * const d = d_func();-
281 d->alignment = alignment;-
282 update();-
283}-
284void QLineEdit::cursorForward(bool mark, int steps)-
285{-
286 QLineEditPrivate * const d = d_func();-
287 d->control->cursorForward(mark, steps);-
288}-
289void QLineEdit::cursorBackward(bool mark, int steps)-
290{-
291 cursorForward(mark, -steps);-
292}-
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}-
305void QLineEdit::cursorWordBackward(bool mark)-
306{-
307 QLineEditPrivate * const d = d_func();-
308 d->control->cursorWordBackward(mark);-
309}-
310void QLineEdit::backspace()-
311{-
312 QLineEditPrivate * const d = d_func();-
313 d->control->backspace();-
314}-
315void QLineEdit::del()-
316{-
317 QLineEditPrivate * const d = d_func();-
318 d->control->del();-
319}-
320void QLineEdit::home(bool mark)-
321{-
322 QLineEditPrivate * const d = d_func();-
323 d->control->home(mark);-
324}-
325void QLineEdit::end(bool mark)-
326{-
327 QLineEditPrivate * const d = d_func();-
328 d->control->end(mark);-
329}-
330bool QLineEdit::isModified() const-
331{-
332 const QLineEditPrivate * const d = d_func();-
333 return d->control->isModified();-
334}-
335-
336void QLineEdit::setModified(bool modified)-
337{-
338 QLineEditPrivate * const d = d_func();-
339 d->control->setModified(modified);-
340}-
341bool QLineEdit::hasSelectedText() const-
342{-
343 const QLineEditPrivate * const d = d_func();-
344 return d->control->hasSelectedText();-
345}-
346QString QLineEdit::selectedText() const-
347{-
348 const QLineEditPrivate * const d = d_func();-
349 return d->control->selectedText();-
350}-
351int QLineEdit::selectionStart() const-
352{-
353 const QLineEditPrivate * const d = d_func();-
354 return d->control->selectionStart();-
355}-
356void QLineEdit::setSelection(int start, int length)-
357{-
358 QLineEditPrivate * const d = d_func();-
359 if (__builtin_expect(!!(
__builtin_expe...end()), false)Description
TRUEnever evaluated
FALSEnever evaluated
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 d->control->isUndoAvailable();-
377}-
378bool QLineEdit::isRedoAvailable() const-
379{-
380 const QLineEditPrivate * const d = d_func();-
381 return d->control->isRedoAvailable();-
382}-
383bool QLineEdit::dragEnabled() const-
384{-
385 const QLineEditPrivate * const d = d_func();-
386 return d->dragEnabled;-
387}-
388-
389void QLineEdit::setDragEnabled(bool b)-
390{-
391 QLineEditPrivate * const d = d_func();-
392 d->dragEnabled = b;-
393}-
394Qt::CursorMoveStyle QLineEdit::cursorMoveStyle() const-
395{-
396 const QLineEditPrivate * const d = d_func();-
397 return d->control->cursorMoveStyle();-
398}-
399-
400void QLineEdit::setCursorMoveStyle(Qt::CursorMoveStyle style)-
401{-
402 QLineEditPrivate * const d = d_func();-
403 d->control->setCursorMoveStyle(style);-
404}-
405bool QLineEdit::hasAcceptableInput() const-
406{-
407 const QLineEditPrivate * const d = d_func();-
408 return d->control->hasAcceptableInput();-
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}-
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}-
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)-
442 *left = d->leftTextMargin;-
443 if (top)-
444 *top = d->topTextMargin;-
445 if (right)-
446 *right = d->rightTextMargin;-
447 if (bottom)-
448 *bottom = d->bottomTextMargin;-
449}-
450-
451-
452-
453-
454-
455-
456-
457QMargins QLineEdit::textMargins() const-
458{-
459 const QLineEditPrivate * const d = d_func();-
460 return QMargins(d->leftTextMargin, d->topTextMargin, d->rightTextMargin, d->bottomTextMargin);-
461}-
462QString QLineEdit::inputMask() const-
463{-
464 const QLineEditPrivate * const d = d_func();-
465 return d->control->inputMask();-
466}-
467-
468void QLineEdit::setInputMask(const QString &inputMask)-
469{-
470 QLineEditPrivate * const d = d_func();-
471 d->control->setInputMask(inputMask);-
472}-
473void QLineEdit::selectAll()-
474{-
475 QLineEditPrivate * const d = d_func();-
476 d->control->selectAll();-
477}-
478-
479-
480-
481-
482-
483-
484-
485void QLineEdit::deselect()-
486{-
487 QLineEditPrivate * const d = d_func();-
488 d->control->deselect();-
489}-
490void QLineEdit::insert(const QString &newText)-
491{-
492-
493 QLineEditPrivate * const d = d_func();-
494 d->control->insert(newText);-
495}-
496-
497-
498-
499-
500-
501-
502void QLineEdit::clear()-
503{-
504 QLineEditPrivate * const d = d_func();-
505 d->resetInputMethod();-
506 d->control->clear();-
507}-
508-
509-
510-
511-
512-
513-
514void QLineEdit::undo()-
515{-
516 QLineEditPrivate * const d = d_func();-
517 d->resetInputMethod();-
518 d->control->undo();-
519}-
520-
521-
522-
523-
524void QLineEdit::redo()-
525{-
526 QLineEditPrivate * const d = d_func();-
527 d->resetInputMethod();-
528 d->control->redo();-
529}-
530bool QLineEdit::isReadOnly() const-
531{-
532 const QLineEditPrivate * const d = d_func();-
533 return d->control->isReadOnly();-
534}-
535-
536void QLineEdit::setReadOnly(bool enable)-
537{-
538 QLineEditPrivate * const d = d_func();-
539 if (d->control->isReadOnly() != enable) {-
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 }-
551}-
552void QLineEdit::cut()-
553{-
554 if (hasSelectedText()) {-
555 copy();-
556 del();-
557 }-
558}-
559void QLineEdit::copy() const-
560{-
561 const QLineEditPrivate * const d = d_func();-
562 d->control->copy();-
563}-
564void QLineEdit::paste()-
565{-
566 QLineEditPrivate * const d = d_func();-
567 d->control->paste();-
568}-
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->setCursorBlinkPeriod(QApplication::cursorFlashTime());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->setCursorBlinkPeriodsetBlinkingCursorEnabled(QApplication::cursorFlashTime());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))-
630 return;-
631 if (e->button() == Qt::RightButton)-
632 return;-
633 if (d->tripleClickTimer.isActive() && (e->pos() - d->tripleClick).manhattanLength() <-
634 QApplication::startDragDistance()) {-
635 selectAll();-
636 return;-
637 }-
638 bool mark = e->modifiers() & Qt::ShiftModifier;-
639-
640-
641-
642 int cursor = d->xToPos(e->pos().x());-
643-
644 if (!mark && d->dragEnabled && d->control->echoMode() == Normal &&-
645 e->button() == Qt::LeftButton && d->inSelection(e->pos().x())) {-
646 if (!d->dndTimer.isActive())-
647 d->dndTimer.start(QApplication::startDragTime(), this);-
648 } else-
649-
650 {-
651 d->control->moveCursor(cursor, mark);-
652 }-
653}-
654-
655-
656-
657void QLineEdit::mouseMoveEvent(QMouseEvent * e)-
658{-
659 QLineEditPrivate * const d = d_func();-
660-
661 if (e->buttons() & Qt::LeftButton) {-
662-
663 if (d->dndTimer.isActive()) {-
664 if ((d->mousePressPos - e->pos()).manhattanLength() > QApplication::startDragDistance())-
665 d->drag();-
666 } else-
667-
668 {-
669-
670 const bool select = true;-
671-
672-
673-
674-
675 if (d->control->composeMode() && select) {-
676 int startPos = d->xToPos(d->mousePressPos.x());-
677 int currentPos = d->xToPos(e->pos().x());-
678 if (startPos != currentPos)-
679 d->control->setSelection(startPos, currentPos - startPos);-
680-
681 } else-
682-
683 {-
684 d->control->moveCursor(d->xToPos(e->pos().x()), select);-
685 }-
686 }-
687 }-
688-
689 d->sendMouseEventToInputContext(e);-
690}-
691-
692-
693-
694void QLineEdit::mouseReleaseEvent(QMouseEvent* e)-
695{-
696 QLineEditPrivate * const d = d_func();-
697 if (d->sendMouseEventToInputContext(e))-
698 return;-
699-
700 if (e->button() == Qt::LeftButton) {-
701 if (d->dndTimer.isActive()) {-
702 d->dndTimer.stop();-
703 deselect();-
704 return;-
705 }-
706 }-
707-
708-
709 if (QApplication::clipboard()->supportsSelection()) {-
710 if (e->button() == Qt::LeftButton) {-
711 d->control->copy(QClipboard::Selection);-
712 } else if (!d->control->isReadOnly() && e->button() == Qt::MidButton) {-
713 deselect();-
714 insert(QApplication::clipboard()->text(QClipboard::Selection));-
715 }-
716 }-
717-
718-
719 if (!isReadOnly() && rect().contains(e->pos()))-
720 d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus);-
721 d->clickCausedFocus = 0;-
722}-
723-
724-
725-
726void QLineEdit::mouseDoubleClickEvent(QMouseEvent* e)-
727{-
728 QLineEditPrivate * const d = d_func();-
729-
730 if (e->button() == Qt::LeftButton) {-
731 int position = d->xToPos(e->pos().x());-
732-
733-
734-
735 if (d->control->composeMode()) {-
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 <= preeditLength)-
742 positionOnPreedit = true;-
743-
744 int textLength = d->control->end();-
745 d->control->commitPreedit();-
746 int sizeChange = d->control->end() - textLength;-
747-
748 if (positionOnPreedit) {-
749 if (sizeChange == 0)-
750 position = -1;-
751 else-
752-
753 position = qBound(preeditPos, position, preeditPos + sizeChange);-
754 } else if (position > preeditPos) {-
755-
756 position += (sizeChange - preeditLength);-
757 }-
758 }-
759-
760-
761 if (position >= 0)-
762 d->control->selectWordAtPos(position);-
763-
764 d->tripleClickTimer.start(QApplication::doubleClickInterval(), this);-
765 d->tripleClick = e->pos();-
766 } else {-
767 d->sendMouseEventToInputContext(e);-
768 }-
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->setCursorBlinkPeriod(0);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 d->cursorRect();-
790}-
791-
792-
793-
794void QLineEdit::inputMethodEvent(QInputMethodEvent *e)-
795{-
796 QLineEditPrivate * const d = d_func();-
797 if (d->control->isReadOnly()) {-
798 e->ignore();-
799 return;-
800 }-
801-
802 if (echoMode() == PasswordEchoOnEdit && !d->control->passwordEchoEditing()) {-
803-
804-
805-
806 d->updatePasswordEchoEditing(true);-
807 clear();-
808 }-
809 d->control->processInputMethodEvent(e);-
810-
811-
812 if (!e->commitString().isEmpty())-
813 d->control->complete(Qt::Key_unknown);-
814-
815}-
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:
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->setCursorBlinkPeriodsetBlinkingCursorEnabled(QApplication::cursorFlashTime());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__ ":" "1814""1826"),-
887 this, qFlagLocation("1""setText(QString)" "\0" __FILE__ ":" "1815""1827"));-
888 QObject::connect(d->control->completer(), qFlagLocation("2""highlighted(QString)" "\0" __FILE__ ":" "1816""1828"),-
889 this, qFlagLocation("1""_q_completionHighlighted(QString)" "\0" __FILE__ ":" "1817""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->setCursorBlinkPeriodsetBlinkingCursorEnabled(0false);-
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 Qt::AlignBottom:-
952 d->vscroll = r.y() + r.height() - fm.height() - d->verticalMargin;-
953 break;-
954 case Qt::AlignTop:-
955 d->vscroll = r.y() + d->verticalMargin;-
956 break;-
957 default:-
958-
959 d->vscroll = r.y() + (r.height() - fm.height() + 1) / 2;-
960 break;-
961 }-
962 QRect lineRect(r.x() + d->horizontalMargin, d->vscroll, r.width() - 2*d->horizontalMargin, fm.height());-
963-
964 if (d->shouldShowPlaceholderText()) {-
965 if (!d->placeholderText.isEmpty()) {-
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 }-
974 }-
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()) {-
985-
986 switch (va & ~(Qt::AlignAbsolute|Qt::AlignVertical_Mask)) {-
987 case Qt::AlignRight:-
988 d->hscroll = widthUsed - lineRect.width() + 1;-
989 break;-
990 case Qt::AlignHCenter:-
991 d->hscroll = (widthUsed - lineRect.width()) / 2;-
992 break;-
993 default:-
994-
995 d->hscroll = 0;-
996 break;-
997 }-
998 } else if (cix - d->hscroll >= lineRect.width()) {-
999-
1000 d->hscroll = cix - lineRect.width() + 1;-
1001 } else if (cix - d->hscroll < 0 && d->hscroll < widthUsed) {-
1002-
1003 d->hscroll = cix;-
1004 } else if (widthUsed - d->hscroll < lineRect.width()) {-
1005-
1006-
1007 d->hscroll = widthUsed - lineRect.width() + 1;-
1008 } else {-
1009-
1010 d->hscroll = qMax(0, d->hscroll);-
1011 }-
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())) {-
1019 cssStyle->styleSheetPalette(this, &panel, &pal);-
1020 }-
1021-
1022 p.setPen(pal.text().color());-
1023-
1024 int flags = QWidgetLineControl::DrawText;-
1025-
1026-
1027-
1028-
1029 if (d->control->hasSelectedText() || (d->cursorVisible && !d->control->inputMask().isEmpty() && !d->control->isReadOnly())){-
1030 flags |= QWidgetLineControl::DrawSelections;-
1031-
1032 if (d->control->palette() != pal-
1033 || d->control->palette().currentColorGroup() != pal.currentColorGroup())-
1034 d->control->setPalette(pal);-
1035 }-
1036-
1037-
1038-
1039-
1040 if (d->cursorVisible && !d->control->isReadOnly())-
1041 flags |= QWidgetLineControl::DrawCursor;-
1042-
1043 d->control->setCursorWidth(style()->pixelMetric(QStyle::PM_TextCursorWidth));-
1044 d->control->draw(&p, topLeft, r, flags);-
1045-
1046}-
1047-
1048-
1049-
1050-
1051-
1052void QLineEdit::dragMoveEvent(QDragMoveEvent *e)-
1053{-
1054 QLineEditPrivate * const d = d_func();-
1055 if (!d->control->isReadOnly() && e->mimeData()->hasFormat(QLatin1String("text/plain"))) {-
1056 e->acceptProposedAction();-
1057 d->control->moveCursor(d->xToPos(e->pos().x()), false);-
1058 d->cursorVisible = true;-
1059 update();-
1060 }-
1061}-
1062-
1063-
1064void QLineEdit::dragEnterEvent(QDragEnterEvent * e)-
1065{-
1066 QLineEdit::dragMoveEvent(e);-
1067}-
1068-
1069-
1070void QLineEdit::dragLeaveEvent(QDragLeaveEvent *)-
1071{-
1072 QLineEditPrivate * const d = d_func();-
1073 if (d->cursorVisible) {-
1074 d->cursorVisible = false;-
1075 update();-
1076 }-
1077}-
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() && !d->control->isReadOnly()) {-
1086 if (e->source() == this && e->dropAction() == Qt::CopyAction)-
1087 deselect();-
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) {-
1097 if (e->dropAction() == Qt::MoveAction) {-
1098 if (selStart > oldSelStart && selStart <= oldSelEnd)-
1099 setSelection(oldSelStart, str.length());-
1100 else if (selStart > oldSelEnd)-
1101 setSelection(selStart - str.length(), str.length());-
1102 else-
1103 setSelection(selStart, str.length());-
1104 } else {-
1105 setSelection(selStart, str.length());-
1106 }-
1107 }-
1108 } else {-
1109 e->ignore();-
1110 update();-
1111 }-
1112}-
1113void QLineEdit::contextMenuEvent(QContextMenuEvent *event)-
1114{-
1115 if (QMenu *menu = createStandardContextMenu()) {-
1116 menu->setAttribute(Qt::WA_DeleteOnClose);-
1117 menu->popup(event->globalPos());-
1118 }-
1119}-
1120-
1121static inline void setActionIcon(QAction *action, const QString &name)-
1122{-
1123 const QIcon icon = QIcon::fromTheme(name);-
1124 if (!icon.isNull())-
1125 action->setIcon(icon);-
1126}-
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()) {-
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 qstring_literal_temp; }()));-
1145 connect(action, qFlagLocation("2""triggered()" "\0" __FILE__ ":" "2102""2114"), qFlagLocation("1""undo()" "\0" __FILE__ ":" "2102""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 qstring_literal_temp; }()));-
1150 connect(action, qFlagLocation("2""triggered()" "\0" __FILE__ ":" "2107""2119"), qFlagLocation("1""redo()" "\0" __FILE__ ":" "2107""2119"));-
1151-
1152 popup->addSeparator();-
1153 }-
1154-
1155-
1156 if (!isReadOnly()) {-
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 qstring_literal_temp; }()));-
1161 connect(action, qFlagLocation("2""triggered()" "\0" __FILE__ ":" "2118""2130"), qFlagLocation("1""cut()" "\0" __FILE__ ":" "2118""2130"));-
1162 }-
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 qstring_literal_temp; }()));-
1168 connect(action, qFlagLocation("2""triggered()" "\0" __FILE__ ":" "2125""2137"), qFlagLocation("1""copy()" "\0" __FILE__ ":" "2125""2137"));-
1169-
1170 if (!isReadOnly()) {-
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 qstring_literal_temp; }()));-
1174 connect(action, qFlagLocation("2""triggered()" "\0" __FILE__ ":" "2131""2143"), qFlagLocation("1""paste()" "\0" __FILE__ ":" "2131""2143"));-
1175 }-
1176-
1177-
1178 if (!isReadOnly()) {-
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 qstring_literal_temp; }()));-
1182 connect(action, qFlagLocation("2""triggered()" "\0" __FILE__ ":" "2139""2151"), d->control, qFlagLocation("1""_q_deleteSelected()" "\0" __FILE__ ":" "2139""2151"));-
1183 }-
1184-
1185 if (!popup->isEmpty())-
1186 popup->addSeparator();-
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__ ":" "2148""2160"), qFlagLocation("1""selectAll()" "\0" __FILE__ ":" "2148""2160"));-
1192-
1193 if (!d->control->isReadOnly() && QGuiApplication::styleHints()->useRtlExtensions()) {-
1194 popup->addSeparator();-
1195 QUnicodeControlCharacterMenu *ctrlCharacterMenu = new QUnicodeControlCharacterMenu(this, popup);-
1196 popup->addMenu(ctrlCharacterMenu);-
1197 }-
1198 return popup;-
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 (QForeachContainer<typename QtPrivate::remove_reference<decltype(d->trailingSideWidgets)>::type> _container_((const auto &e : d->trailingSideWidgets)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QLineEditPrivate::SideWidgetEntry &e = *_container_.i; _container_.control; _container_.control = 0) {-
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