| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qlineedit_p.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | - | |||||||||||||||||||
| 8 | - | |||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | const int QLineEditPrivate::verticalMargin(1); | - | ||||||||||||||||||
| 12 | const int QLineEditPrivate::horizontalMargin(2); | - | ||||||||||||||||||
| 13 | - | |||||||||||||||||||
| 14 | QRect QLineEditPrivate::adjustedControlRect(const QRect &rect) const | - | ||||||||||||||||||
| 15 | { | - | ||||||||||||||||||
| 16 | QRect widgetRect = !rect.isEmpty()
| 0 | ||||||||||||||||||
| 17 | QRect cr = adjustedContentsRect(); | - | ||||||||||||||||||
| 18 | int cix = cr.x() - hscroll + horizontalMargin; | - | ||||||||||||||||||
| 19 | return never executed: widgetRect.translated(QPoint(cix, vscroll));return widgetRect.translated(QPoint(cix, vscroll));never executed: return widgetRect.translated(QPoint(cix, vscroll)); | 0 | ||||||||||||||||||
| 20 | } | - | ||||||||||||||||||
| 21 | - | |||||||||||||||||||
| 22 | int QLineEditPrivate::xToPos(int x, QTextLine::CursorPosition betweenOrOn) const | - | ||||||||||||||||||
| 23 | { | - | ||||||||||||||||||
| 24 | QRect cr = adjustedContentsRect(); | - | ||||||||||||||||||
| 25 | x-= cr.x() - hscroll + horizontalMargin; | - | ||||||||||||||||||
| 26 | return never executed: control->xToPos(x, betweenOrOn);return control->xToPos(x, betweenOrOn);never executed: return control->xToPos(x, betweenOrOn); | 0 | ||||||||||||||||||
| 27 | } | - | ||||||||||||||||||
| 28 | - | |||||||||||||||||||
| 29 | bool QLineEditPrivate::inSelection(int x) const | - | ||||||||||||||||||
| 30 | { | - | ||||||||||||||||||
| 31 | x -= adjustedContentsRect().x() - hscroll + horizontalMargin; | - | ||||||||||||||||||
| 32 | return never executed: control->inSelection(x);return control->inSelection(x);never executed: return control->inSelection(x); | 0 | ||||||||||||||||||
| 33 | } | - | ||||||||||||||||||
| 34 | - | |||||||||||||||||||
| 35 | QRect QLineEditPrivate::cursorRect() const | - | ||||||||||||||||||
| 36 | { | - | ||||||||||||||||||
| 37 | return never executed: adjustedControlRect(control->cursorRect());return adjustedControlRect(control->cursorRect());never executed: return adjustedControlRect(control->cursorRect()); | 0 | ||||||||||||||||||
| 38 | } | - | ||||||||||||||||||
| 39 | - | |||||||||||||||||||
| 40 | - | |||||||||||||||||||
| 41 | - | |||||||||||||||||||
| 42 | void QLineEditPrivate::_q_completionHighlighted(const QString &newText) | - | ||||||||||||||||||
| 43 | { | - | ||||||||||||||||||
| 44 | QLineEdit * const q = q_func(); | - | ||||||||||||||||||
| 45 | if (control->completer()->completionMode() != QCompleter::InlineCompletion
| 0 | ||||||||||||||||||
| 46 | q->setText(newText); | - | ||||||||||||||||||
| 47 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 48 | int c = control->cursor(); | - | ||||||||||||||||||
| 49 | QString text = control->text(); | - | ||||||||||||||||||
| 50 | q->setText(text.leftRef(c) + newText.midRef(c)); | - | ||||||||||||||||||
| 51 | control->moveCursor(control->end(), false); | - | ||||||||||||||||||
| 52 | - | |||||||||||||||||||
| 53 | const bool mark = true; | - | ||||||||||||||||||
| 54 | - | |||||||||||||||||||
| 55 | - | |||||||||||||||||||
| 56 | - | |||||||||||||||||||
| 57 | control->moveCursor(c, mark); | - | ||||||||||||||||||
| 58 | } never executed: end of block | 0 | ||||||||||||||||||
| 59 | } | - | ||||||||||||||||||
| 60 | - | |||||||||||||||||||
| 61 | - | |||||||||||||||||||
| 62 | - | |||||||||||||||||||
| 63 | void QLineEditPrivate::_q_handleWindowActivate() | - | ||||||||||||||||||
| 64 | { | - | ||||||||||||||||||
| 65 | QLineEdit * const q = q_func(); | - | ||||||||||||||||||
| 66 | if (!q->hasFocus()
| 0 | ||||||||||||||||||
| 67 | control->deselect(); never executed: control->deselect(); | 0 | ||||||||||||||||||
| 68 | } never executed: end of block | 0 | ||||||||||||||||||
| 69 | - | |||||||||||||||||||
| 70 | void QLineEditPrivate::_q_textEdited(const QString &text) | - | ||||||||||||||||||
| 71 | { | - | ||||||||||||||||||
| 72 | QLineEdit * const q = q_func(); | - | ||||||||||||||||||
| 73 | q->textEdited(text); | - | ||||||||||||||||||
| 74 | - | |||||||||||||||||||
| 75 | if (control->completer()
| 0 | ||||||||||||||||||
| 76 | && control->completer()->completionMode() != QCompleter::InlineCompletion
| 0 | ||||||||||||||||||
| 77 | control->complete(-1); never executed: control->complete(-1); | 0 | ||||||||||||||||||
| 78 | - | |||||||||||||||||||
| 79 | } never executed: end of block | 0 | ||||||||||||||||||
| 80 | - | |||||||||||||||||||
| 81 | void QLineEditPrivate::_q_cursorPositionChanged(int from, int to) | - | ||||||||||||||||||
| 82 | { | - | ||||||||||||||||||
| 83 | QLineEdit * const q = q_func(); | - | ||||||||||||||||||
| 84 | q->update(); | - | ||||||||||||||||||
| 85 | q->cursorPositionChanged(from, to); | - | ||||||||||||||||||
| 86 | } never executed: end of block | 0 | ||||||||||||||||||
| 87 | void QLineEditPrivate::_q_selectionChanged() | - | ||||||||||||||||||
| 88 | { | - | ||||||||||||||||||
| 89 | QLineEdit * const q = q_func(); | - | ||||||||||||||||||
| 90 | if (control->preeditAreaText().isEmpty()
| 0 | ||||||||||||||||||
| 91 | QStyleOptionFrame opt; | - | ||||||||||||||||||
| 92 | q->initStyleOption(&opt); | - | ||||||||||||||||||
| 93 | bool showCursor = control->hasSelectedText()
| 0 | ||||||||||||||||||
| 94 | q->style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, q): | - | ||||||||||||||||||
| 95 | q->hasFocus(); | - | ||||||||||||||||||
| 96 | setCursorVisible(showCursor); | - | ||||||||||||||||||
| 97 | } never executed: end of block | 0 | ||||||||||||||||||
| 98 | - | |||||||||||||||||||
| 99 | q->selectionChanged(); | - | ||||||||||||||||||
| 100 | - | |||||||||||||||||||
| 101 | QAccessibleTextSelectionEvent ev(q, control->selectionStart(), control->selectionEnd()); | - | ||||||||||||||||||
| 102 | ev.setCursorPosition(control->cursorPosition()); | - | ||||||||||||||||||
| 103 | QAccessible::updateAccessibility(&ev); | - | ||||||||||||||||||
| 104 | - | |||||||||||||||||||
| 105 | } never executed: end of block | 0 | ||||||||||||||||||
| 106 | - | |||||||||||||||||||
| 107 | void QLineEditPrivate::_q_updateNeeded(const QRect &rect) | - | ||||||||||||||||||
| 108 | { | - | ||||||||||||||||||
| 109 | q_func()->update(adjustedControlRect(rect)); | - | ||||||||||||||||||
| 110 | } never executed: end of block | 0 | ||||||||||||||||||
| 111 | - | |||||||||||||||||||
| 112 | void QLineEditPrivate::init(const QString& txt) | - | ||||||||||||||||||
| 113 | { | - | ||||||||||||||||||
| 114 | QLineEdit * const q = q_func(); | - | ||||||||||||||||||
| 115 | control = new QWidgetLineControl(txt); | - | ||||||||||||||||||
| 116 | control->setParent(q); | - | ||||||||||||||||||
| 117 | control->setFont(q->font()); | - | ||||||||||||||||||
| 118 | QObject::connect(control, qFlagLocation("2""textChanged(QString)" "\0" __FILE__ ":" "177"), | - | ||||||||||||||||||
| 119 | q, qFlagLocation("2""textChanged(QString)" "\0" __FILE__ ":" "178")); | - | ||||||||||||||||||
| 120 | QObject::connect(control, qFlagLocation("2""textEdited(QString)" "\0" __FILE__ ":" "179"), | - | ||||||||||||||||||
| 121 | q, qFlagLocation("1""_q_textEdited(QString)" "\0" __FILE__ ":" "180")); | - | ||||||||||||||||||
| 122 | QObject::connect(control, qFlagLocation("2""cursorPositionChanged(int,int)" "\0" __FILE__ ":" "181"), | - | ||||||||||||||||||
| 123 | q, qFlagLocation("1""_q_cursorPositionChanged(int,int)" "\0" __FILE__ ":" "182")); | - | ||||||||||||||||||
| 124 | QObject::connect(control, qFlagLocation("2""selectionChanged()" "\0" __FILE__ ":" "183"), | - | ||||||||||||||||||
| 125 | q, qFlagLocation("1""_q_selectionChanged()" "\0" __FILE__ ":" "184")); | - | ||||||||||||||||||
| 126 | QObject::connect(control, qFlagLocation("2""accepted()" "\0" __FILE__ ":" "185"), | - | ||||||||||||||||||
| 127 | q, qFlagLocation("2""returnPressed()" "\0" __FILE__ ":" "186")); | - | ||||||||||||||||||
| 128 | QObject::connect(control, qFlagLocation("2""editingFinished()" "\0" __FILE__ ":" "187"), | - | ||||||||||||||||||
| 129 | q, qFlagLocation("2""editingFinished()" "\0" __FILE__ ":" "188")); | - | ||||||||||||||||||
| 130 | - | |||||||||||||||||||
| 131 | - | |||||||||||||||||||
| 132 | - | |||||||||||||||||||
| 133 | - | |||||||||||||||||||
| 134 | QObject::connect(control, qFlagLocation("2""cursorPositionChanged(int,int)" "\0" __FILE__ ":" "193"), | - | ||||||||||||||||||
| 135 | q, qFlagLocation("1""updateMicroFocus()" "\0" __FILE__ ":" "194")); | - | ||||||||||||||||||
| 136 | - | |||||||||||||||||||
| 137 | QObject::connect(control, qFlagLocation("2""textChanged(QString)" "\0" __FILE__ ":" "196"), | - | ||||||||||||||||||
| 138 | q, qFlagLocation("1""updateMicroFocus()" "\0" __FILE__ ":" "197")); | - | ||||||||||||||||||
| 139 | - | |||||||||||||||||||
| 140 | - | |||||||||||||||||||
| 141 | QObject::connect(control, qFlagLocation("2""selectionChanged()" "\0" __FILE__ ":" "200"), | - | ||||||||||||||||||
| 142 | q, qFlagLocation("1""update()" "\0" __FILE__ ":" "201")); | - | ||||||||||||||||||
| 143 | - | |||||||||||||||||||
| 144 | QObject::connect(control, qFlagLocation("2""selectionChanged()" "\0" __FILE__ ":" "203"), | - | ||||||||||||||||||
| 145 | q, qFlagLocation("1""updateMicroFocus()" "\0" __FILE__ ":" "204")); | - | ||||||||||||||||||
| 146 | - | |||||||||||||||||||
| 147 | QObject::connect(control, qFlagLocation("2""displayTextChanged(QString)" "\0" __FILE__ ":" "206"), | - | ||||||||||||||||||
| 148 | q, qFlagLocation("1""update()" "\0" __FILE__ ":" "207")); | - | ||||||||||||||||||
| 149 | - | |||||||||||||||||||
| 150 | QObject::connect(control, qFlagLocation("2""updateNeeded(QRect)" "\0" __FILE__ ":" "209"), | - | ||||||||||||||||||
| 151 | q, qFlagLocation("1""_q_updateNeeded(QRect)" "\0" __FILE__ ":" "210")); | - | ||||||||||||||||||
| 152 | - | |||||||||||||||||||
| 153 | QStyleOptionFrame opt; | - | ||||||||||||||||||
| 154 | q->initStyleOption(&opt); | - | ||||||||||||||||||
| 155 | control->setPasswordCharacter(q->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, q)); | - | ||||||||||||||||||
| 156 | control->setPasswordMaskDelay(q->style()->styleHint(QStyle::SH_LineEdit_PasswordMaskDelay, &opt, q)); | - | ||||||||||||||||||
| 157 | - | |||||||||||||||||||
| 158 | q->setCursor(Qt::IBeamCursor); | - | ||||||||||||||||||
| 159 | - | |||||||||||||||||||
| 160 | q->setFocusPolicy(Qt::StrongFocus); | - | ||||||||||||||||||
| 161 | q->setAttribute(Qt::WA_InputMethodEnabled); | - | ||||||||||||||||||
| 162 | - | |||||||||||||||||||
| 163 | - | |||||||||||||||||||
| 164 | q->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed, QSizePolicy::LineEdit)); | - | ||||||||||||||||||
| 165 | q->setBackgroundRole(QPalette::Base); | - | ||||||||||||||||||
| 166 | q->setAttribute(Qt::WA_KeyCompression); | - | ||||||||||||||||||
| 167 | q->setMouseTracking(true); | - | ||||||||||||||||||
| 168 | q->setAcceptDrops(true); | - | ||||||||||||||||||
| 169 | - | |||||||||||||||||||
| 170 | q->setAttribute(Qt::WA_MacShowFocusRect); | - | ||||||||||||||||||
| 171 | } never executed: end of block | 0 | ||||||||||||||||||
| 172 | - | |||||||||||||||||||
| 173 | QRect QLineEditPrivate::adjustedContentsRect() const | - | ||||||||||||||||||
| 174 | { | - | ||||||||||||||||||
| 175 | const QLineEdit * const q = q_func(); | - | ||||||||||||||||||
| 176 | QStyleOptionFrame opt; | - | ||||||||||||||||||
| 177 | q->initStyleOption(&opt); | - | ||||||||||||||||||
| 178 | QRect r = q->style()->subElementRect(QStyle::SE_LineEditContents, &opt, q); | - | ||||||||||||||||||
| 179 | r.setX(r.x() + effectiveLeftTextMargin()); | - | ||||||||||||||||||
| 180 | r.setY(r.y() + topTextMargin); | - | ||||||||||||||||||
| 181 | r.setRight(r.right() - effectiveRightTextMargin()); | - | ||||||||||||||||||
| 182 | r.setBottom(r.bottom() - bottomTextMargin); | - | ||||||||||||||||||
| 183 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||
| 184 | } | - | ||||||||||||||||||
| 185 | - | |||||||||||||||||||
| 186 | void QLineEditPrivate::setCursorVisible(bool visible) | - | ||||||||||||||||||
| 187 | { | - | ||||||||||||||||||
| 188 | QLineEdit * const q = q_func(); | - | ||||||||||||||||||
| 189 | if ((
| 0 | ||||||||||||||||||
| 190 | return; never executed: return; | 0 | ||||||||||||||||||
| 191 | cursorVisible = visible; | - | ||||||||||||||||||
| 192 | if (control->inputMask().isEmpty()
| 0 | ||||||||||||||||||
| 193 | q->update(cursorRect()); never executed: q->update(cursorRect()); | 0 | ||||||||||||||||||
| 194 | else | - | ||||||||||||||||||
| 195 | q->update(); never executed: q->update(); | 0 | ||||||||||||||||||
| 196 | } | - | ||||||||||||||||||
| 197 | - | |||||||||||||||||||
| 198 | void QLineEditPrivate::updatePasswordEchoEditing(bool editing) | - | ||||||||||||||||||
| 199 | { | - | ||||||||||||||||||
| 200 | QLineEdit * const q = q_func(); | - | ||||||||||||||||||
| 201 | control->updatePasswordEchoEditing(editing); | - | ||||||||||||||||||
| 202 | q->setAttribute(Qt::WA_InputMethodEnabled, shouldEnableInputMethod()); | - | ||||||||||||||||||
| 203 | } never executed: end of block | 0 | ||||||||||||||||||
| 204 | - | |||||||||||||||||||
| 205 | void QLineEditPrivate::resetInputMethod() | - | ||||||||||||||||||
| 206 | { | - | ||||||||||||||||||
| 207 | QLineEdit * const q = q_func(); | - | ||||||||||||||||||
| 208 | if (q->hasFocus()
| 0 | ||||||||||||||||||
| 209 | QGuiApplication::inputMethod()->reset(); | - | ||||||||||||||||||
| 210 | } never executed: end of block | 0 | ||||||||||||||||||
| 211 | } never executed: end of block | 0 | ||||||||||||||||||
| 212 | - | |||||||||||||||||||
| 213 | - | |||||||||||||||||||
| 214 | - | |||||||||||||||||||
| 215 | - | |||||||||||||||||||
| 216 | - | |||||||||||||||||||
| 217 | - | |||||||||||||||||||
| 218 | bool QLineEditPrivate::sendMouseEventToInputContext( QMouseEvent *e ) | - | ||||||||||||||||||
| 219 | { | - | ||||||||||||||||||
| 220 | - | |||||||||||||||||||
| 221 | if ( control->composeMode()
| 0 | ||||||||||||||||||
| 222 | int tmp_cursor = xToPos(e->pos().x()); | - | ||||||||||||||||||
| 223 | int mousePos = tmp_cursor - control->cursor(); | - | ||||||||||||||||||
| 224 | if ( mousePos < 0
| 0 | ||||||||||||||||||
| 225 | mousePos = -1; never executed: mousePos = -1; | 0 | ||||||||||||||||||
| 226 | - | |||||||||||||||||||
| 227 | if (mousePos >= 0
| 0 | ||||||||||||||||||
| 228 | if (e->type() == QEvent::MouseButtonRelease
| 0 | ||||||||||||||||||
| 229 | QGuiApplication::inputMethod()->invokeAction(QInputMethod::Click, mousePos); never executed: QGuiApplication::inputMethod()->invokeAction(QInputMethod::Click, mousePos); | 0 | ||||||||||||||||||
| 230 | - | |||||||||||||||||||
| 231 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 232 | } | - | ||||||||||||||||||
| 233 | } never executed: end of block | 0 | ||||||||||||||||||
| 234 | - | |||||||||||||||||||
| 235 | - | |||||||||||||||||||
| 236 | - | |||||||||||||||||||
| 237 | - | |||||||||||||||||||
| 238 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 239 | } | - | ||||||||||||||||||
| 240 | - | |||||||||||||||||||
| 241 | - | |||||||||||||||||||
| 242 | void QLineEditPrivate::drag() | - | ||||||||||||||||||
| 243 | { | - | ||||||||||||||||||
| 244 | QLineEdit * const q = q_func(); | - | ||||||||||||||||||
| 245 | dndTimer.stop(); | - | ||||||||||||||||||
| 246 | QMimeData *data = new QMimeData; | - | ||||||||||||||||||
| 247 | data->setText(control->selectedText()); | - | ||||||||||||||||||
| 248 | QDrag *drag = new QDrag(q); | - | ||||||||||||||||||
| 249 | drag->setMimeData(data); | - | ||||||||||||||||||
| 250 | Qt::DropAction action = drag->start(); | - | ||||||||||||||||||
| 251 | if (action == Qt::MoveAction
| 0 | ||||||||||||||||||
| 252 | control->removeSelection(); never executed: control->removeSelection(); | 0 | ||||||||||||||||||
| 253 | } never executed: end of block | 0 | ||||||||||||||||||
| 254 | - | |||||||||||||||||||
| 255 | - | |||||||||||||||||||
| 256 | - | |||||||||||||||||||
| 257 | QLineEditIconButton::QLineEditIconButton(QWidget *parent) | - | ||||||||||||||||||
| 258 | : QToolButton(parent) | - | ||||||||||||||||||
| 259 | , m_opacity(0) | - | ||||||||||||||||||
| 260 | { | - | ||||||||||||||||||
| 261 | setFocusPolicy(Qt::NoFocus); | - | ||||||||||||||||||
| 262 | } never executed: end of block | 0 | ||||||||||||||||||
| 263 | - | |||||||||||||||||||
| 264 | QLineEditPrivate *QLineEditIconButton::lineEditPrivate() const | - | ||||||||||||||||||
| 265 | { | - | ||||||||||||||||||
| 266 | QLineEdit *le = qobject_cast<QLineEdit *>(parentWidget()); | - | ||||||||||||||||||
| 267 | return never executed: le ? static_cast<QLineEditPrivate *>(qt_widget_private(le)) : nullptr;return le ? static_cast<QLineEditPrivate *>(qt_widget_private(le)) : nullptr;never executed: return le ? static_cast<QLineEditPrivate *>(qt_widget_private(le)) : nullptr; | 0 | ||||||||||||||||||
| 268 | } | - | ||||||||||||||||||
| 269 | - | |||||||||||||||||||
| 270 | void QLineEditIconButton::paintEvent(QPaintEvent *) | - | ||||||||||||||||||
| 271 | { | - | ||||||||||||||||||
| 272 | QPainter painter(this); | - | ||||||||||||||||||
| 273 | QWindow *window = nullptr; | - | ||||||||||||||||||
| 274 | if (const
| 0 | ||||||||||||||||||
| 275 | window = nativeParent->windowHandle(); never executed: window = nativeParent->windowHandle(); | 0 | ||||||||||||||||||
| 276 | - | |||||||||||||||||||
| 277 | - | |||||||||||||||||||
| 278 | QIcon::Mode state = QIcon::Disabled; | - | ||||||||||||||||||
| 279 | if (isEnabled()
| 0 | ||||||||||||||||||
| 280 | state = isDown()
never executed: state = isDown() ? QIcon::Selected : QIcon::Normal; | 0 | ||||||||||||||||||
| 281 | const QLineEditPrivate *lep = lineEditPrivate(); | - | ||||||||||||||||||
| 282 | const int iconWidth = lep
| 0 | ||||||||||||||||||
| 283 | const QSize iconSize(iconWidth, iconWidth); | - | ||||||||||||||||||
| 284 | const QPixmap iconPixmap = icon().pixmap(window, iconSize, state, QIcon::Off); | - | ||||||||||||||||||
| 285 | QRect pixmapRect = QRect(QPoint(0, 0), iconSize); | - | ||||||||||||||||||
| 286 | pixmapRect.moveCenter(rect().center()); | - | ||||||||||||||||||
| 287 | painter.setOpacity(m_opacity); | - | ||||||||||||||||||
| 288 | painter.drawPixmap(pixmapRect, iconPixmap); | - | ||||||||||||||||||
| 289 | } never executed: end of block | 0 | ||||||||||||||||||
| 290 | - | |||||||||||||||||||
| 291 | void QLineEditIconButton::actionEvent(QActionEvent *e) | - | ||||||||||||||||||
| 292 | { | - | ||||||||||||||||||
| 293 | switch (e->type()) { | - | ||||||||||||||||||
| 294 | case never executed: QEvent::ActionChanged:case QEvent::ActionChanged:never executed: {case QEvent::ActionChanged: | 0 | ||||||||||||||||||
| 295 | const QAction *action = e->action(); | - | ||||||||||||||||||
| 296 | if (isVisibleTo(parentWidget()) != action->isVisible()
| 0 | ||||||||||||||||||
| 297 | setVisible(action->isVisible()); | - | ||||||||||||||||||
| 298 | if (QLineEditPrivate *lep = lineEditPrivate()
| 0 | ||||||||||||||||||
| 299 | lep->positionSideWidgets(); never executed: lep->positionSideWidgets(); | 0 | ||||||||||||||||||
| 300 | } never executed: end of block | 0 | ||||||||||||||||||
| 301 | } | - | ||||||||||||||||||
| 302 | break; never executed: break; | 0 | ||||||||||||||||||
| 303 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||
| 304 | break; never executed: break; | 0 | ||||||||||||||||||
| 305 | } | - | ||||||||||||||||||
| 306 | QToolButton::actionEvent(e); | - | ||||||||||||||||||
| 307 | } never executed: end of block | 0 | ||||||||||||||||||
| 308 | - | |||||||||||||||||||
| 309 | void QLineEditIconButton::setOpacity(qreal value) | - | ||||||||||||||||||
| 310 | { | - | ||||||||||||||||||
| 311 | if (!qFuzzyCompare(m_opacity, value)
| 0 | ||||||||||||||||||
| 312 | m_opacity = value; | - | ||||||||||||||||||
| 313 | updateCursor(); | - | ||||||||||||||||||
| 314 | update(); | - | ||||||||||||||||||
| 315 | } never executed: end of block | 0 | ||||||||||||||||||
| 316 | } never executed: end of block | 0 | ||||||||||||||||||
| 317 | - | |||||||||||||||||||
| 318 | - | |||||||||||||||||||
| 319 | void QLineEditIconButton::startOpacityAnimation(qreal endValue) | - | ||||||||||||||||||
| 320 | { | - | ||||||||||||||||||
| 321 | QPropertyAnimation *animation = new QPropertyAnimation(this, ([]() -> QByteArray { enum { Size = sizeof("opacity") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "opacity" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return never executed: ba;return ba;never executed: }()));return ba; | 0 | ||||||||||||||||||
| 322 | animation->setDuration(160); | - | ||||||||||||||||||
| 323 | animation->setEndValue(endValue); | - | ||||||||||||||||||
| 324 | animation->start(QAbstractAnimation::DeleteWhenStopped); | - | ||||||||||||||||||
| 325 | } never executed: end of block | 0 | ||||||||||||||||||
| 326 | - | |||||||||||||||||||
| 327 | - | |||||||||||||||||||
| 328 | void QLineEditIconButton::updateCursor() | - | ||||||||||||||||||
| 329 | { | - | ||||||||||||||||||
| 330 | - | |||||||||||||||||||
| 331 | setCursor(qFuzzyCompare(m_opacity, qreal(1.0)) || !parentWidget() ? QCursor(Qt::ArrowCursor) : parentWidget()->cursor()); | - | ||||||||||||||||||
| 332 | - | |||||||||||||||||||
| 333 | } never executed: end of block | 0 | ||||||||||||||||||
| 334 | - | |||||||||||||||||||
| 335 | void QLineEditPrivate::_q_textChanged(const QString &text) | - | ||||||||||||||||||
| 336 | { | - | ||||||||||||||||||
| 337 | if (hasSideWidgets()
| 0 | ||||||||||||||||||
| 338 | const int newTextSize = text.size(); | - | ||||||||||||||||||
| 339 | if (!newTextSize
| 0 | ||||||||||||||||||
| 340 | lastTextSize = newTextSize; | - | ||||||||||||||||||
| 341 | - | |||||||||||||||||||
| 342 | const bool fadeIn = newTextSize > 0; | - | ||||||||||||||||||
| 343 | for (const SideWidgetEntry &e : leadingSideWidgets) { | - | ||||||||||||||||||
| 344 | if (e.flags & SideWidgetFadeInWithText
| 0 | ||||||||||||||||||
| 345 | static_cast< never executed: QLineEditIconButton *>(e.widget)->animateShow(fadeIn);static_cast<QLineEditIconButton *>(e.widget)->animateShow(fadeIn);never executed: static_cast<QLineEditIconButton *>(e.widget)->animateShow(fadeIn); | 0 | ||||||||||||||||||
| 346 | } never executed: end of block | 0 | ||||||||||||||||||
| 347 | for (const SideWidgetEntry &e : trailingSideWidgets) { | - | ||||||||||||||||||
| 348 | if (e.flags & SideWidgetFadeInWithText
| 0 | ||||||||||||||||||
| 349 | static_cast< never executed: QLineEditIconButton *>(e.widget)->animateShow(fadeIn);static_cast<QLineEditIconButton *>(e.widget)->animateShow(fadeIn);never executed: static_cast<QLineEditIconButton *>(e.widget)->animateShow(fadeIn); | 0 | ||||||||||||||||||
| 350 | } never executed: end of block | 0 | ||||||||||||||||||
| 351 | - | |||||||||||||||||||
| 352 | } never executed: end of block | 0 | ||||||||||||||||||
| 353 | } never executed: end of block | 0 | ||||||||||||||||||
| 354 | } never executed: end of block | 0 | ||||||||||||||||||
| 355 | - | |||||||||||||||||||
| 356 | void QLineEditPrivate::_q_clearButtonClicked() | - | ||||||||||||||||||
| 357 | { | - | ||||||||||||||||||
| 358 | QLineEdit * const q = q_func(); | - | ||||||||||||||||||
| 359 | if (!q->text().isEmpty()
| 0 | ||||||||||||||||||
| 360 | q->clear(); | - | ||||||||||||||||||
| 361 | q->textEdited(QString()); | - | ||||||||||||||||||
| 362 | } never executed: end of block | 0 | ||||||||||||||||||
| 363 | } never executed: end of block | 0 | ||||||||||||||||||
| 364 | - | |||||||||||||||||||
| 365 | QLineEditPrivate::SideWidgetParameters QLineEditPrivate::sideWidgetParameters() const | - | ||||||||||||||||||
| 366 | { | - | ||||||||||||||||||
| 367 | const QLineEdit * const q = q_func(); | - | ||||||||||||||||||
| 368 | SideWidgetParameters result; | - | ||||||||||||||||||
| 369 | result.iconSize = q->height() < 34
| 0 | ||||||||||||||||||
| 370 | result.margin = result.iconSize / 4; | - | ||||||||||||||||||
| 371 | result.widgetWidth = result.iconSize + 6; | - | ||||||||||||||||||
| 372 | result.widgetHeight = result.iconSize + 2; | - | ||||||||||||||||||
| 373 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||
| 374 | } | - | ||||||||||||||||||
| 375 | - | |||||||||||||||||||
| 376 | QIcon QLineEditPrivate::clearButtonIcon() const | - | ||||||||||||||||||
| 377 | { | - | ||||||||||||||||||
| 378 | const QLineEdit * const q = q_func(); | - | ||||||||||||||||||
| 379 | QStyleOptionFrame styleOption; | - | ||||||||||||||||||
| 380 | q->initStyleOption(&styleOption); | - | ||||||||||||||||||
| 381 | return never executed: q->style()->standardIcon(QStyle::SP_LineEditClearButton, &styleOption, q);return q->style()->standardIcon(QStyle::SP_LineEditClearButton, &styleOption, q);never executed: return q->style()->standardIcon(QStyle::SP_LineEditClearButton, &styleOption, q); | 0 | ||||||||||||||||||
| 382 | } | - | ||||||||||||||||||
| 383 | - | |||||||||||||||||||
| 384 | void QLineEditPrivate::setClearButtonEnabled(bool enabled) | - | ||||||||||||||||||
| 385 | { | - | ||||||||||||||||||
| 386 | for (const SideWidgetEntry &e : trailingSideWidgets) { | - | ||||||||||||||||||
| 387 | if (e.flags & SideWidgetClearButton
| 0 | ||||||||||||||||||
| 388 | e.action->setEnabled(enabled); | - | ||||||||||||||||||
| 389 | break; never executed: break; | 0 | ||||||||||||||||||
| 390 | } | - | ||||||||||||||||||
| 391 | } never executed: end of block | 0 | ||||||||||||||||||
| 392 | } never executed: end of block | 0 | ||||||||||||||||||
| 393 | - | |||||||||||||||||||
| 394 | void QLineEditPrivate::positionSideWidgets() | - | ||||||||||||||||||
| 395 | { | - | ||||||||||||||||||
| 396 | QLineEdit * const q = q_func(); | - | ||||||||||||||||||
| 397 | if (hasSideWidgets()
| 0 | ||||||||||||||||||
| 398 | const QRect contentRect = q->rect(); | - | ||||||||||||||||||
| 399 | const SideWidgetParameters p = sideWidgetParameters(); | - | ||||||||||||||||||
| 400 | const int delta = p.margin + p.widgetWidth; | - | ||||||||||||||||||
| 401 | QRect widgetGeometry(QPoint(p.margin, (contentRect.height() - p.widgetHeight) / 2), | - | ||||||||||||||||||
| 402 | QSize(p.widgetWidth, p.widgetHeight)); | - | ||||||||||||||||||
| 403 | for (const SideWidgetEntry &e : leftSideWidgetList()) { | - | ||||||||||||||||||
| 404 | e.widget->setGeometry(widgetGeometry); | - | ||||||||||||||||||
| 405 | if (e.action->isVisible()
| 0 | ||||||||||||||||||
| 406 | widgetGeometry.moveLeft(widgetGeometry.left() + delta); never executed: widgetGeometry.moveLeft(widgetGeometry.left() + delta); | 0 | ||||||||||||||||||
| 407 | } never executed: end of block | 0 | ||||||||||||||||||
| 408 | widgetGeometry.moveLeft(contentRect.width() - p.widgetWidth - p.margin); | - | ||||||||||||||||||
| 409 | for (const SideWidgetEntry &e : rightSideWidgetList()) { | - | ||||||||||||||||||
| 410 | e.widget->setGeometry(widgetGeometry); | - | ||||||||||||||||||
| 411 | if (e.action->isVisible()
| 0 | ||||||||||||||||||
| 412 | widgetGeometry.moveLeft(widgetGeometry.left() - delta); never executed: widgetGeometry.moveLeft(widgetGeometry.left() - delta); | 0 | ||||||||||||||||||
| 413 | } never executed: end of block | 0 | ||||||||||||||||||
| 414 | } never executed: end of block | 0 | ||||||||||||||||||
| 415 | } never executed: end of block | 0 | ||||||||||||||||||
| 416 | - | |||||||||||||||||||
| 417 | QLineEditPrivate::PositionIndexPair QLineEditPrivate::findSideWidget(const QAction *a) const | - | ||||||||||||||||||
| 418 | { | - | ||||||||||||||||||
| 419 | int i = 0; | - | ||||||||||||||||||
| 420 | for (const auto &e : leadingSideWidgets) { | - | ||||||||||||||||||
| 421 | if (a == e.action
| 0 | ||||||||||||||||||
| 422 | return never executed: PositionIndexPair(QLineEdit::LeadingPosition, i);return PositionIndexPair(QLineEdit::LeadingPosition, i);never executed: return PositionIndexPair(QLineEdit::LeadingPosition, i); | 0 | ||||||||||||||||||
| 423 | ++i; | - | ||||||||||||||||||
| 424 | } never executed: end of block | 0 | ||||||||||||||||||
| 425 | i = 0; | - | ||||||||||||||||||
| 426 | for (const auto &e : trailingSideWidgets) { | - | ||||||||||||||||||
| 427 | if (a == e.action
| 0 | ||||||||||||||||||
| 428 | return never executed: PositionIndexPair(QLineEdit::TrailingPosition, i);return PositionIndexPair(QLineEdit::TrailingPosition, i);never executed: return PositionIndexPair(QLineEdit::TrailingPosition, i); | 0 | ||||||||||||||||||
| 429 | ++i; | - | ||||||||||||||||||
| 430 | } never executed: end of block | 0 | ||||||||||||||||||
| 431 | return never executed: PositionIndexPair(QLineEdit::LeadingPosition, -1);return PositionIndexPair(QLineEdit::LeadingPosition, -1);never executed: return PositionIndexPair(QLineEdit::LeadingPosition, -1); | 0 | ||||||||||||||||||
| 432 | } | - | ||||||||||||||||||
| 433 | - | |||||||||||||||||||
| 434 | QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineEdit::ActionPosition position, int flags) | - | ||||||||||||||||||
| 435 | { | - | ||||||||||||||||||
| 436 | QLineEdit * const q = q_func(); | - | ||||||||||||||||||
| 437 | if (!newAction
| 0 | ||||||||||||||||||
| 438 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 439 | if (!hasSideWidgets()
| 0 | ||||||||||||||||||
| 440 | QObject::connect(q, qFlagLocation("2""textChanged(QString)" "\0" __FILE__ ":" "499"), q, qFlagLocation("1""_q_textChanged(QString)" "\0" __FILE__ ":" "499")); | - | ||||||||||||||||||
| 441 | lastTextSize = q->text().size(); | - | ||||||||||||||||||
| 442 | } never executed: end of block | 0 | ||||||||||||||||||
| 443 | QWidget *w = 0; | - | ||||||||||||||||||
| 444 | - | |||||||||||||||||||
| 445 | - | |||||||||||||||||||
| 446 | if (QWidgetAction *widgetAction = qobject_cast<QWidgetAction *>(newAction)
| 0 | ||||||||||||||||||
| 447 | if ((
| 0 | ||||||||||||||||||
| 448 | flags |= SideWidgetCreatedByWidgetAction; never executed: flags |= SideWidgetCreatedByWidgetAction; | 0 | ||||||||||||||||||
| 449 | } never executed: end of block | 0 | ||||||||||||||||||
| 450 | if (!w
| 0 | ||||||||||||||||||
| 451 | QLineEditIconButton *toolButton = new QLineEditIconButton(q); | - | ||||||||||||||||||
| 452 | toolButton->setIcon(newAction->icon()); | - | ||||||||||||||||||
| 453 | toolButton->setOpacity(lastTextSize > 0 || !(flags & SideWidgetFadeInWithText) ? 1 : 0); | - | ||||||||||||||||||
| 454 | if (flags & SideWidgetClearButton
| 0 | ||||||||||||||||||
| 455 | QObject::connect(toolButton, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "514"), q, qFlagLocation("1""_q_clearButtonClicked()" "\0" __FILE__ ":" "514")); never executed: QObject::connect(toolButton, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "514"), q, qFlagLocation("1""_q_clearButtonClicked()" "\0" __FILE__ ":" "514")); | 0 | ||||||||||||||||||
| 456 | toolButton->setDefaultAction(newAction); | - | ||||||||||||||||||
| 457 | w = toolButton; | - | ||||||||||||||||||
| 458 | } never executed: end of block | 0 | ||||||||||||||||||
| 459 | - | |||||||||||||||||||
| 460 | PositionIndexPair positionIndex = before
| 0 | ||||||||||||||||||
| 461 | SideWidgetEntryList &list = positionIndex.first == QLineEdit::TrailingPosition
| 0 | ||||||||||||||||||
| 462 | if (positionIndex.second < 0
| 0 | ||||||||||||||||||
| 463 | positionIndex.second = int(list.size()); never executed: positionIndex.second = int(list.size()); | 0 | ||||||||||||||||||
| 464 | list.insert(list.begin() + positionIndex.second, SideWidgetEntry(w, newAction, flags)); | - | ||||||||||||||||||
| 465 | positionSideWidgets(); | - | ||||||||||||||||||
| 466 | w->show(); | - | ||||||||||||||||||
| 467 | return never executed: w;return w;never executed: return w; | 0 | ||||||||||||||||||
| 468 | } | - | ||||||||||||||||||
| 469 | - | |||||||||||||||||||
| 470 | void QLineEditPrivate::removeAction(QAction *action) | - | ||||||||||||||||||
| 471 | { | - | ||||||||||||||||||
| 472 | QLineEdit * const q = q_func(); | - | ||||||||||||||||||
| 473 | const PositionIndexPair positionIndex = findSideWidget(action); | - | ||||||||||||||||||
| 474 | if (positionIndex.second == -1
| 0 | ||||||||||||||||||
| 475 | return; never executed: return; | 0 | ||||||||||||||||||
| 476 | SideWidgetEntryList &list = positionIndex.first == QLineEdit::TrailingPosition
| 0 | ||||||||||||||||||
| 477 | SideWidgetEntry entry = list[positionIndex.second]; | - | ||||||||||||||||||
| 478 | list.erase(list.begin() + positionIndex.second); | - | ||||||||||||||||||
| 479 | if (entry.flags & SideWidgetCreatedByWidgetAction
| 0 | ||||||||||||||||||
| 480 | static_cast< never executed: QWidgetAction *>(entry.action)->releaseWidget(entry.widget);static_cast<QWidgetAction *>(entry.action)->releaseWidget(entry.widget);never executed: static_cast<QWidgetAction *>(entry.action)->releaseWidget(entry.widget); | 0 | ||||||||||||||||||
| 481 | else | - | ||||||||||||||||||
| 482 | delete entry.widget; never executed: delete entry.widget; | 0 | ||||||||||||||||||
| 483 | positionSideWidgets(); | - | ||||||||||||||||||
| 484 | if (!hasSideWidgets()
| 0 | ||||||||||||||||||
| 485 | QObject::disconnect(q, qFlagLocation("2""textChanged(QString)" "\0" __FILE__ ":" "544"), q, qFlagLocation("1""_q_textChanged(QString)" "\0" __FILE__ ":" "544")); never executed: QObject::disconnect(q, qFlagLocation("2""textChanged(QString)" "\0" __FILE__ ":" "544"), q, qFlagLocation("1""_q_textChanged(QString)" "\0" __FILE__ ":" "544")); | 0 | ||||||||||||||||||
| 486 | q->update(); | - | ||||||||||||||||||
| 487 | } never executed: end of block | 0 | ||||||||||||||||||
| 488 | - | |||||||||||||||||||
| 489 | static bool isSideWidgetVisible(const QLineEditPrivate::SideWidgetEntry &e) | - | ||||||||||||||||||
| 490 | { | - | ||||||||||||||||||
| 491 | return never executed: e.widget->isVisible();return e.widget->isVisible();never executed: return e.widget->isVisible(); | 0 | ||||||||||||||||||
| 492 | } | - | ||||||||||||||||||
| 493 | - | |||||||||||||||||||
| 494 | int QLineEditPrivate::effectiveLeftTextMargin() const | - | ||||||||||||||||||
| 495 | { | - | ||||||||||||||||||
| 496 | int result = leftTextMargin; | - | ||||||||||||||||||
| 497 | if (!leftSideWidgetList().empty()
| 0 | ||||||||||||||||||
| 498 | const SideWidgetParameters p = sideWidgetParameters(); | - | ||||||||||||||||||
| 499 | result += (p.margin + p.widgetWidth) | - | ||||||||||||||||||
| 500 | * int(std::count_if(leftSideWidgetList().begin(), leftSideWidgetList().end(), | - | ||||||||||||||||||
| 501 | isSideWidgetVisible)); | - | ||||||||||||||||||
| 502 | } never executed: end of block | 0 | ||||||||||||||||||
| 503 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||
| 504 | } | - | ||||||||||||||||||
| 505 | - | |||||||||||||||||||
| 506 | int QLineEditPrivate::effectiveRightTextMargin() const | - | ||||||||||||||||||
| 507 | { | - | ||||||||||||||||||
| 508 | int result = rightTextMargin; | - | ||||||||||||||||||
| 509 | if (!rightSideWidgetList().empty()
| 0 | ||||||||||||||||||
| 510 | const SideWidgetParameters p = sideWidgetParameters(); | - | ||||||||||||||||||
| 511 | result += (p.margin + p.widgetWidth) | - | ||||||||||||||||||
| 512 | * int(std::count_if(rightSideWidgetList().begin(), rightSideWidgetList().end(), | - | ||||||||||||||||||
| 513 | isSideWidgetVisible)); | - | ||||||||||||||||||
| 514 | } never executed: end of block | 0 | ||||||||||||||||||
| 515 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||
| 516 | } | - | ||||||||||||||||||
| 517 | - | |||||||||||||||||||
| 518 | - | |||||||||||||||||||
| 519 | - | |||||||||||||||||||
| 520 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |