widgets/qlineedit_p.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9 -
10 -
11const int QLineEditPrivate::verticalMargin(1); -
12const int QLineEditPrivate::horizontalMargin(2); -
13 -
14QRect QLineEditPrivate::adjustedControlRect(const QRect &rect) const -
15{ -
16 QRect widgetRect = !rect.isEmpty() ? rect : q_func()->rect();
evaluated: !rect.isEmpty()
TRUEFALSE
yes
Evaluation Count:7398
yes
Evaluation Count:278
278-7398
17 QRect cr = adjustedContentsRect(); -
18 int cix = cr.x() - hscroll + horizontalMargin; -
19 return widgetRect.translated(QPoint(cix, vscroll));
executed: return widgetRect.translated(QPoint(cix, vscroll));
Execution Count:7676
7676
20} -
21 -
22int QLineEditPrivate::xToPos(int x, QTextLine::CursorPosition betweenOrOn) const -
23{ -
24 QRect cr = adjustedContentsRect(); -
25 x-= cr.x() - hscroll + horizontalMargin; -
26 return control->xToPos(x, betweenOrOn);
executed: return control->xToPos(x, betweenOrOn);
Execution Count:13
13
27} -
28 -
29QRect QLineEditPrivate::cursorRect() const -
30{ -
31 return adjustedControlRect(control->cursorRect());
executed: return adjustedControlRect(control->cursorRect());
Execution Count:5262
5262
32} -
33 -
34 -
35 -
36void QLineEditPrivate::_q_completionHighlighted(QString newText) -
37{ -
38 QLineEdit * const q = q_func(); -
39 if (control->completer()->completionMode() != QCompleter::InlineCompletion) {
evaluated: control->completer()->completionMode() != QCompleter::InlineCompletion
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:13
12-13
40 q->setText(newText); -
41 } else {
executed: }
Execution Count:12
12
42 int c = control->cursor(); -
43 QString text = control->text(); -
44 q->setText(text.left(c) + newText.mid(c)); -
45 control->moveCursor(control->end(), false); -
46 control->moveCursor(c, true); -
47 }
executed: }
Execution Count:13
13
48} -
49 -
50 -
51 -
52void QLineEditPrivate::_q_handleWindowActivate() -
53{ -
54 QLineEdit * const q = q_func(); -
55 if (!q->hasFocus() && control->hasSelectedText())
evaluated: !q->hasFocus()
TRUEFALSE
yes
Evaluation Count:131
yes
Evaluation Count:194
evaluated: control->hasSelectedText()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:129
2-194
56 control->deselect();
executed: control->deselect();
Execution Count:2
2
57}
executed: }
Execution Count:325
325
58 -
59void QLineEditPrivate::_q_textEdited(const QString &text) -
60{ -
61 QLineEdit * const q = q_func(); -
62 q->textEdited(text); -
63 -
64 if (control->completer()
evaluated: control->completer()
TRUEFALSE
yes
Evaluation Count:77
yes
Evaluation Count:1745
77-1745
65 && control->completer()->completionMode() != QCompleter::InlineCompletion)
evaluated: control->completer()->completionMode() != QCompleter::InlineCompletion
TRUEFALSE
yes
Evaluation Count:68
yes
Evaluation Count:9
9-68
66 control->complete(-1);
executed: control->complete(-1);
Execution Count:68
68
67 -
68}
executed: }
Execution Count:1822
1822
69 -
70void QLineEditPrivate::_q_cursorPositionChanged(int from, int to) -
71{ -
72 QLineEdit * const q = q_func(); -
73 q->update(); -
74 q->cursorPositionChanged(from, to); -
75}
executed: }
Execution Count:11650
11650
76void QLineEditPrivate::_q_selectionChanged() -
77{ -
78 QLineEdit * const q = q_func(); -
79 if (control->preeditAreaText().isEmpty()) {
partially evaluated: control->preeditAreaText().isEmpty()
TRUEFALSE
yes
Evaluation Count:6979
no
Evaluation Count:0
0-6979
80 QStyleOptionFrameV2 opt; -
81 q->initStyleOption(&opt); -
82 bool showCursor = control->hasSelectedText() ?
evaluated: control->hasSelectedText()
TRUEFALSE
yes
Evaluation Count:4123
yes
Evaluation Count:2856
2856-4123
83 q->style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, q): -
84 q->hasFocus(); -
85 setCursorVisible(showCursor); -
86 }
executed: }
Execution Count:6979
6979
87 -
88 q->selectionChanged(); -
89 -
90 QAccessibleTextSelectionEvent ev(q, control->selectionStart(), control->selectionEnd()); -
91 ev.setCursorPosition(control->cursorPosition()); -
92 QAccessible::updateAccessibility(&ev); -
93 -
94}
executed: }
Execution Count:6979
6979
95 -
96void QLineEditPrivate::_q_updateNeeded(const QRect &rect) -
97{ -
98 q_func()->update(adjustedControlRect(rect)); -
99}
executed: }
Execution Count:2414
2414
100 -
101void QLineEditPrivate::init(const QString& txt) -
102{ -
103 QLineEdit * const q = q_func(); -
104 control = new QWidgetLineControl(txt); -
105 control->setParent(q); -
106 control->setFont(q->font()); -
107 QObject::connect(control, "2""textChanged(QString)", -
108 q, "2""textChanged(QString)"); -
109 QObject::connect(control, "2""textEdited(QString)", -
110 q, "1""_q_textEdited(QString)"); -
111 QObject::connect(control, "2""cursorPositionChanged(int,int)", -
112 q, "1""_q_cursorPositionChanged(int,int)"); -
113 QObject::connect(control, "2""selectionChanged()", -
114 q, "1""_q_selectionChanged()"); -
115 QObject::connect(control, "2""accepted()", -
116 q, "2""returnPressed()"); -
117 QObject::connect(control, "2""editingFinished()", -
118 q, "2""editingFinished()"); -
119 -
120 -
121 -
122 -
123 QObject::connect(control, "2""cursorPositionChanged(int,int)", -
124 q, "1""updateMicroFocus()"); -
125 -
126 QObject::connect(control, "2""textChanged(QString)", -
127 q, "1""updateMicroFocus()"); -
128 -
129 -
130 QObject::connect(control, "2""selectionChanged()", -
131 q, "1""update()"); -
132 -
133 QObject::connect(control, "2""displayTextChanged(QString)", -
134 q, "1""update()"); -
135 -
136 QObject::connect(control, "2""updateNeeded(QRect)", -
137 q, "1""_q_updateNeeded(QRect)"); -
138 -
139 QStyleOptionFrameV2 opt; -
140 q->initStyleOption(&opt); -
141 control->setPasswordCharacter(q->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, q)); -
142 -
143 q->setCursor(Qt::IBeamCursor); -
144 -
145 q->setFocusPolicy(Qt::StrongFocus); -
146 q->setAttribute(Qt::WA_InputMethodEnabled); -
147 -
148 -
149 q->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed, QSizePolicy::LineEdit)); -
150 q->setBackgroundRole(QPalette::Base); -
151 q->setAttribute(Qt::WA_KeyCompression); -
152 q->setMouseTracking(true); -
153 q->setAcceptDrops(true); -
154 -
155 q->setAttribute(Qt::WA_MacShowFocusRect); -
156}
executed: }
Execution Count:1077
1077
157 -
158QRect QLineEditPrivate::adjustedContentsRect() const -
159{ -
160 const QLineEdit * const q = q_func(); -
161 QStyleOptionFrameV2 opt; -
162 q->initStyleOption(&opt); -
163 QRect r = q->style()->subElementRect(QStyle::SE_LineEditContents, &opt, q); -
164 r.setX(r.x() + leftTextMargin); -
165 r.setY(r.y() + topTextMargin); -
166 r.setRight(r.right() - rightTextMargin); -
167 r.setBottom(r.bottom() - bottomTextMargin); -
168 return r;
executed: return r;
Execution Count:7689
7689
169} -
170 -
171void QLineEditPrivate::setCursorVisible(bool visible) -
172{ -
173 QLineEdit * const q = q_func(); -
174 if ((bool)cursorVisible == visible)
evaluated: (bool)cursorVisible == visible
TRUEFALSE
yes
Evaluation Count:2685
yes
Evaluation Count:5292
2685-5292
175 return;
executed: return;
Execution Count:2685
2685
176 cursorVisible = visible; -
177 if (control->inputMask().isEmpty())
evaluated: control->inputMask().isEmpty()
TRUEFALSE
yes
Evaluation Count:5260
yes
Evaluation Count:32
32-5260
178 q->update(cursorRect());
executed: q->update(cursorRect());
Execution Count:5260
5260
179 else -
180 q->update();
executed: q->update();
Execution Count:32
32
181} -
182 -
183void QLineEditPrivate::updatePasswordEchoEditing(bool editing) -
184{ -
185 QLineEdit * const q = q_func(); -
186 control->updatePasswordEchoEditing(editing); -
187 q->setAttribute(Qt::WA_InputMethodEnabled, shouldEnableInputMethod()); -
188}
executed: }
Execution Count:2
2
189 -
190void QLineEditPrivate::resetInputMethod() -
191{ -
192 QLineEdit * const q = q_func(); -
193 if (q->hasFocus() && (static_cast<QApplication *>(QCoreApplication::instance()))) {
evaluated: q->hasFocus()
TRUEFALSE
yes
Evaluation Count:245
yes
Evaluation Count:168
partially evaluated: (static_cast<QApplication *>(QCoreApplication::instance()))
TRUEFALSE
yes
Evaluation Count:245
no
Evaluation Count:0
0-245
194 (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->reset(); -
195 }
executed: }
Execution Count:245
245
196}
executed: }
Execution Count:413
413
197 -
198 -
199 -
200 -
201 -
202 -
203bool QLineEditPrivate::sendMouseEventToInputContext( QMouseEvent *e ) -
204{ -
205 -
206 if ( control->composeMode() ) {
partially evaluated: control->composeMode()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:53
0-53
207 int tmp_cursor = xToPos(e->pos().x()); -
208 int mousePos = tmp_cursor - control->cursor(); -
209 if ( mousePos < 0 || mousePos > control->preeditAreaText().length() )
never evaluated: mousePos < 0
never evaluated: mousePos > control->preeditAreaText().length()
0
210 mousePos = -1;
never executed: mousePos = -1;
0
211 -
212 if (mousePos >= 0) {
never evaluated: mousePos >= 0
0
213 if (e->type() == QEvent::MouseButtonRelease)
never evaluated: e->type() == QEvent::MouseButtonRelease
0
214 (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->invokeAction(QInputMethod::Click, mousePos);
never executed: (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->invokeAction(QInputMethod::Click, mousePos);
0
215 -
216 return true;
never executed: return true;
0
217 } -
218 }
never executed: }
0
219 -
220 -
221 -
222 -
223 return false;
executed: return false;
Execution Count:53
53
224} -
225 -
226 -
227void QLineEditPrivate::drag() -
228{ -
229 QLineEdit * const q = q_func(); -
230 dndTimer.stop(); -
231 QMimeData *data = new QMimeData; -
232 data->setText(control->selectedText()); -
233 QDrag *drag = new QDrag(q); -
234 drag->setMimeData(data); -
235 Qt::DropAction action = drag->start(); -
236 if (action == Qt::MoveAction && !control->isReadOnly() && drag->target() != q)
never evaluated: action == Qt::MoveAction
never evaluated: !control->isReadOnly()
never evaluated: drag->target() != q
0
237 control->removeSelection();
never executed: control->removeSelection();
0
238}
never executed: }
0
239 -
240 -
241 -
242 -
243 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial