qlineedit_p.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qlineedit_p.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qlineedit.h"-
35#include "qlineedit_p.h"-
36-
37#ifndef QT_NO_LINEEDIT-
38-
39#include "qvariant.h"-
40#include "qabstractitemview.h"-
41#include "qdrag.h"-
42#include "qwidgetaction.h"-
43#include "qclipboard.h"-
44#ifndef QT_NO_ACCESSIBILITY-
45#include "qaccessible.h"-
46#endif-
47#ifndef QT_NO_IM-
48#include "qinputmethod.h"-
49#include "qlist.h"-
50#endif-
51#include <qpropertyanimation.h>-
52-
53QT_BEGIN_NAMESPACE-
54-
55const int QLineEditPrivate::verticalMargin(1);-
56const int QLineEditPrivate::horizontalMargin(2);-
57-
58QRect QLineEditPrivate::adjustedControlRect(const QRect &rect) const-
59{-
60 QRect widgetRect = !rect.isEmpty() ? rect : q_func()->rect();
!rect.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
61 QRect cr = adjustedContentsRect();-
62 int cix = cr.x() - hscroll + horizontalMargin;-
63 return widgetRect.translated(QPoint(cix, vscroll));
never executed: return widgetRect.translated(QPoint(cix, vscroll));
0
64}-
65-
66int QLineEditPrivate::xToPos(int x, QTextLine::CursorPosition betweenOrOn) const-
67{-
68 QRect cr = adjustedContentsRect();-
69 x-= cr.x() - hscroll + horizontalMargin;-
70 return control->xToPos(x, betweenOrOn);
never executed: return control->xToPos(x, betweenOrOn);
0
71}-
72-
73bool QLineEditPrivate::inSelection(int x) const-
74{-
75 x -= adjustedContentsRect().x() - hscroll + horizontalMargin;-
76 return control->inSelection(x);
never executed: return control->inSelection(x);
0
77}-
78-
79QRect QLineEditPrivate::cursorRect() const-
80{-
81 return adjustedControlRect(control->cursorRect());
never executed: return adjustedControlRect(control->cursorRect());
0
82}-
83-
84#ifndef QT_NO_COMPLETER-
85-
86void QLineEditPrivate::_q_completionHighlighted(const QString &newText)-
87{-
88 Q_Q(QLineEdit);-
89 if (control->completer()->completionMode() != QCompleter::InlineCompletion) {
control->compl...lineCompletionDescription
TRUEnever evaluated
FALSEnever evaluated
0
90 q->setText(newText);-
91 } else {
never executed: end of block
0
92 int c = control->cursor();-
93 QString text = control->text();-
94 q->setText(text.left(c) + newText.mid(c));-
95 control->moveCursor(control->end(), false);-
96#ifndef Q_OS_ANDROID-
97 const bool mark = true;-
98#else-
99 const bool mark = (imHints & Qt::ImhNoPredictiveText);-
100#endif-
101 control->moveCursor(c, mark);-
102 }
never executed: end of block
0
103}-
104-
105#endif // QT_NO_COMPLETER-
106-
107void QLineEditPrivate::_q_handleWindowActivate()-
108{-
109 Q_Q(QLineEdit);-
110 if (!q->hasFocus() && control->hasSelectedText())
!q->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
control->hasSelectedText()Description
TRUEnever evaluated
FALSEnever evaluated
0
111 control->deselect();
never executed: control->deselect();
0
112}
never executed: end of block
0
113-
114void QLineEditPrivate::_q_textEdited(const QString &text)-
115{-
116 Q_Q(QLineEdit);-
117 emit q->textEdited(text);-
118#ifndef QT_NO_COMPLETER-
119 if (control->completer()
control->completer()Description
TRUEnever evaluated
FALSEnever evaluated
0
120 && control->completer()->completionMode() != QCompleter::InlineCompletion)
control->compl...lineCompletionDescription
TRUEnever evaluated
FALSEnever evaluated
0
121 control->complete(-1); // update the popup on cut/paste/del
never executed: control->complete(-1);
0
122#endif-
123}
never executed: end of block
0
124-
125void QLineEditPrivate::_q_cursorPositionChanged(int from, int to)-
126{-
127 Q_Q(QLineEdit);-
128 q->update();-
129 emit q->cursorPositionChanged(from, to);-
130}
never executed: end of block
0
131-
132#ifdef QT_KEYPAD_NAVIGATION-
133void QLineEditPrivate::_q_editFocusChange(bool e)-
134{-
135 Q_Q(QLineEdit);-
136 q->setEditFocus(e);-
137}-
138#endif-
139-
140void QLineEditPrivate::_q_selectionChanged()-
141{-
142 Q_Q(QLineEdit);-
143 if (control->preeditAreaText().isEmpty()) {
control->preed...xt().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
144 QStyleOptionFrame opt;-
145 q->initStyleOption(&opt);-
146 bool showCursor = control->hasSelectedText() ?
control->hasSelectedText()Description
TRUEnever evaluated
FALSEnever evaluated
0
147 q->style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, q):-
148 q->hasFocus();-
149 setCursorVisible(showCursor);-
150 }
never executed: end of block
0
151-
152 emit q->selectionChanged();-
153#ifndef QT_NO_ACCESSIBILITY-
154 QAccessibleTextSelectionEvent ev(q, control->selectionStart(), control->selectionEnd());-
155 ev.setCursorPosition(control->cursorPosition());-
156 QAccessible::updateAccessibility(&ev);-
157#endif-
158}
never executed: end of block
0
159-
160void QLineEditPrivate::_q_updateNeeded(const QRect &rect)-
161{-
162 q_func()->update(adjustedControlRect(rect));-
163}
never executed: end of block
0
164-
165void QLineEditPrivate::init(const QString& txt)-
166{-
167 Q_Q(QLineEdit);-
168 control = new QWidgetLineControl(txt);-
169 control->setParent(q);-
170 control->setFont(q->font());-
171 QObject::connect(control, SIGNAL(textChanged(QString)),-
172 q, SIGNAL(textChanged(QString)));-
173 QObject::connect(control, SIGNAL(textEdited(QString)),-
174 q, SLOT(_q_textEdited(QString)));-
175 QObject::connect(control, SIGNAL(cursorPositionChanged(int,int)),-
176 q, SLOT(_q_cursorPositionChanged(int,int)));-
177 QObject::connect(control, SIGNAL(selectionChanged()),-
178 q, SLOT(_q_selectionChanged()));-
179 QObject::connect(control, SIGNAL(accepted()),-
180 q, SIGNAL(returnPressed()));-
181 QObject::connect(control, SIGNAL(editingFinished()),-
182 q, SIGNAL(editingFinished()));-
183#ifdef QT_KEYPAD_NAVIGATION-
184 QObject::connect(control, SIGNAL(editFocusChange(bool)),-
185 q, SLOT(_q_editFocusChange(bool)));-
186#endif-
187 QObject::connect(control, SIGNAL(cursorPositionChanged(int,int)),-
188 q, SLOT(updateMicroFocus()));-
189-
190 QObject::connect(control, SIGNAL(textChanged(QString)),-
191 q, SLOT(updateMicroFocus()));-
192-
193 // for now, going completely overboard with updates.-
194 QObject::connect(control, SIGNAL(selectionChanged()),-
195 q, SLOT(update()));-
196-
197 QObject::connect(control, SIGNAL(selectionChanged()),-
198 q, SLOT(updateMicroFocus()));-
199-
200 QObject::connect(control, SIGNAL(displayTextChanged(QString)),-
201 q, SLOT(update()));-
202-
203 QObject::connect(control, SIGNAL(updateNeeded(QRect)),-
204 q, SLOT(_q_updateNeeded(QRect)));-
205-
206 QStyleOptionFrame opt;-
207 q->initStyleOption(&opt);-
208 control->setPasswordCharacter(q->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, q));-
209 control->setPasswordMaskDelay(q->style()->styleHint(QStyle::SH_LineEdit_PasswordMaskDelay, &opt, q));-
210#ifndef QT_NO_CURSOR-
211 q->setCursor(Qt::IBeamCursor);-
212#endif-
213 q->setFocusPolicy(Qt::StrongFocus);-
214 q->setAttribute(Qt::WA_InputMethodEnabled);-
215 // Specifies that this widget can use more, but is able to survive on-
216 // less, horizontal space; and is fixed vertically.-
217 q->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed, QSizePolicy::LineEdit));-
218 q->setBackgroundRole(QPalette::Base);-
219 q->setAttribute(Qt::WA_KeyCompression);-
220 q->setMouseTracking(true);-
221 q->setAcceptDrops(true);-
222-
223 q->setAttribute(Qt::WA_MacShowFocusRect);-
224}
never executed: end of block
0
225-
226QRect QLineEditPrivate::adjustedContentsRect() const-
227{-
228 Q_Q(const QLineEdit);-
229 QStyleOptionFrame opt;-
230 q->initStyleOption(&opt);-
231 QRect r = q->style()->subElementRect(QStyle::SE_LineEditContents, &opt, q);-
232 r.setX(r.x() + effectiveLeftTextMargin());-
233 r.setY(r.y() + topTextMargin);-
234 r.setRight(r.right() - effectiveRightTextMargin());-
235 r.setBottom(r.bottom() - bottomTextMargin);-
236 return r;
never executed: return r;
0
237}-
238-
239void QLineEditPrivate::setCursorVisible(bool visible)-
240{-
241 Q_Q(QLineEdit);-
242 if ((bool)cursorVisible == visible)
(bool)cursorVisible == visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
243 return;
never executed: return;
0
244 cursorVisible = visible;-
245 if (control->inputMask().isEmpty())
control->inputMask().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
246 q->update(cursorRect());
never executed: q->update(cursorRect());
0
247 else-
248 q->update();
never executed: q->update();
0
249}-
250-
251void QLineEditPrivate::updatePasswordEchoEditing(bool editing)-
252{-
253 Q_Q(QLineEdit);-
254 control->updatePasswordEchoEditing(editing);-
255 q->setAttribute(Qt::WA_InputMethodEnabled, shouldEnableInputMethod());-
256}
never executed: end of block
0
257-
258void QLineEditPrivate::resetInputMethod()-
259{-
260 Q_Q(QLineEdit);-
261 if (q->hasFocus() && qApp) {
q->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
(static_cast<Q...::instance()))Description
TRUEnever evaluated
FALSEnever evaluated
0
262 QGuiApplication::inputMethod()->reset();-
263 }
never executed: end of block
0
264}
never executed: end of block
0
265-
266/*!-
267 This function is not intended as polymorphic usage. Just a shared code-
268 fragment that calls QInputMethod::invokeAction for this-
269 class.-
270*/-
271bool QLineEditPrivate::sendMouseEventToInputContext( QMouseEvent *e )-
272{-
273#if !defined QT_NO_IM-
274 if ( control->composeMode() ) {
control->composeMode()Description
TRUEnever evaluated
FALSEnever evaluated
0
275 int tmp_cursor = xToPos(e->pos().x());-
276 int mousePos = tmp_cursor - control->cursor();-
277 if ( mousePos < 0 || mousePos > control->preeditAreaText().length() )
mousePos < 0Description
TRUEnever evaluated
FALSEnever evaluated
mousePos > con...ext().length()Description
TRUEnever evaluated
FALSEnever evaluated
0
278 mousePos = -1;
never executed: mousePos = -1;
0
279-
280 if (mousePos >= 0) {
mousePos >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
281 if (e->type() == QEvent::MouseButtonRelease)
e->type() == Q...eButtonReleaseDescription
TRUEnever evaluated
FALSEnever evaluated
0
282 QGuiApplication::inputMethod()->invokeAction(QInputMethod::Click, mousePos);
never executed: QGuiApplication::inputMethod()->invokeAction(QInputMethod::Click, mousePos);
0
283-
284 return true;
never executed: return true;
0
285 }-
286 }
never executed: end of block
0
287#else-
288 Q_UNUSED(e);-
289#endif-
290-
291 return false;
never executed: return false;
0
292}-
293-
294#ifndef QT_NO_DRAGANDDROP-
295void QLineEditPrivate::drag()-
296{-
297 Q_Q(QLineEdit);-
298 dndTimer.stop();-
299 QMimeData *data = new QMimeData;-
300 data->setText(control->selectedText());-
301 QDrag *drag = new QDrag(q);-
302 drag->setMimeData(data);-
303 Qt::DropAction action = drag->start();-
304 if (action == Qt::MoveAction && !control->isReadOnly() && drag->target() != q)
action == Qt::MoveActionDescription
TRUEnever evaluated
FALSEnever evaluated
!control->isReadOnly()Description
TRUEnever evaluated
FALSEnever evaluated
drag->target() != qDescription
TRUEnever evaluated
FALSEnever evaluated
0
305 control->removeSelection();
never executed: control->removeSelection();
0
306}
never executed: end of block
0
307-
308#endif // QT_NO_DRAGANDDROP-
309-
310QLineEditIconButton::QLineEditIconButton(QWidget *parent)-
311 : QToolButton(parent)-
312 , m_opacity(0)-
313{-
314 setFocusPolicy(Qt::NoFocus);-
315}
never executed: end of block
0
316-
317QLineEditPrivate *QLineEditIconButton::lineEditPrivate() const-
318{-
319 QLineEdit *le = qobject_cast<QLineEdit *>(parentWidget());-
320 return le ? static_cast<QLineEditPrivate *>(qt_widget_private(le)) : Q_NULLPTR;
never executed: return le ? static_cast<QLineEditPrivate *>(qt_widget_private(le)) : nullptr;
leDescription
TRUEnever evaluated
FALSEnever evaluated
0
321}-
322-
323void QLineEditIconButton::paintEvent(QPaintEvent *)-
324{-
325 QPainter painter(this);-
326 QWindow *window = Q_NULLPTR;-
327 if (const QWidget *nativeParent = nativeParentWidget())
const QWidget ...ParentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
328 window = nativeParent->windowHandle();
never executed: window = nativeParent->windowHandle();
0
329 // Note isDown should really use the active state but in most styles-
330 // this has no proper feedback-
331 QIcon::Mode state = QIcon::Disabled;-
332 if (isEnabled())
isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
333 state = isDown() ? QIcon::Selected : QIcon::Normal;
never executed: state = isDown() ? QIcon::Selected : QIcon::Normal;
isDown()Description
TRUEnever evaluated
FALSEnever evaluated
0
334 const QLineEditPrivate *lep = lineEditPrivate();-
335 const int iconWidth = lep ? lep->sideWidgetParameters().iconSize : 16;
lepDescription
TRUEnever evaluated
FALSEnever evaluated
0
336 const QSize iconSize(iconWidth, iconWidth);-
337 const QPixmap iconPixmap = icon().pixmap(window, iconSize, state, QIcon::Off);-
338 QRect pixmapRect = QRect(QPoint(0, 0), iconSize);-
339 pixmapRect.moveCenter(rect().center());-
340 painter.setOpacity(m_opacity);-
341 painter.drawPixmap(pixmapRect, iconPixmap);-
342}
never executed: end of block
0
343-
344void QLineEditIconButton::actionEvent(QActionEvent *e)-
345{-
346 switch (e->type()) {-
347 case QEvent::ActionChanged: {
never executed: case QEvent::ActionChanged:
0
348 const QAction *action = e->action();-
349 if (isVisibleTo(parentWidget()) != action->isVisible()) {
isVisibleTo(pa...n->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
350 setVisible(action->isVisible());-
351 if (QLineEditPrivate *lep = lineEditPrivate())
QLineEditPriva...eEditPrivate()Description
TRUEnever evaluated
FALSEnever evaluated
0
352 lep->positionSideWidgets();
never executed: lep->positionSideWidgets();
0
353 }
never executed: end of block
0
354 }-
355 break;
never executed: break;
0
356 default:
never executed: default:
0
357 break;
never executed: break;
0
358 }-
359 QToolButton::actionEvent(e);-
360}
never executed: end of block
0
361-
362void QLineEditIconButton::setOpacity(qreal value)-
363{-
364 if (!qFuzzyCompare(m_opacity, value)) {
!qFuzzyCompare...pacity, value)Description
TRUEnever evaluated
FALSEnever evaluated
0
365 m_opacity = value;-
366 updateCursor();-
367 update();-
368 }
never executed: end of block
0
369}
never executed: end of block
0
370-
371#ifndef QT_NO_ANIMATION-
372void QLineEditIconButton::startOpacityAnimation(qreal endValue)-
373{-
374 QPropertyAnimation *animation = new QPropertyAnimation(this, QByteArrayLiteral("opacity"));
never executed: return ba;
0
375 animation->setDuration(160);-
376 animation->setEndValue(endValue);-
377 animation->start(QAbstractAnimation::DeleteWhenStopped);-
378}
never executed: end of block
0
379#endif-
380-
381void QLineEditIconButton::updateCursor()-
382{-
383#ifndef QT_NO_CURSOR-
384 setCursor(qFuzzyCompare(m_opacity, qreal(1.0)) || !parentWidget() ? QCursor(Qt::ArrowCursor) : parentWidget()->cursor());-
385#endif-
386}
never executed: end of block
0
387-
388void QLineEditPrivate::_q_textChanged(const QString &text)-
389{-
390 if (hasSideWidgets()) {
hasSideWidgets()Description
TRUEnever evaluated
FALSEnever evaluated
0
391 const int newTextSize = text.size();-
392 if (!newTextSize || !lastTextSize) {
!newTextSizeDescription
TRUEnever evaluated
FALSEnever evaluated
!lastTextSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
393 lastTextSize = newTextSize;-
394#ifndef QT_NO_ANIMATION-
395 const bool fadeIn = newTextSize > 0;-
396 foreach (const SideWidgetEntry &e, leadingSideWidgets) {-
397 if (e.flags & SideWidgetFadeInWithText)
e.flags & Side...FadeInWithTextDescription
TRUEnever evaluated
FALSEnever evaluated
0
398 static_cast<QLineEditIconButton *>(e.widget)->animateShow(fadeIn);
never executed: static_cast<QLineEditIconButton *>(e.widget)->animateShow(fadeIn);
0
399 }
never executed: end of block
0
400 foreach (const SideWidgetEntry &e, trailingSideWidgets) {-
401 if (e.flags & SideWidgetFadeInWithText)
e.flags & Side...FadeInWithTextDescription
TRUEnever evaluated
FALSEnever evaluated
0
402 static_cast<QLineEditIconButton *>(e.widget)->animateShow(fadeIn);
never executed: static_cast<QLineEditIconButton *>(e.widget)->animateShow(fadeIn);
0
403 }
never executed: end of block
0
404#endif-
405 }
never executed: end of block
0
406 }
never executed: end of block
0
407}
never executed: end of block
0
408-
409void QLineEditPrivate::_q_clearButtonClicked()-
410{-
411 Q_Q(QLineEdit);-
412 if (!q->text().isEmpty()) {
!q->text().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
413 q->clear();-
414 emit q->textEdited(QString());-
415 }
never executed: end of block
0
416}
never executed: end of block
0
417-
418QLineEditPrivate::SideWidgetParameters QLineEditPrivate::sideWidgetParameters() const-
419{-
420 Q_Q(const QLineEdit);-
421 SideWidgetParameters result;-
422 result.iconSize = q->height() < 34 ? 16 : 32;
q->height() < 34Description
TRUEnever evaluated
FALSEnever evaluated
0
423 result.margin = result.iconSize / 4;-
424 result.widgetWidth = result.iconSize + 6;-
425 result.widgetHeight = result.iconSize + 2;-
426 return result;
never executed: return result;
0
427}-
428-
429QIcon QLineEditPrivate::clearButtonIcon() const-
430{-
431 Q_Q(const QLineEdit);-
432 QStyleOptionFrame styleOption;-
433 q->initStyleOption(&styleOption);-
434 return q->style()->standardIcon(QStyle::SP_LineEditClearButton, &styleOption, q);
never executed: return q->style()->standardIcon(QStyle::SP_LineEditClearButton, &styleOption, q);
0
435}-
436-
437void QLineEditPrivate::setClearButtonEnabled(bool enabled)-
438{-
439 foreach (const SideWidgetEntry &e, trailingSideWidgets) {-
440 if (e.flags & SideWidgetClearButton) {
e.flags & Side...getClearButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
441 e.action->setEnabled(enabled);-
442 break;
never executed: break;
0
443 }-
444 }
never executed: end of block
0
445}
never executed: end of block
0
446-
447void QLineEditPrivate::positionSideWidgets()-
448{-
449 Q_Q(QLineEdit);-
450 if (hasSideWidgets()) {
hasSideWidgets()Description
TRUEnever evaluated
FALSEnever evaluated
0
451 const QRect contentRect = q->rect();-
452 const SideWidgetParameters p = sideWidgetParameters();-
453 const int delta = p.margin + p.widgetWidth;-
454 QRect widgetGeometry(QPoint(p.margin, (contentRect.height() - p.widgetHeight) / 2),-
455 QSize(p.widgetWidth, p.widgetHeight));-
456 foreach (const SideWidgetEntry &e, leftSideWidgetList()) {-
457 e.widget->setGeometry(widgetGeometry);-
458 if (e.action->isVisible())
e.action->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
459 widgetGeometry.moveLeft(widgetGeometry.left() + delta);
never executed: widgetGeometry.moveLeft(widgetGeometry.left() + delta);
0
460 }
never executed: end of block
0
461 widgetGeometry.moveLeft(contentRect.width() - p.widgetWidth - p.margin);-
462 foreach (const SideWidgetEntry &e, rightSideWidgetList()) {-
463 e.widget->setGeometry(widgetGeometry);-
464 if (e.action->isVisible())
e.action->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
465 widgetGeometry.moveLeft(widgetGeometry.left() - delta);
never executed: widgetGeometry.moveLeft(widgetGeometry.left() - delta);
0
466 }
never executed: end of block
0
467 }
never executed: end of block
0
468}
never executed: end of block
0
469-
470QLineEditPrivate::PositionIndexPair QLineEditPrivate::findSideWidget(const QAction *a) const-
471{-
472 for (int i = 0; i < leadingSideWidgets.size(); ++i) {
i < leadingSideWidgets.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
473 if (a == leadingSideWidgets.at(i).action)
a == leadingSi...s.at(i).actionDescription
TRUEnever evaluated
FALSEnever evaluated
0
474 return PositionIndexPair(QLineEdit::LeadingPosition, i);
never executed: return PositionIndexPair(QLineEdit::LeadingPosition, i);
0
475 }
never executed: end of block
0
476 for (int i = 0; i < trailingSideWidgets.size(); ++i) {
i < trailingSideWidgets.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
477 if (a == trailingSideWidgets.at(i).action)
a == trailingS...s.at(i).actionDescription
TRUEnever evaluated
FALSEnever evaluated
0
478 return PositionIndexPair(QLineEdit::TrailingPosition, i);
never executed: return PositionIndexPair(QLineEdit::TrailingPosition, i);
0
479 }
never executed: end of block
0
480 return PositionIndexPair(QLineEdit::LeadingPosition, -1);
never executed: return PositionIndexPair(QLineEdit::LeadingPosition, -1);
0
481}-
482-
483QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineEdit::ActionPosition position, int flags)-
484{-
485 Q_Q(QLineEdit);-
486 if (!newAction)
!newActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
487 return 0;
never executed: return 0;
0
488 if (!hasSideWidgets()) { // initial setup.
!hasSideWidgets()Description
TRUEnever evaluated
FALSEnever evaluated
0
489 QObject::connect(q, SIGNAL(textChanged(QString)), q, SLOT(_q_textChanged(QString)));-
490 lastTextSize = q->text().size();-
491 }
never executed: end of block
0
492 QWidget *w = 0;-
493 // Store flags about QWidgetAction here since removeAction() may be called from ~QAction,-
494 // in which a qobject_cast<> no longer works.-
495 if (QWidgetAction *widgetAction = qobject_cast<QWidgetAction *>(newAction)) {
QWidgetAction ... *>(newAction)Description
TRUEnever evaluated
FALSEnever evaluated
0
496 if ((w = widgetAction->requestWidget(q)))
(w = widgetAct...uestWidget(q))Description
TRUEnever evaluated
FALSEnever evaluated
0
497 flags |= SideWidgetCreatedByWidgetAction;
never executed: flags |= SideWidgetCreatedByWidgetAction;
0
498 }
never executed: end of block
0
499 if (!w) {
!wDescription
TRUEnever evaluated
FALSEnever evaluated
0
500 QLineEditIconButton *toolButton = new QLineEditIconButton(q);-
501 toolButton->setIcon(newAction->icon());-
502 toolButton->setOpacity(lastTextSize > 0 || !(flags & SideWidgetFadeInWithText) ? 1 : 0);-
503 if (flags & SideWidgetClearButton)
flags & SideWidgetClearButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
504 QObject::connect(toolButton, SIGNAL(clicked()), q, SLOT(_q_clearButtonClicked()));
never executed: QObject::connect(toolButton, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "504"), q, qFlagLocation("1""_q_clearButtonClicked()" "\0" __FILE__ ":" "504"));
0
505 toolButton->setDefaultAction(newAction);-
506 w = toolButton;-
507 }
never executed: end of block
0
508 // If there is a 'before' action, it takes preference-
509 PositionIndexPair positionIndex = before ? findSideWidget(before) : PositionIndexPair(position, -1);
beforeDescription
TRUEnever evaluated
FALSEnever evaluated
0
510 SideWidgetEntryList &list = positionIndex.first == QLineEdit::TrailingPosition ? trailingSideWidgets : leadingSideWidgets;
positionIndex....ailingPositionDescription
TRUEnever evaluated
FALSEnever evaluated
0
511 if (positionIndex.second < 0)
positionIndex.second < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
512 positionIndex.second = list.size();
never executed: positionIndex.second = list.size();
0
513 list.insert(positionIndex.second, SideWidgetEntry(w, newAction, flags));-
514 positionSideWidgets();-
515 w->show();-
516 return w;
never executed: return w;
0
517}-
518-
519void QLineEditPrivate::removeAction(QAction *action)-
520{-
521 Q_Q(QLineEdit);-
522 const PositionIndexPair positionIndex = findSideWidget(action);-
523 if (positionIndex.second == -1)
positionIndex.second == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
524 return;
never executed: return;
0
525 SideWidgetEntryList &list = positionIndex.first == QLineEdit::TrailingPosition ? trailingSideWidgets : leadingSideWidgets;
positionIndex....ailingPositionDescription
TRUEnever evaluated
FALSEnever evaluated
0
526 SideWidgetEntry entry = list.takeAt(positionIndex.second);-
527 if (entry.flags & SideWidgetCreatedByWidgetAction)
entry.flags & ...ByWidgetActionDescription
TRUEnever evaluated
FALSEnever evaluated
0
528 static_cast<QWidgetAction *>(entry.action)->releaseWidget(entry.widget);
never executed: static_cast<QWidgetAction *>(entry.action)->releaseWidget(entry.widget);
0
529 else-
530 delete entry.widget;
never executed: delete entry.widget;
0
531 positionSideWidgets();-
532 if (!hasSideWidgets()) // Last widget, remove connection
!hasSideWidgets()Description
TRUEnever evaluated
FALSEnever evaluated
0
533 QObject::disconnect(q, SIGNAL(textChanged(QString)), q, SLOT(_q_textChanged(QString)));
never executed: QObject::disconnect(q, qFlagLocation("2""textChanged(QString)" "\0" __FILE__ ":" "533"), q, qFlagLocation("1""_q_textChanged(QString)" "\0" __FILE__ ":" "533"));
0
534 q->update();-
535}
never executed: end of block
0
536-
537QT_END_NAMESPACE-
538-
539#include "moc_qlineedit_p.cpp"-
540-
541#endif-
Source codeSwitch to Preprocessed file

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