Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
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 Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/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 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "qwidgetlinecontrol_p.h" | - |
43 | | - |
44 | #ifndef QT_NO_LINEEDIT | - |
45 | | - |
46 | #include "qabstractitemview.h" | - |
47 | #include "qclipboard.h" | - |
48 | #include <private/qguiapplication_p.h> | - |
49 | #include <qpa/qplatformtheme.h> | - |
50 | #include <qstylehints.h> | - |
51 | #ifndef QT_NO_ACCESSIBILITY | - |
52 | #include "qaccessible.h" | - |
53 | #endif | - |
54 | | - |
55 | #include "qapplication.h" | - |
56 | #ifndef QT_NO_GRAPHICSVIEW | - |
57 | #include "qgraphicssceneevent.h" | - |
58 | #endif | - |
59 | | - |
60 | QT_BEGIN_NAMESPACE | - |
61 | | - |
62 | | - |
63 | /*! | - |
64 | \internal | - |
65 | | - |
66 | Updates the internal text layout. Returns the ascent of the | - |
67 | created QTextLine. | - |
68 | */ | - |
69 | int QWidgetLineControl::redoTextLayout() const | - |
70 | { | - |
71 | m_textLayout.clearLayout(); executed (the execution status of this line is deduced): m_textLayout.clearLayout(); | - |
72 | | - |
73 | m_textLayout.beginLayout(); executed (the execution status of this line is deduced): m_textLayout.beginLayout(); | - |
74 | QTextLine l = m_textLayout.createLine(); executed (the execution status of this line is deduced): QTextLine l = m_textLayout.createLine(); | - |
75 | m_textLayout.endLayout(); executed (the execution status of this line is deduced): m_textLayout.endLayout(); | - |
76 | | - |
77 | #if defined(Q_WS_MAC) | - |
78 | if (m_threadChecks) | - |
79 | m_textLayoutThread = QThread::currentThread(); | - |
80 | #endif | - |
81 | | - |
82 | return qRound(l.ascent()); executed: return qRound(l.ascent()); Execution Count:10359 | 10359 |
83 | } | - |
84 | | - |
85 | /*! | - |
86 | \internal | - |
87 | | - |
88 | Updates the display text based of the current edit text | - |
89 | If the text has changed will emit displayTextChanged() | - |
90 | */ | - |
91 | void QWidgetLineControl::updateDisplayText(bool forceUpdate) | - |
92 | { | - |
93 | QString orig = m_textLayout.text(); executed (the execution status of this line is deduced): QString orig = m_textLayout.text(); | - |
94 | QString str; executed (the execution status of this line is deduced): QString str; | - |
95 | if (m_echoMode == QLineEdit::NoEcho) evaluated: m_echoMode == QLineEdit::NoEcho yes Evaluation Count:42 | yes Evaluation Count:10317 |
| 42-10317 |
96 | str = QString::fromLatin1(""); executed: str = QString::fromLatin1(""); Execution Count:42 | 42 |
97 | else | - |
98 | str = m_text; executed: str = m_text; Execution Count:10317 | 10317 |
99 | | - |
100 | if (m_echoMode == QLineEdit::Password) { evaluated: m_echoMode == QLineEdit::Password yes Evaluation Count:42 | yes Evaluation Count:10317 |
| 42-10317 |
101 | str.fill(m_passwordCharacter); executed (the execution status of this line is deduced): str.fill(m_passwordCharacter); | - |
102 | if (m_passwordEchoTimer != 0 && m_cursor > 0 && m_cursor <= m_text.length()) { partially evaluated: m_passwordEchoTimer != 0 no Evaluation Count:0 | yes Evaluation Count:42 |
never evaluated: m_cursor > 0 never evaluated: m_cursor <= m_text.length() | 0-42 |
103 | int cursor = m_cursor - 1; never executed (the execution status of this line is deduced): int cursor = m_cursor - 1; | - |
104 | QChar uc = m_text.at(cursor); never executed (the execution status of this line is deduced): QChar uc = m_text.at(cursor); | - |
105 | str[cursor] = uc; never executed (the execution status of this line is deduced): str[cursor] = uc; | - |
106 | if (cursor > 0 && uc.isLowSurrogate()) { never evaluated: cursor > 0 never evaluated: uc.isLowSurrogate() | 0 |
107 | // second half of a surrogate, check if we have the first half as well, | - |
108 | // if yes restore both at once | - |
109 | uc = m_text.at(cursor - 1); never executed (the execution status of this line is deduced): uc = m_text.at(cursor - 1); | - |
110 | if (uc.isHighSurrogate()) never evaluated: uc.isHighSurrogate() | 0 |
111 | str[cursor - 1] = uc; never executed: str[cursor - 1] = uc; | 0 |
112 | } | 0 |
113 | } | 0 |
114 | } else if (m_echoMode == QLineEdit::PasswordEchoOnEdit && !m_passwordEchoEditing) { executed: } Execution Count:42 evaluated: m_echoMode == QLineEdit::PasswordEchoOnEdit yes Evaluation Count:33 | yes Evaluation Count:10284 |
evaluated: !m_passwordEchoEditing yes Evaluation Count:18 | yes Evaluation Count:15 |
| 15-10284 |
115 | str.fill(m_passwordCharacter); executed (the execution status of this line is deduced): str.fill(m_passwordCharacter); | - |
116 | } executed: } Execution Count:18 | 18 |
117 | | - |
118 | // replace certain non-printable characters with spaces (to avoid | - |
119 | // drawing boxes when using fonts that don't have glyphs for such | - |
120 | // characters) | - |
121 | QChar* uc = str.data(); executed (the execution status of this line is deduced): QChar* uc = str.data(); | - |
122 | for (int i = 0; i < (int)str.length(); ++i) { evaluated: i < (int)str.length() yes Evaluation Count:59619 | yes Evaluation Count:10359 |
| 10359-59619 |
123 | if ((uc[i] < 0x20 && uc[i] != 0x09) evaluated: uc[i] < 0x20 yes Evaluation Count:9 | yes Evaluation Count:59610 |
partially evaluated: uc[i] != 0x09 yes Evaluation Count:9 | no Evaluation Count:0 |
| 0-59610 |
124 | || uc[i] == QChar::LineSeparator partially evaluated: uc[i] == QChar::LineSeparator no Evaluation Count:0 | yes Evaluation Count:59610 |
| 0-59610 |
125 | || uc[i] == QChar::ParagraphSeparator partially evaluated: uc[i] == QChar::ParagraphSeparator no Evaluation Count:0 | yes Evaluation Count:59610 |
| 0-59610 |
126 | || uc[i] == QChar::ObjectReplacementCharacter) partially evaluated: uc[i] == QChar::ObjectReplacementCharacter no Evaluation Count:0 | yes Evaluation Count:59610 |
| 0-59610 |
127 | uc[i] = QChar(0x0020); executed: uc[i] = QChar(0x0020); Execution Count:9 | 9 |
128 | } executed: } Execution Count:59619 | 59619 |
129 | | - |
130 | m_textLayout.setText(str); executed (the execution status of this line is deduced): m_textLayout.setText(str); | - |
131 | | - |
132 | QTextOption option = m_textLayout.textOption(); executed (the execution status of this line is deduced): QTextOption option = m_textLayout.textOption(); | - |
133 | option.setTextDirection(m_layoutDirection); executed (the execution status of this line is deduced): option.setTextDirection(m_layoutDirection); | - |
134 | option.setFlags(QTextOption::IncludeTrailingSpaces); executed (the execution status of this line is deduced): option.setFlags(QTextOption::IncludeTrailingSpaces); | - |
135 | m_textLayout.setTextOption(option); executed (the execution status of this line is deduced): m_textLayout.setTextOption(option); | - |
136 | | - |
137 | m_ascent = redoTextLayout(); executed (the execution status of this line is deduced): m_ascent = redoTextLayout(); | - |
138 | | - |
139 | if (str != orig || forceUpdate) evaluated: str != orig yes Evaluation Count:6080 | yes Evaluation Count:4279 |
evaluated: forceUpdate yes Evaluation Count:47 | yes Evaluation Count:4232 |
| 47-6080 |
140 | emit displayTextChanged(str); executed: displayTextChanged(str); Execution Count:6127 | 6127 |
141 | } executed: } Execution Count:10359 | 10359 |
142 | | - |
143 | #ifndef QT_NO_CLIPBOARD | - |
144 | /*! | - |
145 | \internal | - |
146 | | - |
147 | Copies the currently selected text into the clipboard using the given | - |
148 | \a mode. | - |
149 | | - |
150 | \note If the echo mode is set to a mode other than Normal then copy | - |
151 | will not work. This is to prevent using copy as a method of bypassing | - |
152 | password features of the line control. | - |
153 | */ | - |
154 | void QWidgetLineControl::copy(QClipboard::Mode mode) const | - |
155 | { | - |
156 | QString t = selectedText(); executed (the execution status of this line is deduced): QString t = selectedText(); | - |
157 | if (!t.isEmpty() && m_echoMode == QLineEdit::Normal) { evaluated: !t.isEmpty() yes Evaluation Count:5 | yes Evaluation Count:11 |
partially evaluated: m_echoMode == QLineEdit::Normal yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-11 |
158 | disconnect(QApplication::clipboard(), SIGNAL(selectionChanged()), this, 0); executed (the execution status of this line is deduced): disconnect(QApplication::clipboard(), "2""selectionChanged()", this, 0); | - |
159 | QApplication::clipboard()->setText(t, mode); executed (the execution status of this line is deduced): QApplication::clipboard()->setText(t, mode); | - |
160 | connect(QApplication::clipboard(), SIGNAL(selectionChanged()), executed (the execution status of this line is deduced): connect(QApplication::clipboard(), "2""selectionChanged()", | - |
161 | this, SLOT(_q_clipboardChanged())); executed (the execution status of this line is deduced): this, "1""_q_clipboardChanged()"); | - |
162 | } executed: } Execution Count:5 | 5 |
163 | } executed: } Execution Count:16 | 16 |
164 | | - |
165 | /*! | - |
166 | \internal | - |
167 | | - |
168 | Inserts the text stored in the application clipboard into the line | - |
169 | control. | - |
170 | | - |
171 | \sa insert() | - |
172 | */ | - |
173 | void QWidgetLineControl::paste(QClipboard::Mode clipboardMode) | - |
174 | { | - |
175 | QString clip = QApplication::clipboard()->text(clipboardMode); executed (the execution status of this line is deduced): QString clip = QApplication::clipboard()->text(clipboardMode); | - |
176 | if (!clip.isEmpty() || hasSelectedText()) { evaluated: !clip.isEmpty() yes Evaluation Count:7 | yes Evaluation Count:1 |
partially evaluated: hasSelectedText() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-7 |
177 | separate(); //make it a separate undo/redo command executed (the execution status of this line is deduced): separate(); | - |
178 | insert(clip); executed (the execution status of this line is deduced): insert(clip); | - |
179 | separate(); executed (the execution status of this line is deduced): separate(); | - |
180 | } executed: } Execution Count:8 | 8 |
181 | } executed: } Execution Count:8 | 8 |
182 | | - |
183 | #endif // !QT_NO_CLIPBOARD | - |
184 | | - |
185 | /*! | - |
186 | \internal | - |
187 | */ | - |
188 | void QWidgetLineControl::commitPreedit() | - |
189 | { | - |
190 | if (!composeMode()) partially evaluated: !composeMode() yes Evaluation Count:7490 | no Evaluation Count:0 |
| 0-7490 |
191 | return; executed: return; Execution Count:7490 | 7490 |
192 | | - |
193 | qApp->inputMethod()->commit(); never executed (the execution status of this line is deduced): (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->commit(); | - |
194 | if (!composeMode()) never evaluated: !composeMode() | 0 |
195 | return; | 0 |
196 | | - |
197 | m_preeditCursor = 0; never executed (the execution status of this line is deduced): m_preeditCursor = 0; | - |
198 | setPreeditArea(-1, QString()); never executed (the execution status of this line is deduced): setPreeditArea(-1, QString()); | - |
199 | m_textLayout.clearAdditionalFormats(); never executed (the execution status of this line is deduced): m_textLayout.clearAdditionalFormats(); | - |
200 | updateDisplayText(/*force*/ true); never executed (the execution status of this line is deduced): updateDisplayText( true); | - |
201 | } | 0 |
202 | | - |
203 | | - |
204 | /*! | - |
205 | \internal | - |
206 | | - |
207 | Handles the behavior for the backspace key or function. | - |
208 | Removes the current selection if there is a selection, otherwise | - |
209 | removes the character prior to the cursor position. | - |
210 | | - |
211 | \sa del() | - |
212 | */ | - |
213 | void QWidgetLineControl::backspace() | - |
214 | { | - |
215 | int priorState = m_undoState; executed (the execution status of this line is deduced): int priorState = m_undoState; | - |
216 | if (hasSelectedText()) { evaluated: hasSelectedText() yes Evaluation Count:10 | yes Evaluation Count:51 |
| 10-51 |
217 | removeSelectedText(); executed (the execution status of this line is deduced): removeSelectedText(); | - |
218 | } else if (m_cursor) { executed: } Execution Count:10 evaluated: m_cursor yes Evaluation Count:43 | yes Evaluation Count:8 |
| 8-43 |
219 | --m_cursor; executed (the execution status of this line is deduced): --m_cursor; | - |
220 | if (m_maskData) evaluated: m_maskData yes Evaluation Count:2 | yes Evaluation Count:41 |
| 2-41 |
221 | m_cursor = prevMaskBlank(m_cursor); executed: m_cursor = prevMaskBlank(m_cursor); Execution Count:2 | 2 |
222 | QChar uc = m_text.at(m_cursor); executed (the execution status of this line is deduced): QChar uc = m_text.at(m_cursor); | - |
223 | if (m_cursor > 0 && uc.isLowSurrogate()) { evaluated: m_cursor > 0 yes Evaluation Count:39 | yes Evaluation Count:4 |
partially evaluated: uc.isLowSurrogate() no Evaluation Count:0 | yes Evaluation Count:39 |
| 0-39 |
224 | // second half of a surrogate, check if we have the first half as well, | - |
225 | // if yes delete both at once | - |
226 | uc = m_text.at(m_cursor - 1); never executed (the execution status of this line is deduced): uc = m_text.at(m_cursor - 1); | - |
227 | if (uc.isHighSurrogate()) { never evaluated: uc.isHighSurrogate() | 0 |
228 | internalDelete(true); never executed (the execution status of this line is deduced): internalDelete(true); | - |
229 | --m_cursor; never executed (the execution status of this line is deduced): --m_cursor; | - |
230 | } | 0 |
231 | } | 0 |
232 | internalDelete(true); executed (the execution status of this line is deduced): internalDelete(true); | - |
233 | } executed: } Execution Count:43 | 43 |
234 | finishChange(priorState); executed (the execution status of this line is deduced): finishChange(priorState); | - |
235 | } executed: } Execution Count:61 | 61 |
236 | | - |
237 | /*! | - |
238 | \internal | - |
239 | | - |
240 | Handles the behavior for the delete key or function. | - |
241 | Removes the current selection if there is a selection, otherwise | - |
242 | removes the character after the cursor position. | - |
243 | | - |
244 | \sa del() | - |
245 | */ | - |
246 | void QWidgetLineControl::del() | - |
247 | { | - |
248 | int priorState = m_undoState; executed (the execution status of this line is deduced): int priorState = m_undoState; | - |
249 | if (hasSelectedText()) { evaluated: hasSelectedText() yes Evaluation Count:35 | yes Evaluation Count:50 |
| 35-50 |
250 | removeSelectedText(); executed (the execution status of this line is deduced): removeSelectedText(); | - |
251 | } else { executed: } Execution Count:35 | 35 |
252 | int n = textLayout()->nextCursorPosition(m_cursor) - m_cursor; executed (the execution status of this line is deduced): int n = textLayout()->nextCursorPosition(m_cursor) - m_cursor; | - |
253 | while (n--) evaluated: n-- yes Evaluation Count:45 | yes Evaluation Count:50 |
| 45-50 |
254 | internalDelete(); executed: internalDelete(); Execution Count:45 | 45 |
255 | } executed: } Execution Count:50 | 50 |
256 | finishChange(priorState); executed (the execution status of this line is deduced): finishChange(priorState); | - |
257 | } executed: } Execution Count:85 | 85 |
258 | | - |
259 | /*! | - |
260 | \internal | - |
261 | | - |
262 | Inserts the given \a newText at the current cursor position. | - |
263 | If there is any selected text it is removed prior to insertion of | - |
264 | the new text. | - |
265 | */ | - |
266 | void QWidgetLineControl::insert(const QString &newText) | - |
267 | { | - |
268 | int priorState = m_undoState; executed (the execution status of this line is deduced): int priorState = m_undoState; | - |
269 | removeSelectedText(); executed (the execution status of this line is deduced): removeSelectedText(); | - |
270 | internalInsert(newText); executed (the execution status of this line is deduced): internalInsert(newText); | - |
271 | finishChange(priorState); executed (the execution status of this line is deduced): finishChange(priorState); | - |
272 | } executed: } Execution Count:1664 | 1664 |
273 | | - |
274 | /*! | - |
275 | \internal | - |
276 | | - |
277 | Clears the line control text. | - |
278 | */ | - |
279 | void QWidgetLineControl::clear() | - |
280 | { | - |
281 | int priorState = m_undoState; executed (the execution status of this line is deduced): int priorState = m_undoState; | - |
282 | m_selstart = 0; executed (the execution status of this line is deduced): m_selstart = 0; | - |
283 | m_selend = m_text.length(); executed (the execution status of this line is deduced): m_selend = m_text.length(); | - |
284 | removeSelectedText(); executed (the execution status of this line is deduced): removeSelectedText(); | - |
285 | separate(); executed (the execution status of this line is deduced): separate(); | - |
286 | finishChange(priorState, /*update*/false, /*edited*/false); executed (the execution status of this line is deduced): finishChange(priorState, false, false); | - |
287 | } executed: } Execution Count:348 | 348 |
288 | | - |
289 | /*! | - |
290 | \internal | - |
291 | | - |
292 | Sets \a length characters from the given \a start position as selected. | - |
293 | The given \a start position must be within the current text for | - |
294 | the line control. If \a length characters cannot be selected, then | - |
295 | the selection will extend to the end of the current text. | - |
296 | */ | - |
297 | void QWidgetLineControl::setSelection(int start, int length) | - |
298 | { | - |
299 | commitPreedit(); executed (the execution status of this line is deduced): commitPreedit(); | - |
300 | | - |
301 | if(start < 0 || start > (int)m_text.length()){ partially evaluated: start < 0 no Evaluation Count:0 | yes Evaluation Count:3985 |
partially evaluated: start > (int)m_text.length() no Evaluation Count:0 | yes Evaluation Count:3985 |
| 0-3985 |
302 | qWarning("QWidgetLineControl::setSelection: Invalid start position"); never executed (the execution status of this line is deduced): QMessageLogger("widgets/qwidgetlinecontrol.cpp", 302, __PRETTY_FUNCTION__).warning("QWidgetLineControl::setSelection: Invalid start position"); | - |
303 | return; | 0 |
304 | } | - |
305 | | - |
306 | if (length > 0) { evaluated: length > 0 yes Evaluation Count:2158 | yes Evaluation Count:1827 |
| 1827-2158 |
307 | if (start == m_selstart && start + length == m_selend && m_cursor == m_selend) evaluated: start == m_selstart yes Evaluation Count:858 | yes Evaluation Count:1300 |
evaluated: start + length == m_selend yes Evaluation Count:144 | yes Evaluation Count:714 |
evaluated: m_cursor == m_selend yes Evaluation Count:73 | yes Evaluation Count:71 |
| 71-1300 |
308 | return; executed: return; Execution Count:73 | 73 |
309 | m_selstart = start; executed (the execution status of this line is deduced): m_selstart = start; | - |
310 | m_selend = qMin(start + length, (int)m_text.length()); executed (the execution status of this line is deduced): m_selend = qMin(start + length, (int)m_text.length()); | - |
311 | m_cursor = m_selend; executed (the execution status of this line is deduced): m_cursor = m_selend; | - |
312 | } else if (length < 0){ executed: } Execution Count:2085 evaluated: length < 0 yes Evaluation Count:1813 | yes Evaluation Count:14 |
| 14-2085 |
313 | if (start == m_selend && start + length == m_selstart && m_cursor == m_selstart) evaluated: start == m_selend yes Evaluation Count:1484 | yes Evaluation Count:329 |
evaluated: start + length == m_selstart yes Evaluation Count:1482 | yes Evaluation Count:2 |
evaluated: m_cursor == m_selstart yes Evaluation Count:92 | yes Evaluation Count:1390 |
| 2-1484 |
314 | return; executed: return; Execution Count:92 | 92 |
315 | m_selstart = qMax(start + length, 0); executed (the execution status of this line is deduced): m_selstart = qMax(start + length, 0); | - |
316 | m_selend = start; executed (the execution status of this line is deduced): m_selend = start; | - |
317 | m_cursor = m_selstart; executed (the execution status of this line is deduced): m_cursor = m_selstart; | - |
318 | } else if (m_selstart != m_selend) { executed: } Execution Count:1721 evaluated: m_selstart != m_selend yes Evaluation Count:4 | yes Evaluation Count:10 |
| 4-1721 |
319 | m_selstart = 0; executed (the execution status of this line is deduced): m_selstart = 0; | - |
320 | m_selend = 0; executed (the execution status of this line is deduced): m_selend = 0; | - |
321 | m_cursor = start; executed (the execution status of this line is deduced): m_cursor = start; | - |
322 | } else { executed: } Execution Count:4 | 4 |
323 | m_cursor = start; executed (the execution status of this line is deduced): m_cursor = start; | - |
324 | emitCursorPositionChanged(); executed (the execution status of this line is deduced): emitCursorPositionChanged(); | - |
325 | return; executed: return; Execution Count:10 | 10 |
326 | } | - |
327 | emit selectionChanged(); executed (the execution status of this line is deduced): selectionChanged(); | - |
328 | emitCursorPositionChanged(); executed (the execution status of this line is deduced): emitCursorPositionChanged(); | - |
329 | } executed: } Execution Count:3810 | 3810 |
330 | | - |
331 | void QWidgetLineControl::_q_clipboardChanged() | - |
332 | { | - |
333 | } | - |
334 | | - |
335 | void QWidgetLineControl::_q_deleteSelected() | - |
336 | { | - |
337 | if (!hasSelectedText()) partially evaluated: !hasSelectedText() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
338 | return; | 0 |
339 | | - |
340 | int priorState = m_undoState; executed (the execution status of this line is deduced): int priorState = m_undoState; | - |
341 | emit resetInputContext(); executed (the execution status of this line is deduced): resetInputContext(); | - |
342 | removeSelectedText(); executed (the execution status of this line is deduced): removeSelectedText(); | - |
343 | separate(); executed (the execution status of this line is deduced): separate(); | - |
344 | finishChange(priorState); executed (the execution status of this line is deduced): finishChange(priorState); | - |
345 | } executed: } Execution Count:1 | 1 |
346 | | - |
347 | /*! | - |
348 | \internal | - |
349 | | - |
350 | Initializes the line control with a starting text value of \a txt. | - |
351 | */ | - |
352 | void QWidgetLineControl::init(const QString &txt) | - |
353 | { | - |
354 | m_textLayout.setCacheEnabled(true); executed (the execution status of this line is deduced): m_textLayout.setCacheEnabled(true); | - |
355 | m_text = txt; executed (the execution status of this line is deduced): m_text = txt; | - |
356 | updateDisplayText(); executed (the execution status of this line is deduced): updateDisplayText(); | - |
357 | m_cursor = m_text.length(); executed (the execution status of this line is deduced): m_cursor = m_text.length(); | - |
358 | if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) partially evaluated: const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme() yes Evaluation Count:1077 | no Evaluation Count:0 |
| 0-1077 |
359 | m_keyboardScheme = theme->themeHint(QPlatformTheme::KeyboardScheme).toInt(); executed: m_keyboardScheme = theme->themeHint(QPlatformTheme::KeyboardScheme).toInt(); Execution Count:1077 | 1077 |
360 | // Generalize for X11 | - |
361 | if (m_keyboardScheme == QPlatformTheme::KdeKeyboardScheme partially evaluated: m_keyboardScheme == QPlatformTheme::KdeKeyboardScheme no Evaluation Count:0 | yes Evaluation Count:1077 |
| 0-1077 |
362 | || m_keyboardScheme == QPlatformTheme::GnomeKeyboardScheme partially evaluated: m_keyboardScheme == QPlatformTheme::GnomeKeyboardScheme yes Evaluation Count:1077 | no Evaluation Count:0 |
| 0-1077 |
363 | || m_keyboardScheme == QPlatformTheme::CdeKeyboardScheme) { never evaluated: m_keyboardScheme == QPlatformTheme::CdeKeyboardScheme | 0 |
364 | m_keyboardScheme = QPlatformTheme::X11KeyboardScheme; executed (the execution status of this line is deduced): m_keyboardScheme = QPlatformTheme::X11KeyboardScheme; | - |
365 | } executed: } Execution Count:1077 | 1077 |
366 | } executed: } Execution Count:1077 | 1077 |
367 | | - |
368 | /*! | - |
369 | \internal | - |
370 | | - |
371 | Sets the password echo editing to \a editing. If password echo editing | - |
372 | is true, then the text of the password is displayed even if the echo | - |
373 | mode is set to QLineEdit::PasswordEchoOnEdit. Password echoing editing | - |
374 | does not affect other echo modes. | - |
375 | */ | - |
376 | void QWidgetLineControl::updatePasswordEchoEditing(bool editing) | - |
377 | { | - |
378 | cancelPasswordEchoTimer(); executed (the execution status of this line is deduced): cancelPasswordEchoTimer(); | - |
379 | m_passwordEchoEditing = editing; executed (the execution status of this line is deduced): m_passwordEchoEditing = editing; | - |
380 | updateDisplayText(); executed (the execution status of this line is deduced): updateDisplayText(); | - |
381 | } executed: } Execution Count:6 | 6 |
382 | | - |
383 | /*! | - |
384 | \internal | - |
385 | | - |
386 | Returns the cursor position of the given \a x pixel value in relation | - |
387 | to the displayed text. The given \a betweenOrOn specified what kind | - |
388 | of cursor position is requested. | - |
389 | */ | - |
390 | int QWidgetLineControl::xToPos(int x, QTextLine::CursorPosition betweenOrOn) const | - |
391 | { | - |
392 | return textLayout()->lineAt(0).xToCursor(x, betweenOrOn); executed: return textLayout()->lineAt(0).xToCursor(x, betweenOrOn); Execution Count:13 | 13 |
393 | } | - |
394 | | - |
395 | /*! | - |
396 | \internal | - |
397 | | - |
398 | Returns the bounds of the current cursor, as defined as a | - |
399 | between characters cursor. | - |
400 | */ | - |
401 | QRect QWidgetLineControl::cursorRect() const | - |
402 | { | - |
403 | QTextLine l = textLayout()->lineAt(0); executed (the execution status of this line is deduced): QTextLine l = textLayout()->lineAt(0); | - |
404 | int c = m_cursor; executed (the execution status of this line is deduced): int c = m_cursor; | - |
405 | if (m_preeditCursor != -1) partially evaluated: m_preeditCursor != -1 yes Evaluation Count:7398 | no Evaluation Count:0 |
| 0-7398 |
406 | c += m_preeditCursor; executed: c += m_preeditCursor; Execution Count:7398 | 7398 |
407 | int cix = qRound(l.cursorToX(c)); executed (the execution status of this line is deduced): int cix = qRound(l.cursorToX(c)); | - |
408 | int w = m_cursorWidth; executed (the execution status of this line is deduced): int w = m_cursorWidth; | - |
409 | int ch = l.height() + 1; executed (the execution status of this line is deduced): int ch = l.height() + 1; | - |
410 | | - |
411 | return QRect(cix-5, 0, w+9, ch); executed: return QRect(cix-5, 0, w+9, ch); Execution Count:7398 | 7398 |
412 | } | - |
413 | | - |
414 | /*! | - |
415 | \internal | - |
416 | | - |
417 | Fixes the current text so that it is valid given any set validators. | - |
418 | | - |
419 | Returns true if the text was changed. Otherwise returns false. | - |
420 | */ | - |
421 | bool QWidgetLineControl::fixup() // this function assumes that validate currently returns != Acceptable | - |
422 | { | - |
423 | #ifndef QT_NO_VALIDATOR | - |
424 | if (m_validator) { evaluated: m_validator yes Evaluation Count:30 | yes Evaluation Count:75 |
| 30-75 |
425 | QString textCopy = m_text; executed (the execution status of this line is deduced): QString textCopy = m_text; | - |
426 | int cursorCopy = m_cursor; executed (the execution status of this line is deduced): int cursorCopy = m_cursor; | - |
427 | m_validator->fixup(textCopy); executed (the execution status of this line is deduced): m_validator->fixup(textCopy); | - |
428 | if (m_validator->validate(textCopy, cursorCopy) == QValidator::Acceptable) { evaluated: m_validator->validate(textCopy, cursorCopy) == QValidator::Acceptable yes Evaluation Count:3 | yes Evaluation Count:27 |
| 3-27 |
429 | if (textCopy != m_text || cursorCopy != m_cursor) partially evaluated: textCopy != m_text yes Evaluation Count:3 | no Evaluation Count:0 |
never evaluated: cursorCopy != m_cursor | 0-3 |
430 | internalSetText(textCopy, cursorCopy); executed: internalSetText(textCopy, cursorCopy); Execution Count:3 | 3 |
431 | return true; executed: return true; Execution Count:3 | 3 |
432 | } | - |
433 | } executed: } Execution Count:27 | 27 |
434 | #endif | - |
435 | return false; executed: return false; Execution Count:102 | 102 |
436 | } | - |
437 | | - |
438 | /*! | - |
439 | \internal | - |
440 | | - |
441 | Moves the cursor to the given position \a pos. If \a mark is true will | - |
442 | adjust the currently selected text. | - |
443 | */ | - |
444 | void QWidgetLineControl::moveCursor(int pos, bool mark) | - |
445 | { | - |
446 | commitPreedit(); executed (the execution status of this line is deduced): commitPreedit(); | - |
447 | | - |
448 | if (pos != m_cursor) { evaluated: pos != m_cursor yes Evaluation Count:2518 | yes Evaluation Count:987 |
| 987-2518 |
449 | separate(); executed (the execution status of this line is deduced): separate(); | - |
450 | if (m_maskData) evaluated: m_maskData yes Evaluation Count:108 | yes Evaluation Count:2410 |
| 108-2410 |
451 | pos = pos > m_cursor ? nextMaskBlank(pos) : prevMaskBlank(pos); executed: pos = pos > m_cursor ? nextMaskBlank(pos) : prevMaskBlank(pos); Execution Count:108 evaluated: pos > m_cursor yes Evaluation Count:1 | yes Evaluation Count:107 |
| 1-108 |
452 | } executed: } Execution Count:2518 | 2518 |
453 | if (mark) { evaluated: mark yes Evaluation Count:453 | yes Evaluation Count:3052 |
| 453-3052 |
454 | int anchor; executed (the execution status of this line is deduced): int anchor; | - |
455 | if (m_selend > m_selstart && m_cursor == m_selstart) evaluated: m_selend > m_selstart yes Evaluation Count:31 | yes Evaluation Count:422 |
evaluated: m_cursor == m_selstart yes Evaluation Count:17 | yes Evaluation Count:14 |
| 14-422 |
456 | anchor = m_selend; executed: anchor = m_selend; Execution Count:17 | 17 |
457 | else if (m_selend > m_selstart && m_cursor == m_selend) evaluated: m_selend > m_selstart yes Evaluation Count:14 | yes Evaluation Count:422 |
partially evaluated: m_cursor == m_selend yes Evaluation Count:14 | no Evaluation Count:0 |
| 0-422 |
458 | anchor = m_selstart; executed: anchor = m_selstart; Execution Count:14 | 14 |
459 | else | - |
460 | anchor = m_cursor; executed: anchor = m_cursor; Execution Count:422 | 422 |
461 | m_selstart = qMin(anchor, pos); executed (the execution status of this line is deduced): m_selstart = qMin(anchor, pos); | - |
462 | m_selend = qMax(anchor, pos); executed (the execution status of this line is deduced): m_selend = qMax(anchor, pos); | - |
463 | updateDisplayText(); executed (the execution status of this line is deduced): updateDisplayText(); | - |
464 | } else { executed: } Execution Count:453 | 453 |
465 | internalDeselect(); executed (the execution status of this line is deduced): internalDeselect(); | - |
466 | } executed: } Execution Count:3052 | 3052 |
467 | m_cursor = pos; executed (the execution status of this line is deduced): m_cursor = pos; | - |
468 | if (mark || m_selDirty) { evaluated: mark yes Evaluation Count:453 | yes Evaluation Count:3052 |
evaluated: m_selDirty yes Evaluation Count:66 | yes Evaluation Count:2986 |
| 66-3052 |
469 | m_selDirty = false; executed (the execution status of this line is deduced): m_selDirty = false; | - |
470 | emit selectionChanged(); executed (the execution status of this line is deduced): selectionChanged(); | - |
471 | } executed: } Execution Count:519 | 519 |
472 | emitCursorPositionChanged(); executed (the execution status of this line is deduced): emitCursorPositionChanged(); | - |
473 | } executed: } Execution Count:3505 | 3505 |
474 | | - |
475 | /*! | - |
476 | \internal | - |
477 | | - |
478 | Applies the given input method event \a event to the text of the line | - |
479 | control | - |
480 | */ | - |
481 | void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event) | - |
482 | { | - |
483 | int priorState = -1; executed (the execution status of this line is deduced): int priorState = -1; | - |
484 | bool isGettingInput = !event->commitString().isEmpty() evaluated: !event->commitString().isEmpty() yes Evaluation Count:25 | yes Evaluation Count:41 |
| 25-41 |
485 | || event->preeditString() != preeditAreaText() evaluated: event->preeditString() != preeditAreaText() yes Evaluation Count:1 | yes Evaluation Count:40 |
| 1-40 |
486 | || event->replacementLength() > 0; partially evaluated: event->replacementLength() > 0 no Evaluation Count:0 | yes Evaluation Count:40 |
| 0-40 |
487 | bool cursorPositionChanged = false; executed (the execution status of this line is deduced): bool cursorPositionChanged = false; | - |
488 | bool selectionChange = false; executed (the execution status of this line is deduced): bool selectionChange = false; | - |
489 | | - |
490 | if (isGettingInput) { evaluated: isGettingInput yes Evaluation Count:26 | yes Evaluation Count:40 |
| 26-40 |
491 | // If any text is being input, remove selected text. | - |
492 | priorState = m_undoState; executed (the execution status of this line is deduced): priorState = m_undoState; | - |
493 | if (echoMode() == QLineEdit::PasswordEchoOnEdit && !passwordEchoEditing()) { partially evaluated: echoMode() == QLineEdit::PasswordEchoOnEdit no Evaluation Count:0 | yes Evaluation Count:26 |
never evaluated: !passwordEchoEditing() | 0-26 |
494 | updatePasswordEchoEditing(true); never executed (the execution status of this line is deduced): updatePasswordEchoEditing(true); | - |
495 | m_selstart = 0; never executed (the execution status of this line is deduced): m_selstart = 0; | - |
496 | m_selend = m_text.length(); never executed (the execution status of this line is deduced): m_selend = m_text.length(); | - |
497 | } | 0 |
498 | removeSelectedText(); executed (the execution status of this line is deduced): removeSelectedText(); | - |
499 | } executed: } Execution Count:26 | 26 |
500 | | - |
501 | int c = m_cursor; // cursor position after insertion of commit string executed (the execution status of this line is deduced): int c = m_cursor; | - |
502 | if (event->replacementStart() <= 0) partially evaluated: event->replacementStart() <= 0 yes Evaluation Count:66 | no Evaluation Count:0 |
| 0-66 |
503 | c += event->commitString().length() - qMin(-event->replacementStart(), event->replacementLength()); executed: c += event->commitString().length() - qMin(-event->replacementStart(), event->replacementLength()); Execution Count:66 | 66 |
504 | | - |
505 | m_cursor += event->replacementStart(); executed (the execution status of this line is deduced): m_cursor += event->replacementStart(); | - |
506 | if (m_cursor < 0) partially evaluated: m_cursor < 0 no Evaluation Count:0 | yes Evaluation Count:66 |
| 0-66 |
507 | m_cursor = 0; never executed: m_cursor = 0; | 0 |
508 | | - |
509 | // insert commit string | - |
510 | if (event->replacementLength()) { evaluated: event->replacementLength() yes Evaluation Count:9 | yes Evaluation Count:57 |
| 9-57 |
511 | m_selstart = m_cursor; executed (the execution status of this line is deduced): m_selstart = m_cursor; | - |
512 | m_selend = m_selstart + event->replacementLength(); executed (the execution status of this line is deduced): m_selend = m_selstart + event->replacementLength(); | - |
513 | removeSelectedText(); executed (the execution status of this line is deduced): removeSelectedText(); | - |
514 | } executed: } Execution Count:9 | 9 |
515 | if (!event->commitString().isEmpty()) { evaluated: !event->commitString().isEmpty() yes Evaluation Count:25 | yes Evaluation Count:41 |
| 25-41 |
516 | internalInsert(event->commitString()); executed (the execution status of this line is deduced): internalInsert(event->commitString()); | - |
517 | cursorPositionChanged = true; executed (the execution status of this line is deduced): cursorPositionChanged = true; | - |
518 | } executed: } Execution Count:25 | 25 |
519 | | - |
520 | m_cursor = qBound(0, c, m_text.length()); executed (the execution status of this line is deduced): m_cursor = qBound(0, c, m_text.length()); | - |
521 | | - |
522 | for (int i = 0; i < event->attributes().size(); ++i) { evaluated: i < event->attributes().size() yes Evaluation Count:2 | yes Evaluation Count:66 |
| 2-66 |
523 | const QInputMethodEvent::Attribute &a = event->attributes().at(i); executed (the execution status of this line is deduced): const QInputMethodEvent::Attribute &a = event->attributes().at(i); | - |
524 | if (a.type == QInputMethodEvent::Selection) { partially evaluated: a.type == QInputMethodEvent::Selection yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
525 | m_cursor = qBound(0, a.start + a.length, m_text.length()); executed (the execution status of this line is deduced): m_cursor = qBound(0, a.start + a.length, m_text.length()); | - |
526 | if (a.length) { evaluated: a.length yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
527 | m_selstart = qMax(0, qMin(a.start, m_text.length())); executed (the execution status of this line is deduced): m_selstart = qMax(0, qMin(a.start, m_text.length())); | - |
528 | m_selend = m_cursor; executed (the execution status of this line is deduced): m_selend = m_cursor; | - |
529 | if (m_selend < m_selstart) { partially evaluated: m_selend < m_selstart no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
530 | qSwap(m_selstart, m_selend); never executed (the execution status of this line is deduced): qSwap(m_selstart, m_selend); | - |
531 | } | 0 |
532 | selectionChange = true; executed (the execution status of this line is deduced): selectionChange = true; | - |
533 | } else { executed: } Execution Count:1 | 1 |
534 | if (m_selstart != m_selend) partially evaluated: m_selstart != m_selend yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
535 | selectionChange = true; executed: selectionChange = true; Execution Count:1 | 1 |
536 | m_selstart = m_selend = 0; executed (the execution status of this line is deduced): m_selstart = m_selend = 0; | - |
537 | } executed: } Execution Count:1 | 1 |
538 | cursorPositionChanged = true; executed (the execution status of this line is deduced): cursorPositionChanged = true; | - |
539 | } executed: } Execution Count:2 | 2 |
540 | } executed: } Execution Count:2 | 2 |
541 | #ifndef QT_NO_IM | - |
542 | setPreeditArea(m_cursor, event->preeditString()); executed (the execution status of this line is deduced): setPreeditArea(m_cursor, event->preeditString()); | - |
543 | #endif //QT_NO_IM | - |
544 | const int oldPreeditCursor = m_preeditCursor; executed (the execution status of this line is deduced): const int oldPreeditCursor = m_preeditCursor; | - |
545 | m_preeditCursor = event->preeditString().length(); executed (the execution status of this line is deduced): m_preeditCursor = event->preeditString().length(); | - |
546 | m_hideCursor = false; executed (the execution status of this line is deduced): m_hideCursor = false; | - |
547 | QList<QTextLayout::FormatRange> formats; executed (the execution status of this line is deduced): QList<QTextLayout::FormatRange> formats; | - |
548 | for (int i = 0; i < event->attributes().size(); ++i) { evaluated: i < event->attributes().size() yes Evaluation Count:2 | yes Evaluation Count:66 |
| 2-66 |
549 | const QInputMethodEvent::Attribute &a = event->attributes().at(i); executed (the execution status of this line is deduced): const QInputMethodEvent::Attribute &a = event->attributes().at(i); | - |
550 | if (a.type == QInputMethodEvent::Cursor) { partially evaluated: a.type == QInputMethodEvent::Cursor no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
551 | m_preeditCursor = a.start; never executed (the execution status of this line is deduced): m_preeditCursor = a.start; | - |
552 | m_hideCursor = !a.length; never executed (the execution status of this line is deduced): m_hideCursor = !a.length; | - |
553 | } else if (a.type == QInputMethodEvent::TextFormat) { never executed: } partially evaluated: a.type == QInputMethodEvent::TextFormat no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
554 | QTextCharFormat f = qvariant_cast<QTextFormat>(a.value).toCharFormat(); never executed (the execution status of this line is deduced): QTextCharFormat f = qvariant_cast<QTextFormat>(a.value).toCharFormat(); | - |
555 | if (f.isValid()) { never evaluated: f.isValid() | 0 |
556 | QTextLayout::FormatRange o; never executed (the execution status of this line is deduced): QTextLayout::FormatRange o; | - |
557 | o.start = a.start + m_cursor; never executed (the execution status of this line is deduced): o.start = a.start + m_cursor; | - |
558 | o.length = a.length; never executed (the execution status of this line is deduced): o.length = a.length; | - |
559 | o.format = f; never executed (the execution status of this line is deduced): o.format = f; | - |
560 | formats.append(o); never executed (the execution status of this line is deduced): formats.append(o); | - |
561 | } | 0 |
562 | } | 0 |
563 | } | - |
564 | m_textLayout.setAdditionalFormats(formats); executed (the execution status of this line is deduced): m_textLayout.setAdditionalFormats(formats); | - |
565 | updateDisplayText(/*force*/ true); executed (the execution status of this line is deduced): updateDisplayText( true); | - |
566 | if (cursorPositionChanged) evaluated: cursorPositionChanged yes Evaluation Count:27 | yes Evaluation Count:39 |
| 27-39 |
567 | emitCursorPositionChanged(); executed: emitCursorPositionChanged(); Execution Count:27 | 27 |
568 | else if (m_preeditCursor != oldPreeditCursor) evaluated: m_preeditCursor != oldPreeditCursor yes Evaluation Count:1 | yes Evaluation Count:38 |
| 1-38 |
569 | emit updateMicroFocus(); executed: updateMicroFocus(); Execution Count:1 | 1 |
570 | | - |
571 | if (isGettingInput) evaluated: isGettingInput yes Evaluation Count:26 | yes Evaluation Count:40 |
| 26-40 |
572 | finishChange(priorState); executed: finishChange(priorState); Execution Count:26 | 26 |
573 | | - |
574 | if (selectionChange) evaluated: selectionChange yes Evaluation Count:2 | yes Evaluation Count:64 |
| 2-64 |
575 | emit selectionChanged(); executed: selectionChanged(); Execution Count:2 | 2 |
576 | } executed: } Execution Count:66 | 66 |
577 | | - |
578 | /*! | - |
579 | \internal | - |
580 | | - |
581 | Draws the display text for the line control using the given | - |
582 | \a painter, \a clip, and \a offset. Which aspects of the display text | - |
583 | are drawn is specified by the given \a flags. | - |
584 | | - |
585 | If the flags contain DrawSelections, then the selection or input mask | - |
586 | backgrounds and foregrounds will be applied before drawing the text. | - |
587 | | - |
588 | If the flags contain DrawCursor a cursor of the current cursorWidth() | - |
589 | will be drawn after drawing the text. | - |
590 | | - |
591 | The display text will only be drawn if the flags contain DrawText | - |
592 | */ | - |
593 | void QWidgetLineControl::draw(QPainter *painter, const QPoint &offset, const QRect &clip, int flags) | - |
594 | { | - |
595 | QVector<QTextLayout::FormatRange> selections; executed (the execution status of this line is deduced): QVector<QTextLayout::FormatRange> selections; | - |
596 | if (flags & DrawSelections) { evaluated: flags & DrawSelections yes Evaluation Count:51 | yes Evaluation Count:711 |
| 51-711 |
597 | QTextLayout::FormatRange o; executed (the execution status of this line is deduced): QTextLayout::FormatRange o; | - |
598 | if (m_selstart < m_selend) { partially evaluated: m_selstart < m_selend yes Evaluation Count:51 | no Evaluation Count:0 |
| 0-51 |
599 | o.start = m_selstart; executed (the execution status of this line is deduced): o.start = m_selstart; | - |
600 | o.length = m_selend - m_selstart; executed (the execution status of this line is deduced): o.length = m_selend - m_selstart; | - |
601 | o.format.setBackground(m_palette.brush(QPalette::Highlight)); executed (the execution status of this line is deduced): o.format.setBackground(m_palette.brush(QPalette::Highlight)); | - |
602 | o.format.setForeground(m_palette.brush(QPalette::HighlightedText)); executed (the execution status of this line is deduced): o.format.setForeground(m_palette.brush(QPalette::HighlightedText)); | - |
603 | } else { executed: } Execution Count:51 | 51 |
604 | // mask selection | - |
605 | if(!m_blinkPeriod || m_blinkStatus){ never evaluated: !m_blinkPeriod never evaluated: m_blinkStatus | 0 |
606 | o.start = m_cursor; never executed (the execution status of this line is deduced): o.start = m_cursor; | - |
607 | o.length = 1; never executed (the execution status of this line is deduced): o.length = 1; | - |
608 | o.format.setBackground(m_palette.brush(QPalette::Text)); never executed (the execution status of this line is deduced): o.format.setBackground(m_palette.brush(QPalette::Text)); | - |
609 | o.format.setForeground(m_palette.brush(QPalette::Window)); never executed (the execution status of this line is deduced): o.format.setForeground(m_palette.brush(QPalette::Window)); | - |
610 | } | 0 |
611 | } | 0 |
612 | selections.append(o); executed (the execution status of this line is deduced): selections.append(o); | - |
613 | } executed: } Execution Count:51 | 51 |
614 | | - |
615 | if (flags & DrawText) partially evaluated: flags & DrawText yes Evaluation Count:762 | no Evaluation Count:0 |
| 0-762 |
616 | textLayout()->draw(painter, offset, selections, clip); executed: textLayout()->draw(painter, offset, selections, clip); Execution Count:762 | 762 |
617 | | - |
618 | if (flags & DrawCursor){ evaluated: flags & DrawCursor yes Evaluation Count:386 | yes Evaluation Count:376 |
| 376-386 |
619 | int cursor = m_cursor; executed (the execution status of this line is deduced): int cursor = m_cursor; | - |
620 | if (m_preeditCursor != -1) partially evaluated: m_preeditCursor != -1 yes Evaluation Count:386 | no Evaluation Count:0 |
| 0-386 |
621 | cursor += m_preeditCursor; executed: cursor += m_preeditCursor; Execution Count:386 | 386 |
622 | if (!m_hideCursor && (!m_blinkPeriod || m_blinkStatus)) partially evaluated: !m_hideCursor yes Evaluation Count:386 | no Evaluation Count:0 |
evaluated: !m_blinkPeriod yes Evaluation Count:12 | yes Evaluation Count:374 |
evaluated: m_blinkStatus yes Evaluation Count:337 | yes Evaluation Count:37 |
| 0-386 |
623 | textLayout()->drawCursor(painter, offset, cursor, m_cursorWidth); executed: textLayout()->drawCursor(painter, offset, cursor, m_cursorWidth); Execution Count:349 | 349 |
624 | } executed: } Execution Count:386 | 386 |
625 | } executed: } Execution Count:762 | 762 |
626 | | - |
627 | /*! | - |
628 | \internal | - |
629 | | - |
630 | Sets the selection to cover the word at the given cursor position. | - |
631 | The word boundaries are defined by the behavior of QTextLayout::SkipWords | - |
632 | cursor mode. | - |
633 | */ | - |
634 | void QWidgetLineControl::selectWordAtPos(int cursor) | - |
635 | { | - |
636 | int next = cursor + 1; executed (the execution status of this line is deduced): int next = cursor + 1; | - |
637 | if(next > end()) evaluated: next > end() yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
638 | --next; executed: --next; Execution Count:1 | 1 |
639 | int c = textLayout()->previousCursorPosition(next, QTextLayout::SkipWords); executed (the execution status of this line is deduced): int c = textLayout()->previousCursorPosition(next, QTextLayout::SkipWords); | - |
640 | moveCursor(c, false); executed (the execution status of this line is deduced): moveCursor(c, false); | - |
641 | // ## text layout should support end of words. | - |
642 | int end = textLayout()->nextCursorPosition(c, QTextLayout::SkipWords); executed (the execution status of this line is deduced): int end = textLayout()->nextCursorPosition(c, QTextLayout::SkipWords); | - |
643 | while (end > cursor && m_text[end-1].isSpace()) evaluated: end > cursor yes Evaluation Count:1 | yes Evaluation Count:1 |
partially evaluated: m_text[end-1].isSpace() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
644 | --end; | 0 |
645 | moveCursor(end, true); executed (the execution status of this line is deduced): moveCursor(end, true); | - |
646 | } executed: } Execution Count:2 | 2 |
647 | | - |
648 | /*! | - |
649 | \internal | - |
650 | | - |
651 | Completes a change to the line control text. If the change is not valid | - |
652 | will undo the line control state back to the given \a validateFromState. | - |
653 | | - |
654 | If \a edited is true and the change is valid, will emit textEdited() in | - |
655 | addition to textChanged(). Otherwise only emits textChanged() on a valid | - |
656 | change. | - |
657 | | - |
658 | The \a update value is currently unused. | - |
659 | */ | - |
660 | bool QWidgetLineControl::finishChange(int validateFromState, bool update, bool edited) | - |
661 | { | - |
662 | Q_UNUSED(update) executed (the execution status of this line is deduced): (void)update; | - |
663 | | - |
664 | if (m_textDirty) { evaluated: m_textDirty yes Evaluation Count:6438 | yes Evaluation Count:2194 |
| 2194-6438 |
665 | // do validation | - |
666 | bool wasValidInput = m_validInput; executed (the execution status of this line is deduced): bool wasValidInput = m_validInput; | - |
667 | m_validInput = true; executed (the execution status of this line is deduced): m_validInput = true; | - |
668 | #ifndef QT_NO_VALIDATOR | - |
669 | if (m_validator) { evaluated: m_validator yes Evaluation Count:4333 | yes Evaluation Count:2105 |
| 2105-4333 |
670 | QString textCopy = m_text; executed (the execution status of this line is deduced): QString textCopy = m_text; | - |
671 | int cursorCopy = m_cursor; executed (the execution status of this line is deduced): int cursorCopy = m_cursor; | - |
672 | m_validInput = (m_validator->validate(textCopy, cursorCopy) != QValidator::Invalid); executed (the execution status of this line is deduced): m_validInput = (m_validator->validate(textCopy, cursorCopy) != QValidator::Invalid); | - |
673 | if (m_validInput) { evaluated: m_validInput yes Evaluation Count:4071 | yes Evaluation Count:262 |
| 262-4071 |
674 | if (m_text != textCopy) { evaluated: m_text != textCopy yes Evaluation Count:17 | yes Evaluation Count:4054 |
| 17-4054 |
675 | internalSetText(textCopy, cursorCopy); executed (the execution status of this line is deduced): internalSetText(textCopy, cursorCopy); | - |
676 | return true; executed: return true; Execution Count:17 | 17 |
677 | } | - |
678 | m_cursor = cursorCopy; executed (the execution status of this line is deduced): m_cursor = cursorCopy; | - |
679 | } executed: } Execution Count:4054 | 4054 |
680 | } executed: } Execution Count:4316 | 4316 |
681 | #endif | - |
682 | if (validateFromState >= 0 && wasValidInput && !m_validInput) { evaluated: validateFromState >= 0 yes Evaluation Count:2012 | yes Evaluation Count:4409 |
evaluated: wasValidInput yes Evaluation Count:2009 | yes Evaluation Count:3 |
evaluated: !m_validInput yes Evaluation Count:253 | yes Evaluation Count:1756 |
| 3-4409 |
683 | if (m_transactions.count()) partially evaluated: m_transactions.count() no Evaluation Count:0 | yes Evaluation Count:253 |
| 0-253 |
684 | return false; never executed: return false; | 0 |
685 | internalUndo(validateFromState); executed (the execution status of this line is deduced): internalUndo(validateFromState); | - |
686 | m_history.resize(m_undoState); executed (the execution status of this line is deduced): m_history.resize(m_undoState); | - |
687 | if (m_modifiedState > m_undoState) partially evaluated: m_modifiedState > m_undoState no Evaluation Count:0 | yes Evaluation Count:253 |
| 0-253 |
688 | m_modifiedState = -1; never executed: m_modifiedState = -1; | 0 |
689 | m_validInput = true; executed (the execution status of this line is deduced): m_validInput = true; | - |
690 | m_textDirty = false; executed (the execution status of this line is deduced): m_textDirty = false; | - |
691 | } executed: } Execution Count:253 | 253 |
692 | updateDisplayText(); executed (the execution status of this line is deduced): updateDisplayText(); | - |
693 | | - |
694 | if (m_textDirty) { evaluated: m_textDirty yes Evaluation Count:6168 | yes Evaluation Count:253 |
| 253-6168 |
695 | m_textDirty = false; executed (the execution status of this line is deduced): m_textDirty = false; | - |
696 | QString actualText = text(); executed (the execution status of this line is deduced): QString actualText = text(); | - |
697 | if (edited) evaluated: edited yes Evaluation Count:1822 | yes Evaluation Count:4346 |
| 1822-4346 |
698 | emit textEdited(actualText); executed: textEdited(actualText); Execution Count:1822 | 1822 |
699 | emit textChanged(actualText); executed (the execution status of this line is deduced): textChanged(actualText); | - |
700 | } executed: } Execution Count:6168 | 6168 |
701 | } executed: } Execution Count:6421 | 6421 |
702 | if (m_selDirty) { evaluated: m_selDirty yes Evaluation Count:2648 | yes Evaluation Count:5967 |
| 2648-5967 |
703 | m_selDirty = false; executed (the execution status of this line is deduced): m_selDirty = false; | - |
704 | emit selectionChanged(); executed (the execution status of this line is deduced): selectionChanged(); | - |
705 | } executed: } Execution Count:2648 | 2648 |
706 | if (m_cursor == m_lastCursorPos) evaluated: m_cursor == m_lastCursorPos yes Evaluation Count:2503 | yes Evaluation Count:6112 |
| 2503-6112 |
707 | updateMicroFocus(); executed: updateMicroFocus(); Execution Count:2503 | 2503 |
708 | emitCursorPositionChanged(); executed (the execution status of this line is deduced): emitCursorPositionChanged(); | - |
709 | return true; executed: return true; Execution Count:8615 | 8615 |
710 | } | - |
711 | | - |
712 | /*! | - |
713 | \internal | - |
714 | | - |
715 | An internal function for setting the text of the line control. | - |
716 | */ | - |
717 | void QWidgetLineControl::internalSetText(const QString &txt, int pos, bool edited) | - |
718 | { | - |
719 | cancelPasswordEchoTimer(); executed (the execution status of this line is deduced): cancelPasswordEchoTimer(); | - |
720 | internalDeselect(); executed (the execution status of this line is deduced): internalDeselect(); | - |
721 | emit resetInputContext(); executed (the execution status of this line is deduced): resetInputContext(); | - |
722 | QString oldText = m_text; executed (the execution status of this line is deduced): QString oldText = m_text; | - |
723 | if (m_maskData) { evaluated: m_maskData yes Evaluation Count:414 | yes Evaluation Count:5515 |
| 414-5515 |
724 | m_text = maskString(0, txt, true); executed (the execution status of this line is deduced): m_text = maskString(0, txt, true); | - |
725 | m_text += clearString(m_text.length(), m_maxLength - m_text.length()); executed (the execution status of this line is deduced): m_text += clearString(m_text.length(), m_maxLength - m_text.length()); | - |
726 | } else { executed: } Execution Count:414 | 414 |
727 | m_text = txt.isEmpty() ? txt : txt.left(m_maxLength); evaluated: txt.isEmpty() yes Evaluation Count:789 | yes Evaluation Count:4726 |
| 789-4726 |
728 | } executed: } Execution Count:5515 | 5515 |
729 | m_history.clear(); executed (the execution status of this line is deduced): m_history.clear(); | - |
730 | m_modifiedState = m_undoState = 0; executed (the execution status of this line is deduced): m_modifiedState = m_undoState = 0; | - |
731 | m_cursor = (pos < 0 || pos > m_text.length()) ? m_text.length() : pos; evaluated: pos < 0 yes Evaluation Count:5909 | yes Evaluation Count:20 |
partially evaluated: pos > m_text.length() no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-5909 |
732 | m_textDirty = (oldText != m_text); executed (the execution status of this line is deduced): m_textDirty = (oldText != m_text); | - |
733 | const bool changed = finishChange(-1, true, edited); executed (the execution status of this line is deduced): const bool changed = finishChange(-1, true, edited); | - |
734 | | - |
735 | #ifndef QT_NO_ACCESSIBILITY | - |
736 | if (changed) { partially evaluated: changed yes Evaluation Count:5929 | no Evaluation Count:0 |
| 0-5929 |
737 | if (oldText.isEmpty()) { evaluated: oldText.isEmpty() yes Evaluation Count:1554 | yes Evaluation Count:4375 |
| 1554-4375 |
738 | QAccessibleTextInsertEvent event(parent(), 0, txt); executed (the execution status of this line is deduced): QAccessibleTextInsertEvent event(parent(), 0, txt); | - |
739 | event.setCursorPosition(m_cursor); executed (the execution status of this line is deduced): event.setCursorPosition(m_cursor); | - |
740 | QAccessible::updateAccessibility(&event); executed (the execution status of this line is deduced): QAccessible::updateAccessibility(&event); | - |
741 | } else if (txt.isEmpty()) { executed: } Execution Count:1554 evaluated: txt.isEmpty() yes Evaluation Count:197 | yes Evaluation Count:4178 |
| 197-4178 |
742 | QAccessibleTextRemoveEvent event(parent(), 0, oldText); executed (the execution status of this line is deduced): QAccessibleTextRemoveEvent event(parent(), 0, oldText); | - |
743 | event.setCursorPosition(m_cursor); executed (the execution status of this line is deduced): event.setCursorPosition(m_cursor); | - |
744 | QAccessible::updateAccessibility(&event); executed (the execution status of this line is deduced): QAccessible::updateAccessibility(&event); | - |
745 | } else { executed: } Execution Count:197 | 197 |
746 | QAccessibleTextUpdateEvent event(parent(), 0, oldText, txt); executed (the execution status of this line is deduced): QAccessibleTextUpdateEvent event(parent(), 0, oldText, txt); | - |
747 | event.setCursorPosition(m_cursor); executed (the execution status of this line is deduced): event.setCursorPosition(m_cursor); | - |
748 | QAccessible::updateAccessibility(&event); executed (the execution status of this line is deduced): QAccessible::updateAccessibility(&event); | - |
749 | } executed: } Execution Count:4178 | 4178 |
750 | } | - |
751 | #else | - |
752 | Q_UNUSED(changed) | - |
753 | #endif | - |
754 | } executed: } Execution Count:5929 | 5929 |
755 | | - |
756 | | - |
757 | /*! | - |
758 | \internal | - |
759 | | - |
760 | Adds the given \a command to the undo history | - |
761 | of the line control. Does not apply the command. | - |
762 | */ | - |
763 | void QWidgetLineControl::addCommand(const Command &cmd) | - |
764 | { | - |
765 | if (m_separator && m_undoState && m_history[m_undoState - 1].type != Separator) { evaluated: m_separator yes Evaluation Count:906 | yes Evaluation Count:7858 |
evaluated: m_undoState yes Evaluation Count:470 | yes Evaluation Count:436 |
evaluated: m_history[m_undoState - 1].type != Separator yes Evaluation Count:466 | yes Evaluation Count:4 |
| 4-7858 |
766 | m_history.resize(m_undoState + 2); executed (the execution status of this line is deduced): m_history.resize(m_undoState + 2); | - |
767 | m_history[m_undoState++] = Command(Separator, m_cursor, 0, m_selstart, m_selend); executed (the execution status of this line is deduced): m_history[m_undoState++] = Command(Separator, m_cursor, 0, m_selstart, m_selend); | - |
768 | } else { executed: } Execution Count:466 | 466 |
769 | m_history.resize(m_undoState + 1); executed (the execution status of this line is deduced): m_history.resize(m_undoState + 1); | - |
770 | } executed: } Execution Count:8298 | 8298 |
771 | m_separator = false; executed (the execution status of this line is deduced): m_separator = false; | - |
772 | m_history[m_undoState++] = cmd; executed (the execution status of this line is deduced): m_history[m_undoState++] = cmd; | - |
773 | } executed: } Execution Count:8764 | 8764 |
774 | | - |
775 | /*! | - |
776 | \internal | - |
777 | | - |
778 | Inserts the given string \a s into the line | - |
779 | control. | - |
780 | | - |
781 | Also adds the appropriate commands into the undo history. | - |
782 | This function does not call finishChange(), and may leave the text | - |
783 | in an invalid state. | - |
784 | */ | - |
785 | void QWidgetLineControl::internalInsert(const QString &s) | - |
786 | { | - |
787 | if (m_echoMode == QLineEdit::Password) { evaluated: m_echoMode == QLineEdit::Password yes Evaluation Count:3 | yes Evaluation Count:1686 |
| 3-1686 |
788 | if (m_passwordEchoTimer != 0) partially evaluated: m_passwordEchoTimer != 0 no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
789 | killTimer(m_passwordEchoTimer); never executed: killTimer(m_passwordEchoTimer); | 0 |
790 | int delay = qGuiApp->styleHints()->passwordMaskDelay(); executed (the execution status of this line is deduced): int delay = (static_cast<QGuiApplication *>(QCoreApplication::instance()))->styleHints()->passwordMaskDelay(); | - |
791 | #ifdef QT_BUILD_INTERNAL | - |
792 | if (m_passwordMaskDelayOverride >= 0) | - |
793 | delay = m_passwordMaskDelayOverride; | - |
794 | #endif | - |
795 | | - |
796 | if (delay > 0) partially evaluated: delay > 0 no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
797 | m_passwordEchoTimer = startTimer(delay); never executed: m_passwordEchoTimer = startTimer(delay); | 0 |
798 | } executed: } Execution Count:3 | 3 |
799 | if (hasSelectedText()) evaluated: hasSelectedText() yes Evaluation Count:3 | yes Evaluation Count:1686 |
| 3-1686 |
800 | addCommand(Command(SetSelection, m_cursor, 0, m_selstart, m_selend)); executed: addCommand(Command(SetSelection, m_cursor, 0, m_selstart, m_selend)); Execution Count:3 | 3 |
801 | if (m_maskData) { evaluated: m_maskData yes Evaluation Count:260 | yes Evaluation Count:1429 |
| 260-1429 |
802 | QString ms = maskString(m_cursor, s); executed (the execution status of this line is deduced): QString ms = maskString(m_cursor, s); | - |
803 | #ifndef QT_NO_ACCESSIBILITY | - |
804 | QAccessibleTextInsertEvent insertEvent(parent(), m_cursor, ms); executed (the execution status of this line is deduced): QAccessibleTextInsertEvent insertEvent(parent(), m_cursor, ms); | - |
805 | QAccessible::updateAccessibility(&insertEvent); executed (the execution status of this line is deduced): QAccessible::updateAccessibility(&insertEvent); | - |
806 | #endif | - |
807 | for (int i = 0; i < (int) ms.length(); ++i) { evaluated: i < (int) ms.length() yes Evaluation Count:451 | yes Evaluation Count:260 |
| 260-451 |
808 | addCommand (Command(DeleteSelection, m_cursor + i, m_text.at(m_cursor + i), -1, -1)); executed (the execution status of this line is deduced): addCommand (Command(DeleteSelection, m_cursor + i, m_text.at(m_cursor + i), -1, -1)); | - |
809 | addCommand(Command(Insert, m_cursor + i, ms.at(i), -1, -1)); executed (the execution status of this line is deduced): addCommand(Command(Insert, m_cursor + i, ms.at(i), -1, -1)); | - |
810 | } executed: } Execution Count:451 | 451 |
811 | m_text.replace(m_cursor, ms.length(), ms); executed (the execution status of this line is deduced): m_text.replace(m_cursor, ms.length(), ms); | - |
812 | m_cursor += ms.length(); executed (the execution status of this line is deduced): m_cursor += ms.length(); | - |
813 | m_cursor = nextMaskBlank(m_cursor); executed (the execution status of this line is deduced): m_cursor = nextMaskBlank(m_cursor); | - |
814 | m_textDirty = true; executed (the execution status of this line is deduced): m_textDirty = true; | - |
815 | #ifndef QT_NO_ACCESSIBILITY | - |
816 | QAccessibleTextCursorEvent event(parent(), m_cursor); executed (the execution status of this line is deduced): QAccessibleTextCursorEvent event(parent(), m_cursor); | - |
817 | QAccessible::updateAccessibility(&event); executed (the execution status of this line is deduced): QAccessible::updateAccessibility(&event); | - |
818 | #endif | - |
819 | } else { executed: } Execution Count:260 | 260 |
820 | int remaining = m_maxLength - m_text.length(); executed (the execution status of this line is deduced): int remaining = m_maxLength - m_text.length(); | - |
821 | if (remaining != 0) { evaluated: remaining != 0 yes Evaluation Count:1417 | yes Evaluation Count:12 |
| 12-1417 |
822 | #ifndef QT_NO_ACCESSIBILITY | - |
823 | QAccessibleTextInsertEvent insertEvent(parent(), m_cursor, s); executed (the execution status of this line is deduced): QAccessibleTextInsertEvent insertEvent(parent(), m_cursor, s); | - |
824 | QAccessible::updateAccessibility(&insertEvent); executed (the execution status of this line is deduced): QAccessible::updateAccessibility(&insertEvent); | - |
825 | #endif | - |
826 | m_text.insert(m_cursor, s.left(remaining)); executed (the execution status of this line is deduced): m_text.insert(m_cursor, s.left(remaining)); | - |
827 | for (int i = 0; i < (int) s.left(remaining).length(); ++i) evaluated: i < (int) s.left(remaining).length() yes Evaluation Count:1683 | yes Evaluation Count:1417 |
| 1417-1683 |
828 | addCommand(Command(Insert, m_cursor++, s.at(i), -1, -1)); executed: addCommand(Command(Insert, m_cursor++, s.at(i), -1, -1)); Execution Count:1683 | 1683 |
829 | m_textDirty = true; executed (the execution status of this line is deduced): m_textDirty = true; | - |
830 | } executed: } Execution Count:1417 | 1417 |
831 | } executed: } Execution Count:1429 | 1429 |
832 | } | - |
833 | | - |
834 | /*! | - |
835 | \internal | - |
836 | | - |
837 | deletes a single character from the current text. If \a wasBackspace, | - |
838 | the character prior to the cursor is removed. Otherwise the character | - |
839 | after the cursor is removed. | - |
840 | | - |
841 | Also adds the appropriate commands into the undo history. | - |
842 | This function does not call finishChange(), and may leave the text | - |
843 | in an invalid state. | - |
844 | */ | - |
845 | void QWidgetLineControl::internalDelete(bool wasBackspace) | - |
846 | { | - |
847 | if (m_cursor < (int) m_text.length()) { partially evaluated: m_cursor < (int) m_text.length() yes Evaluation Count:88 | no Evaluation Count:0 |
| 0-88 |
848 | cancelPasswordEchoTimer(); executed (the execution status of this line is deduced): cancelPasswordEchoTimer(); | - |
849 | if (hasSelectedText()) partially evaluated: hasSelectedText() no Evaluation Count:0 | yes Evaluation Count:88 |
| 0-88 |
850 | addCommand(Command(SetSelection, m_cursor, 0, m_selstart, m_selend)); never executed: addCommand(Command(SetSelection, m_cursor, 0, m_selstart, m_selend)); | 0 |
851 | addCommand(Command((CommandType)((m_maskData ? 2 : 0) + (wasBackspace ? Remove : Delete)), executed (the execution status of this line is deduced): addCommand(Command((CommandType)((m_maskData ? 2 : 0) + (wasBackspace ? Remove : Delete)), | - |
852 | m_cursor, m_text.at(m_cursor), -1, -1)); executed (the execution status of this line is deduced): m_cursor, m_text.at(m_cursor), -1, -1)); | - |
853 | #ifndef QT_NO_ACCESSIBILITY | - |
854 | QAccessibleTextRemoveEvent event(parent(), m_cursor, m_text.at(m_cursor)); executed (the execution status of this line is deduced): QAccessibleTextRemoveEvent event(parent(), m_cursor, m_text.at(m_cursor)); | - |
855 | QAccessible::updateAccessibility(&event); executed (the execution status of this line is deduced): QAccessible::updateAccessibility(&event); | - |
856 | #endif | - |
857 | if (m_maskData) { evaluated: m_maskData yes Evaluation Count:3 | yes Evaluation Count:85 |
| 3-85 |
858 | m_text.replace(m_cursor, 1, clearString(m_cursor, 1)); executed (the execution status of this line is deduced): m_text.replace(m_cursor, 1, clearString(m_cursor, 1)); | - |
859 | addCommand(Command(Insert, m_cursor, m_text.at(m_cursor), -1, -1)); executed (the execution status of this line is deduced): addCommand(Command(Insert, m_cursor, m_text.at(m_cursor), -1, -1)); | - |
860 | } else { executed: } Execution Count:3 | 3 |
861 | m_text.remove(m_cursor, 1); executed (the execution status of this line is deduced): m_text.remove(m_cursor, 1); | - |
862 | } executed: } Execution Count:85 | 85 |
863 | m_textDirty = true; executed (the execution status of this line is deduced): m_textDirty = true; | - |
864 | } executed: } Execution Count:88 | 88 |
865 | } executed: } Execution Count:88 | 88 |
866 | | - |
867 | /*! | - |
868 | \internal | - |
869 | | - |
870 | removes the currently selected text from the line control. | - |
871 | | - |
872 | Also adds the appropriate commands into the undo history. | - |
873 | This function does not call finishChange(), and may leave the text | - |
874 | in an invalid state. | - |
875 | */ | - |
876 | void QWidgetLineControl::removeSelectedText() | - |
877 | { | - |
878 | if (m_selstart < m_selend && m_selend <= (int) m_text.length()) { evaluated: m_selstart < m_selend yes Evaluation Count:636 | yes Evaluation Count:1457 |
evaluated: m_selend <= (int) m_text.length() yes Evaluation Count:630 | yes Evaluation Count:6 |
| 6-1457 |
879 | cancelPasswordEchoTimer(); executed (the execution status of this line is deduced): cancelPasswordEchoTimer(); | - |
880 | separate(); executed (the execution status of this line is deduced): separate(); | - |
881 | int i ; executed (the execution status of this line is deduced): int i ; | - |
882 | addCommand(Command(SetSelection, m_cursor, 0, m_selstart, m_selend)); executed (the execution status of this line is deduced): addCommand(Command(SetSelection, m_cursor, 0, m_selstart, m_selend)); | - |
883 | if (m_selstart <= m_cursor && m_cursor < m_selend) { partially evaluated: m_selstart <= m_cursor yes Evaluation Count:630 | no Evaluation Count:0 |
evaluated: m_cursor < m_selend yes Evaluation Count:380 | yes Evaluation Count:250 |
| 0-630 |
884 | // cursor is within the selection. Split up the commands | - |
885 | // to be able to restore the correct cursor position | - |
886 | for (i = m_cursor; i >= m_selstart; --i) evaluated: i >= m_selstart yes Evaluation Count:628 | yes Evaluation Count:380 |
| 380-628 |
887 | addCommand (Command(DeleteSelection, i, m_text.at(i), -1, 1)); executed: addCommand (Command(DeleteSelection, i, m_text.at(i), -1, 1)); Execution Count:628 | 628 |
888 | for (i = m_selend - 1; i > m_cursor; --i) evaluated: i > m_cursor yes Evaluation Count:1017 | yes Evaluation Count:380 |
| 380-1017 |
889 | addCommand (Command(DeleteSelection, i - m_cursor + m_selstart - 1, m_text.at(i), -1, -1)); executed: addCommand (Command(DeleteSelection, i - m_cursor + m_selstart - 1, m_text.at(i), -1, -1)); Execution Count:1017 | 1017 |
890 | } else { executed: } Execution Count:380 | 380 |
891 | for (i = m_selend-1; i >= m_selstart; --i) evaluated: i >= m_selstart yes Evaluation Count:3087 | yes Evaluation Count:250 |
| 250-3087 |
892 | addCommand (Command(RemoveSelection, i, m_text.at(i), -1, -1)); executed: addCommand (Command(RemoveSelection, i, m_text.at(i), -1, -1)); Execution Count:3087 | 3087 |
893 | } executed: } Execution Count:250 | 250 |
894 | #ifndef QT_NO_ACCESSIBILITY | - |
895 | QAccessibleTextRemoveEvent event(parent(), m_selstart, m_text.mid(m_selstart, m_selend - m_selstart)); executed (the execution status of this line is deduced): QAccessibleTextRemoveEvent event(parent(), m_selstart, m_text.mid(m_selstart, m_selend - m_selstart)); | - |
896 | QAccessible::updateAccessibility(&event); executed (the execution status of this line is deduced): QAccessible::updateAccessibility(&event); | - |
897 | #endif | - |
898 | if (m_maskData) { evaluated: m_maskData yes Evaluation Count:95 | yes Evaluation Count:535 |
| 95-535 |
899 | m_text.replace(m_selstart, m_selend - m_selstart, clearString(m_selstart, m_selend - m_selstart)); executed (the execution status of this line is deduced): m_text.replace(m_selstart, m_selend - m_selstart, clearString(m_selstart, m_selend - m_selstart)); | - |
900 | for (int i = 0; i < m_selend - m_selstart; ++i) evaluated: i < m_selend - m_selstart yes Evaluation Count:723 | yes Evaluation Count:95 |
| 95-723 |
901 | addCommand(Command(Insert, m_selstart + i, m_text.at(m_selstart + i), -1, -1)); executed: addCommand(Command(Insert, m_selstart + i, m_text.at(m_selstart + i), -1, -1)); Execution Count:723 | 723 |
902 | } else { executed: } Execution Count:95 | 95 |
903 | m_text.remove(m_selstart, m_selend - m_selstart); executed (the execution status of this line is deduced): m_text.remove(m_selstart, m_selend - m_selstart); | - |
904 | } executed: } Execution Count:535 | 535 |
905 | if (m_cursor > m_selstart) evaluated: m_cursor > m_selstart yes Evaluation Count:289 | yes Evaluation Count:341 |
| 289-341 |
906 | m_cursor -= qMin(m_cursor, m_selend) - m_selstart; executed: m_cursor -= qMin(m_cursor, m_selend) - m_selstart; Execution Count:289 | 289 |
907 | internalDeselect(); executed (the execution status of this line is deduced): internalDeselect(); | - |
908 | m_textDirty = true; executed (the execution status of this line is deduced): m_textDirty = true; | - |
909 | } executed: } Execution Count:630 | 630 |
910 | } executed: } Execution Count:2093 | 2093 |
911 | | - |
912 | /*! | - |
913 | \internal | - |
914 | | - |
915 | Parses the input mask specified by \a maskFields to generate | - |
916 | the mask data used to handle input masks. | - |
917 | */ | - |
918 | void QWidgetLineControl::parseInputMask(const QString &maskFields) | - |
919 | { | - |
920 | int delimiter = maskFields.indexOf(QLatin1Char(';')); executed (the execution status of this line is deduced): int delimiter = maskFields.indexOf(QLatin1Char(';')); | - |
921 | if (maskFields.isEmpty() || delimiter == 0) { evaluated: maskFields.isEmpty() yes Evaluation Count:332 | yes Evaluation Count:104 |
partially evaluated: delimiter == 0 no Evaluation Count:0 | yes Evaluation Count:104 |
| 0-332 |
922 | if (m_maskData) { evaluated: m_maskData yes Evaluation Count:95 | yes Evaluation Count:237 |
| 95-237 |
923 | delete [] m_maskData; executed (the execution status of this line is deduced): delete [] m_maskData; | - |
924 | m_maskData = 0; executed (the execution status of this line is deduced): m_maskData = 0; | - |
925 | m_maxLength = 32767; executed (the execution status of this line is deduced): m_maxLength = 32767; | - |
926 | internalSetText(QString()); executed (the execution status of this line is deduced): internalSetText(QString()); | - |
927 | } executed: } Execution Count:95 | 95 |
928 | return; executed: return; Execution Count:332 | 332 |
929 | } | - |
930 | | - |
931 | if (delimiter == -1) { evaluated: delimiter == -1 yes Evaluation Count:80 | yes Evaluation Count:24 |
| 24-80 |
932 | m_blank = QLatin1Char(' '); executed (the execution status of this line is deduced): m_blank = QLatin1Char(' '); | - |
933 | m_inputMask = maskFields; executed (the execution status of this line is deduced): m_inputMask = maskFields; | - |
934 | } else { executed: } Execution Count:80 | 80 |
935 | m_inputMask = maskFields.left(delimiter); executed (the execution status of this line is deduced): m_inputMask = maskFields.left(delimiter); | - |
936 | m_blank = (delimiter + 1 < maskFields.length()) ? maskFields[delimiter + 1] : QLatin1Char(' '); evaluated: (delimiter + 1 < maskFields.length()) yes Evaluation Count:22 | yes Evaluation Count:2 |
| 2-22 |
937 | } executed: } Execution Count:24 | 24 |
938 | | - |
939 | // calculate m_maxLength / m_maskData length | - |
940 | m_maxLength = 0; executed (the execution status of this line is deduced): m_maxLength = 0; | - |
941 | QChar c = 0; executed (the execution status of this line is deduced): QChar c = 0; | - |
942 | for (int i=0; i<m_inputMask.length(); i++) { evaluated: i<m_inputMask.length() yes Evaluation Count:928 | yes Evaluation Count:104 |
| 104-928 |
943 | c = m_inputMask.at(i); executed (the execution status of this line is deduced): c = m_inputMask.at(i); | - |
944 | if (i > 0 && m_inputMask.at(i-1) == QLatin1Char('\\')) { evaluated: i > 0 yes Evaluation Count:824 | yes Evaluation Count:104 |
evaluated: m_inputMask.at(i-1) == QLatin1Char('\\') yes Evaluation Count:14 | yes Evaluation Count:810 |
| 14-824 |
945 | m_maxLength++; executed (the execution status of this line is deduced): m_maxLength++; | - |
946 | continue; executed: continue; Execution Count:14 | 14 |
947 | } | - |
948 | if (c != QLatin1Char('\\') && c != QLatin1Char('!') && evaluated: c != QLatin1Char('\\') yes Evaluation Count:902 | yes Evaluation Count:12 |
evaluated: c != QLatin1Char('!') yes Evaluation Count:862 | yes Evaluation Count:40 |
| 12-902 |
949 | c != QLatin1Char('<') && c != QLatin1Char('>') && evaluated: c != QLatin1Char('<') yes Evaluation Count:815 | yes Evaluation Count:47 |
evaluated: c != QLatin1Char('>') yes Evaluation Count:767 | yes Evaluation Count:48 |
| 47-815 |
950 | c != QLatin1Char('{') && c != QLatin1Char('}') && evaluated: c != QLatin1Char('{') yes Evaluation Count:765 | yes Evaluation Count:2 |
evaluated: c != QLatin1Char('}') yes Evaluation Count:763 | yes Evaluation Count:2 |
| 2-765 |
951 | c != QLatin1Char('[') && c != QLatin1Char(']')) evaluated: c != QLatin1Char('[') yes Evaluation Count:761 | yes Evaluation Count:2 |
evaluated: c != QLatin1Char(']') yes Evaluation Count:759 | yes Evaluation Count:2 |
| 2-761 |
952 | m_maxLength++; executed: m_maxLength++; Execution Count:759 | 759 |
953 | } executed: } Execution Count:914 | 914 |
954 | | - |
955 | delete [] m_maskData; executed (the execution status of this line is deduced): delete [] m_maskData; | - |
956 | m_maskData = new MaskInputData[m_maxLength]; executed (the execution status of this line is deduced): m_maskData = new MaskInputData[m_maxLength]; | - |
957 | | - |
958 | MaskInputData::Casemode m = MaskInputData::NoCaseMode; executed (the execution status of this line is deduced): MaskInputData::Casemode m = MaskInputData::NoCaseMode; | - |
959 | c = 0; executed (the execution status of this line is deduced): c = 0; | - |
960 | bool s; executed (the execution status of this line is deduced): bool s; | - |
961 | bool escape = false; executed (the execution status of this line is deduced): bool escape = false; | - |
962 | int index = 0; executed (the execution status of this line is deduced): int index = 0; | - |
963 | for (int i = 0; i < m_inputMask.length(); i++) { evaluated: i < m_inputMask.length() yes Evaluation Count:928 | yes Evaluation Count:104 |
| 104-928 |
964 | c = m_inputMask.at(i); executed (the execution status of this line is deduced): c = m_inputMask.at(i); | - |
965 | if (escape) { evaluated: escape yes Evaluation Count:12 | yes Evaluation Count:916 |
| 12-916 |
966 | s = true; executed (the execution status of this line is deduced): s = true; | - |
967 | m_maskData[index].maskChar = c; executed (the execution status of this line is deduced): m_maskData[index].maskChar = c; | - |
968 | m_maskData[index].separator = s; executed (the execution status of this line is deduced): m_maskData[index].separator = s; | - |
969 | m_maskData[index].caseMode = m; executed (the execution status of this line is deduced): m_maskData[index].caseMode = m; | - |
970 | index++; executed (the execution status of this line is deduced): index++; | - |
971 | escape = false; executed (the execution status of this line is deduced): escape = false; | - |
972 | } else if (c == QLatin1Char('<')) { executed: } Execution Count:12 evaluated: c == QLatin1Char('<') yes Evaluation Count:47 | yes Evaluation Count:869 |
| 12-869 |
973 | m = MaskInputData::Lower; executed (the execution status of this line is deduced): m = MaskInputData::Lower; | - |
974 | } else if (c == QLatin1Char('>')) { executed: } Execution Count:47 evaluated: c == QLatin1Char('>') yes Evaluation Count:48 | yes Evaluation Count:821 |
| 47-821 |
975 | m = MaskInputData::Upper; executed (the execution status of this line is deduced): m = MaskInputData::Upper; | - |
976 | } else if (c == QLatin1Char('!')) { executed: } Execution Count:48 evaluated: c == QLatin1Char('!') yes Evaluation Count:40 | yes Evaluation Count:781 |
| 40-781 |
977 | m = MaskInputData::NoCaseMode; executed (the execution status of this line is deduced): m = MaskInputData::NoCaseMode; | - |
978 | } else if (c != QLatin1Char('{') && c != QLatin1Char('}') && c != QLatin1Char('[') && c != QLatin1Char(']')) { executed: } Execution Count:40 evaluated: c != QLatin1Char('{') yes Evaluation Count:779 | yes Evaluation Count:2 |
evaluated: c != QLatin1Char('}') yes Evaluation Count:777 | yes Evaluation Count:2 |
evaluated: c != QLatin1Char('[') yes Evaluation Count:775 | yes Evaluation Count:2 |
evaluated: c != QLatin1Char(']') yes Evaluation Count:773 | yes Evaluation Count:2 |
| 2-779 |
979 | switch (c.unicode()) { | - |
980 | case 'A': | - |
981 | case 'a': | - |
982 | case 'N': | - |
983 | case 'n': | - |
984 | case 'X': | - |
985 | case 'x': | - |
986 | case '9': | - |
987 | case '0': | - |
988 | case 'D': | - |
989 | case 'd': | - |
990 | case '#': | - |
991 | case 'H': | - |
992 | case 'h': | - |
993 | case 'B': | - |
994 | case 'b': | - |
995 | s = false; executed (the execution status of this line is deduced): s = false; | - |
996 | break; executed: break; Execution Count:656 | 656 |
997 | case '\\': | - |
998 | escape = true; executed (the execution status of this line is deduced): escape = true; | - |
999 | default: code before this statement executed: default: Execution Count:12 | 12 |
1000 | s = true; executed (the execution status of this line is deduced): s = true; | - |
1001 | break; executed: break; Execution Count:117 | 117 |
1002 | } | - |
1003 | | - |
1004 | if (!escape) { evaluated: !escape yes Evaluation Count:761 | yes Evaluation Count:12 |
| 12-761 |
1005 | m_maskData[index].maskChar = c; executed (the execution status of this line is deduced): m_maskData[index].maskChar = c; | - |
1006 | m_maskData[index].separator = s; executed (the execution status of this line is deduced): m_maskData[index].separator = s; | - |
1007 | m_maskData[index].caseMode = m; executed (the execution status of this line is deduced): m_maskData[index].caseMode = m; | - |
1008 | index++; executed (the execution status of this line is deduced): index++; | - |
1009 | } executed: } Execution Count:761 | 761 |
1010 | } executed: } Execution Count:773 | 773 |
1011 | } | - |
1012 | internalSetText(m_text); executed (the execution status of this line is deduced): internalSetText(m_text); | - |
1013 | } executed: } Execution Count:104 | 104 |
1014 | | - |
1015 | | - |
1016 | /*! | - |
1017 | \internal | - |
1018 | | - |
1019 | checks if the key is valid compared to the inputMask | - |
1020 | */ | - |
1021 | bool QWidgetLineControl::isValidInput(QChar key, QChar mask) const | - |
1022 | { | - |
1023 | switch (mask.unicode()) { | - |
1024 | case 'A': | - |
1025 | if (key.isLetter()) evaluated: key.isLetter() yes Evaluation Count:132 | yes Evaluation Count:119 |
| 119-132 |
1026 | return true; executed: return true; Execution Count:132 | 132 |
1027 | break; executed: break; Execution Count:119 | 119 |
1028 | case 'a': | - |
1029 | if (key.isLetter() || key == m_blank) evaluated: key.isLetter() yes Evaluation Count:64 | yes Evaluation Count:4 |
partially evaluated: key == m_blank yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-64 |
1030 | return true; executed: return true; Execution Count:68 | 68 |
1031 | break; | 0 |
1032 | case 'N': | - |
1033 | if (key.isLetterOrNumber()) evaluated: key.isLetterOrNumber() yes Evaluation Count:18 | yes Evaluation Count:7 |
| 7-18 |
1034 | return true; executed: return true; Execution Count:18 | 18 |
1035 | break; executed: break; Execution Count:7 | 7 |
1036 | case 'n': | - |
1037 | if (key.isLetterOrNumber() || key == m_blank) evaluated: key.isLetterOrNumber() yes Evaluation Count:8 | yes Evaluation Count:4 |
partially evaluated: key == m_blank yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-8 |
1038 | return true; executed: return true; Execution Count:12 | 12 |
1039 | break; | 0 |
1040 | case 'X': | - |
1041 | if (key.isPrint()) partially evaluated: key.isPrint() yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-12 |
1042 | return true; executed: return true; Execution Count:12 | 12 |
1043 | break; | 0 |
1044 | case 'x': | - |
1045 | if (key.isPrint() || key == m_blank) partially evaluated: key.isPrint() yes Evaluation Count:10 | no Evaluation Count:0 |
never evaluated: key == m_blank | 0-10 |
1046 | return true; executed: return true; Execution Count:10 | 10 |
1047 | break; | 0 |
1048 | case '9': | - |
1049 | if (key.isNumber()) evaluated: key.isNumber() yes Evaluation Count:55 | yes Evaluation Count:11 |
| 11-55 |
1050 | return true; executed: return true; Execution Count:55 | 55 |
1051 | break; executed: break; Execution Count:11 | 11 |
1052 | case '0': | - |
1053 | if (key.isNumber() || key == m_blank) evaluated: key.isNumber() yes Evaluation Count:82 | yes Evaluation Count:73 |
evaluated: key == m_blank yes Evaluation Count:6 | yes Evaluation Count:67 |
| 6-82 |
1054 | return true; executed: return true; Execution Count:88 | 88 |
1055 | break; executed: break; Execution Count:67 | 67 |
1056 | case 'D': | - |
1057 | if (key.isNumber() && key.digitValue() > 0) evaluated: key.isNumber() yes Evaluation Count:20 | yes Evaluation Count:7 |
evaluated: key.digitValue() > 0 yes Evaluation Count:18 | yes Evaluation Count:2 |
| 2-20 |
1058 | return true; executed: return true; Execution Count:18 | 18 |
1059 | break; executed: break; Execution Count:9 | 9 |
1060 | case 'd': | - |
1061 | if ((key.isNumber() && key.digitValue() > 0) || key == m_blank) evaluated: key.isNumber() yes Evaluation Count:6 | yes Evaluation Count:4 |
partially evaluated: key.digitValue() > 0 yes Evaluation Count:6 | no Evaluation Count:0 |
partially evaluated: key == m_blank yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-6 |
1062 | return true; executed: return true; Execution Count:10 | 10 |
1063 | break; | 0 |
1064 | case '#': | - |
1065 | if (key.isNumber() || key == QLatin1Char('+') || key == QLatin1Char('-') || key == m_blank) never evaluated: key.isNumber() never evaluated: key == QLatin1Char('+') never evaluated: key == QLatin1Char('-') never evaluated: key == m_blank | 0 |
1066 | return true; never executed: return true; | 0 |
1067 | break; | 0 |
1068 | case 'B': | - |
1069 | if (key == QLatin1Char('0') || key == QLatin1Char('1')) evaluated: key == QLatin1Char('0') yes Evaluation Count:9 | yes Evaluation Count:117 |
evaluated: key == QLatin1Char('1') yes Evaluation Count:13 | yes Evaluation Count:104 |
| 9-117 |
1070 | return true; executed: return true; Execution Count:22 | 22 |
1071 | break; executed: break; Execution Count:104 | 104 |
1072 | case 'b': | - |
1073 | if (key == QLatin1Char('0') || key == QLatin1Char('1') || key == m_blank) evaluated: key == QLatin1Char('0') yes Evaluation Count:11 | yes Evaluation Count:157 |
evaluated: key == QLatin1Char('1') yes Evaluation Count:9 | yes Evaluation Count:148 |
evaluated: key == m_blank yes Evaluation Count:68 | yes Evaluation Count:80 |
| 9-157 |
1074 | return true; executed: return true; Execution Count:88 | 88 |
1075 | break; executed: break; Execution Count:80 | 80 |
1076 | case 'H': | - |
1077 | if (key.isNumber() || (key >= QLatin1Char('a') && key <= QLatin1Char('f')) || (key >= QLatin1Char('A') && key <= QLatin1Char('F'))) evaluated: key.isNumber() yes Evaluation Count:66 | yes Evaluation Count:191 |
evaluated: key >= QLatin1Char('a') yes Evaluation Count:68 | yes Evaluation Count:123 |
evaluated: key <= QLatin1Char('f') yes Evaluation Count:28 | yes Evaluation Count:40 |
evaluated: key >= QLatin1Char('A') yes Evaluation Count:116 | yes Evaluation Count:47 |
evaluated: key <= QLatin1Char('F') yes Evaluation Count:36 | yes Evaluation Count:80 |
| 28-191 |
1078 | return true; executed: return true; Execution Count:130 | 130 |
1079 | break; executed: break; Execution Count:127 | 127 |
1080 | case 'h': | - |
1081 | if (key.isNumber() || (key >= QLatin1Char('a') && key <= QLatin1Char('f')) || (key >= QLatin1Char('A') && key <= QLatin1Char('F')) || key == m_blank) evaluated: key.isNumber() yes Evaluation Count:34 | yes Evaluation Count:208 |
evaluated: key >= QLatin1Char('a') yes Evaluation Count:66 | yes Evaluation Count:142 |
evaluated: key <= QLatin1Char('f') yes Evaluation Count:26 | yes Evaluation Count:40 |
evaluated: key >= QLatin1Char('A') yes Evaluation Count:102 | yes Evaluation Count:80 |
evaluated: key <= QLatin1Char('F') yes Evaluation Count:22 | yes Evaluation Count:80 |
evaluated: key == m_blank yes Evaluation Count:80 | yes Evaluation Count:80 |
| 22-208 |
1082 | return true; executed: return true; Execution Count:162 | 162 |
1083 | break; executed: break; Execution Count:80 | 80 |
1084 | default: | - |
1085 | break; | 0 |
1086 | } | - |
1087 | return false; executed: return false; Execution Count:604 | 604 |
1088 | } | - |
1089 | | - |
1090 | /*! | - |
1091 | \internal | - |
1092 | | - |
1093 | Returns true if the given text \a str is valid for any | - |
1094 | validator or input mask set for the line control. | - |
1095 | | - |
1096 | Otherwise returns false | - |
1097 | */ | - |
1098 | bool QWidgetLineControl::hasAcceptableInput(const QString &str) const | - |
1099 | { | - |
1100 | #ifndef QT_NO_VALIDATOR | - |
1101 | QString textCopy = str; executed (the execution status of this line is deduced): QString textCopy = str; | - |
1102 | int cursorCopy = m_cursor; executed (the execution status of this line is deduced): int cursorCopy = m_cursor; | - |
1103 | if (m_validator && m_validator->validate(textCopy, cursorCopy) evaluated: m_validator yes Evaluation Count:1615 | yes Evaluation Count:739 |
evaluated: m_validator->validate(textCopy, cursorCopy) != QValidator::Acceptable yes Evaluation Count:642 | yes Evaluation Count:973 |
| 642-1615 |
1104 | != QValidator::Acceptable) evaluated: m_validator->validate(textCopy, cursorCopy) != QValidator::Acceptable yes Evaluation Count:642 | yes Evaluation Count:973 |
| 642-973 |
1105 | return false; executed: return false; Execution Count:642 | 642 |
1106 | #endif | - |
1107 | | - |
1108 | if (!m_maskData) evaluated: !m_maskData yes Evaluation Count:1366 | yes Evaluation Count:346 |
| 346-1366 |
1109 | return true; executed: return true; Execution Count:1366 | 1366 |
1110 | | - |
1111 | if (str.length() != m_maxLength) partially evaluated: str.length() != m_maxLength no Evaluation Count:0 | yes Evaluation Count:346 |
| 0-346 |
1112 | return false; never executed: return false; | 0 |
1113 | | - |
1114 | for (int i=0; i < m_maxLength; ++i) { evaluated: i < m_maxLength yes Evaluation Count:421 | yes Evaluation Count:267 |
| 267-421 |
1115 | if (m_maskData[i].separator) { partially evaluated: m_maskData[i].separator no Evaluation Count:0 | yes Evaluation Count:421 |
| 0-421 |
1116 | if (str.at(i) != m_maskData[i].maskChar) never evaluated: str.at(i) != m_maskData[i].maskChar | 0 |
1117 | return false; never executed: return false; | 0 |
1118 | } else { | 0 |
1119 | if (!isValidInput(str.at(i), m_maskData[i].maskChar)) evaluated: !isValidInput(str.at(i), m_maskData[i].maskChar) yes Evaluation Count:79 | yes Evaluation Count:342 |
| 79-342 |
1120 | return false; executed: return false; Execution Count:79 | 79 |
1121 | } executed: } Execution Count:342 | 342 |
1122 | } | - |
1123 | return true; executed: return true; Execution Count:267 | 267 |
1124 | } | - |
1125 | | - |
1126 | /*! | - |
1127 | \internal | - |
1128 | | - |
1129 | Applies the inputMask on \a str starting from position \a pos in the mask. \a clear | - |
1130 | specifies from where characters should be gotten when a separator is met in \a str - true means | - |
1131 | that blanks will be used, false that previous input is used. | - |
1132 | Calling this when no inputMask is set is undefined. | - |
1133 | */ | - |
1134 | QString QWidgetLineControl::maskString(uint pos, const QString &str, bool clear) const | - |
1135 | { | - |
1136 | if (pos >= (uint)m_maxLength) evaluated: pos >= (uint)m_maxLength yes Evaluation Count:5 | yes Evaluation Count:669 |
| 5-669 |
1137 | return QString::fromLatin1(""); executed: return QString::fromLatin1(""); Execution Count:5 | 5 |
1138 | | - |
1139 | QString fill; executed (the execution status of this line is deduced): QString fill; | - |
1140 | fill = clear ? clearString(0, m_maxLength) : m_text; evaluated: clear yes Evaluation Count:414 | yes Evaluation Count:255 |
| 255-414 |
1141 | | - |
1142 | int strIndex = 0; executed (the execution status of this line is deduced): int strIndex = 0; | - |
1143 | QString s = QString::fromLatin1(""); executed (the execution status of this line is deduced): QString s = QString::fromLatin1(""); | - |
1144 | int i = pos; executed (the execution status of this line is deduced): int i = pos; | - |
1145 | while (i < m_maxLength) { evaluated: i < m_maxLength yes Evaluation Count:1278 | yes Evaluation Count:103 |
| 103-1278 |
1146 | if (strIndex < str.length()) { evaluated: strIndex < str.length() yes Evaluation Count:712 | yes Evaluation Count:566 |
| 566-712 |
1147 | if (m_maskData[i].separator) { evaluated: m_maskData[i].separator yes Evaluation Count:23 | yes Evaluation Count:689 |
| 23-689 |
1148 | s += m_maskData[i].maskChar; executed (the execution status of this line is deduced): s += m_maskData[i].maskChar; | - |
1149 | if (str[(int)strIndex] == m_maskData[i].maskChar) evaluated: str[(int)strIndex] == m_maskData[i].maskChar yes Evaluation Count:7 | yes Evaluation Count:16 |
| 7-16 |
1150 | strIndex++; executed: strIndex++; Execution Count:7 | 7 |
1151 | ++i; executed (the execution status of this line is deduced): ++i; | - |
1152 | } else { executed: } Execution Count:23 | 23 |
1153 | if (isValidInput(str[(int)strIndex], m_maskData[i].maskChar)) { evaluated: isValidInput(str[(int)strIndex], m_maskData[i].maskChar) yes Evaluation Count:478 | yes Evaluation Count:211 |
| 211-478 |
1154 | switch (m_maskData[i].caseMode) { | - |
1155 | case MaskInputData::Upper: | - |
1156 | s += str[(int)strIndex].toUpper(); executed (the execution status of this line is deduced): s += str[(int)strIndex].toUpper(); | - |
1157 | break; executed: break; Execution Count:65 | 65 |
1158 | case MaskInputData::Lower: | - |
1159 | s += str[(int)strIndex].toLower(); executed (the execution status of this line is deduced): s += str[(int)strIndex].toLower(); | - |
1160 | break; executed: break; Execution Count:64 | 64 |
1161 | default: | - |
1162 | s += str[(int)strIndex]; executed (the execution status of this line is deduced): s += str[(int)strIndex]; | - |
1163 | } executed: } Execution Count:349 | 349 |
1164 | ++i; executed (the execution status of this line is deduced): ++i; | - |
1165 | } else { executed: } Execution Count:478 | 478 |
1166 | // search for separator first | - |
1167 | int n = findInMask(i, true, true, str[(int)strIndex]); executed (the execution status of this line is deduced): int n = findInMask(i, true, true, str[(int)strIndex]); | - |
1168 | if (n != -1) { evaluated: n != -1 yes Evaluation Count:24 | yes Evaluation Count:187 |
| 24-187 |
1169 | if (str.length() != 1 || i == 0 || (i > 0 && (!m_maskData[i-1].separator || m_maskData[i-1].maskChar != str[(int)strIndex]))) { evaluated: str.length() != 1 yes Evaluation Count:8 | yes Evaluation Count:16 |
evaluated: i == 0 yes Evaluation Count:1 | yes Evaluation Count:15 |
partially evaluated: i > 0 yes Evaluation Count:15 | no Evaluation Count:0 |
evaluated: !m_maskData[i-1].separator yes Evaluation Count:9 | yes Evaluation Count:6 |
partially evaluated: m_maskData[i-1].maskChar != str[(int)strIndex] no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-16 |
1170 | s += fill.mid(i, n-i+1); executed (the execution status of this line is deduced): s += fill.mid(i, n-i+1); | - |
1171 | i = n + 1; // update i to find + 1 executed (the execution status of this line is deduced): i = n + 1; | - |
1172 | } executed: } Execution Count:18 | 18 |
1173 | } else { executed: } Execution Count:24 | 24 |
1174 | // search for valid m_blank if not | - |
1175 | n = findInMask(i, true, false, str[(int)strIndex]); executed (the execution status of this line is deduced): n = findInMask(i, true, false, str[(int)strIndex]); | - |
1176 | if (n != -1) { evaluated: n != -1 yes Evaluation Count:5 | yes Evaluation Count:182 |
| 5-182 |
1177 | s += fill.mid(i, n-i); executed (the execution status of this line is deduced): s += fill.mid(i, n-i); | - |
1178 | switch (m_maskData[n].caseMode) { | - |
1179 | case MaskInputData::Upper: | - |
1180 | s += str[(int)strIndex].toUpper(); executed (the execution status of this line is deduced): s += str[(int)strIndex].toUpper(); | - |
1181 | break; executed: break; Execution Count:1 | 1 |
1182 | case MaskInputData::Lower: | - |
1183 | s += str[(int)strIndex].toLower(); never executed (the execution status of this line is deduced): s += str[(int)strIndex].toLower(); | - |
1184 | break; | 0 |
1185 | default: | - |
1186 | s += str[(int)strIndex]; executed (the execution status of this line is deduced): s += str[(int)strIndex]; | - |
1187 | } executed: } Execution Count:4 | 4 |
1188 | i = n + 1; // updates i to find + 1 executed (the execution status of this line is deduced): i = n + 1; | - |
1189 | } executed: } Execution Count:5 | 5 |
1190 | } executed: } Execution Count:187 | 187 |
1191 | } | - |
1192 | ++strIndex; executed (the execution status of this line is deduced): ++strIndex; | - |
1193 | } executed: } Execution Count:689 | 689 |
1194 | } else | - |
1195 | break; executed: break; Execution Count:566 | 566 |
1196 | } | - |
1197 | | - |
1198 | return s; executed: return s; Execution Count:669 | 669 |
1199 | } | - |
1200 | | - |
1201 | | - |
1202 | | - |
1203 | /*! | - |
1204 | \internal | - |
1205 | | - |
1206 | Returns a "cleared" string with only separators and blank chars. | - |
1207 | Calling this when no inputMask is set is undefined. | - |
1208 | */ | - |
1209 | QString QWidgetLineControl::clearString(uint pos, uint len) const | - |
1210 | { | - |
1211 | if (pos >= (uint)m_maxLength) evaluated: pos >= (uint)m_maxLength yes Evaluation Count:59 | yes Evaluation Count:867 |
| 59-867 |
1212 | return QString(); executed: return QString(); Execution Count:59 | 59 |
1213 | | - |
1214 | QString s; executed (the execution status of this line is deduced): QString s; | - |
1215 | int end = qMin((uint)m_maxLength, pos + len); executed (the execution status of this line is deduced): int end = qMin((uint)m_maxLength, pos + len); | - |
1216 | for (int i = pos; i < end; ++i) evaluated: i < end yes Evaluation Count:4159 | yes Evaluation Count:867 |
| 867-4159 |
1217 | if (m_maskData[i].separator) evaluated: m_maskData[i].separator yes Evaluation Count:560 | yes Evaluation Count:3599 |
| 560-3599 |
1218 | s += m_maskData[i].maskChar; executed: s += m_maskData[i].maskChar; Execution Count:560 | 560 |
1219 | else | - |
1220 | s += m_blank; executed: s += m_blank; Execution Count:3599 | 3599 |
1221 | | - |
1222 | return s; executed: return s; Execution Count:867 | 867 |
1223 | } | - |
1224 | | - |
1225 | /*! | - |
1226 | \internal | - |
1227 | | - |
1228 | Strips blank parts of the input in a QWidgetLineControl when an inputMask is set, | - |
1229 | separators are still included. Typically "127.0__.0__.1__" becomes "127.0.0.1". | - |
1230 | */ | - |
1231 | QString QWidgetLineControl::stripString(const QString &str) const | - |
1232 | { | - |
1233 | if (!m_maskData) partially evaluated: !m_maskData no Evaluation Count:0 | yes Evaluation Count:786 |
| 0-786 |
1234 | return str; never executed: return str; | 0 |
1235 | | - |
1236 | QString s; executed (the execution status of this line is deduced): QString s; | - |
1237 | int end = qMin(m_maxLength, (int)str.length()); executed (the execution status of this line is deduced): int end = qMin(m_maxLength, (int)str.length()); | - |
1238 | for (int i = 0; i < end; ++i) evaluated: i < end yes Evaluation Count:4974 | yes Evaluation Count:786 |
| 786-4974 |
1239 | if (m_maskData[i].separator) evaluated: m_maskData[i].separator yes Evaluation Count:657 | yes Evaluation Count:4317 |
| 657-4317 |
1240 | s += m_maskData[i].maskChar; executed: s += m_maskData[i].maskChar; Execution Count:657 | 657 |
1241 | else | - |
1242 | if (str[i] != m_blank) evaluated: str[i] != m_blank yes Evaluation Count:1621 | yes Evaluation Count:2696 |
| 1621-2696 |
1243 | s += str[i]; executed: s += str[i]; Execution Count:1621 | 1621 |
1244 | | - |
1245 | return s; executed: return s; Execution Count:786 | 786 |
1246 | } | - |
1247 | | - |
1248 | /*! | - |
1249 | \internal | - |
1250 | searches forward/backward in m_maskData for either a separator or a m_blank | - |
1251 | */ | - |
1252 | int QWidgetLineControl::findInMask(int pos, bool forward, bool findSeparator, QChar searchChar) const | - |
1253 | { | - |
1254 | if (pos >= m_maxLength || pos < 0) evaluated: pos >= m_maxLength yes Evaluation Count:49 | yes Evaluation Count:823 |
partially evaluated: pos < 0 no Evaluation Count:0 | yes Evaluation Count:823 |
| 0-823 |
1255 | return -1; executed: return -1; Execution Count:49 | 49 |
1256 | | - |
1257 | int end = forward ? m_maxLength : -1; evaluated: forward yes Evaluation Count:714 | yes Evaluation Count:109 |
| 109-714 |
1258 | int step = forward ? 1 : -1; evaluated: forward yes Evaluation Count:714 | yes Evaluation Count:109 |
| 109-714 |
1259 | int i = pos; executed (the execution status of this line is deduced): int i = pos; | - |
1260 | | - |
1261 | while (i != end) { evaluated: i != end yes Evaluation Count:1215 | yes Evaluation Count:372 |
| 372-1215 |
1262 | if (findSeparator) { evaluated: findSeparator yes Evaluation Count:428 | yes Evaluation Count:787 |
| 428-787 |
1263 | if (m_maskData[i].separator && m_maskData[i].maskChar == searchChar) evaluated: m_maskData[i].separator yes Evaluation Count:45 | yes Evaluation Count:383 |
evaluated: m_maskData[i].maskChar == searchChar yes Evaluation Count:24 | yes Evaluation Count:21 |
| 21-383 |
1264 | return i; executed: return i; Execution Count:24 | 24 |
1265 | } else { executed: } Execution Count:404 | 404 |
1266 | if (!m_maskData[i].separator) { evaluated: !m_maskData[i].separator yes Evaluation Count:741 | yes Evaluation Count:46 |
| 46-741 |
1267 | if (searchChar.isNull()) evaluated: searchChar.isNull() yes Evaluation Count:422 | yes Evaluation Count:319 |
| 319-422 |
1268 | return i; executed: return i; Execution Count:422 | 422 |
1269 | else if (isValidInput(searchChar, m_maskData[i].maskChar)) evaluated: isValidInput(searchChar, m_maskData[i].maskChar) yes Evaluation Count:5 | yes Evaluation Count:314 |
| 5-314 |
1270 | return i; executed: return i; Execution Count:5 | 5 |
1271 | } | - |
1272 | } executed: } Execution Count:360 | 360 |
1273 | i += step; executed (the execution status of this line is deduced): i += step; | - |
1274 | } executed: } Execution Count:764 | 764 |
1275 | return -1; executed: return -1; Execution Count:372 | 372 |
1276 | } | - |
1277 | | - |
1278 | void QWidgetLineControl::internalUndo(int until) | - |
1279 | { | - |
1280 | if (!isUndoAvailable()) evaluated: !isUndoAvailable() yes Evaluation Count:3 | yes Evaluation Count:312 |
| 3-312 |
1281 | return; executed: return; Execution Count:3 | 3 |
1282 | cancelPasswordEchoTimer(); executed (the execution status of this line is deduced): cancelPasswordEchoTimer(); | - |
1283 | internalDeselect(); executed (the execution status of this line is deduced): internalDeselect(); | - |
1284 | | - |
1285 | // Undo works only for clearing the line when in any of password the modes | - |
1286 | if (m_echoMode != QLineEdit::Normal) { evaluated: m_echoMode != QLineEdit::Normal yes Evaluation Count:3 | yes Evaluation Count:309 |
| 3-309 |
1287 | clear(); executed (the execution status of this line is deduced): clear(); | - |
1288 | return; executed: return; Execution Count:3 | 3 |
1289 | } | - |
1290 | | - |
1291 | while (m_undoState && m_undoState > until) { evaluated: m_undoState yes Evaluation Count:1391 | yes Evaluation Count:76 |
evaluated: m_undoState > until yes Evaluation Count:1195 | yes Evaluation Count:196 |
| 76-1391 |
1292 | Command& cmd = m_history[--m_undoState]; executed (the execution status of this line is deduced): Command& cmd = m_history[--m_undoState]; | - |
1293 | switch (cmd.type) { | - |
1294 | case Insert: | - |
1295 | m_text.remove(cmd.pos, 1); executed (the execution status of this line is deduced): m_text.remove(cmd.pos, 1); | - |
1296 | m_cursor = cmd.pos; executed (the execution status of this line is deduced): m_cursor = cmd.pos; | - |
1297 | break; executed: break; Execution Count:460 | 460 |
1298 | case SetSelection: | - |
1299 | m_selstart = cmd.selStart; executed (the execution status of this line is deduced): m_selstart = cmd.selStart; | - |
1300 | m_selend = cmd.selEnd; executed (the execution status of this line is deduced): m_selend = cmd.selEnd; | - |
1301 | m_cursor = cmd.pos; executed (the execution status of this line is deduced): m_cursor = cmd.pos; | - |
1302 | break; executed: break; Execution Count:160 | 160 |
1303 | case Remove: | - |
1304 | case RemoveSelection: | - |
1305 | m_text.insert(cmd.pos, cmd.uc); executed (the execution status of this line is deduced): m_text.insert(cmd.pos, cmd.uc); | - |
1306 | m_cursor = cmd.pos + 1; executed (the execution status of this line is deduced): m_cursor = cmd.pos + 1; | - |
1307 | break; executed: break; Execution Count:50 | 50 |
1308 | case Delete: | - |
1309 | case DeleteSelection: | - |
1310 | m_text.insert(cmd.pos, cmd.uc); executed (the execution status of this line is deduced): m_text.insert(cmd.pos, cmd.uc); | - |
1311 | m_cursor = cmd.pos; executed (the execution status of this line is deduced): m_cursor = cmd.pos; | - |
1312 | break; executed: break; Execution Count:354 | 354 |
1313 | case Separator: | - |
1314 | continue; executed: continue; Execution Count:171 | 171 |
1315 | } | - |
1316 | if (until < 0 && m_undoState) { evaluated: until < 0 yes Evaluation Count:273 | yes Evaluation Count:751 |
evaluated: m_undoState yes Evaluation Count:254 | yes Evaluation Count:19 |
| 19-751 |
1317 | Command& next = m_history[m_undoState-1]; executed (the execution status of this line is deduced): Command& next = m_history[m_undoState-1]; | - |
1318 | if (next.type != cmd.type && next.type < RemoveSelection evaluated: next.type != cmd.type yes Evaluation Count:61 | yes Evaluation Count:193 |
evaluated: next.type < RemoveSelection yes Evaluation Count:37 | yes Evaluation Count:24 |
| 24-193 |
1319 | && (cmd.type < RemoveSelection || next.type == Separator)) evaluated: cmd.type < RemoveSelection yes Evaluation Count:26 | yes Evaluation Count:11 |
partially evaluated: next.type == Separator yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-26 |
1320 | break; executed: break; Execution Count:37 | 37 |
1321 | } executed: } Execution Count:217 | 217 |
1322 | } executed: } Execution Count:987 | 987 |
1323 | m_textDirty = true; executed (the execution status of this line is deduced): m_textDirty = true; | - |
1324 | emitCursorPositionChanged(); executed (the execution status of this line is deduced): emitCursorPositionChanged(); | - |
1325 | } executed: } Execution Count:309 | 309 |
1326 | | - |
1327 | void QWidgetLineControl::internalRedo() | - |
1328 | { | - |
1329 | if (!isRedoAvailable()) evaluated: !isRedoAvailable() yes Evaluation Count:7 | yes Evaluation Count:9 |
| 7-9 |
1330 | return; executed: return; Execution Count:7 | 7 |
1331 | internalDeselect(); executed (the execution status of this line is deduced): internalDeselect(); | - |
1332 | while (m_undoState < (int)m_history.size()) { evaluated: m_undoState < (int)m_history.size() yes Evaluation Count:41 | yes Evaluation Count:6 |
| 6-41 |
1333 | Command& cmd = m_history[m_undoState++]; executed (the execution status of this line is deduced): Command& cmd = m_history[m_undoState++]; | - |
1334 | switch (cmd.type) { | - |
1335 | case Insert: | - |
1336 | m_text.insert(cmd.pos, cmd.uc); executed (the execution status of this line is deduced): m_text.insert(cmd.pos, cmd.uc); | - |
1337 | m_cursor = cmd.pos + 1; executed (the execution status of this line is deduced): m_cursor = cmd.pos + 1; | - |
1338 | break; executed: break; Execution Count:22 | 22 |
1339 | case SetSelection: | - |
1340 | m_selstart = cmd.selStart; executed (the execution status of this line is deduced): m_selstart = cmd.selStart; | - |
1341 | m_selend = cmd.selEnd; executed (the execution status of this line is deduced): m_selend = cmd.selEnd; | - |
1342 | m_cursor = cmd.pos; executed (the execution status of this line is deduced): m_cursor = cmd.pos; | - |
1343 | break; executed: break; Execution Count:5 | 5 |
1344 | case Remove: | - |
1345 | case Delete: | - |
1346 | case RemoveSelection: | - |
1347 | case DeleteSelection: | - |
1348 | m_text.remove(cmd.pos, 1); executed (the execution status of this line is deduced): m_text.remove(cmd.pos, 1); | - |
1349 | m_selstart = cmd.selStart; executed (the execution status of this line is deduced): m_selstart = cmd.selStart; | - |
1350 | m_selend = cmd.selEnd; executed (the execution status of this line is deduced): m_selend = cmd.selEnd; | - |
1351 | m_cursor = cmd.pos; executed (the execution status of this line is deduced): m_cursor = cmd.pos; | - |
1352 | break; executed: break; Execution Count:11 | 11 |
1353 | case Separator: | - |
1354 | m_selstart = cmd.selStart; executed (the execution status of this line is deduced): m_selstart = cmd.selStart; | - |
1355 | m_selend = cmd.selEnd; executed (the execution status of this line is deduced): m_selend = cmd.selEnd; | - |
1356 | m_cursor = cmd.pos; executed (the execution status of this line is deduced): m_cursor = cmd.pos; | - |
1357 | break; executed: break; Execution Count:3 | 3 |
1358 | } | - |
1359 | if (m_undoState < (int)m_history.size()) { evaluated: m_undoState < (int)m_history.size() yes Evaluation Count:35 | yes Evaluation Count:6 |
| 6-35 |
1360 | Command& next = m_history[m_undoState]; executed (the execution status of this line is deduced): Command& next = m_history[m_undoState]; | - |
1361 | if (next.type != cmd.type && cmd.type < RemoveSelection && next.type != Separator evaluated: next.type != cmd.type yes Evaluation Count:14 | yes Evaluation Count:21 |
evaluated: cmd.type < RemoveSelection yes Evaluation Count:6 | yes Evaluation Count:8 |
evaluated: next.type != Separator yes Evaluation Count:3 | yes Evaluation Count:3 |
| 3-21 |
1362 | && (next.type < RemoveSelection || cmd.type == Separator)) partially evaluated: next.type < RemoveSelection yes Evaluation Count:3 | no Evaluation Count:0 |
never evaluated: cmd.type == Separator | 0-3 |
1363 | break; executed: break; Execution Count:3 | 3 |
1364 | } executed: } Execution Count:32 | 32 |
1365 | } executed: } Execution Count:38 | 38 |
1366 | m_textDirty = true; executed (the execution status of this line is deduced): m_textDirty = true; | - |
1367 | emitCursorPositionChanged(); executed (the execution status of this line is deduced): emitCursorPositionChanged(); | - |
1368 | } executed: } Execution Count:9 | 9 |
1369 | | - |
1370 | /*! | - |
1371 | \internal | - |
1372 | | - |
1373 | If the current cursor position differs from the last emitted cursor | - |
1374 | position, emits cursorPositionChanged(). | - |
1375 | */ | - |
1376 | void QWidgetLineControl::emitCursorPositionChanged() | - |
1377 | { | - |
1378 | if (m_cursor != m_lastCursorPos) { evaluated: m_cursor != m_lastCursorPos yes Evaluation Count:11650 | yes Evaluation Count:4635 |
| 4635-11650 |
1379 | const int oldLast = m_lastCursorPos; executed (the execution status of this line is deduced): const int oldLast = m_lastCursorPos; | - |
1380 | m_lastCursorPos = m_cursor; executed (the execution status of this line is deduced): m_lastCursorPos = m_cursor; | - |
1381 | cursorPositionChanged(oldLast, m_cursor); executed (the execution status of this line is deduced): cursorPositionChanged(oldLast, m_cursor); | - |
1382 | #ifndef QT_NO_ACCESSIBILITY | - |
1383 | // otherwise we send a selection update which includes the cursor | - |
1384 | if (!hasSelectedText()) { evaluated: !hasSelectedText() yes Evaluation Count:8710 | yes Evaluation Count:2940 |
| 2940-8710 |
1385 | QAccessibleTextCursorEvent event(parent(), m_cursor); executed (the execution status of this line is deduced): QAccessibleTextCursorEvent event(parent(), m_cursor); | - |
1386 | QAccessible::updateAccessibility(&event); executed (the execution status of this line is deduced): QAccessible::updateAccessibility(&event); | - |
1387 | } executed: } Execution Count:8710 | 8710 |
1388 | #endif | - |
1389 | } executed: } Execution Count:11650 | 11650 |
1390 | } executed: } Execution Count:16285 | 16285 |
1391 | | - |
1392 | #ifndef QT_NO_COMPLETER | - |
1393 | // iterating forward(dir=1)/backward(dir=-1) from the | - |
1394 | // current row based. dir=0 indicates a new completion prefix was set. | - |
1395 | bool QWidgetLineControl::advanceToEnabledItem(int dir) | - |
1396 | { | - |
1397 | int start = m_completer->currentRow(); executed (the execution status of this line is deduced): int start = m_completer->currentRow(); | - |
1398 | if (start == -1) evaluated: start == -1 yes Evaluation Count:4 | yes Evaluation Count:15 |
| 4-15 |
1399 | return false; executed: return false; Execution Count:4 | 4 |
1400 | int i = start + dir; executed (the execution status of this line is deduced): int i = start + dir; | - |
1401 | if (dir == 0) dir = 1; executed: dir = 1; Execution Count:8 evaluated: dir == 0 yes Evaluation Count:8 | yes Evaluation Count:7 |
| 7-8 |
1402 | do { | - |
1403 | if (!m_completer->setCurrentRow(i)) { evaluated: !m_completer->setCurrentRow(i) yes Evaluation Count:4 | yes Evaluation Count:24 |
| 4-24 |
1404 | if (!m_completer->wrapAround()) evaluated: !m_completer->wrapAround() yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
1405 | break; executed: break; Execution Count:2 | 2 |
1406 | i = i > 0 ? 0 : m_completer->completionCount() - 1; evaluated: i > 0 yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
1407 | } else { executed: } Execution Count:2 | 2 |
1408 | QModelIndex currentIndex = m_completer->currentIndex(); executed (the execution status of this line is deduced): QModelIndex currentIndex = m_completer->currentIndex(); | - |
1409 | if (m_completer->completionModel()->flags(currentIndex) & Qt::ItemIsEnabled) evaluated: m_completer->completionModel()->flags(currentIndex) & Qt::ItemIsEnabled yes Evaluation Count:13 | yes Evaluation Count:11 |
| 11-13 |
1410 | return true; executed: return true; Execution Count:13 | 13 |
1411 | i += dir; executed (the execution status of this line is deduced): i += dir; | - |
1412 | } executed: } Execution Count:11 | 11 |
1413 | } while (i != start); partially evaluated: i != start yes Evaluation Count:13 | no Evaluation Count:0 |
| 0-13 |
1414 | | - |
1415 | m_completer->setCurrentRow(start); // restore executed (the execution status of this line is deduced): m_completer->setCurrentRow(start); | - |
1416 | return false; executed: return false; Execution Count:2 | 2 |
1417 | } | - |
1418 | | - |
1419 | void QWidgetLineControl::complete(int key) | - |
1420 | { | - |
1421 | if (!m_completer || isReadOnly() || echoMode() != QLineEdit::Normal) evaluated: !m_completer yes Evaluation Count:1554 | yes Evaluation Count:121 |
partially evaluated: isReadOnly() no Evaluation Count:0 | yes Evaluation Count:121 |
partially evaluated: echoMode() != QLineEdit::Normal no Evaluation Count:0 | yes Evaluation Count:121 |
| 0-1554 |
1422 | return; executed: return; Execution Count:1554 | 1554 |
1423 | | - |
1424 | QString text = this->text(); executed (the execution status of this line is deduced): QString text = this->text(); | - |
1425 | if (m_completer->completionMode() == QCompleter::InlineCompletion) { evaluated: m_completer->completionMode() == QCompleter::InlineCompletion yes Evaluation Count:20 | yes Evaluation Count:101 |
| 20-101 |
1426 | if (key == Qt::Key_Backspace) partially evaluated: key == Qt::Key_Backspace no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
1427 | return; | 0 |
1428 | int n = 0; executed (the execution status of this line is deduced): int n = 0; | - |
1429 | if (key == Qt::Key_Up || key == Qt::Key_Down) { evaluated: key == Qt::Key_Up yes Evaluation Count:4 | yes Evaluation Count:16 |
evaluated: key == Qt::Key_Down yes Evaluation Count:8 | yes Evaluation Count:8 |
| 4-16 |
1430 | if (textAfterSelection().length()) evaluated: textAfterSelection().length() yes Evaluation Count:1 | yes Evaluation Count:11 |
| 1-11 |
1431 | return; executed: return; Execution Count:1 | 1 |
1432 | QString prefix = hasSelectedText() ? textBeforeSelection() evaluated: hasSelectedText() yes Evaluation Count:6 | yes Evaluation Count:5 |
| 5-6 |
1433 | : text; executed (the execution status of this line is deduced): : text; | - |
1434 | if (text.compare(m_completer->currentCompletion(), m_completer->caseSensitivity()) != 0 evaluated: text.compare(m_completer->currentCompletion(), m_completer->caseSensitivity()) != 0 yes Evaluation Count:3 | yes Evaluation Count:8 |
| 3-8 |
1435 | || prefix.compare(m_completer->completionPrefix(), m_completer->caseSensitivity()) != 0) { evaluated: prefix.compare(m_completer->completionPrefix(), m_completer->caseSensitivity()) != 0 yes Evaluation Count:1 | yes Evaluation Count:7 |
| 1-7 |
1436 | m_completer->setCompletionPrefix(prefix); executed (the execution status of this line is deduced): m_completer->setCompletionPrefix(prefix); | - |
1437 | } else { executed: } Execution Count:4 | 4 |
1438 | n = (key == Qt::Key_Up) ? -1 : +1; evaluated: (key == Qt::Key_Up) yes Evaluation Count:3 | yes Evaluation Count:4 |
| 3-4 |
1439 | } executed: } Execution Count:7 | 7 |
1440 | } else { | - |
1441 | m_completer->setCompletionPrefix(text); executed (the execution status of this line is deduced): m_completer->setCompletionPrefix(text); | - |
1442 | } executed: } Execution Count:8 | 8 |
1443 | if (!advanceToEnabledItem(n)) evaluated: !advanceToEnabledItem(n) yes Evaluation Count:6 | yes Evaluation Count:13 |
| 6-13 |
1444 | return; executed: return; Execution Count:6 | 6 |
1445 | } else { executed: } Execution Count:13 | 13 |
1446 | #ifndef QT_KEYPAD_NAVIGATION | - |
1447 | if (text.isEmpty()) { partially evaluated: text.isEmpty() no Evaluation Count:0 | yes Evaluation Count:101 |
| 0-101 |
1448 | m_completer->popup()->hide(); never executed (the execution status of this line is deduced): m_completer->popup()->hide(); | - |
1449 | return; | 0 |
1450 | } | - |
1451 | #endif | - |
1452 | m_completer->setCompletionPrefix(text); executed (the execution status of this line is deduced): m_completer->setCompletionPrefix(text); | - |
1453 | } executed: } Execution Count:101 | 101 |
1454 | | - |
1455 | m_completer->complete(); executed (the execution status of this line is deduced): m_completer->complete(); | - |
1456 | } executed: } Execution Count:114 | 114 |
1457 | #endif | - |
1458 | | - |
1459 | void QWidgetLineControl::setReadOnly(bool enable) | - |
1460 | { | - |
1461 | m_readOnly = enable; executed (the execution status of this line is deduced): m_readOnly = enable; | - |
1462 | if (enable) evaluated: enable yes Evaluation Count:15 | yes Evaluation Count:7 |
| 7-15 |
1463 | setCursorBlinkPeriod(0); executed: setCursorBlinkPeriod(0); Execution Count:15 | 15 |
1464 | else | - |
1465 | setCursorBlinkPeriod(QApplication::cursorFlashTime()); executed: setCursorBlinkPeriod(QApplication::cursorFlashTime()); Execution Count:7 | 7 |
1466 | } | - |
1467 | | - |
1468 | void QWidgetLineControl::setCursorBlinkPeriod(int msec) | - |
1469 | { | - |
1470 | if (msec == m_blinkPeriod) evaluated: msec == m_blinkPeriod yes Evaluation Count:1979 | yes Evaluation Count:4882 |
| 1979-4882 |
1471 | return; executed: return; Execution Count:1979 | 1979 |
1472 | if (m_blinkTimer) { evaluated: m_blinkTimer yes Evaluation Count:2355 | yes Evaluation Count:2527 |
| 2355-2527 |
1473 | killTimer(m_blinkTimer); executed (the execution status of this line is deduced): killTimer(m_blinkTimer); | - |
1474 | } executed: } Execution Count:2355 | 2355 |
1475 | if (msec && !m_readOnly) { evaluated: msec yes Evaluation Count:2525 | yes Evaluation Count:2357 |
evaluated: !m_readOnly yes Evaluation Count:2519 | yes Evaluation Count:6 |
| 6-2525 |
1476 | m_blinkTimer = startTimer(msec / 2); executed (the execution status of this line is deduced): m_blinkTimer = startTimer(msec / 2); | - |
1477 | m_blinkStatus = 1; executed (the execution status of this line is deduced): m_blinkStatus = 1; | - |
1478 | } else { executed: } Execution Count:2519 | 2519 |
1479 | m_blinkTimer = 0; executed (the execution status of this line is deduced): m_blinkTimer = 0; | - |
1480 | if (m_blinkStatus == 1) evaluated: m_blinkStatus == 1 yes Evaluation Count:2351 | yes Evaluation Count:12 |
| 12-2351 |
1481 | emit updateNeeded(inputMask().isEmpty() ? cursorRect() : QRect()); executed: updateNeeded(inputMask().isEmpty() ? cursorRect() : QRect()); Execution Count:2351 | 2351 |
1482 | } executed: } Execution Count:2363 | 2363 |
1483 | m_blinkPeriod = msec; executed (the execution status of this line is deduced): m_blinkPeriod = msec; | - |
1484 | } executed: } Execution Count:4882 | 4882 |
1485 | | - |
1486 | // This is still used by QDeclarativeTextInput in the qtquick1 repo | - |
1487 | void QWidgetLineControl::resetCursorBlinkTimer() | - |
1488 | { | - |
1489 | if (m_blinkPeriod == 0 || m_blinkTimer == 0) never evaluated: m_blinkPeriod == 0 never evaluated: m_blinkTimer == 0 | 0 |
1490 | return; | 0 |
1491 | killTimer(m_blinkTimer); never executed (the execution status of this line is deduced): killTimer(m_blinkTimer); | - |
1492 | m_blinkTimer = startTimer(m_blinkPeriod / 2); never executed (the execution status of this line is deduced): m_blinkTimer = startTimer(m_blinkPeriod / 2); | - |
1493 | m_blinkStatus = 1; never executed (the execution status of this line is deduced): m_blinkStatus = 1; | - |
1494 | } | 0 |
1495 | | - |
1496 | void QWidgetLineControl::timerEvent(QTimerEvent *event) | - |
1497 | { | - |
1498 | if (event->timerId() == m_blinkTimer) { partially evaluated: event->timerId() == m_blinkTimer yes Evaluation Count:63 | no Evaluation Count:0 |
| 0-63 |
1499 | m_blinkStatus = !m_blinkStatus; executed (the execution status of this line is deduced): m_blinkStatus = !m_blinkStatus; | - |
1500 | emit updateNeeded(inputMask().isEmpty() ? cursorRect() : QRect()); executed (the execution status of this line is deduced): updateNeeded(inputMask().isEmpty() ? cursorRect() : QRect()); | - |
1501 | } else if (event->timerId() == m_deleteAllTimer) { executed: } Execution Count:63 never evaluated: event->timerId() == m_deleteAllTimer | 0-63 |
1502 | killTimer(m_deleteAllTimer); never executed (the execution status of this line is deduced): killTimer(m_deleteAllTimer); | - |
1503 | m_deleteAllTimer = 0; never executed (the execution status of this line is deduced): m_deleteAllTimer = 0; | - |
1504 | clear(); never executed (the execution status of this line is deduced): clear(); | - |
1505 | } else if (event->timerId() == m_tripleClickTimer) { never executed: } never evaluated: event->timerId() == m_tripleClickTimer | 0 |
1506 | killTimer(m_tripleClickTimer); never executed (the execution status of this line is deduced): killTimer(m_tripleClickTimer); | - |
1507 | m_tripleClickTimer = 0; never executed (the execution status of this line is deduced): m_tripleClickTimer = 0; | - |
1508 | } else if (event->timerId() == m_passwordEchoTimer) { never executed: } never evaluated: event->timerId() == m_passwordEchoTimer | 0 |
1509 | killTimer(m_passwordEchoTimer); never executed (the execution status of this line is deduced): killTimer(m_passwordEchoTimer); | - |
1510 | m_passwordEchoTimer = 0; never executed (the execution status of this line is deduced): m_passwordEchoTimer = 0; | - |
1511 | updateDisplayText(); never executed (the execution status of this line is deduced): updateDisplayText(); | - |
1512 | } | 0 |
1513 | } | - |
1514 | | - |
1515 | #ifndef QT_NO_SHORTCUT | - |
1516 | void QWidgetLineControl::processShortcutOverrideEvent(QKeyEvent *ke) | - |
1517 | { | - |
1518 | if (isReadOnly()) evaluated: isReadOnly() yes Evaluation Count:39 | yes Evaluation Count:3762 |
| 39-3762 |
1519 | return; executed: return; Execution Count:39 | 39 |
1520 | | - |
1521 | if (ke == QKeySequence::Copy partially evaluated: ke == QKeySequence::Copy no Evaluation Count:0 | yes Evaluation Count:3762 |
| 0-3762 |
1522 | || ke == QKeySequence::Paste partially evaluated: ke == QKeySequence::Paste no Evaluation Count:0 | yes Evaluation Count:3762 |
| 0-3762 |
1523 | || ke == QKeySequence::Cut partially evaluated: ke == QKeySequence::Cut no Evaluation Count:0 | yes Evaluation Count:3762 |
| 0-3762 |
1524 | || ke == QKeySequence::Redo evaluated: ke == QKeySequence::Redo yes Evaluation Count:2 | yes Evaluation Count:3760 |
| 2-3760 |
1525 | || ke == QKeySequence::Undo evaluated: ke == QKeySequence::Undo yes Evaluation Count:4 | yes Evaluation Count:3756 |
| 4-3756 |
1526 | || ke == QKeySequence::MoveToNextWord evaluated: ke == QKeySequence::MoveToNextWord yes Evaluation Count:2 | yes Evaluation Count:3754 |
| 2-3754 |
1527 | || ke == QKeySequence::MoveToPreviousWord evaluated: ke == QKeySequence::MoveToPreviousWord yes Evaluation Count:2 | yes Evaluation Count:3752 |
| 2-3752 |
1528 | || ke == QKeySequence::MoveToStartOfDocument partially evaluated: ke == QKeySequence::MoveToStartOfDocument no Evaluation Count:0 | yes Evaluation Count:3752 |
| 0-3752 |
1529 | || ke == QKeySequence::MoveToEndOfDocument partially evaluated: ke == QKeySequence::MoveToEndOfDocument no Evaluation Count:0 | yes Evaluation Count:3752 |
| 0-3752 |
1530 | || ke == QKeySequence::SelectNextWord partially evaluated: ke == QKeySequence::SelectNextWord no Evaluation Count:0 | yes Evaluation Count:3752 |
| 0-3752 |
1531 | || ke == QKeySequence::SelectPreviousWord partially evaluated: ke == QKeySequence::SelectPreviousWord no Evaluation Count:0 | yes Evaluation Count:3752 |
| 0-3752 |
1532 | || ke == QKeySequence::SelectStartOfLine partially evaluated: ke == QKeySequence::SelectStartOfLine no Evaluation Count:0 | yes Evaluation Count:3752 |
| 0-3752 |
1533 | || ke == QKeySequence::SelectEndOfLine evaluated: ke == QKeySequence::SelectEndOfLine yes Evaluation Count:4 | yes Evaluation Count:3748 |
| 4-3748 |
1534 | || ke == QKeySequence::SelectStartOfBlock partially evaluated: ke == QKeySequence::SelectStartOfBlock no Evaluation Count:0 | yes Evaluation Count:3748 |
| 0-3748 |
1535 | || ke == QKeySequence::SelectEndOfBlock partially evaluated: ke == QKeySequence::SelectEndOfBlock no Evaluation Count:0 | yes Evaluation Count:3748 |
| 0-3748 |
1536 | || ke == QKeySequence::SelectStartOfDocument partially evaluated: ke == QKeySequence::SelectStartOfDocument no Evaluation Count:0 | yes Evaluation Count:3748 |
| 0-3748 |
1537 | || ke == QKeySequence::SelectAll partially evaluated: ke == QKeySequence::SelectAll no Evaluation Count:0 | yes Evaluation Count:3748 |
| 0-3748 |
1538 | || ke == QKeySequence::SelectEndOfDocument) { partially evaluated: ke == QKeySequence::SelectEndOfDocument no Evaluation Count:0 | yes Evaluation Count:3748 |
| 0-3748 |
1539 | ke->accept(); executed (the execution status of this line is deduced): ke->accept(); | - |
1540 | } else if (ke->modifiers() == Qt::NoModifier || ke->modifiers() == Qt::ShiftModifier executed: } Execution Count:14 evaluated: ke->modifiers() == Qt::NoModifier yes Evaluation Count:3591 | yes Evaluation Count:157 |
evaluated: ke->modifiers() == Qt::ShiftModifier yes Evaluation Count:110 | yes Evaluation Count:47 |
| 14-3591 |
1541 | || ke->modifiers() == Qt::KeypadModifier) { evaluated: ke->modifiers() == Qt::KeypadModifier yes Evaluation Count:2 | yes Evaluation Count:45 |
| 2-45 |
1542 | if (ke->key() < Qt::Key_Escape) { evaluated: ke->key() < Qt::Key_Escape yes Evaluation Count:1516 | yes Evaluation Count:2187 |
| 1516-2187 |
1543 | ke->accept(); executed (the execution status of this line is deduced): ke->accept(); | - |
1544 | } else { executed: } Execution Count:1516 | 1516 |
1545 | switch (ke->key()) { | - |
1546 | case Qt::Key_Delete: | - |
1547 | case Qt::Key_Home: | - |
1548 | case Qt::Key_End: | - |
1549 | case Qt::Key_Backspace: | - |
1550 | case Qt::Key_Left: | - |
1551 | case Qt::Key_Right: | - |
1552 | ke->accept(); executed (the execution status of this line is deduced): ke->accept(); | - |
1553 | default: | - |
1554 | break; executed: break; Execution Count:2187 | 2187 |
1555 | } | - |
1556 | } executed: } Execution Count:2187 | 2187 |
1557 | } | - |
1558 | } | - |
1559 | #endif | - |
1560 | | - |
1561 | void QWidgetLineControl::processKeyEvent(QKeyEvent* event) | - |
1562 | { | - |
1563 | bool inlineCompletionAccepted = false; executed (the execution status of this line is deduced): bool inlineCompletionAccepted = false; | - |
1564 | | - |
1565 | #ifndef QT_NO_COMPLETER | - |
1566 | if (m_completer) { evaluated: m_completer yes Evaluation Count:78 | yes Evaluation Count:2344 |
| 78-2344 |
1567 | QCompleter::CompletionMode completionMode = m_completer->completionMode(); executed (the execution status of this line is deduced): QCompleter::CompletionMode completionMode = m_completer->completionMode(); | - |
1568 | if ((completionMode == QCompleter::PopupCompletion evaluated: completionMode == QCompleter::PopupCompletion yes Evaluation Count:39 | yes Evaluation Count:39 |
| 39 |
1569 | || completionMode == QCompleter::UnfilteredPopupCompletion) evaluated: completionMode == QCompleter::UnfilteredPopupCompletion yes Evaluation Count:2 | yes Evaluation Count:37 |
| 2-37 |
1570 | && m_completer->popup() partially evaluated: m_completer->popup() yes Evaluation Count:41 | no Evaluation Count:0 |
| 0-41 |
1571 | && m_completer->popup()->isVisible()) { evaluated: m_completer->popup()->isVisible() yes Evaluation Count:17 | yes Evaluation Count:24 |
| 17-24 |
1572 | // The following keys are forwarded by the completer to the widget | - |
1573 | // Ignoring the events lets the completer provide suitable default behavior | - |
1574 | switch (event->key()) { | - |
1575 | case Qt::Key_Escape: | - |
1576 | event->ignore(); executed (the execution status of this line is deduced): event->ignore(); | - |
1577 | return; executed: return; Execution Count:1 | 1 |
1578 | case Qt::Key_Enter: | - |
1579 | case Qt::Key_Return: | - |
1580 | case Qt::Key_F4: | - |
1581 | #ifdef QT_KEYPAD_NAVIGATION | - |
1582 | case Qt::Key_Select: | - |
1583 | if (!QApplication::keypadNavigationEnabled()) | - |
1584 | break; | - |
1585 | #endif | - |
1586 | m_completer->popup()->hide(); // just hide. will end up propagating to parent executed (the execution status of this line is deduced): m_completer->popup()->hide(); | - |
1587 | default: | - |
1588 | break; // normal key processing executed: break; Execution Count:16 | 16 |
1589 | } | - |
1590 | } else if (completionMode == QCompleter::InlineCompletion) { executed: } Execution Count:16 evaluated: completionMode == QCompleter::InlineCompletion yes Evaluation Count:37 | yes Evaluation Count:24 |
| 16-37 |
1591 | switch (event->key()) { | - |
1592 | case Qt::Key_Enter: | - |
1593 | case Qt::Key_Return: | - |
1594 | case Qt::Key_F4: | - |
1595 | #ifdef QT_KEYPAD_NAVIGATION | - |
1596 | case Qt::Key_Select: | - |
1597 | if (!QApplication::keypadNavigationEnabled()) | - |
1598 | break; | - |
1599 | #endif | - |
1600 | if (!m_completer->currentCompletion().isEmpty() && hasSelectedText() evaluated: !m_completer->currentCompletion().isEmpty() yes Evaluation Count:2 | yes Evaluation Count:1 |
partially evaluated: hasSelectedText() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
1601 | && textAfterSelection().isEmpty()) { partially evaluated: textAfterSelection().isEmpty() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
1602 | setText(m_completer->currentCompletion()); executed (the execution status of this line is deduced): setText(m_completer->currentCompletion()); | - |
1603 | inlineCompletionAccepted = true; executed (the execution status of this line is deduced): inlineCompletionAccepted = true; | - |
1604 | } executed: } Execution Count:2 | 2 |
1605 | default: | - |
1606 | break; // normal key processing executed: break; Execution Count:37 | 37 |
1607 | } | - |
1608 | } executed: } Execution Count:37 | 37 |
1609 | } | - |
1610 | #endif // QT_NO_COMPLETER | - |
1611 | | - |
1612 | if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) { evaluated: event->key() == Qt::Key_Enter yes Evaluation Count:24 | yes Evaluation Count:2397 |
evaluated: event->key() == Qt::Key_Return yes Evaluation Count:45 | yes Evaluation Count:2352 |
| 24-2397 |
1613 | if (hasAcceptableInput() || fixup()) { evaluated: hasAcceptableInput() yes Evaluation Count:40 | yes Evaluation Count:29 |
evaluated: fixup() yes Evaluation Count:2 | yes Evaluation Count:27 |
| 2-40 |
1614 | emit accepted(); executed (the execution status of this line is deduced): accepted(); | - |
1615 | emit editingFinished(); executed (the execution status of this line is deduced): editingFinished(); | - |
1616 | } executed: } Execution Count:42 | 42 |
1617 | if (inlineCompletionAccepted) evaluated: inlineCompletionAccepted yes Evaluation Count:2 | yes Evaluation Count:67 |
| 2-67 |
1618 | event->accept(); executed: event->accept(); Execution Count:2 | 2 |
1619 | else | - |
1620 | event->ignore(); executed: event->ignore(); Execution Count:67 | 67 |
1621 | return; executed: return; Execution Count:69 | 69 |
1622 | } | - |
1623 | | - |
1624 | if (echoMode() == QLineEdit::PasswordEchoOnEdit evaluated: echoMode() == QLineEdit::PasswordEchoOnEdit yes Evaluation Count:8 | yes Evaluation Count:2344 |
| 8-2344 |
1625 | && !passwordEchoEditing() evaluated: !passwordEchoEditing() yes Evaluation Count:4 | yes Evaluation Count:4 |
| 4 |
1626 | && !isReadOnly() partially evaluated: !isReadOnly() yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
1627 | && !event->text().isEmpty() partially evaluated: !event->text().isEmpty() yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
1628 | #ifdef QT_KEYPAD_NAVIGATION executed (the execution status of this line is deduced):
| - |
1629 | && event->key() != Qt::Key_Select executed (the execution status of this line is deduced):
| - |
1630 | && event->key() != Qt::Key_Up executed (the execution status of this line is deduced):
| - |
1631 | && event->key() != Qt::Key_Down executed (the execution status of this line is deduced):
| - |
1632 | && event->key() != Qt::Key_Back executed (the execution status of this line is deduced):
| - |
1633 | #endif executed (the execution status of this line is deduced):
| - |
1634 | && !(event->modifiers() & Qt::ControlModifier)) { partially evaluated: !(event->modifiers() & Qt::ControlModifier) yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
1635 | // Clear the edit and reset to normal echo mode while editing; the | - |
1636 | // echo mode switches back when the edit loses focus | - |
1637 | // ### resets current content. dubious code; you can | - |
1638 | // navigate with keys up, down, back, and select(?), but if you press | - |
1639 | // "left" or "right" it clears? | - |
1640 | updatePasswordEchoEditing(true); executed (the execution status of this line is deduced): updatePasswordEchoEditing(true); | - |
1641 | clear(); executed (the execution status of this line is deduced): clear(); | - |
1642 | } executed: } Execution Count:4 | 4 |
1643 | | - |
1644 | bool unknown = false; executed (the execution status of this line is deduced): bool unknown = false; | - |
1645 | bool visual = cursorMoveStyle() == Qt::VisualMoveStyle; executed (the execution status of this line is deduced): bool visual = cursorMoveStyle() == Qt::VisualMoveStyle; | - |
1646 | | - |
1647 | if (false) { partially evaluated: false no Evaluation Count:0 | yes Evaluation Count:2352 |
| 0-2352 |
1648 | } | 0 |
1649 | #ifndef QT_NO_SHORTCUT | - |
1650 | else if (event == QKeySequence::Undo) { evaluated: event == QKeySequence::Undo yes Evaluation Count:4 | yes Evaluation Count:2348 |
| 4-2348 |
1651 | if (!isReadOnly()) partially evaluated: !isReadOnly() yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
1652 | undo(); executed: undo(); Execution Count:4 | 4 |
1653 | } executed: } Execution Count:4 | 4 |
1654 | else if (event == QKeySequence::Redo) { evaluated: event == QKeySequence::Redo yes Evaluation Count:2 | yes Evaluation Count:2346 |
| 2-2346 |
1655 | if (!isReadOnly()) partially evaluated: !isReadOnly() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
1656 | redo(); executed: redo(); Execution Count:2 | 2 |
1657 | } executed: } Execution Count:2 | 2 |
1658 | else if (event == QKeySequence::SelectAll) { partially evaluated: event == QKeySequence::SelectAll no Evaluation Count:0 | yes Evaluation Count:2346 |
| 0-2346 |
1659 | selectAll(); never executed (the execution status of this line is deduced): selectAll(); | - |
1660 | } | 0 |
1661 | #ifndef QT_NO_CLIPBOARD | - |
1662 | else if (event == QKeySequence::Copy) { partially evaluated: event == QKeySequence::Copy no Evaluation Count:0 | yes Evaluation Count:2346 |
| 0-2346 |
1663 | copy(); never executed (the execution status of this line is deduced): copy(); | - |
1664 | } | 0 |
1665 | else if (event == QKeySequence::Paste) { partially evaluated: event == QKeySequence::Paste no Evaluation Count:0 | yes Evaluation Count:2346 |
| 0-2346 |
1666 | if (!isReadOnly()) { never evaluated: !isReadOnly() | 0 |
1667 | QClipboard::Mode mode = QClipboard::Clipboard; never executed (the execution status of this line is deduced): QClipboard::Mode mode = QClipboard::Clipboard; | - |
1668 | if (m_keyboardScheme == QPlatformTheme::X11KeyboardScheme never evaluated: m_keyboardScheme == QPlatformTheme::X11KeyboardScheme | 0 |
1669 | && event->modifiers() == (Qt::CTRL | Qt::SHIFT) never evaluated: event->modifiers() == (Qt::CTRL | Qt::SHIFT) | 0 |
1670 | && event->key() == Qt::Key_Insert) { never evaluated: event->key() == Qt::Key_Insert | 0 |
1671 | mode = QClipboard::Selection; never executed (the execution status of this line is deduced): mode = QClipboard::Selection; | - |
1672 | } | 0 |
1673 | paste(mode); never executed (the execution status of this line is deduced): paste(mode); | - |
1674 | } | 0 |
1675 | } | 0 |
1676 | else if (event == QKeySequence::Cut) { partially evaluated: event == QKeySequence::Cut no Evaluation Count:0 | yes Evaluation Count:2346 |
| 0-2346 |
1677 | if (!isReadOnly()) { never evaluated: !isReadOnly() | 0 |
1678 | copy(); never executed (the execution status of this line is deduced): copy(); | - |
1679 | del(); never executed (the execution status of this line is deduced): del(); | - |
1680 | } | 0 |
1681 | } | 0 |
1682 | else if (event == QKeySequence::DeleteEndOfLine) { partially evaluated: event == QKeySequence::DeleteEndOfLine no Evaluation Count:0 | yes Evaluation Count:2346 |
| 0-2346 |
1683 | if (!isReadOnly()) { never evaluated: !isReadOnly() | 0 |
1684 | setSelection(cursor(), end()); never executed (the execution status of this line is deduced): setSelection(cursor(), end()); | - |
1685 | copy(); never executed (the execution status of this line is deduced): copy(); | - |
1686 | del(); never executed (the execution status of this line is deduced): del(); | - |
1687 | } | 0 |
1688 | } | 0 |
1689 | #endif //QT_NO_CLIPBOARD | - |
1690 | else if (event == QKeySequence::MoveToStartOfLine || event == QKeySequence::MoveToStartOfBlock) { evaluated: event == QKeySequence::MoveToStartOfLine yes Evaluation Count:84 | yes Evaluation Count:2262 |
partially evaluated: event == QKeySequence::MoveToStartOfBlock no Evaluation Count:0 | yes Evaluation Count:2262 |
| 0-2262 |
1691 | home(0); executed (the execution status of this line is deduced): home(0); | - |
1692 | } executed: } Execution Count:84 | 84 |
1693 | else if (event == QKeySequence::MoveToEndOfLine || event == QKeySequence::MoveToEndOfBlock) { evaluated: event == QKeySequence::MoveToEndOfLine yes Evaluation Count:35 | yes Evaluation Count:2227 |
partially evaluated: event == QKeySequence::MoveToEndOfBlock no Evaluation Count:0 | yes Evaluation Count:2227 |
| 0-2227 |
1694 | end(0); executed (the execution status of this line is deduced): end(0); | - |
1695 | } executed: } Execution Count:35 | 35 |
1696 | else if (event == QKeySequence::SelectStartOfLine || event == QKeySequence::SelectStartOfBlock) { partially evaluated: event == QKeySequence::SelectStartOfLine no Evaluation Count:0 | yes Evaluation Count:2227 |
partially evaluated: event == QKeySequence::SelectStartOfBlock no Evaluation Count:0 | yes Evaluation Count:2227 |
| 0-2227 |
1697 | home(1); never executed (the execution status of this line is deduced): home(1); | - |
1698 | } | 0 |
1699 | else if (event == QKeySequence::SelectEndOfLine || event == QKeySequence::SelectEndOfBlock) { evaluated: event == QKeySequence::SelectEndOfLine yes Evaluation Count:4 | yes Evaluation Count:2223 |
partially evaluated: event == QKeySequence::SelectEndOfBlock no Evaluation Count:0 | yes Evaluation Count:2223 |
| 0-2223 |
1700 | end(1); executed (the execution status of this line is deduced): end(1); | - |
1701 | } executed: } Execution Count:4 | 4 |
1702 | else if (event == QKeySequence::MoveToNextChar) { evaluated: event == QKeySequence::MoveToNextChar yes Evaluation Count:227 | yes Evaluation Count:1996 |
| 227-1996 |
1703 | #if defined(QT_NO_COMPLETER) | - |
1704 | const bool inlineCompletion = false; | - |
1705 | #else | - |
1706 | const bool inlineCompletion = m_completer && m_completer->completionMode() == QCompleter::InlineCompletion; partially evaluated: m_completer no Evaluation Count:0 | yes Evaluation Count:227 |
never evaluated: m_completer->completionMode() == QCompleter::InlineCompletion | 0-227 |
1707 | #endif | - |
1708 | if (hasSelectedText() evaluated: hasSelectedText() yes Evaluation Count:1 | yes Evaluation Count:226 |
| 1-226 |
1709 | && (m_keyboardScheme != QPlatformTheme::WindowsKeyboardScheme partially evaluated: m_keyboardScheme != QPlatformTheme::WindowsKeyboardScheme yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1710 | || inlineCompletion)) { never evaluated: inlineCompletion | 0 |
1711 | moveCursor(selectionEnd(), false); executed (the execution status of this line is deduced): moveCursor(selectionEnd(), false); | - |
1712 | } else { executed: } Execution Count:1 | 1 |
1713 | cursorForward(0, visual ? 1 : (layoutDirection() == Qt::LeftToRight ? 1 : -1)); executed (the execution status of this line is deduced): cursorForward(0, visual ? 1 : (layoutDirection() == Qt::LeftToRight ? 1 : -1)); | - |
1714 | } executed: } Execution Count:226 | 226 |
1715 | } | - |
1716 | else if (event == QKeySequence::SelectNextChar) { evaluated: event == QKeySequence::SelectNextChar yes Evaluation Count:20 | yes Evaluation Count:1976 |
| 20-1976 |
1717 | cursorForward(1, visual ? 1 : (layoutDirection() == Qt::LeftToRight ? 1 : -1)); executed (the execution status of this line is deduced): cursorForward(1, visual ? 1 : (layoutDirection() == Qt::LeftToRight ? 1 : -1)); | - |
1718 | } executed: } Execution Count:20 | 20 |
1719 | else if (event == QKeySequence::MoveToPreviousChar) { evaluated: event == QKeySequence::MoveToPreviousChar yes Evaluation Count:168 | yes Evaluation Count:1808 |
| 168-1808 |
1720 | #if defined(QT_NO_COMPLETER) | - |
1721 | const bool inlineCompletion = false; | - |
1722 | #else | - |
1723 | const bool inlineCompletion = m_completer && m_completer->completionMode() == QCompleter::InlineCompletion; partially evaluated: m_completer no Evaluation Count:0 | yes Evaluation Count:168 |
never evaluated: m_completer->completionMode() == QCompleter::InlineCompletion | 0-168 |
1724 | #endif | - |
1725 | if (hasSelectedText() evaluated: hasSelectedText() yes Evaluation Count:2 | yes Evaluation Count:166 |
| 2-166 |
1726 | && (m_keyboardScheme != QPlatformTheme::WindowsKeyboardScheme partially evaluated: m_keyboardScheme != QPlatformTheme::WindowsKeyboardScheme yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
1727 | || inlineCompletion)) { never evaluated: inlineCompletion | 0 |
1728 | moveCursor(selectionStart(), false); executed (the execution status of this line is deduced): moveCursor(selectionStart(), false); | - |
1729 | } else { executed: } Execution Count:2 | 2 |
1730 | cursorForward(0, visual ? -1 : (layoutDirection() == Qt::LeftToRight ? -1 : 1)); executed (the execution status of this line is deduced): cursorForward(0, visual ? -1 : (layoutDirection() == Qt::LeftToRight ? -1 : 1)); | - |
1731 | } executed: } Execution Count:166 | 166 |
1732 | } | - |
1733 | else if (event == QKeySequence::SelectPreviousChar) { evaluated: event == QKeySequence::SelectPreviousChar yes Evaluation Count:21 | yes Evaluation Count:1787 |
| 21-1787 |
1734 | cursorForward(1, visual ? -1 : (layoutDirection() == Qt::LeftToRight ? -1 : 1)); executed (the execution status of this line is deduced): cursorForward(1, visual ? -1 : (layoutDirection() == Qt::LeftToRight ? -1 : 1)); | - |
1735 | } executed: } Execution Count:21 | 21 |
1736 | else if (event == QKeySequence::MoveToNextWord) { evaluated: event == QKeySequence::MoveToNextWord yes Evaluation Count:1 | yes Evaluation Count:1786 |
| 1-1786 |
1737 | if (echoMode() == QLineEdit::Normal) partially evaluated: echoMode() == QLineEdit::Normal yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1738 | layoutDirection() == Qt::LeftToRight ? cursorWordForward(0) : cursorWordBackward(0); executed: layoutDirection() == Qt::LeftToRight ? cursorWordForward(0) : cursorWordBackward(0); Execution Count:1 | 1 |
1739 | else | - |
1740 | layoutDirection() == Qt::LeftToRight ? end(0) : home(0); never executed: layoutDirection() == Qt::LeftToRight ? end(0) : home(0); | 0 |
1741 | } | - |
1742 | else if (event == QKeySequence::MoveToPreviousWord) { evaluated: event == QKeySequence::MoveToPreviousWord yes Evaluation Count:1 | yes Evaluation Count:1785 |
| 1-1785 |
1743 | if (echoMode() == QLineEdit::Normal) partially evaluated: echoMode() == QLineEdit::Normal yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1744 | layoutDirection() == Qt::LeftToRight ? cursorWordBackward(0) : cursorWordForward(0); executed: layoutDirection() == Qt::LeftToRight ? cursorWordBackward(0) : cursorWordForward(0); Execution Count:1 | 1 |
1745 | else if (!isReadOnly()) { never evaluated: !isReadOnly() | 0 |
1746 | layoutDirection() == Qt::LeftToRight ? home(0) : end(0); never executed (the execution status of this line is deduced): layoutDirection() == Qt::LeftToRight ? home(0) : end(0); | - |
1747 | } | 0 |
1748 | } | - |
1749 | else if (event == QKeySequence::SelectNextWord) { partially evaluated: event == QKeySequence::SelectNextWord no Evaluation Count:0 | yes Evaluation Count:1785 |
| 0-1785 |
1750 | if (echoMode() == QLineEdit::Normal) never evaluated: echoMode() == QLineEdit::Normal | 0 |
1751 | layoutDirection() == Qt::LeftToRight ? cursorWordForward(1) : cursorWordBackward(1); never executed: layoutDirection() == Qt::LeftToRight ? cursorWordForward(1) : cursorWordBackward(1); | 0 |
1752 | else | - |
1753 | layoutDirection() == Qt::LeftToRight ? end(1) : home(1); never executed: layoutDirection() == Qt::LeftToRight ? end(1) : home(1); | 0 |
1754 | } | - |
1755 | else if (event == QKeySequence::SelectPreviousWord) { partially evaluated: event == QKeySequence::SelectPreviousWord no Evaluation Count:0 | yes Evaluation Count:1785 |
| 0-1785 |
1756 | if (echoMode() == QLineEdit::Normal) never evaluated: echoMode() == QLineEdit::Normal | 0 |
1757 | layoutDirection() == Qt::LeftToRight ? cursorWordBackward(1) : cursorWordForward(1); never executed: layoutDirection() == Qt::LeftToRight ? cursorWordBackward(1) : cursorWordForward(1); | 0 |
1758 | else | - |
1759 | layoutDirection() == Qt::LeftToRight ? home(1) : end(1); never executed: layoutDirection() == Qt::LeftToRight ? home(1) : end(1); | 0 |
1760 | } | - |
1761 | else if (event == QKeySequence::Delete) { evaluated: event == QKeySequence::Delete yes Evaluation Count:80 | yes Evaluation Count:1705 |
| 80-1705 |
1762 | if (!isReadOnly()) evaluated: !isReadOnly() yes Evaluation Count:79 | yes Evaluation Count:1 |
| 1-79 |
1763 | del(); executed: del(); Execution Count:79 | 79 |
1764 | } executed: } Execution Count:80 | 80 |
1765 | else if (event == QKeySequence::DeleteEndOfWord) { partially evaluated: event == QKeySequence::DeleteEndOfWord no Evaluation Count:0 | yes Evaluation Count:1705 |
| 0-1705 |
1766 | if (!isReadOnly()) { never evaluated: !isReadOnly() | 0 |
1767 | cursorWordForward(true); never executed (the execution status of this line is deduced): cursorWordForward(true); | - |
1768 | del(); never executed (the execution status of this line is deduced): del(); | - |
1769 | } | 0 |
1770 | } | 0 |
1771 | else if (event == QKeySequence::DeleteStartOfWord) { partially evaluated: event == QKeySequence::DeleteStartOfWord no Evaluation Count:0 | yes Evaluation Count:1705 |
| 0-1705 |
1772 | if (!isReadOnly()) { never evaluated: !isReadOnly() | 0 |
1773 | cursorWordBackward(true); never executed (the execution status of this line is deduced): cursorWordBackward(true); | - |
1774 | del(); never executed (the execution status of this line is deduced): del(); | - |
1775 | } | 0 |
1776 | } | 0 |
1777 | #endif // QT_NO_SHORTCUT | - |
1778 | else { | - |
1779 | bool handled = false; executed (the execution status of this line is deduced): bool handled = false; | - |
1780 | if (m_keyboardScheme == QPlatformTheme::MacKeyboardScheme partially evaluated: m_keyboardScheme == QPlatformTheme::MacKeyboardScheme no Evaluation Count:0 | yes Evaluation Count:1705 |
| 0-1705 |
1781 | && (event->key() == Qt::Key_Up || event->key() == Qt::Key_Down)) { never evaluated: event->key() == Qt::Key_Up never evaluated: event->key() == Qt::Key_Down | 0 |
1782 | Qt::KeyboardModifiers myModifiers = (event->modifiers() & ~Qt::KeypadModifier); never executed (the execution status of this line is deduced): Qt::KeyboardModifiers myModifiers = (event->modifiers() & ~Qt::KeypadModifier); | - |
1783 | if (myModifiers & Qt::ShiftModifier) { never evaluated: myModifiers & Qt::ShiftModifier | 0 |
1784 | if (myModifiers == (Qt::ControlModifier|Qt::ShiftModifier) never evaluated: myModifiers == (Qt::ControlModifier|Qt::ShiftModifier) | 0 |
1785 | || myModifiers == (Qt::AltModifier|Qt::ShiftModifier) never evaluated: myModifiers == (Qt::AltModifier|Qt::ShiftModifier) | 0 |
1786 | || myModifiers == Qt::ShiftModifier) { never evaluated: myModifiers == Qt::ShiftModifier | 0 |
1787 | | - |
1788 | event->key() == Qt::Key_Up ? home(1) : end(1); never executed (the execution status of this line is deduced): event->key() == Qt::Key_Up ? home(1) : end(1); | - |
1789 | } | 0 |
1790 | } else { | 0 |
1791 | if ((myModifiers == Qt::ControlModifier never evaluated: myModifiers == Qt::ControlModifier | 0 |
1792 | || myModifiers == Qt::AltModifier never evaluated: myModifiers == Qt::AltModifier | 0 |
1793 | || myModifiers == Qt::NoModifier)) { never evaluated: myModifiers == Qt::NoModifier | 0 |
1794 | event->key() == Qt::Key_Up ? home(0) : end(0); never executed (the execution status of this line is deduced): event->key() == Qt::Key_Up ? home(0) : end(0); | - |
1795 | } | 0 |
1796 | } | 0 |
1797 | handled = true; never executed (the execution status of this line is deduced): handled = true; | - |
1798 | } | 0 |
1799 | if (event->modifiers() & Qt::ControlModifier) { evaluated: event->modifiers() & Qt::ControlModifier yes Evaluation Count:40 | yes Evaluation Count:1665 |
| 40-1665 |
1800 | switch (event->key()) { | - |
1801 | case Qt::Key_Backspace: | - |
1802 | if (!isReadOnly()) { never evaluated: !isReadOnly() | 0 |
1803 | cursorWordBackward(true); never executed (the execution status of this line is deduced): cursorWordBackward(true); | - |
1804 | del(); never executed (the execution status of this line is deduced): del(); | - |
1805 | } | 0 |
1806 | break; | 0 |
1807 | #ifndef QT_NO_COMPLETER | - |
1808 | case Qt::Key_Up: | - |
1809 | case Qt::Key_Down: | - |
1810 | complete(event->key()); executed (the execution status of this line is deduced): complete(event->key()); | - |
1811 | break; executed: break; Execution Count:12 | 12 |
1812 | #endif | - |
1813 | case Qt::Key_E: | - |
1814 | if (m_keyboardScheme == QPlatformTheme::X11KeyboardScheme) never evaluated: m_keyboardScheme == QPlatformTheme::X11KeyboardScheme | 0 |
1815 | end(0); | 0 |
1816 | break; | 0 |
1817 | | - |
1818 | case Qt::Key_U: | - |
1819 | if (m_keyboardScheme == QPlatformTheme::X11KeyboardScheme && !isReadOnly()) { never evaluated: m_keyboardScheme == QPlatformTheme::X11KeyboardScheme never evaluated: !isReadOnly() | 0 |
1820 | setSelection(0, text().size()); never executed (the execution status of this line is deduced): setSelection(0, text().size()); | - |
1821 | #ifndef QT_NO_CLIPBOARD | - |
1822 | copy(); never executed (the execution status of this line is deduced): copy(); | - |
1823 | #endif | - |
1824 | del(); never executed (the execution status of this line is deduced): del(); | - |
1825 | } | 0 |
1826 | break; | 0 |
1827 | default: | - |
1828 | if (!handled) partially evaluated: !handled yes Evaluation Count:28 | no Evaluation Count:0 |
| 0-28 |
1829 | unknown = true; executed: unknown = true; Execution Count:28 | 28 |
1830 | } executed: } Execution Count:28 | 28 |
1831 | } else { // ### check for *no* modifier executed: } Execution Count:40 | 40 |
1832 | switch (event->key()) { | - |
1833 | case Qt::Key_Backspace: | - |
1834 | if (!isReadOnly()) { partially evaluated: !isReadOnly() yes Evaluation Count:53 | no Evaluation Count:0 |
| 0-53 |
1835 | backspace(); executed (the execution status of this line is deduced): backspace(); | - |
1836 | #ifndef QT_NO_COMPLETER | - |
1837 | complete(Qt::Key_Backspace); executed (the execution status of this line is deduced): complete(Qt::Key_Backspace); | - |
1838 | #endif | - |
1839 | } executed: } Execution Count:53 | 53 |
1840 | break; executed: break; Execution Count:53 | 53 |
1841 | #ifdef QT_KEYPAD_NAVIGATION | - |
1842 | case Qt::Key_Back: | - |
1843 | if (QApplication::keypadNavigationEnabled() && !event->isAutoRepeat() | - |
1844 | && !isReadOnly()) { | - |
1845 | if (text().length() == 0) { | - |
1846 | setText(m_cancelText); | - |
1847 | | - |
1848 | if (passwordEchoEditing()) | - |
1849 | updatePasswordEchoEditing(false); | - |
1850 | | - |
1851 | emit editFocusChange(false); | - |
1852 | } else if (!m_deleteAllTimer) { | - |
1853 | m_deleteAllTimer = startTimer(750); | - |
1854 | } | - |
1855 | } else { | - |
1856 | unknown = true; | - |
1857 | } | - |
1858 | break; | - |
1859 | #endif | - |
1860 | default: | - |
1861 | if (!handled) partially evaluated: !handled yes Evaluation Count:1612 | no Evaluation Count:0 |
| 0-1612 |
1862 | unknown = true; executed: unknown = true; Execution Count:1612 | 1612 |
1863 | } executed: } Execution Count:1612 | 1612 |
1864 | } executed: } Execution Count:1665 | 1665 |
1865 | } | - |
1866 | | - |
1867 | if (event->key() == Qt::Key_Direction_L || event->key() == Qt::Key_Direction_R) { partially evaluated: event->key() == Qt::Key_Direction_L no Evaluation Count:0 | yes Evaluation Count:2352 |
partially evaluated: event->key() == Qt::Key_Direction_R no Evaluation Count:0 | yes Evaluation Count:2352 |
| 0-2352 |
1868 | setLayoutDirection((event->key() == Qt::Key_Direction_L) ? Qt::LeftToRight : Qt::RightToLeft); never executed (the execution status of this line is deduced): setLayoutDirection((event->key() == Qt::Key_Direction_L) ? Qt::LeftToRight : Qt::RightToLeft); | - |
1869 | unknown = false; never executed (the execution status of this line is deduced): unknown = false; | - |
1870 | } | 0 |
1871 | | - |
1872 | if (unknown && !isReadOnly()) { evaluated: unknown yes Evaluation Count:1640 | yes Evaluation Count:712 |
evaluated: !isReadOnly() yes Evaluation Count:1606 | yes Evaluation Count:34 |
| 34-1640 |
1873 | QString t = event->text(); executed (the execution status of this line is deduced): QString t = event->text(); | - |
1874 | if (!t.isEmpty() && t.at(0).isPrint()) { evaluated: !t.isEmpty() yes Evaluation Count:1519 | yes Evaluation Count:87 |
evaluated: t.at(0).isPrint() yes Evaluation Count:1517 | yes Evaluation Count:2 |
| 2-1519 |
1875 | insert(t); executed (the execution status of this line is deduced): insert(t); | - |
1876 | #ifndef QT_NO_COMPLETER | - |
1877 | complete(event->key()); executed (the execution status of this line is deduced): complete(event->key()); | - |
1878 | #endif | - |
1879 | event->accept(); executed (the execution status of this line is deduced): event->accept(); | - |
1880 | return; executed: return; Execution Count:1517 | 1517 |
1881 | } | - |
1882 | } executed: } Execution Count:89 | 89 |
1883 | | - |
1884 | if (unknown) evaluated: unknown yes Evaluation Count:123 | yes Evaluation Count:712 |
| 123-712 |
1885 | event->ignore(); executed: event->ignore(); Execution Count:123 | 123 |
1886 | else | - |
1887 | event->accept(); executed: event->accept(); Execution Count:712 | 712 |
1888 | } | - |
1889 | | - |
1890 | bool QWidgetLineControl::isUndoAvailable() const | - |
1891 | { | - |
1892 | // For security reasons undo is not available in any password mode (NoEcho included) | - |
1893 | // with the exception that the user can clear the password with undo. | - |
1894 | return !m_readOnly && m_undoState executed: return !m_readOnly && m_undoState && (m_echoMode == QLineEdit::Normal || m_history[m_undoState - 1].type == QWidgetLineControl::Insert); Execution Count:376 | 376 |
1895 | && (m_echoMode == QLineEdit::Normal || m_history[m_undoState - 1].type == QWidgetLineControl::Insert); executed: return !m_readOnly && m_undoState && (m_echoMode == QLineEdit::Normal || m_history[m_undoState - 1].type == QWidgetLineControl::Insert); Execution Count:376 | 376 |
1896 | } | - |
1897 | | - |
1898 | bool QWidgetLineControl::isRedoAvailable() const | - |
1899 | { | - |
1900 | // Same as with undo. Disabled for password modes. | - |
1901 | return !m_readOnly executed: return !m_readOnly && m_echoMode == QLineEdit::Normal && m_undoState < m_history.size(); Execution Count:44 | 44 |
1902 | && m_echoMode == QLineEdit::Normal executed: return !m_readOnly && m_echoMode == QLineEdit::Normal && m_undoState < m_history.size(); Execution Count:44 | 44 |
1903 | && m_undoState < m_history.size(); executed: return !m_readOnly && m_echoMode == QLineEdit::Normal && m_undoState < m_history.size(); Execution Count:44 | 44 |
1904 | } | - |
1905 | | - |
1906 | QT_END_NAMESPACE | - |
1907 | | - |
1908 | #endif | - |
1909 | | - |
| | |