Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qlineedit.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | - | |||||||||||||
7 | - | |||||||||||||
8 | - | |||||||||||||
9 | - | |||||||||||||
10 | - | |||||||||||||
11 | - | |||||||||||||
12 | - | |||||||||||||
13 | - | |||||||||||||
14 | - | |||||||||||||
15 | - | |||||||||||||
16 | - | |||||||||||||
17 | - | |||||||||||||
18 | void QLineEdit::initStyleOption(QStyleOptionFrame *option) const | - | ||||||||||||
19 | { | - | ||||||||||||
20 | if (!option) | - | ||||||||||||
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 | } | - | ||||||||||||
38 | QLineEdit::QLineEdit(QWidget* parent) | - | ||||||||||||
39 | : QWidget(*new QLineEditPrivate, parent,0) | - | ||||||||||||
40 | { | - | ||||||||||||
41 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
42 | d->init(QString()); | - | ||||||||||||
43 | } | - | ||||||||||||
44 | QLineEdit::QLineEdit(const QString& contents, QWidget* parent) | - | ||||||||||||
45 | : QWidget(*new QLineEditPrivate, parent, 0) | - | ||||||||||||
46 | { | - | ||||||||||||
47 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
48 | d->init(contents); | - | ||||||||||||
49 | } | - | ||||||||||||
50 | - | |||||||||||||
51 | - | |||||||||||||
52 | - | |||||||||||||
53 | - | |||||||||||||
54 | - | |||||||||||||
55 | - | |||||||||||||
56 | - | |||||||||||||
57 | QLineEdit::~QLineEdit() | - | ||||||||||||
58 | { | - | ||||||||||||
59 | } | - | ||||||||||||
60 | QString QLineEdit::text() const | - | ||||||||||||
61 | { | - | ||||||||||||
62 | const QLineEditPrivate * const d = d_func(); | - | ||||||||||||
63 | return d->control->text(); | - | ||||||||||||
64 | } | - | ||||||||||||
65 | - | |||||||||||||
66 | void QLineEdit::setText(const QString& text) | - | ||||||||||||
67 | { | - | ||||||||||||
68 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
69 | d->control->setText(text); | - | ||||||||||||
70 | } | - | ||||||||||||
71 | QString QLineEdit::placeholderText() const | - | ||||||||||||
72 | { | - | ||||||||||||
73 | const QLineEditPrivate * const d = d_func(); | - | ||||||||||||
74 | return d->placeholderText; | - | ||||||||||||
75 | } | - | ||||||||||||
76 | - | |||||||||||||
77 | void 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 | } | - | ||||||||||||
86 | QString QLineEdit::displayText() const | - | ||||||||||||
87 | { | - | ||||||||||||
88 | const QLineEditPrivate * const d = d_func(); | - | ||||||||||||
89 | return d->control->displayText(); | - | ||||||||||||
90 | } | - | ||||||||||||
91 | int QLineEdit::maxLength() const | - | ||||||||||||
92 | { | - | ||||||||||||
93 | const QLineEditPrivate * const d = d_func(); | - | ||||||||||||
94 | return d->control->maxLength(); | - | ||||||||||||
95 | } | - | ||||||||||||
96 | - | |||||||||||||
97 | void QLineEdit::setMaxLength(int maxLength) | - | ||||||||||||
98 | { | - | ||||||||||||
99 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
100 | d->control->setMaxLength(maxLength); | - | ||||||||||||
101 | } | - | ||||||||||||
102 | bool QLineEdit::hasFrame() const | - | ||||||||||||
103 | { | - | ||||||||||||
104 | const QLineEditPrivate * const d = d_func(); | - | ||||||||||||
105 | return d->frame; | - | ||||||||||||
106 | } | - | ||||||||||||
107 | void QLineEdit::addAction(QAction *action, ActionPosition position) | - | ||||||||||||
108 | { | - | ||||||||||||
109 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
110 | QWidget::addAction(action); | - | ||||||||||||
111 | d->addAction(action, 0, position); | - | ||||||||||||
112 | } | - | ||||||||||||
113 | QAction *QLineEdit::addAction(const QIcon &icon, ActionPosition position) | - | ||||||||||||
114 | { | - | ||||||||||||
115 | QAction *result = new QAction(icon, QString(), this); | - | ||||||||||||
116 | addAction(result, position); | - | ||||||||||||
117 | return result; | - | ||||||||||||
118 | } | - | ||||||||||||
119 | static const char clearButtonActionNameC[] = "_q_qlineeditclearaction"; | - | ||||||||||||
120 | - | |||||||||||||
121 | void 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 | - | |||||||||||||
139 | bool QLineEdit::isClearButtonEnabled() const | - | ||||||||||||
140 | { | - | ||||||||||||
141 | return findChild<QAction *>(QLatin1String(clearButtonActionNameC)); | - | ||||||||||||
142 | } | - | ||||||||||||
143 | - | |||||||||||||
144 | void QLineEdit::setFrame(bool enable) | - | ||||||||||||
145 | { | - | ||||||||||||
146 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
147 | d->frame = enable; | - | ||||||||||||
148 | update(); | - | ||||||||||||
149 | updateGeometry(); | - | ||||||||||||
150 | } | - | ||||||||||||
151 | QLineEdit::EchoMode QLineEdit::echoMode() const | - | ||||||||||||
152 | { | - | ||||||||||||
153 | const QLineEditPrivate * const d = d_func(); | - | ||||||||||||
154 | return (EchoMode) d->control->echoMode(); | - | ||||||||||||
155 | } | - | ||||||||||||
156 | - | |||||||||||||
157 | void QLineEdit::setEchoMode(EchoMode mode) | - | ||||||||||||
158 | { | - | ||||||||||||
159 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
160 | if (mode == (EchoMode)d->control->echoMode()
| 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 | ||||||||||||
175 | const QValidator * QLineEdit::validator() const | - | ||||||||||||
176 | { | - | ||||||||||||
177 | const QLineEditPrivate * const d = d_func(); | - | ||||||||||||
178 | return d->control->validator(); | - | ||||||||||||
179 | } | - | ||||||||||||
180 | void QLineEdit::setValidator(const QValidator *v) | - | ||||||||||||
181 | { | - | ||||||||||||
182 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
183 | d->control->setValidator(v); | - | ||||||||||||
184 | } | - | ||||||||||||
185 | void 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 | - | |||||||||||||
214 | QCompleter *QLineEdit::completer() const | - | ||||||||||||
215 | { | - | ||||||||||||
216 | const QLineEditPrivate * const d = d_func(); | - | ||||||||||||
217 | return d->control->completer(); | - | ||||||||||||
218 | } | - | ||||||||||||
219 | QSize 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 | } | - | ||||||||||||
235 | QSize 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 | } | - | ||||||||||||
251 | int QLineEdit::cursorPosition() const | - | ||||||||||||
252 | { | - | ||||||||||||
253 | const QLineEditPrivate * const d = d_func(); | - | ||||||||||||
254 | return d->control->cursorPosition(); | - | ||||||||||||
255 | } | - | ||||||||||||
256 | - | |||||||||||||
257 | void QLineEdit::setCursorPosition(int pos) | - | ||||||||||||
258 | { | - | ||||||||||||
259 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
260 | d->control->setCursorPosition(pos); | - | ||||||||||||
261 | } | - | ||||||||||||
262 | - | |||||||||||||
263 | - | |||||||||||||
264 | - | |||||||||||||
265 | - | |||||||||||||
266 | - | |||||||||||||
267 | int QLineEdit::cursorPositionAt(const QPoint &pos) | - | ||||||||||||
268 | { | - | ||||||||||||
269 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
270 | return d->xToPos(pos.x()); | - | ||||||||||||
271 | } | - | ||||||||||||
272 | Qt::Alignment QLineEdit::alignment() const | - | ||||||||||||
273 | { | - | ||||||||||||
274 | const QLineEditPrivate * const d = d_func(); | - | ||||||||||||
275 | return QFlag(d->alignment); | - | ||||||||||||
276 | } | - | ||||||||||||
277 | - | |||||||||||||
278 | void QLineEdit::setAlignment(Qt::Alignment alignment) | - | ||||||||||||
279 | { | - | ||||||||||||
280 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
281 | d->alignment = alignment; | - | ||||||||||||
282 | update(); | - | ||||||||||||
283 | } | - | ||||||||||||
284 | void QLineEdit::cursorForward(bool mark, int steps) | - | ||||||||||||
285 | { | - | ||||||||||||
286 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
287 | d->control->cursorForward(mark, steps); | - | ||||||||||||
288 | } | - | ||||||||||||
289 | void QLineEdit::cursorBackward(bool mark, int steps) | - | ||||||||||||
290 | { | - | ||||||||||||
291 | cursorForward(mark, -steps); | - | ||||||||||||
292 | } | - | ||||||||||||
293 | - | |||||||||||||
294 | - | |||||||||||||
295 | - | |||||||||||||
296 | - | |||||||||||||
297 | - | |||||||||||||
298 | - | |||||||||||||
299 | - | |||||||||||||
300 | void QLineEdit::cursorWordForward(bool mark) | - | ||||||||||||
301 | { | - | ||||||||||||
302 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
303 | d->control->cursorWordForward(mark); | - | ||||||||||||
304 | } | - | ||||||||||||
305 | void QLineEdit::cursorWordBackward(bool mark) | - | ||||||||||||
306 | { | - | ||||||||||||
307 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
308 | d->control->cursorWordBackward(mark); | - | ||||||||||||
309 | } | - | ||||||||||||
310 | void QLineEdit::backspace() | - | ||||||||||||
311 | { | - | ||||||||||||
312 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
313 | d->control->backspace(); | - | ||||||||||||
314 | } | - | ||||||||||||
315 | void QLineEdit::del() | - | ||||||||||||
316 | { | - | ||||||||||||
317 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
318 | d->control->del(); | - | ||||||||||||
319 | } | - | ||||||||||||
320 | void QLineEdit::home(bool mark) | - | ||||||||||||
321 | { | - | ||||||||||||
322 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
323 | d->control->home(mark); | - | ||||||||||||
324 | } | - | ||||||||||||
325 | void QLineEdit::end(bool mark) | - | ||||||||||||
326 | { | - | ||||||||||||
327 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
328 | d->control->end(mark); | - | ||||||||||||
329 | } | - | ||||||||||||
330 | bool QLineEdit::isModified() const | - | ||||||||||||
331 | { | - | ||||||||||||
332 | const QLineEditPrivate * const d = d_func(); | - | ||||||||||||
333 | return d->control->isModified(); | - | ||||||||||||
334 | } | - | ||||||||||||
335 | - | |||||||||||||
336 | void QLineEdit::setModified(bool modified) | - | ||||||||||||
337 | { | - | ||||||||||||
338 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
339 | d->control->setModified(modified); | - | ||||||||||||
340 | } | - | ||||||||||||
341 | bool QLineEdit::hasSelectedText() const | - | ||||||||||||
342 | { | - | ||||||||||||
343 | const QLineEditPrivate * const d = d_func(); | - | ||||||||||||
344 | return d->control->hasSelectedText(); | - | ||||||||||||
345 | } | - | ||||||||||||
346 | QString QLineEdit::selectedText() const | - | ||||||||||||
347 | { | - | ||||||||||||
348 | const QLineEditPrivate * const d = d_func(); | - | ||||||||||||
349 | return d->control->selectedText(); | - | ||||||||||||
350 | } | - | ||||||||||||
351 | int QLineEdit::selectionStart() const | - | ||||||||||||
352 | { | - | ||||||||||||
353 | const QLineEditPrivate * const d = d_func(); | - | ||||||||||||
354 | return d->control->selectionStart(); | - | ||||||||||||
355 | } | - | ||||||||||||
356 | void QLineEdit::setSelection(int start, int length) | - | ||||||||||||
357 | { | - | ||||||||||||
358 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
359 | if (__builtin_expect(!!(
| 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()
| 0 | ||||||||||||
367 | QStyleOptionFrame opt; | - | ||||||||||||
368 | initStyleOption(&opt); | - | ||||||||||||
369 | if (!style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, this)
| 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 | ||||||||||||
373 | bool QLineEdit::isUndoAvailable() const | - | ||||||||||||
374 | { | - | ||||||||||||
375 | const QLineEditPrivate * const d = d_func(); | - | ||||||||||||
376 | return d->control->isUndoAvailable(); | - | ||||||||||||
377 | } | - | ||||||||||||
378 | bool QLineEdit::isRedoAvailable() const | - | ||||||||||||
379 | { | - | ||||||||||||
380 | const QLineEditPrivate * const d = d_func(); | - | ||||||||||||
381 | return d->control->isRedoAvailable(); | - | ||||||||||||
382 | } | - | ||||||||||||
383 | bool QLineEdit::dragEnabled() const | - | ||||||||||||
384 | { | - | ||||||||||||
385 | const QLineEditPrivate * const d = d_func(); | - | ||||||||||||
386 | return d->dragEnabled; | - | ||||||||||||
387 | } | - | ||||||||||||
388 | - | |||||||||||||
389 | void QLineEdit::setDragEnabled(bool b) | - | ||||||||||||
390 | { | - | ||||||||||||
391 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
392 | d->dragEnabled = b; | - | ||||||||||||
393 | } | - | ||||||||||||
394 | Qt::CursorMoveStyle QLineEdit::cursorMoveStyle() const | - | ||||||||||||
395 | { | - | ||||||||||||
396 | const QLineEditPrivate * const d = d_func(); | - | ||||||||||||
397 | return d->control->cursorMoveStyle(); | - | ||||||||||||
398 | } | - | ||||||||||||
399 | - | |||||||||||||
400 | void QLineEdit::setCursorMoveStyle(Qt::CursorMoveStyle style) | - | ||||||||||||
401 | { | - | ||||||||||||
402 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
403 | d->control->setCursorMoveStyle(style); | - | ||||||||||||
404 | } | - | ||||||||||||
405 | bool QLineEdit::hasAcceptableInput() const | - | ||||||||||||
406 | { | - | ||||||||||||
407 | const QLineEditPrivate * const d = d_func(); | - | ||||||||||||
408 | return d->control->hasAcceptableInput(); | - | ||||||||||||
409 | } | - | ||||||||||||
410 | void 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 | - | |||||||||||||
427 | void QLineEdit::setTextMargins(const QMargins &margins) | - | ||||||||||||
428 | { | - | ||||||||||||
429 | setTextMargins(margins.left(), margins.top(), margins.right(), margins.bottom()); | - | ||||||||||||
430 | } | - | ||||||||||||
431 | - | |||||||||||||
432 | - | |||||||||||||
433 | - | |||||||||||||
434 | - | |||||||||||||
435 | - | |||||||||||||
436 | - | |||||||||||||
437 | - | |||||||||||||
438 | void 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 | - | |||||||||||||
457 | QMargins QLineEdit::textMargins() const | - | ||||||||||||
458 | { | - | ||||||||||||
459 | const QLineEditPrivate * const d = d_func(); | - | ||||||||||||
460 | return QMargins(d->leftTextMargin, d->topTextMargin, d->rightTextMargin, d->bottomTextMargin); | - | ||||||||||||
461 | } | - | ||||||||||||
462 | QString QLineEdit::inputMask() const | - | ||||||||||||
463 | { | - | ||||||||||||
464 | const QLineEditPrivate * const d = d_func(); | - | ||||||||||||
465 | return d->control->inputMask(); | - | ||||||||||||
466 | } | - | ||||||||||||
467 | - | |||||||||||||
468 | void QLineEdit::setInputMask(const QString &inputMask) | - | ||||||||||||
469 | { | - | ||||||||||||
470 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
471 | d->control->setInputMask(inputMask); | - | ||||||||||||
472 | } | - | ||||||||||||
473 | void QLineEdit::selectAll() | - | ||||||||||||
474 | { | - | ||||||||||||
475 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
476 | d->control->selectAll(); | - | ||||||||||||
477 | } | - | ||||||||||||
478 | - | |||||||||||||
479 | - | |||||||||||||
480 | - | |||||||||||||
481 | - | |||||||||||||
482 | - | |||||||||||||
483 | - | |||||||||||||
484 | - | |||||||||||||
485 | void QLineEdit::deselect() | - | ||||||||||||
486 | { | - | ||||||||||||
487 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
488 | d->control->deselect(); | - | ||||||||||||
489 | } | - | ||||||||||||
490 | void 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 | - | |||||||||||||
502 | void QLineEdit::clear() | - | ||||||||||||
503 | { | - | ||||||||||||
504 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
505 | d->resetInputMethod(); | - | ||||||||||||
506 | d->control->clear(); | - | ||||||||||||
507 | } | - | ||||||||||||
508 | - | |||||||||||||
509 | - | |||||||||||||
510 | - | |||||||||||||
511 | - | |||||||||||||
512 | - | |||||||||||||
513 | - | |||||||||||||
514 | void QLineEdit::undo() | - | ||||||||||||
515 | { | - | ||||||||||||
516 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
517 | d->resetInputMethod(); | - | ||||||||||||
518 | d->control->undo(); | - | ||||||||||||
519 | } | - | ||||||||||||
520 | - | |||||||||||||
521 | - | |||||||||||||
522 | - | |||||||||||||
523 | - | |||||||||||||
524 | void QLineEdit::redo() | - | ||||||||||||
525 | { | - | ||||||||||||
526 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
527 | d->resetInputMethod(); | - | ||||||||||||
528 | d->control->redo(); | - | ||||||||||||
529 | } | - | ||||||||||||
530 | bool QLineEdit::isReadOnly() const | - | ||||||||||||
531 | { | - | ||||||||||||
532 | const QLineEditPrivate * const d = d_func(); | - | ||||||||||||
533 | return d->control->isReadOnly(); | - | ||||||||||||
534 | } | - | ||||||||||||
535 | - | |||||||||||||
536 | void 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 | } | - | ||||||||||||
552 | void QLineEdit::cut() | - | ||||||||||||
553 | { | - | ||||||||||||
554 | if (hasSelectedText()) { | - | ||||||||||||
555 | copy(); | - | ||||||||||||
556 | del(); | - | ||||||||||||
557 | } | - | ||||||||||||
558 | } | - | ||||||||||||
559 | void QLineEdit::copy() const | - | ||||||||||||
560 | { | - | ||||||||||||
561 | const QLineEditPrivate * const d = d_func(); | - | ||||||||||||
562 | d->control->copy(); | - | ||||||||||||
563 | } | - | ||||||||||||
564 | void QLineEdit::paste() | - | ||||||||||||
565 | { | - | ||||||||||||
566 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
567 | d->control->paste(); | - | ||||||||||||
568 | } | - | ||||||||||||
569 | - | |||||||||||||
570 | - | |||||||||||||
571 | - | |||||||||||||
572 | - | |||||||||||||
573 | - | |||||||||||||
574 | bool QLineEdit::event(QEvent * e) | - | ||||||||||||
575 | { | - | ||||||||||||
576 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
577 | if (e->type() == QEvent::Timer
| 0 | ||||||||||||
578 | - | |||||||||||||
579 | int timerId = ((QTimerEvent*)e)->timerId(); | - | ||||||||||||
580 | if (false) { dead code: { } | - | ||||||||||||
581 | - | |||||||||||||
582 | } dead code: else if (timerId == d->dndTimer.timerId(){ }
| - | ||||||||||||
583 | d->drag(); | - | ||||||||||||
584 | - | |||||||||||||
585 | } never executed: end of block | 0 | ||||||||||||
586 | else if (timerId == d->tripleClickTimer.timerId()
| 0 | ||||||||||||
587 | d->tripleClickTimer.stop(); never executed: d->tripleClickTimer.stop(); | 0 | ||||||||||||
588 | } never executed: else if (e->type() == QEvent::ContextMenuend of block
| 0 | ||||||||||||
589 | - | |||||||||||||
590 | if (d->control->composeMode()
| 0 | ||||||||||||
591 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||
592 | - | |||||||||||||
593 | - | |||||||||||||
594 | } never executed: else if (e->type() == QEvent::WindowActivateend of block
| 0 | ||||||||||||
595 | QTimer::singleShot(0, this, qFlagLocation("1""_q_handleWindowActivate()" "\0" __FILE__ ":" "1419")); | - | ||||||||||||
596 | - | |||||||||||||
597 | } never executed: else if (e->type() == QEvent::ShortcutOverrideend of block
| 0 | ||||||||||||
598 | QKeyEvent *ke = static_cast<QKeyEvent*>(e); | - | ||||||||||||
599 | d->control->processShortcutOverrideEvent(ke); | - | ||||||||||||
600 | - | |||||||||||||
601 | } never executed: else if (e->type() == QEvent::KeyReleaseend of block
| 0 | ||||||||||||
602 | d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime());updateCursorBlinking(); | - | ||||||||||||
603 | } never executed: else if (e->type() == QEvent::Showend of block
| 0 | ||||||||||||
604 | - | |||||||||||||
605 | if (hasFocus()
| 0 | ||||||||||||
606 | d->control->setCursorBlinkPeriodsetBlinkingCursorEnabled(QApplication::cursorFlashTime());true); | - | ||||||||||||
607 | QStyleOptionFrame opt; | - | ||||||||||||
608 | initStyleOption(&opt); | - | ||||||||||||
609 | if ((!hasSelectedText()
| 0 | ||||||||||||
610 | || style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, this)
| 0 | ||||||||||||
611 | d->setCursorVisible(true); never executed: d->setCursorVisible(true); | 0 | ||||||||||||
612 | } never executed: end of block | 0 | ||||||||||||
613 | } never executed: else if (e->type() == QEvent::ActionRemovedend of block
| 0 | ||||||||||||
614 | d->removeAction(static_cast<QActionEvent *>(e)->action()); | - | ||||||||||||
615 | } never executed: else if (e->type() == QEvent::Resizeend of block
| 0 | ||||||||||||
616 | d->positionSideWidgets(); | - | ||||||||||||
617 | } never executed: end of block | 0 | ||||||||||||
618 | return never executed: QWidget::event(e);return QWidget::event(e); never executed: return QWidget::event(e); | 0 | ||||||||||||
619 | } | - | ||||||||||||
620 | - | |||||||||||||
621 | - | |||||||||||||
622 | - | |||||||||||||
623 | void 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 | - | |||||||||||||
657 | void 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 | - | |||||||||||||
694 | void 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 | - | |||||||||||||
726 | void 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 | } | - | ||||||||||||
770 | void QLineEdit::keyPressEvent(QKeyEvent *event) | - | ||||||||||||
771 | { | - | ||||||||||||
772 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
773 | d->control->processKeyEvent(event); | - | ||||||||||||
774 | if (event->isAccepted()
| 0 | ||||||||||||
775 | if (layoutDirection() != d->control->layoutDirection()
| 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 | - | |||||||||||||
786 | QRect QLineEdit::cursorRect() const | - | ||||||||||||
787 | { | - | ||||||||||||
788 | const QLineEditPrivate * const d = d_func(); | - | ||||||||||||
789 | return d->cursorRect(); | - | ||||||||||||
790 | } | - | ||||||||||||
791 | - | |||||||||||||
792 | - | |||||||||||||
793 | - | |||||||||||||
794 | void 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 | - | |||||||||||||
819 | QVariant QLineEdit::inputMethodQuery(Qt::InputMethodQuery property) const | - | ||||||||||||
820 | { | - | ||||||||||||
821 | return never executed: inputMethodQuery(property, QVariant());return inputMethodQuery(property, QVariant()); never executed: return inputMethodQuery(property, QVariant()); | 0 | ||||||||||||
822 | } | - | ||||||||||||
823 | - | |||||||||||||
824 | - | |||||||||||||
825 | - | |||||||||||||
826 | QVariant QLineEdit::inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const | - | ||||||||||||
827 | { | - | ||||||||||||
828 | const QLineEditPrivate * const d = d_func(); | - | ||||||||||||
829 | switch(property) { | - | ||||||||||||
830 | case never executed: Qt::ImCursorRectangle:case Qt::ImCursorRectangle: never executed: case Qt::ImCursorRectangle: | 0 | ||||||||||||
831 | return never executed: d->cursorRect();return d->cursorRect(); never executed: return d->cursorRect(); | 0 | ||||||||||||
832 | case never executed: case Qt::ImAnchorRectangle: never executed: Qt::ImAnchorRectangle:case Qt::ImAnchorRectangle: never executed: case Qt::ImAnchorRectangle: | 0 | ||||||||||||
833 | return never executed: d->adjustedControlRect(d->control->anchorRect());return d->adjustedControlRect(d->control->anchorRect()); never executed: return d->adjustedControlRect(d->control->anchorRect()); | 0 | ||||||||||||
834 | case never executed: Qt::ImFont:case Qt::ImFont: never executed: case Qt::ImFont: | 0 | ||||||||||||
835 | return never executed: font();return font(); never executed: return font(); | 0 | ||||||||||||
836 | case never executed: Qt::ImCursorPosition:case Qt::ImCursorPosition: never executed: {case Qt::ImCursorPosition: | 0 | ||||||||||||
837 | const QPointF pt = argument.toPointF(); | - | ||||||||||||
838 | if (!pt.isNull()
| 0 | ||||||||||||
839 | return never executed: QVariant(d->xToPos(pt.x(), QTextLine::CursorBetweenCharacters));return QVariant(d->xToPos(pt.x(), QTextLine::CursorBetweenCharacters)); never executed: return QVariant(d->xToPos(pt.x(), QTextLine::CursorBetweenCharacters)); | 0 | ||||||||||||
840 | return never executed: QVariant(d->control->cursor());return QVariant(d->control->cursor()); never executed: }return QVariant(d->control->cursor()); | 0 | ||||||||||||
841 | case never executed: Qt::ImSurroundingText:case Qt::ImSurroundingText: never executed: case Qt::ImSurroundingText: | 0 | ||||||||||||
842 | return never executed: QVariant(d->control->text());return QVariant(d->control->text()); never executed: return QVariant(d->control->text()); | 0 | ||||||||||||
843 | case never executed: Qt::ImCurrentSelection:case Qt::ImCurrentSelection: never executed: case Qt::ImCurrentSelection: | 0 | ||||||||||||
844 | return never executed: QVariant(selectedText());return QVariant(selectedText()); never executed: return QVariant(selectedText()); | 0 | ||||||||||||
845 | case never executed: Qt::ImMaximumTextLength:case Qt::ImMaximumTextLength: never executed: case Qt::ImMaximumTextLength: | 0 | ||||||||||||
846 | return never executed: QVariant(maxLength());return QVariant(maxLength()); never executed: return QVariant(maxLength()); | 0 | ||||||||||||
847 | case never executed: Qt::ImAnchorPosition:case Qt::ImAnchorPosition: never executed: case Qt::ImAnchorPosition: | 0 | ||||||||||||
848 | if (d->control->selectionStart() == d->control->selectionEnd()
| 0 | ||||||||||||
849 | return never executed: QVariant(d->control->cursor());return QVariant(d->control->cursor()); never executed: return QVariant(d->control->cursor()); | 0 | ||||||||||||
850 | else if (d->control->selectionStart() == d->control->cursor()
| 0 | ||||||||||||
851 | return never executed: QVariant(d->control->selectionEnd());return QVariant(d->control->selectionEnd()); never executed: return QVariant(d->control->selectionEnd()); | 0 | ||||||||||||
852 | else | - | ||||||||||||
853 | return never executed: QVariant(d->control->selectionStart());return 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: QWidget::inputMethodQuery(property);return QWidget::inputMethodQuery(property); never executed: return QWidget::inputMethodQuery(property); | 0 | ||||||||||||
856 | } | - | ||||||||||||
857 | } | - | ||||||||||||
858 | - | |||||||||||||
859 | - | |||||||||||||
860 | - | |||||||||||||
861 | - | |||||||||||||
862 | void QLineEdit::focusInEvent(QFocusEvent *e) | - | ||||||||||||
863 | { | - | ||||||||||||
864 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
865 | if (e->reason() == Qt::TabFocusReason
| 0 | ||||||||||||
866 | e->reason() == Qt::BacktabFocusReason
| 0 | ||||||||||||
867 | e->reason() == Qt::ShortcutFocusReason
| 0 | ||||||||||||
868 | if (!d->control->inputMask().isEmpty()
| 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()
| 0 | ||||||||||||
871 | selectAll(); never executed: selectAll(); | 0 | ||||||||||||
872 | } never executed: else if (e->reason() == Qt::MouseFocusReasonend of block
| 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()
| 0 | ||||||||||||
882 | || style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, this)
| 0 | ||||||||||||
883 | d->setCursorVisible(true); never executed: d->setCursorVisible(true); | 0 | ||||||||||||
884 | if (d->control->completer()
| 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 | - | |||||||||||||
898 | void QLineEdit::focusOutEvent(QFocusEvent *e) | - | ||||||||||||
899 | { | - | ||||||||||||
900 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
901 | if (d->control->passwordEchoEditing()
| 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
| 0 | ||||||||||||
909 | reason != Qt::PopupFocusReason
| 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
| 0 | ||||||||||||
919 | || !(QApplication::activePopupWidget()
| 0 | ||||||||||||
920 | if (hasAcceptableInput()
| 0 | ||||||||||||
921 | editingFinished(); never executed: editingFinished(); | 0 | ||||||||||||
922 | } never executed: end of block | 0 | ||||||||||||
923 | if (d->control->completer()
| 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 | - | |||||||||||||
932 | void 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 | - | |||||||||||||
1052 | void 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 | - | |||||||||||||
1064 | void QLineEdit::dragEnterEvent(QDragEnterEvent * e) | - | ||||||||||||
1065 | { | - | ||||||||||||
1066 | QLineEdit::dragMoveEvent(e); | - | ||||||||||||
1067 | } | - | ||||||||||||
1068 | - | |||||||||||||
1069 | - | |||||||||||||
1070 | void QLineEdit::dragLeaveEvent(QDragLeaveEvent *) | - | ||||||||||||
1071 | { | - | ||||||||||||
1072 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
1073 | if (d->cursorVisible) { | - | ||||||||||||
1074 | d->cursorVisible = false; | - | ||||||||||||
1075 | update(); | - | ||||||||||||
1076 | } | - | ||||||||||||
1077 | } | - | ||||||||||||
1078 | - | |||||||||||||
1079 | - | |||||||||||||
1080 | void 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 | } | - | ||||||||||||
1113 | void QLineEdit::contextMenuEvent(QContextMenuEvent *event) | - | ||||||||||||
1114 | { | - | ||||||||||||
1115 | if (QMenu *menu = createStandardContextMenu()) { | - | ||||||||||||
1116 | menu->setAttribute(Qt::WA_DeleteOnClose); | - | ||||||||||||
1117 | menu->popup(event->globalPos()); | - | ||||||||||||
1118 | } | - | ||||||||||||
1119 | } | - | ||||||||||||
1120 | - | |||||||||||||
1121 | static 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 | - | |||||||||||||
1134 | QMenu *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 | - | |||||||||||||
1203 | void QLineEdit::changeEvent(QEvent *ev) | - | ||||||||||||
1204 | { | - | ||||||||||||
1205 | QLineEditPrivate * const d = d_func(); | - | ||||||||||||
1206 | switch(ev->type()) | - | ||||||||||||
1207 | { | - | ||||||||||||
1208 | case never executed: QEvent::ActivationChange:case QEvent::ActivationChange: never executed: case QEvent::ActivationChange: | 0 | ||||||||||||
1209 | if (!palette().isEqual(QPalette::Active, QPalette::Inactive)
| 0 | ||||||||||||
1210 | update(); never executed: update(); | 0 | ||||||||||||
1211 | break; never executed: break; | 0 | ||||||||||||
1212 | case never executed: QEvent::FontChange:case QEvent::FontChange: never executed: case QEvent::FontChange: | 0 | ||||||||||||
1213 | d->control->setFont(font()); | - | ||||||||||||
1214 | break; never executed: break; | 0 | ||||||||||||
1215 | case never executed: QEvent::StyleChange:case 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: QEvent::LayoutDirectionChange:case 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
| 0 | ||||||||||||
1227 | static_cast< never executed: QLineEditIconButton *>(e.widget)->setIcon(d->clearButtonIcon());static_cast<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 code | Preprocessed file |