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 "qplaintextedit_p.h" | - |
43 | | - |
44 | | - |
45 | #include <qfont.h> | - |
46 | #include <qpainter.h> | - |
47 | #include <qevent.h> | - |
48 | #include <qdebug.h> | - |
49 | #include <qdrag.h> | - |
50 | #include <qclipboard.h> | - |
51 | #include <qmenu.h> | - |
52 | #include <qstyle.h> | - |
53 | #include <qtimer.h> | - |
54 | #include "private/qtextdocumentlayout_p.h" | - |
55 | #include "private/qabstracttextdocumentlayout_p.h" | - |
56 | #include "qtextdocument.h" | - |
57 | #include "private/qtextdocument_p.h" | - |
58 | #include "qtextlist.h" | - |
59 | #include "qaccessible.h" | - |
60 | | - |
61 | #include <qtextformat.h> | - |
62 | #include <qdatetime.h> | - |
63 | #include <qapplication.h> | - |
64 | #include <limits.h> | - |
65 | #include <qtexttable.h> | - |
66 | #include <qvariant.h> | - |
67 | | - |
68 | #ifndef QT_NO_TEXTEDIT | - |
69 | | - |
70 | QT_BEGIN_NAMESPACE | - |
71 | | - |
72 | static inline bool shouldEnableInputMethod(QPlainTextEdit *plaintextedit) | - |
73 | { | - |
74 | return !plaintextedit->isReadOnly(); executed: return !plaintextedit->isReadOnly(); Execution Count:2 | 2 |
75 | } | - |
76 | | - |
77 | class QPlainTextDocumentLayoutPrivate : public QAbstractTextDocumentLayoutPrivate | - |
78 | { | - |
79 | Q_DECLARE_PUBLIC(QPlainTextDocumentLayout) | - |
80 | public: | - |
81 | QPlainTextDocumentLayoutPrivate() { | - |
82 | mainViewPrivate = 0; executed (the execution status of this line is deduced): mainViewPrivate = 0; | - |
83 | width = 0; executed (the execution status of this line is deduced): width = 0; | - |
84 | maximumWidth = 0; executed (the execution status of this line is deduced): maximumWidth = 0; | - |
85 | maximumWidthBlockNumber = 0; executed (the execution status of this line is deduced): maximumWidthBlockNumber = 0; | - |
86 | blockCount = 1; executed (the execution status of this line is deduced): blockCount = 1; | - |
87 | blockUpdate = blockDocumentSizeChanged = false; executed (the execution status of this line is deduced): blockUpdate = blockDocumentSizeChanged = false; | - |
88 | cursorWidth = 1; executed (the execution status of this line is deduced): cursorWidth = 1; | - |
89 | textLayoutFlags = 0; executed (the execution status of this line is deduced): textLayoutFlags = 0; | - |
90 | } executed: } Execution Count:92 | 92 |
91 | | - |
92 | qreal width; | - |
93 | qreal maximumWidth; | - |
94 | int maximumWidthBlockNumber; | - |
95 | int blockCount; | - |
96 | QPlainTextEditPrivate *mainViewPrivate; | - |
97 | bool blockUpdate; | - |
98 | bool blockDocumentSizeChanged; | - |
99 | int cursorWidth; | - |
100 | int textLayoutFlags; | - |
101 | | - |
102 | void layoutBlock(const QTextBlock &block); | - |
103 | qreal blockWidth(const QTextBlock &block); | - |
104 | | - |
105 | void relayout(); | - |
106 | }; | - |
107 | | - |
108 | | - |
109 | | - |
110 | /*! \class QPlainTextDocumentLayout | - |
111 | \since 4.4 | - |
112 | \brief The QPlainTextDocumentLayout class implements a plain text layout for QTextDocument | - |
113 | | - |
114 | \ingroup richtext-processing | - |
115 | \inmodule QtWidgets | - |
116 | | - |
117 | A QPlainTextDocumentLayout is required for text documents that can | - |
118 | be display or edited in a QPlainTextEdit. See | - |
119 | QTextDocument::setDocumentLayout(). | - |
120 | | - |
121 | QPlainTextDocumentLayout uses the QAbstractTextDocumentLayout API | - |
122 | that QTextDocument requires, but redefines it partially in order to | - |
123 | support plain text better. For instances, it does not operate on | - |
124 | vertical pixels, but on paragraphs (called blocks) instead. The | - |
125 | height of a document is identical to the number of paragraphs it | - |
126 | contains. The layout also doesn't support tables or nested frames, | - |
127 | or any sort of advanced text layout that goes beyond a list of | - |
128 | paragraphs with syntax highlighting. | - |
129 | | - |
130 | */ | - |
131 | | - |
132 | | - |
133 | | - |
134 | /*! | - |
135 | Constructs a plain text document layout for the text \a document. | - |
136 | */ | - |
137 | QPlainTextDocumentLayout::QPlainTextDocumentLayout(QTextDocument *document) | - |
138 | :QAbstractTextDocumentLayout(* new QPlainTextDocumentLayoutPrivate, document) { | - |
139 | } executed: } Execution Count:92 | 92 |
140 | /*! | - |
141 | Destructs a plain text document layout. | - |
142 | */ | - |
143 | QPlainTextDocumentLayout::~QPlainTextDocumentLayout() {} | - |
144 | | - |
145 | | - |
146 | /*! | - |
147 | \reimp | - |
148 | */ | - |
149 | void QPlainTextDocumentLayout::draw(QPainter *, const PaintContext &) | - |
150 | { | - |
151 | } | - |
152 | | - |
153 | /*! | - |
154 | \reimp | - |
155 | */ | - |
156 | int QPlainTextDocumentLayout::hitTest(const QPointF &, Qt::HitTestAccuracy ) const | - |
157 | { | - |
158 | // this function is used from | - |
159 | // QAbstractTextDocumentLayout::anchorAt(), but is not | - |
160 | // implementable in a plain text document layout, because the | - |
161 | // layout depends on the top block and top line which depends on | - |
162 | // the view | - |
163 | return -1; never executed: return -1; | 0 |
164 | } | - |
165 | | - |
166 | /*! | - |
167 | \reimp | - |
168 | */ | - |
169 | int QPlainTextDocumentLayout::pageCount() const | - |
170 | { return 1; } never executed: return 1; | 0 |
171 | | - |
172 | /*! | - |
173 | \reimp | - |
174 | */ | - |
175 | QSizeF QPlainTextDocumentLayout::documentSize() const | - |
176 | { | - |
177 | Q_D(const QPlainTextDocumentLayout); executed (the execution status of this line is deduced): const QPlainTextDocumentLayoutPrivate * const d = d_func(); | - |
178 | return QSizeF(d->maximumWidth, document()->lineCount()); executed: return QSizeF(d->maximumWidth, document()->lineCount()); Execution Count:516 | 516 |
179 | } | - |
180 | | - |
181 | /*! | - |
182 | \reimp | - |
183 | */ | - |
184 | QRectF QPlainTextDocumentLayout::frameBoundingRect(QTextFrame *) const | - |
185 | { | - |
186 | Q_D(const QPlainTextDocumentLayout); executed (the execution status of this line is deduced): const QPlainTextDocumentLayoutPrivate * const d = d_func(); | - |
187 | return QRectF(0, 0, qMax(d->width, d->maximumWidth), qreal(INT_MAX)); executed: return QRectF(0, 0, qMax(d->width, d->maximumWidth), qreal(2147483647)); Execution Count:7 | 7 |
188 | } | - |
189 | | - |
190 | /*! | - |
191 | \reimp | - |
192 | */ | - |
193 | QRectF QPlainTextDocumentLayout::blockBoundingRect(const QTextBlock &block) const | - |
194 | { | - |
195 | if (!block.isValid()) { return QRectF(); } never executed: return QRectF(); partially evaluated: !block.isValid() no Evaluation Count:0 | yes Evaluation Count:2896 |
| 0-2896 |
196 | QTextLayout *tl = block.layout(); executed (the execution status of this line is deduced): QTextLayout *tl = block.layout(); | - |
197 | if (!tl->lineCount()) evaluated: !tl->lineCount() yes Evaluation Count:453 | yes Evaluation Count:2443 |
| 453-2443 |
198 | const_cast<QPlainTextDocumentLayout*>(this)->layoutBlock(block); executed: const_cast<QPlainTextDocumentLayout*>(this)->layoutBlock(block); Execution Count:453 | 453 |
199 | QRectF br; executed (the execution status of this line is deduced): QRectF br; | - |
200 | if (block.isVisible()) { partially evaluated: block.isVisible() yes Evaluation Count:2896 | no Evaluation Count:0 |
| 0-2896 |
201 | br = QRectF(QPointF(0, 0), tl->boundingRect().bottomRight()); executed (the execution status of this line is deduced): br = QRectF(QPointF(0, 0), tl->boundingRect().bottomRight()); | - |
202 | if (tl->lineCount() == 1) evaluated: tl->lineCount() == 1 yes Evaluation Count:2758 | yes Evaluation Count:138 |
| 138-2758 |
203 | br.setWidth(qMax(br.width(), tl->lineAt(0).naturalTextWidth())); executed: br.setWidth(qMax(br.width(), tl->lineAt(0).naturalTextWidth())); Execution Count:2758 | 2758 |
204 | qreal margin = document()->documentMargin(); executed (the execution status of this line is deduced): qreal margin = document()->documentMargin(); | - |
205 | br.adjust(0, 0, margin, 0); executed (the execution status of this line is deduced): br.adjust(0, 0, margin, 0); | - |
206 | if (!block.next().isValid()) evaluated: !block.next().isValid() yes Evaluation Count:1939 | yes Evaluation Count:957 |
| 957-1939 |
207 | br.adjust(0, 0, 0, margin); executed: br.adjust(0, 0, 0, margin); Execution Count:1939 | 1939 |
208 | } executed: } Execution Count:2896 | 2896 |
209 | return br; executed: return br; Execution Count:2896 | 2896 |
210 | | - |
211 | } | - |
212 | | - |
213 | /*! | - |
214 | Ensures that \a block has a valid layout | - |
215 | */ | - |
216 | void QPlainTextDocumentLayout::ensureBlockLayout(const QTextBlock &block) const | - |
217 | { | - |
218 | if (!block.isValid()) never evaluated: !block.isValid() | 0 |
219 | return; | 0 |
220 | QTextLayout *tl = block.layout(); never executed (the execution status of this line is deduced): QTextLayout *tl = block.layout(); | - |
221 | if (!tl->lineCount()) never evaluated: !tl->lineCount() | 0 |
222 | const_cast<QPlainTextDocumentLayout*>(this)->layoutBlock(block); never executed: const_cast<QPlainTextDocumentLayout*>(this)->layoutBlock(block); | 0 |
223 | } | 0 |
224 | | - |
225 | | - |
226 | /*! \property QPlainTextDocumentLayout::cursorWidth | - |
227 | | - |
228 | This property specifies the width of the cursor in pixels. The default value is 1. | - |
229 | */ | - |
230 | void QPlainTextDocumentLayout::setCursorWidth(int width) | - |
231 | { | - |
232 | Q_D(QPlainTextDocumentLayout); never executed (the execution status of this line is deduced): QPlainTextDocumentLayoutPrivate * const d = d_func(); | - |
233 | d->cursorWidth = width; never executed (the execution status of this line is deduced): d->cursorWidth = width; | - |
234 | } | 0 |
235 | | - |
236 | int QPlainTextDocumentLayout::cursorWidth() const | - |
237 | { | - |
238 | Q_D(const QPlainTextDocumentLayout); executed (the execution status of this line is deduced): const QPlainTextDocumentLayoutPrivate * const d = d_func(); | - |
239 | return d->cursorWidth; executed: return d->cursorWidth; Execution Count:850 | 850 |
240 | } | - |
241 | | - |
242 | QPlainTextDocumentLayoutPrivate *QPlainTextDocumentLayout::priv() const | - |
243 | { | - |
244 | Q_D(const QPlainTextDocumentLayout); executed (the execution status of this line is deduced): const QPlainTextDocumentLayoutPrivate * const d = d_func(); | - |
245 | return const_cast<QPlainTextDocumentLayoutPrivate*>(d); executed: return const_cast<QPlainTextDocumentLayoutPrivate*>(d); Execution Count:861 | 861 |
246 | } | - |
247 | | - |
248 | | - |
249 | /*! | - |
250 | | - |
251 | Requests a complete update on all views. | - |
252 | */ | - |
253 | void QPlainTextDocumentLayout::requestUpdate() | - |
254 | { | - |
255 | emit update(QRectF(0., -document()->documentMargin(), 1000000000., 1000000000.)); never executed (the execution status of this line is deduced): update(QRectF(0., -document()->documentMargin(), 1000000000., 1000000000.)); | - |
256 | } | 0 |
257 | | - |
258 | | - |
259 | void QPlainTextDocumentLayout::setTextWidth(qreal newWidth) | - |
260 | { | - |
261 | Q_D(QPlainTextDocumentLayout); executed (the execution status of this line is deduced): QPlainTextDocumentLayoutPrivate * const d = d_func(); | - |
262 | d->width = d->maximumWidth = newWidth; executed (the execution status of this line is deduced): d->width = d->maximumWidth = newWidth; | - |
263 | d->relayout(); executed (the execution status of this line is deduced): d->relayout(); | - |
264 | } executed: } Execution Count:31 | 31 |
265 | | - |
266 | qreal QPlainTextDocumentLayout::textWidth() const | - |
267 | { | - |
268 | Q_D(const QPlainTextDocumentLayout); never executed (the execution status of this line is deduced): const QPlainTextDocumentLayoutPrivate * const d = d_func(); | - |
269 | return d->width; never executed: return d->width; | 0 |
270 | } | - |
271 | | - |
272 | void QPlainTextDocumentLayoutPrivate::relayout() | - |
273 | { | - |
274 | Q_Q(QPlainTextDocumentLayout); executed (the execution status of this line is deduced): QPlainTextDocumentLayout * const q = q_func(); | - |
275 | QTextBlock block = q->document()->firstBlock(); executed (the execution status of this line is deduced): QTextBlock block = q->document()->firstBlock(); | - |
276 | while (block.isValid()) { evaluated: block.isValid() yes Evaluation Count:833 | yes Evaluation Count:31 |
| 31-833 |
277 | block.layout()->clearLayout(); executed (the execution status of this line is deduced): block.layout()->clearLayout(); | - |
278 | block.setLineCount(block.isVisible() ? 1 : 0); executed (the execution status of this line is deduced): block.setLineCount(block.isVisible() ? 1 : 0); | - |
279 | block = block.next(); executed (the execution status of this line is deduced): block = block.next(); | - |
280 | } executed: } Execution Count:833 | 833 |
281 | emit q->update(); executed (the execution status of this line is deduced): q->update(); | - |
282 | } executed: } Execution Count:31 | 31 |
283 | | - |
284 | | - |
285 | /*! \reimp | - |
286 | */ | - |
287 | void QPlainTextDocumentLayout::documentChanged(int from, int /*charsRemoved*/, int charsAdded) | - |
288 | { | - |
289 | Q_D(QPlainTextDocumentLayout); executed (the execution status of this line is deduced): QPlainTextDocumentLayoutPrivate * const d = d_func(); | - |
290 | QTextDocument *doc = document(); executed (the execution status of this line is deduced): QTextDocument *doc = document(); | - |
291 | int newBlockCount = doc->blockCount(); executed (the execution status of this line is deduced): int newBlockCount = doc->blockCount(); | - |
292 | | - |
293 | QTextBlock changeStartBlock = doc->findBlock(from); executed (the execution status of this line is deduced): QTextBlock changeStartBlock = doc->findBlock(from); | - |
294 | QTextBlock changeEndBlock = doc->findBlock(qMax(0, from + charsAdded - 1)); executed (the execution status of this line is deduced): QTextBlock changeEndBlock = doc->findBlock(qMax(0, from + charsAdded - 1)); | - |
295 | | - |
296 | if (changeStartBlock == changeEndBlock && newBlockCount == d->blockCount) { evaluated: changeStartBlock == changeEndBlock yes Evaluation Count:530 | yes Evaluation Count:23 |
evaluated: newBlockCount == d->blockCount yes Evaluation Count:515 | yes Evaluation Count:15 |
| 15-530 |
297 | QTextBlock block = changeStartBlock; executed (the execution status of this line is deduced): QTextBlock block = changeStartBlock; | - |
298 | int blockLineCount = block.layout()->lineCount(); executed (the execution status of this line is deduced): int blockLineCount = block.layout()->lineCount(); | - |
299 | if (block.isValid() && blockLineCount) { partially evaluated: block.isValid() yes Evaluation Count:515 | no Evaluation Count:0 |
evaluated: blockLineCount yes Evaluation Count:335 | yes Evaluation Count:180 |
| 0-515 |
300 | QRectF oldBr = blockBoundingRect(block); executed (the execution status of this line is deduced): QRectF oldBr = blockBoundingRect(block); | - |
301 | layoutBlock(block); executed (the execution status of this line is deduced): layoutBlock(block); | - |
302 | QRectF newBr = blockBoundingRect(block); executed (the execution status of this line is deduced): QRectF newBr = blockBoundingRect(block); | - |
303 | if (newBr.height() == oldBr.height()) { evaluated: newBr.height() == oldBr.height() yes Evaluation Count:331 | yes Evaluation Count:4 |
| 4-331 |
304 | if (!d->blockUpdate) partially evaluated: !d->blockUpdate yes Evaluation Count:331 | no Evaluation Count:0 |
| 0-331 |
305 | emit updateBlock(block); executed: updateBlock(block); Execution Count:331 | 331 |
306 | return; executed: return; Execution Count:331 | 331 |
307 | } | - |
308 | } executed: } Execution Count:4 | 4 |
309 | } else { executed: } Execution Count:184 | 184 |
310 | QTextBlock block = changeStartBlock; executed (the execution status of this line is deduced): QTextBlock block = changeStartBlock; | - |
311 | do { | - |
312 | block.clearLayout(); executed (the execution status of this line is deduced): block.clearLayout(); | - |
313 | if (block == changeEndBlock) evaluated: block == changeEndBlock yes Evaluation Count:34 | yes Evaluation Count:2839 |
| 34-2839 |
314 | break; executed: break; Execution Count:34 | 34 |
315 | block = block.next(); executed (the execution status of this line is deduced): block = block.next(); | - |
316 | } while(block.isValid()); executed: } Execution Count:2839 evaluated: block.isValid() yes Evaluation Count:2835 | yes Evaluation Count:4 |
| 4-2839 |
317 | } executed: } Execution Count:38 | 38 |
318 | | - |
319 | if (newBlockCount != d->blockCount) { evaluated: newBlockCount != d->blockCount yes Evaluation Count:36 | yes Evaluation Count:186 |
| 36-186 |
320 | | - |
321 | int changeEnd = changeEndBlock.blockNumber(); executed (the execution status of this line is deduced): int changeEnd = changeEndBlock.blockNumber(); | - |
322 | int blockDiff = newBlockCount - d->blockCount; executed (the execution status of this line is deduced): int blockDiff = newBlockCount - d->blockCount; | - |
323 | int oldChangeEnd = changeEnd - blockDiff; executed (the execution status of this line is deduced): int oldChangeEnd = changeEnd - blockDiff; | - |
324 | | - |
325 | if (d->maximumWidthBlockNumber > oldChangeEnd) evaluated: d->maximumWidthBlockNumber > oldChangeEnd yes Evaluation Count:16 | yes Evaluation Count:20 |
| 16-20 |
326 | d->maximumWidthBlockNumber += blockDiff; executed: d->maximumWidthBlockNumber += blockDiff; Execution Count:16 | 16 |
327 | | - |
328 | d->blockCount = newBlockCount; executed (the execution status of this line is deduced): d->blockCount = newBlockCount; | - |
329 | if (d->blockCount == 1) evaluated: d->blockCount == 1 yes Evaluation Count:3 | yes Evaluation Count:33 |
| 3-33 |
330 | d->maximumWidth = blockWidth(doc->firstBlock()); executed: d->maximumWidth = blockWidth(doc->firstBlock()); Execution Count:3 | 3 |
331 | | - |
332 | if (!d->blockDocumentSizeChanged) evaluated: !d->blockDocumentSizeChanged yes Evaluation Count:27 | yes Evaluation Count:9 |
| 9-27 |
333 | emit documentSizeChanged(documentSize()); executed: documentSizeChanged(documentSize()); Execution Count:27 | 27 |
334 | | - |
335 | if (blockDiff == 1 && changeEnd == newBlockCount -1 ) { evaluated: blockDiff == 1 yes Evaluation Count:23 | yes Evaluation Count:13 |
evaluated: changeEnd == newBlockCount -1 yes Evaluation Count:12 | yes Evaluation Count:11 |
| 11-23 |
336 | if (!d->blockUpdate) { partially evaluated: !d->blockUpdate yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-12 |
337 | QTextBlock b = changeStartBlock; executed (the execution status of this line is deduced): QTextBlock b = changeStartBlock; | - |
338 | for(;;) { executed (the execution status of this line is deduced): for(;;) { | - |
339 | emit updateBlock(b); executed (the execution status of this line is deduced): updateBlock(b); | - |
340 | if (b == changeEndBlock) evaluated: b == changeEndBlock yes Evaluation Count:12 | yes Evaluation Count:12 |
| 12 |
341 | break; executed: break; Execution Count:12 | 12 |
342 | b = b.next(); executed (the execution status of this line is deduced): b = b.next(); | - |
343 | } executed: } Execution Count:12 | 12 |
344 | } executed: } Execution Count:12 | 12 |
345 | return; executed: return; Execution Count:12 | 12 |
346 | } | - |
347 | } executed: } Execution Count:24 | 24 |
348 | | - |
349 | if (!d->blockUpdate) partially evaluated: !d->blockUpdate yes Evaluation Count:210 | no Evaluation Count:0 |
| 0-210 |
350 | emit update(QRectF(0., -doc->documentMargin(), 1000000000., 1000000000.)); // optimization potential executed: update(QRectF(0., -doc->documentMargin(), 1000000000., 1000000000.)); Execution Count:210 | 210 |
351 | } executed: } Execution Count:210 | 210 |
352 | | - |
353 | | - |
354 | void QPlainTextDocumentLayout::layoutBlock(const QTextBlock &block) | - |
355 | { | - |
356 | Q_D(QPlainTextDocumentLayout); executed (the execution status of this line is deduced): QPlainTextDocumentLayoutPrivate * const d = d_func(); | - |
357 | QTextDocument *doc = document(); executed (the execution status of this line is deduced): QTextDocument *doc = document(); | - |
358 | qreal margin = doc->documentMargin(); executed (the execution status of this line is deduced): qreal margin = doc->documentMargin(); | - |
359 | qreal blockMaximumWidth = 0; executed (the execution status of this line is deduced): qreal blockMaximumWidth = 0; | - |
360 | | - |
361 | qreal height = 0; executed (the execution status of this line is deduced): qreal height = 0; | - |
362 | QTextLayout *tl = block.layout(); executed (the execution status of this line is deduced): QTextLayout *tl = block.layout(); | - |
363 | QTextOption option = doc->defaultTextOption(); executed (the execution status of this line is deduced): QTextOption option = doc->defaultTextOption(); | - |
364 | tl->setTextOption(option); executed (the execution status of this line is deduced): tl->setTextOption(option); | - |
365 | | - |
366 | int extraMargin = 0; executed (the execution status of this line is deduced): int extraMargin = 0; | - |
367 | if (option.flags() & QTextOption::AddSpaceForLineAndParagraphSeparators) { partially evaluated: option.flags() & QTextOption::AddSpaceForLineAndParagraphSeparators no Evaluation Count:0 | yes Evaluation Count:788 |
| 0-788 |
368 | QFontMetrics fm(block.charFormat().font()); never executed (the execution status of this line is deduced): QFontMetrics fm(block.charFormat().font()); | - |
369 | extraMargin += fm.width(QChar(0x21B5)); never executed (the execution status of this line is deduced): extraMargin += fm.width(QChar(0x21B5)); | - |
370 | } | 0 |
371 | tl->beginLayout(); executed (the execution status of this line is deduced): tl->beginLayout(); | - |
372 | qreal availableWidth = d->width; executed (the execution status of this line is deduced): qreal availableWidth = d->width; | - |
373 | if (availableWidth <= 0) { evaluated: availableWidth <= 0 yes Evaluation Count:668 | yes Evaluation Count:120 |
| 120-668 |
374 | availableWidth = qreal(INT_MAX); // similar to text edit with pageSize.width == 0 executed (the execution status of this line is deduced): availableWidth = qreal(2147483647); | - |
375 | } executed: } Execution Count:668 | 668 |
376 | availableWidth -= 2*margin + extraMargin; executed (the execution status of this line is deduced): availableWidth -= 2*margin + extraMargin; | - |
377 | while (1) { partially evaluated: 1 yes Evaluation Count:1675 | no Evaluation Count:0 |
| 0-1675 |
378 | QTextLine line = tl->createLine(); executed (the execution status of this line is deduced): QTextLine line = tl->createLine(); | - |
379 | if (!line.isValid()) evaluated: !line.isValid() yes Evaluation Count:788 | yes Evaluation Count:887 |
| 788-887 |
380 | break; executed: break; Execution Count:788 | 788 |
381 | line.setLeadingIncluded(true); executed (the execution status of this line is deduced): line.setLeadingIncluded(true); | - |
382 | line.setLineWidth(availableWidth); executed (the execution status of this line is deduced): line.setLineWidth(availableWidth); | - |
383 | line.setPosition(QPointF(margin, height)); executed (the execution status of this line is deduced): line.setPosition(QPointF(margin, height)); | - |
384 | height += line.height(); executed (the execution status of this line is deduced): height += line.height(); | - |
385 | blockMaximumWidth = qMax(blockMaximumWidth, line.naturalTextWidth() + 2*margin); executed (the execution status of this line is deduced): blockMaximumWidth = qMax(blockMaximumWidth, line.naturalTextWidth() + 2*margin); | - |
386 | } executed: } Execution Count:887 | 887 |
387 | tl->endLayout(); executed (the execution status of this line is deduced): tl->endLayout(); | - |
388 | | - |
389 | int previousLineCount = doc->lineCount(); executed (the execution status of this line is deduced): int previousLineCount = doc->lineCount(); | - |
390 | const_cast<QTextBlock&>(block).setLineCount(block.isVisible() ? tl->lineCount() : 0); executed (the execution status of this line is deduced): const_cast<QTextBlock&>(block).setLineCount(block.isVisible() ? tl->lineCount() : 0); | - |
391 | int lineCount = doc->lineCount(); executed (the execution status of this line is deduced): int lineCount = doc->lineCount(); | - |
392 | | - |
393 | bool emitDocumentSizeChanged = previousLineCount != lineCount; executed (the execution status of this line is deduced): bool emitDocumentSizeChanged = previousLineCount != lineCount; | - |
394 | if (blockMaximumWidth > d->maximumWidth) { evaluated: blockMaximumWidth > d->maximumWidth yes Evaluation Count:231 | yes Evaluation Count:557 |
| 231-557 |
395 | // new longest line | - |
396 | d->maximumWidth = blockMaximumWidth; executed (the execution status of this line is deduced): d->maximumWidth = blockMaximumWidth; | - |
397 | d->maximumWidthBlockNumber = block.blockNumber(); executed (the execution status of this line is deduced): d->maximumWidthBlockNumber = block.blockNumber(); | - |
398 | emitDocumentSizeChanged = true; executed (the execution status of this line is deduced): emitDocumentSizeChanged = true; | - |
399 | } else if (block.blockNumber() == d->maximumWidthBlockNumber && blockMaximumWidth < d->maximumWidth) { executed: } Execution Count:231 evaluated: block.blockNumber() == d->maximumWidthBlockNumber yes Evaluation Count:307 | yes Evaluation Count:250 |
evaluated: blockMaximumWidth < d->maximumWidth yes Evaluation Count:40 | yes Evaluation Count:267 |
| 40-307 |
400 | // longest line shrinking | - |
401 | QTextBlock b = doc->firstBlock(); executed (the execution status of this line is deduced): QTextBlock b = doc->firstBlock(); | - |
402 | d->maximumWidth = 0; executed (the execution status of this line is deduced): d->maximumWidth = 0; | - |
403 | QTextBlock maximumBlock; executed (the execution status of this line is deduced): QTextBlock maximumBlock; | - |
404 | while (b.isValid()) { evaluated: b.isValid() yes Evaluation Count:854 | yes Evaluation Count:40 |
| 40-854 |
405 | qreal blockMaximumWidth = blockWidth(b); executed (the execution status of this line is deduced): qreal blockMaximumWidth = blockWidth(b); | - |
406 | if (blockMaximumWidth > d->maximumWidth) { evaluated: blockMaximumWidth > d->maximumWidth yes Evaluation Count:40 | yes Evaluation Count:814 |
| 40-814 |
407 | d->maximumWidth = blockMaximumWidth; executed (the execution status of this line is deduced): d->maximumWidth = blockMaximumWidth; | - |
408 | maximumBlock = b; executed (the execution status of this line is deduced): maximumBlock = b; | - |
409 | } executed: } Execution Count:40 | 40 |
410 | b = b.next(); executed (the execution status of this line is deduced): b = b.next(); | - |
411 | } executed: } Execution Count:854 | 854 |
412 | if (maximumBlock.isValid()) { partially evaluated: maximumBlock.isValid() yes Evaluation Count:40 | no Evaluation Count:0 |
| 0-40 |
413 | d->maximumWidthBlockNumber = maximumBlock.blockNumber(); executed (the execution status of this line is deduced): d->maximumWidthBlockNumber = maximumBlock.blockNumber(); | - |
414 | emitDocumentSizeChanged = true; executed (the execution status of this line is deduced): emitDocumentSizeChanged = true; | - |
415 | } executed: } Execution Count:40 | 40 |
416 | } executed: } Execution Count:40 | 40 |
417 | if (emitDocumentSizeChanged && !d->blockDocumentSizeChanged) evaluated: emitDocumentSizeChanged yes Evaluation Count:285 | yes Evaluation Count:503 |
evaluated: !d->blockDocumentSizeChanged yes Evaluation Count:249 | yes Evaluation Count:36 |
| 36-503 |
418 | emit documentSizeChanged(documentSize()); executed: documentSizeChanged(documentSize()); Execution Count:249 | 249 |
419 | } executed: } Execution Count:788 | 788 |
420 | | - |
421 | qreal QPlainTextDocumentLayout::blockWidth(const QTextBlock &block) | - |
422 | { | - |
423 | QTextLayout *layout = block.layout(); executed (the execution status of this line is deduced): QTextLayout *layout = block.layout(); | - |
424 | if (!layout->lineCount()) evaluated: !layout->lineCount() yes Evaluation Count:784 | yes Evaluation Count:73 |
| 73-784 |
425 | return 0; // only for layouted blocks executed: return 0; Execution Count:784 | 784 |
426 | qreal blockWidth = 0; executed (the execution status of this line is deduced): qreal blockWidth = 0; | - |
427 | for (int i = 0; i < layout->lineCount(); ++i) { evaluated: i < layout->lineCount() yes Evaluation Count:75 | yes Evaluation Count:73 |
| 73-75 |
428 | QTextLine line = layout->lineAt(i); executed (the execution status of this line is deduced): QTextLine line = layout->lineAt(i); | - |
429 | blockWidth = qMax(line.naturalTextWidth() + 8, blockWidth); executed (the execution status of this line is deduced): blockWidth = qMax(line.naturalTextWidth() + 8, blockWidth); | - |
430 | } executed: } Execution Count:75 | 75 |
431 | return blockWidth; executed: return blockWidth; Execution Count:73 | 73 |
432 | } | - |
433 | | - |
434 | | - |
435 | QPlainTextEditControl::QPlainTextEditControl(QPlainTextEdit *parent) | - |
436 | : QWidgetTextControl(parent), textEdit(parent), | - |
437 | topBlock(0) | - |
438 | { | - |
439 | setAcceptRichText(false); executed (the execution status of this line is deduced): setAcceptRichText(false); | - |
440 | } executed: } Execution Count:87 | 87 |
441 | | - |
442 | void QPlainTextEditPrivate::_q_cursorPositionChanged() | - |
443 | { | - |
444 | pageUpDownLastCursorYIsValid = false; executed (the execution status of this line is deduced): pageUpDownLastCursorYIsValid = false; | - |
445 | Q_Q(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEdit * const q = q_func(); | - |
446 | #ifndef QT_NO_ACCESSIBILITY | - |
447 | QAccessibleTextCursorEvent ev(q, q->textCursor().position()); executed (the execution status of this line is deduced): QAccessibleTextCursorEvent ev(q, q->textCursor().position()); | - |
448 | QAccessible::updateAccessibility(&ev); executed (the execution status of this line is deduced): QAccessible::updateAccessibility(&ev); | - |
449 | #endif | - |
450 | emit q->cursorPositionChanged(); executed (the execution status of this line is deduced): q->cursorPositionChanged(); | - |
451 | } executed: } Execution Count:250 | 250 |
452 | | - |
453 | void QPlainTextEditPrivate::_q_verticalScrollbarActionTriggered(int action) { | - |
454 | if (action == QAbstractSlider::SliderPageStepAdd) { never evaluated: action == QAbstractSlider::SliderPageStepAdd | 0 |
455 | pageUpDown(QTextCursor::Down, QTextCursor::MoveAnchor, false); never executed (the execution status of this line is deduced): pageUpDown(QTextCursor::Down, QTextCursor::MoveAnchor, false); | - |
456 | } else if (action == QAbstractSlider::SliderPageStepSub) { never executed: } never evaluated: action == QAbstractSlider::SliderPageStepSub | 0 |
457 | pageUpDown(QTextCursor::Up, QTextCursor::MoveAnchor, false); never executed (the execution status of this line is deduced): pageUpDown(QTextCursor::Up, QTextCursor::MoveAnchor, false); | - |
458 | } | 0 |
459 | } | - |
460 | | - |
461 | QMimeData *QPlainTextEditControl::createMimeDataFromSelection() const { | - |
462 | QPlainTextEdit *ed = qobject_cast<QPlainTextEdit *>(parent()); executed (the execution status of this line is deduced): QPlainTextEdit *ed = qobject_cast<QPlainTextEdit *>(parent()); | - |
463 | if (!ed) partially evaluated: !ed no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
464 | return QWidgetTextControl::createMimeDataFromSelection(); never executed: return QWidgetTextControl::createMimeDataFromSelection(); | 0 |
465 | return ed->createMimeDataFromSelection(); executed: return ed->createMimeDataFromSelection(); Execution Count:7 | 7 |
466 | } | - |
467 | bool QPlainTextEditControl::canInsertFromMimeData(const QMimeData *source) const { | - |
468 | QPlainTextEdit *ed = qobject_cast<QPlainTextEdit *>(parent()); executed (the execution status of this line is deduced): QPlainTextEdit *ed = qobject_cast<QPlainTextEdit *>(parent()); | - |
469 | if (!ed) partially evaluated: !ed no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
470 | return QWidgetTextControl::canInsertFromMimeData(source); never executed: return QWidgetTextControl::canInsertFromMimeData(source); | 0 |
471 | return ed->canInsertFromMimeData(source); executed: return ed->canInsertFromMimeData(source); Execution Count:9 | 9 |
472 | } | - |
473 | void QPlainTextEditControl::insertFromMimeData(const QMimeData *source) { | - |
474 | QPlainTextEdit *ed = qobject_cast<QPlainTextEdit *>(parent()); executed (the execution status of this line is deduced): QPlainTextEdit *ed = qobject_cast<QPlainTextEdit *>(parent()); | - |
475 | if (!ed) partially evaluated: !ed no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
476 | QWidgetTextControl::insertFromMimeData(source); never executed: QWidgetTextControl::insertFromMimeData(source); | 0 |
477 | else | - |
478 | ed->insertFromMimeData(source); executed: ed->insertFromMimeData(source); Execution Count:3 | 3 |
479 | } | - |
480 | | - |
481 | qreal QPlainTextEditPrivate::verticalOffset(int topBlock, int topLine) const | - |
482 | { | - |
483 | qreal offset = 0; executed (the execution status of this line is deduced): qreal offset = 0; | - |
484 | QTextDocument *doc = control->document(); executed (the execution status of this line is deduced): QTextDocument *doc = control->document(); | - |
485 | | - |
486 | if (topLine) { evaluated: topLine yes Evaluation Count:7 | yes Evaluation Count:1476 |
| 7-1476 |
487 | QTextBlock currentBlock = doc->findBlockByNumber(topBlock); executed (the execution status of this line is deduced): QTextBlock currentBlock = doc->findBlockByNumber(topBlock); | - |
488 | QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(doc->documentLayout()); executed (the execution status of this line is deduced): QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(doc->documentLayout()); | - |
489 | Q_ASSERT(documentLayout); executed (the execution status of this line is deduced): qt_noop(); | - |
490 | QRectF r = documentLayout->blockBoundingRect(currentBlock); executed (the execution status of this line is deduced): QRectF r = documentLayout->blockBoundingRect(currentBlock); | - |
491 | Q_UNUSED(r); executed (the execution status of this line is deduced): (void)r;; | - |
492 | QTextLayout *layout = currentBlock.layout(); executed (the execution status of this line is deduced): QTextLayout *layout = currentBlock.layout(); | - |
493 | if (layout && topLine <= layout->lineCount()) { partially evaluated: layout yes Evaluation Count:7 | no Evaluation Count:0 |
partially evaluated: topLine <= layout->lineCount() yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
494 | QTextLine line = layout->lineAt(topLine - 1); executed (the execution status of this line is deduced): QTextLine line = layout->lineAt(topLine - 1); | - |
495 | const QRectF lr = line.naturalTextRect(); executed (the execution status of this line is deduced): const QRectF lr = line.naturalTextRect(); | - |
496 | offset = lr.bottom(); executed (the execution status of this line is deduced): offset = lr.bottom(); | - |
497 | } executed: } Execution Count:7 | 7 |
498 | } executed: } Execution Count:7 | 7 |
499 | if (topBlock == 0 && topLine == 0) evaluated: topBlock == 0 yes Evaluation Count:1452 | yes Evaluation Count:31 |
evaluated: topLine == 0 yes Evaluation Count:1451 | yes Evaluation Count:1 |
| 1-1452 |
500 | offset -= doc->documentMargin(); // top margin executed: offset -= doc->documentMargin(); Execution Count:1451 | 1451 |
501 | return offset; executed: return offset; Execution Count:1483 | 1483 |
502 | } | - |
503 | | - |
504 | | - |
505 | qreal QPlainTextEditPrivate::verticalOffset() const { | - |
506 | return verticalOffset(control->topBlock, topLine) + topLineFracture; executed: return verticalOffset(control->topBlock, topLine) + topLineFracture; Execution Count:1461 | 1461 |
507 | } | - |
508 | | - |
509 | | - |
510 | QTextBlock QPlainTextEditControl::firstVisibleBlock() const | - |
511 | { | - |
512 | return document()->findBlockByNumber(topBlock); executed: return document()->findBlockByNumber(topBlock); Execution Count:239 | 239 |
513 | } | - |
514 | | - |
515 | | - |
516 | | - |
517 | int QPlainTextEditControl::hitTest(const QPointF &point, Qt::HitTestAccuracy ) const { | - |
518 | int currentBlockNumber = topBlock; never executed (the execution status of this line is deduced): int currentBlockNumber = topBlock; | - |
519 | QTextBlock currentBlock = document()->findBlockByNumber(currentBlockNumber); never executed (the execution status of this line is deduced): QTextBlock currentBlock = document()->findBlockByNumber(currentBlockNumber); | - |
520 | if (!currentBlock.isValid()) never evaluated: !currentBlock.isValid() | 0 |
521 | return -1; never executed: return -1; | 0 |
522 | | - |
523 | QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(document()->documentLayout()); never executed (the execution status of this line is deduced): QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(document()->documentLayout()); | - |
524 | Q_ASSERT(documentLayout); never executed (the execution status of this line is deduced): qt_noop(); | - |
525 | | - |
526 | QPointF offset; never executed (the execution status of this line is deduced): QPointF offset; | - |
527 | QRectF r = documentLayout->blockBoundingRect(currentBlock); never executed (the execution status of this line is deduced): QRectF r = documentLayout->blockBoundingRect(currentBlock); | - |
528 | while (currentBlock.next().isValid() && r.bottom() + offset.y() <= point.y()) { never evaluated: currentBlock.next().isValid() never evaluated: r.bottom() + offset.y() <= point.y() | 0 |
529 | offset.ry() += r.height(); never executed (the execution status of this line is deduced): offset.ry() += r.height(); | - |
530 | currentBlock = currentBlock.next(); never executed (the execution status of this line is deduced): currentBlock = currentBlock.next(); | - |
531 | ++currentBlockNumber; never executed (the execution status of this line is deduced): ++currentBlockNumber; | - |
532 | r = documentLayout->blockBoundingRect(currentBlock); never executed (the execution status of this line is deduced): r = documentLayout->blockBoundingRect(currentBlock); | - |
533 | } | 0 |
534 | while (currentBlock.previous().isValid() && r.top() + offset.y() > point.y()) { never evaluated: currentBlock.previous().isValid() never evaluated: r.top() + offset.y() > point.y() | 0 |
535 | offset.ry() -= r.height(); never executed (the execution status of this line is deduced): offset.ry() -= r.height(); | - |
536 | currentBlock = currentBlock.previous(); never executed (the execution status of this line is deduced): currentBlock = currentBlock.previous(); | - |
537 | --currentBlockNumber; never executed (the execution status of this line is deduced): --currentBlockNumber; | - |
538 | r = documentLayout->blockBoundingRect(currentBlock); never executed (the execution status of this line is deduced): r = documentLayout->blockBoundingRect(currentBlock); | - |
539 | } | 0 |
540 | | - |
541 | | - |
542 | if (!currentBlock.isValid()) never evaluated: !currentBlock.isValid() | 0 |
543 | return -1; never executed: return -1; | 0 |
544 | QTextLayout *layout = currentBlock.layout(); never executed (the execution status of this line is deduced): QTextLayout *layout = currentBlock.layout(); | - |
545 | int off = 0; never executed (the execution status of this line is deduced): int off = 0; | - |
546 | QPointF pos = point - offset; never executed (the execution status of this line is deduced): QPointF pos = point - offset; | - |
547 | for (int i = 0; i < layout->lineCount(); ++i) { never evaluated: i < layout->lineCount() | 0 |
548 | QTextLine line = layout->lineAt(i); never executed (the execution status of this line is deduced): QTextLine line = layout->lineAt(i); | - |
549 | const QRectF lr = line.naturalTextRect(); never executed (the execution status of this line is deduced): const QRectF lr = line.naturalTextRect(); | - |
550 | if (lr.top() > pos.y()) { never evaluated: lr.top() > pos.y() | 0 |
551 | off = qMin(off, line.textStart()); never executed (the execution status of this line is deduced): off = qMin(off, line.textStart()); | - |
552 | } else if (lr.bottom() <= pos.y()) { never executed: } never evaluated: lr.bottom() <= pos.y() | 0 |
553 | off = qMax(off, line.textStart() + line.textLength()); never executed (the execution status of this line is deduced): off = qMax(off, line.textStart() + line.textLength()); | - |
554 | } else { | 0 |
555 | off = line.xToCursor(pos.x(), overwriteMode() ? never executed (the execution status of this line is deduced): off = line.xToCursor(pos.x(), overwriteMode() ? | - |
556 | QTextLine::CursorOnCharacter : QTextLine::CursorBetweenCharacters); never executed (the execution status of this line is deduced): QTextLine::CursorOnCharacter : QTextLine::CursorBetweenCharacters); | - |
557 | break; | 0 |
558 | } | - |
559 | } | - |
560 | | - |
561 | return currentBlock.position() + off; never executed: return currentBlock.position() + off; | 0 |
562 | } | - |
563 | | - |
564 | QRectF QPlainTextEditControl::blockBoundingRect(const QTextBlock &block) const { | - |
565 | int currentBlockNumber = topBlock; executed (the execution status of this line is deduced): int currentBlockNumber = topBlock; | - |
566 | int blockNumber = block.blockNumber(); executed (the execution status of this line is deduced): int blockNumber = block.blockNumber(); | - |
567 | QTextBlock currentBlock = document()->findBlockByNumber(currentBlockNumber); executed (the execution status of this line is deduced): QTextBlock currentBlock = document()->findBlockByNumber(currentBlockNumber); | - |
568 | if (!currentBlock.isValid()) partially evaluated: !currentBlock.isValid() no Evaluation Count:0 | yes Evaluation Count:1262 |
| 0-1262 |
569 | return QRectF(); never executed: return QRectF(); | 0 |
570 | Q_ASSERT(currentBlock.blockNumber() == currentBlockNumber); executed (the execution status of this line is deduced): qt_noop(); | - |
571 | QTextDocument *doc = document(); executed (the execution status of this line is deduced): QTextDocument *doc = document(); | - |
572 | QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(doc->documentLayout()); executed (the execution status of this line is deduced): QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(doc->documentLayout()); | - |
573 | Q_ASSERT(documentLayout); executed (the execution status of this line is deduced): qt_noop(); | - |
574 | | - |
575 | QPointF offset; executed (the execution status of this line is deduced): QPointF offset; | - |
576 | if (!block.isValid()) partially evaluated: !block.isValid() no Evaluation Count:0 | yes Evaluation Count:1262 |
| 0-1262 |
577 | return QRectF(); never executed: return QRectF(); | 0 |
578 | QRectF r = documentLayout->blockBoundingRect(currentBlock); executed (the execution status of this line is deduced): QRectF r = documentLayout->blockBoundingRect(currentBlock); | - |
579 | int maxVerticalOffset = r.height(); executed (the execution status of this line is deduced): int maxVerticalOffset = r.height(); | - |
580 | while (currentBlockNumber < blockNumber && offset.y() - maxVerticalOffset <= 2* textEdit->viewport()->height()) { evaluated: currentBlockNumber < blockNumber yes Evaluation Count:626 | yes Evaluation Count:1255 |
evaluated: offset.y() - maxVerticalOffset <= 2* textEdit->viewport()->height() yes Evaluation Count:619 | yes Evaluation Count:7 |
| 7-1255 |
581 | offset.ry() += r.height(); executed (the execution status of this line is deduced): offset.ry() += r.height(); | - |
582 | currentBlock = currentBlock.next(); executed (the execution status of this line is deduced): currentBlock = currentBlock.next(); | - |
583 | ++currentBlockNumber; executed (the execution status of this line is deduced): ++currentBlockNumber; | - |
584 | if (!currentBlock.isVisible()) { partially evaluated: !currentBlock.isVisible() no Evaluation Count:0 | yes Evaluation Count:619 |
| 0-619 |
585 | currentBlock = doc->findBlockByLineNumber(currentBlock.firstLineNumber()); never executed (the execution status of this line is deduced): currentBlock = doc->findBlockByLineNumber(currentBlock.firstLineNumber()); | - |
586 | currentBlockNumber = currentBlock.blockNumber(); never executed (the execution status of this line is deduced): currentBlockNumber = currentBlock.blockNumber(); | - |
587 | } | 0 |
588 | r = documentLayout->blockBoundingRect(currentBlock); executed (the execution status of this line is deduced): r = documentLayout->blockBoundingRect(currentBlock); | - |
589 | } executed: } Execution Count:619 | 619 |
590 | while (currentBlockNumber > blockNumber && offset.y() + maxVerticalOffset >= -textEdit->viewport()->height()) { evaluated: currentBlockNumber > blockNumber yes Evaluation Count:108 | yes Evaluation Count:1257 |
evaluated: offset.y() + maxVerticalOffset >= -textEdit->viewport()->height() yes Evaluation Count:103 | yes Evaluation Count:5 |
| 5-1257 |
591 | currentBlock = currentBlock.previous(); executed (the execution status of this line is deduced): currentBlock = currentBlock.previous(); | - |
592 | --currentBlockNumber; executed (the execution status of this line is deduced): --currentBlockNumber; | - |
593 | while (!currentBlock.isVisible()) { partially evaluated: !currentBlock.isVisible() no Evaluation Count:0 | yes Evaluation Count:103 |
| 0-103 |
594 | currentBlock = currentBlock.previous(); never executed (the execution status of this line is deduced): currentBlock = currentBlock.previous(); | - |
595 | --currentBlockNumber; never executed (the execution status of this line is deduced): --currentBlockNumber; | - |
596 | } | 0 |
597 | if (!currentBlock.isValid()) partially evaluated: !currentBlock.isValid() no Evaluation Count:0 | yes Evaluation Count:103 |
| 0-103 |
598 | break; | 0 |
599 | | - |
600 | r = documentLayout->blockBoundingRect(currentBlock); executed (the execution status of this line is deduced): r = documentLayout->blockBoundingRect(currentBlock); | - |
601 | offset.ry() -= r.height(); executed (the execution status of this line is deduced): offset.ry() -= r.height(); | - |
602 | } executed: } Execution Count:103 | 103 |
603 | | - |
604 | if (currentBlockNumber != blockNumber) { evaluated: currentBlockNumber != blockNumber yes Evaluation Count:12 | yes Evaluation Count:1250 |
| 12-1250 |
605 | // fallback for blocks out of reach. Give it some geometry at | - |
606 | // least, and ensure the layout is up to date. | - |
607 | r = documentLayout->blockBoundingRect(block); executed (the execution status of this line is deduced): r = documentLayout->blockBoundingRect(block); | - |
608 | if (currentBlockNumber > blockNumber) evaluated: currentBlockNumber > blockNumber yes Evaluation Count:5 | yes Evaluation Count:7 |
| 5-7 |
609 | offset.ry() -= r.height(); executed: offset.ry() -= r.height(); Execution Count:5 | 5 |
610 | } executed: } Execution Count:12 | 12 |
611 | r.translate(offset); executed (the execution status of this line is deduced): r.translate(offset); | - |
612 | return r; executed: return r; Execution Count:1262 | 1262 |
613 | } | - |
614 | | - |
615 | | - |
616 | void QPlainTextEditPrivate::setTopLine(int visualTopLine, int dx) | - |
617 | { | - |
618 | QTextDocument *doc = control->document(); executed (the execution status of this line is deduced): QTextDocument *doc = control->document(); | - |
619 | QTextBlock block = doc->findBlockByLineNumber(visualTopLine); executed (the execution status of this line is deduced): QTextBlock block = doc->findBlockByLineNumber(visualTopLine); | - |
620 | int blockNumber = block.blockNumber(); executed (the execution status of this line is deduced): int blockNumber = block.blockNumber(); | - |
621 | int lineNumber = visualTopLine - block.firstLineNumber(); executed (the execution status of this line is deduced): int lineNumber = visualTopLine - block.firstLineNumber(); | - |
622 | setTopBlock(blockNumber, lineNumber, dx); executed (the execution status of this line is deduced): setTopBlock(blockNumber, lineNumber, dx); | - |
623 | } executed: } Execution Count:239 | 239 |
624 | | - |
625 | void QPlainTextEditPrivate::setTopBlock(int blockNumber, int lineNumber, int dx) | - |
626 | { | - |
627 | Q_Q(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEdit * const q = q_func(); | - |
628 | blockNumber = qMax(0, blockNumber); executed (the execution status of this line is deduced): blockNumber = qMax(0, blockNumber); | - |
629 | lineNumber = qMax(0, lineNumber); executed (the execution status of this line is deduced): lineNumber = qMax(0, lineNumber); | - |
630 | QTextDocument *doc = control->document(); executed (the execution status of this line is deduced): QTextDocument *doc = control->document(); | - |
631 | QTextBlock block = doc->findBlockByNumber(blockNumber); executed (the execution status of this line is deduced): QTextBlock block = doc->findBlockByNumber(blockNumber); | - |
632 | | - |
633 | int newTopLine = block.firstLineNumber() + lineNumber; executed (the execution status of this line is deduced): int newTopLine = block.firstLineNumber() + lineNumber; | - |
634 | int maxTopLine = vbar->maximum(); executed (the execution status of this line is deduced): int maxTopLine = vbar->maximum(); | - |
635 | | - |
636 | if (newTopLine > maxTopLine) { partially evaluated: newTopLine > maxTopLine no Evaluation Count:0 | yes Evaluation Count:251 |
| 0-251 |
637 | block = doc->findBlockByLineNumber(maxTopLine); never executed (the execution status of this line is deduced): block = doc->findBlockByLineNumber(maxTopLine); | - |
638 | blockNumber = block.blockNumber(); never executed (the execution status of this line is deduced): blockNumber = block.blockNumber(); | - |
639 | lineNumber = maxTopLine - block.firstLineNumber(); never executed (the execution status of this line is deduced): lineNumber = maxTopLine - block.firstLineNumber(); | - |
640 | } | 0 |
641 | | - |
642 | bool vbarSignalsBlocked = vbar->blockSignals(true); executed (the execution status of this line is deduced): bool vbarSignalsBlocked = vbar->blockSignals(true); | - |
643 | vbar->setValue(newTopLine); executed (the execution status of this line is deduced): vbar->setValue(newTopLine); | - |
644 | vbar->blockSignals(vbarSignalsBlocked); executed (the execution status of this line is deduced): vbar->blockSignals(vbarSignalsBlocked); | - |
645 | | - |
646 | if (!dx && blockNumber == control->topBlock && lineNumber == topLine) evaluated: !dx yes Evaluation Count:246 | yes Evaluation Count:5 |
evaluated: blockNumber == control->topBlock yes Evaluation Count:238 | yes Evaluation Count:8 |
evaluated: lineNumber == topLine yes Evaluation Count:237 | yes Evaluation Count:1 |
| 1-246 |
647 | return; executed: return; Execution Count:237 | 237 |
648 | | - |
649 | if (viewport->updatesEnabled() && viewport->isVisible()) { partially evaluated: viewport->updatesEnabled() yes Evaluation Count:14 | no Evaluation Count:0 |
evaluated: viewport->isVisible() yes Evaluation Count:11 | yes Evaluation Count:3 |
| 0-14 |
650 | int dy = 0; executed (the execution status of this line is deduced): int dy = 0; | - |
651 | if (doc->findBlockByNumber(control->topBlock).isValid()) { partially evaluated: doc->findBlockByNumber(control->topBlock).isValid() yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-11 |
652 | qreal realdy = -q->blockBoundingGeometry(block).y() executed (the execution status of this line is deduced): qreal realdy = -q->blockBoundingGeometry(block).y() | - |
653 | + verticalOffset() - verticalOffset(blockNumber, lineNumber); executed (the execution status of this line is deduced): + verticalOffset() - verticalOffset(blockNumber, lineNumber); | - |
654 | dy = (int)realdy; executed (the execution status of this line is deduced): dy = (int)realdy; | - |
655 | topLineFracture = realdy - dy; executed (the execution status of this line is deduced): topLineFracture = realdy - dy; | - |
656 | } executed: } Execution Count:11 | 11 |
657 | control->topBlock = blockNumber; executed (the execution status of this line is deduced): control->topBlock = blockNumber; | - |
658 | topLine = lineNumber; executed (the execution status of this line is deduced): topLine = lineNumber; | - |
659 | | - |
660 | bool vbarSignalsBlocked = vbar->blockSignals(true); executed (the execution status of this line is deduced): bool vbarSignalsBlocked = vbar->blockSignals(true); | - |
661 | vbar->setValue(block.firstLineNumber() + lineNumber); executed (the execution status of this line is deduced): vbar->setValue(block.firstLineNumber() + lineNumber); | - |
662 | vbar->blockSignals(vbarSignalsBlocked); executed (the execution status of this line is deduced): vbar->blockSignals(vbarSignalsBlocked); | - |
663 | | - |
664 | if (dx || dy) { evaluated: dx yes Evaluation Count:4 | yes Evaluation Count:7 |
partially evaluated: dy yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
665 | viewport->scroll(q->isRightToLeft() ? -dx : dx, dy); executed (the execution status of this line is deduced): viewport->scroll(q->isRightToLeft() ? -dx : dx, dy); | - |
666 | } else { executed: } Execution Count:11 | 11 |
667 | viewport->update(); never executed (the execution status of this line is deduced): viewport->update(); | - |
668 | topLineFracture = 0; never executed (the execution status of this line is deduced): topLineFracture = 0; | - |
669 | } | 0 |
670 | emit q->updateRequest(viewport->rect(), dy); executed (the execution status of this line is deduced): q->updateRequest(viewport->rect(), dy); | - |
671 | } else { executed: } Execution Count:11 | 11 |
672 | control->topBlock = blockNumber; executed (the execution status of this line is deduced): control->topBlock = blockNumber; | - |
673 | topLine = lineNumber; executed (the execution status of this line is deduced): topLine = lineNumber; | - |
674 | topLineFracture = 0; executed (the execution status of this line is deduced): topLineFracture = 0; | - |
675 | } executed: } Execution Count:3 | 3 |
676 | | - |
677 | } | - |
678 | | - |
679 | | - |
680 | | - |
681 | void QPlainTextEditPrivate::ensureVisible(int position, bool center, bool forceCenter) { | - |
682 | Q_Q(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEdit * const q = q_func(); | - |
683 | QRectF visible = QRectF(viewport->rect()).translated(-q->contentOffset()); executed (the execution status of this line is deduced): QRectF visible = QRectF(viewport->rect()).translated(-q->contentOffset()); | - |
684 | QTextBlock block = control->document()->findBlock(position); executed (the execution status of this line is deduced): QTextBlock block = control->document()->findBlock(position); | - |
685 | if (!block.isValid()) partially evaluated: !block.isValid() no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
686 | return; | 0 |
687 | QRectF br = control->blockBoundingRect(block); executed (the execution status of this line is deduced): QRectF br = control->blockBoundingRect(block); | - |
688 | if (!br.isValid()) partially evaluated: !br.isValid() no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
689 | return; | 0 |
690 | QRectF lr = br; executed (the execution status of this line is deduced): QRectF lr = br; | - |
691 | QTextLine line = block.layout()->lineForTextPosition(position - block.position()); executed (the execution status of this line is deduced): QTextLine line = block.layout()->lineForTextPosition(position - block.position()); | - |
692 | Q_ASSERT(line.isValid()); executed (the execution status of this line is deduced): qt_noop(); | - |
693 | lr = line.naturalTextRect().translated(br.topLeft()); executed (the execution status of this line is deduced): lr = line.naturalTextRect().translated(br.topLeft()); | - |
694 | | - |
695 | if (lr.bottom() >= visible.bottom() || (center && lr.top() < visible.top()) || forceCenter){ evaluated: lr.bottom() >= visible.bottom() yes Evaluation Count:11 | yes Evaluation Count:1 |
partially evaluated: center no Evaluation Count:0 | yes Evaluation Count:1 |
never evaluated: lr.top() < visible.top() partially evaluated: forceCenter no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-11 |
696 | | - |
697 | qreal height = visible.height(); executed (the execution status of this line is deduced): qreal height = visible.height(); | - |
698 | if (center) partially evaluated: center no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
699 | height /= 2; never executed: height /= 2; | 0 |
700 | | - |
701 | qreal h = center ? line.naturalTextRect().center().y() : line.naturalTextRect().bottom(); partially evaluated: center no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
702 | | - |
703 | QTextBlock previousVisibleBlock = block; executed (the execution status of this line is deduced): QTextBlock previousVisibleBlock = block; | - |
704 | while (h < height && block.previous().isValid()) { evaluated: h < height yes Evaluation Count:40 | yes Evaluation Count:11 |
partially evaluated: block.previous().isValid() yes Evaluation Count:40 | no Evaluation Count:0 |
| 0-40 |
705 | previousVisibleBlock = block; executed (the execution status of this line is deduced): previousVisibleBlock = block; | - |
706 | do { | - |
707 | block = block.previous(); executed (the execution status of this line is deduced): block = block.previous(); | - |
708 | } while (!block.isVisible() && block.previous().isValid()); executed: } Execution Count:40 partially evaluated: !block.isVisible() no Evaluation Count:0 | yes Evaluation Count:40 |
never evaluated: block.previous().isValid() | 0-40 |
709 | h += q->blockBoundingRect(block).height(); executed (the execution status of this line is deduced): h += q->blockBoundingRect(block).height(); | - |
710 | } executed: } Execution Count:40 | 40 |
711 | | - |
712 | int l = 0; executed (the execution status of this line is deduced): int l = 0; | - |
713 | int lineCount = block.layout()->lineCount(); executed (the execution status of this line is deduced): int lineCount = block.layout()->lineCount(); | - |
714 | qreal voffset = verticalOffset(block.blockNumber(), 0); executed (the execution status of this line is deduced): qreal voffset = verticalOffset(block.blockNumber(), 0); | - |
715 | while (l < lineCount) { evaluated: l < lineCount yes Evaluation Count:21 | yes Evaluation Count:8 |
| 8-21 |
716 | QRectF lineRect = block.layout()->lineAt(l).naturalTextRect(); executed (the execution status of this line is deduced): QRectF lineRect = block.layout()->lineAt(l).naturalTextRect(); | - |
717 | if (h - voffset - lineRect.top() <= height) evaluated: h - voffset - lineRect.top() <= height yes Evaluation Count:3 | yes Evaluation Count:18 |
| 3-18 |
718 | break; executed: break; Execution Count:3 | 3 |
719 | ++l; executed (the execution status of this line is deduced): ++l; | - |
720 | } executed: } Execution Count:18 | 18 |
721 | | - |
722 | if (l >= lineCount) { evaluated: l >= lineCount yes Evaluation Count:8 | yes Evaluation Count:3 |
| 3-8 |
723 | block = previousVisibleBlock; executed (the execution status of this line is deduced): block = previousVisibleBlock; | - |
724 | l = 0; executed (the execution status of this line is deduced): l = 0; | - |
725 | } executed: } Execution Count:8 | 8 |
726 | setTopBlock(block.blockNumber(), l); executed (the execution status of this line is deduced): setTopBlock(block.blockNumber(), l); | - |
727 | } else if (lr.top() < visible.top()) { executed: } Execution Count:11 partially evaluated: lr.top() < visible.top() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-11 |
728 | setTopBlock(block.blockNumber(), line.lineNumber()); executed (the execution status of this line is deduced): setTopBlock(block.blockNumber(), line.lineNumber()); | - |
729 | } executed: } Execution Count:1 | 1 |
730 | | - |
731 | } | - |
732 | | - |
733 | | - |
734 | void QPlainTextEditPrivate::updateViewport() | - |
735 | { | - |
736 | Q_Q(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEdit * const q = q_func(); | - |
737 | viewport->update(); executed (the execution status of this line is deduced): viewport->update(); | - |
738 | emit q->updateRequest(viewport->rect(), 0); executed (the execution status of this line is deduced): q->updateRequest(viewport->rect(), 0); | - |
739 | } executed: } Execution Count:3 | 3 |
740 | | - |
741 | QPlainTextEditPrivate::QPlainTextEditPrivate() | - |
742 | : control(0), | - |
743 | tabChangesFocus(false), | - |
744 | lineWrap(QPlainTextEdit::WidgetWidth), | - |
745 | wordWrap(QTextOption::WrapAtWordBoundaryOrAnywhere), | - |
746 | clickCausedFocus(0),topLine(0),topLineFracture(0), | - |
747 | pageUpDownLastCursorYIsValid(false) | - |
748 | { | - |
749 | showCursorOnInitialShow = true; executed (the execution status of this line is deduced): showCursorOnInitialShow = true; | - |
750 | backgroundVisible = false; executed (the execution status of this line is deduced): backgroundVisible = false; | - |
751 | centerOnScroll = false; executed (the execution status of this line is deduced): centerOnScroll = false; | - |
752 | inDrag = false; executed (the execution status of this line is deduced): inDrag = false; | - |
753 | } executed: } Execution Count:87 | 87 |
754 | | - |
755 | | - |
756 | void QPlainTextEditPrivate::init(const QString &txt) | - |
757 | { | - |
758 | Q_Q(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEdit * const q = q_func(); | - |
759 | control = new QPlainTextEditControl(q); executed (the execution status of this line is deduced): control = new QPlainTextEditControl(q); | - |
760 | | - |
761 | QTextDocument *doc = new QTextDocument(control); executed (the execution status of this line is deduced): QTextDocument *doc = new QTextDocument(control); | - |
762 | QAbstractTextDocumentLayout *layout = new QPlainTextDocumentLayout(doc); executed (the execution status of this line is deduced): QAbstractTextDocumentLayout *layout = new QPlainTextDocumentLayout(doc); | - |
763 | doc->setDocumentLayout(layout); executed (the execution status of this line is deduced): doc->setDocumentLayout(layout); | - |
764 | control->setDocument(doc); executed (the execution status of this line is deduced): control->setDocument(doc); | - |
765 | | - |
766 | control->setPalette(q->palette()); executed (the execution status of this line is deduced): control->setPalette(q->palette()); | - |
767 | | - |
768 | QObject::connect(vbar, SIGNAL(actionTriggered(int)), q, SLOT(_q_verticalScrollbarActionTriggered(int))); executed (the execution status of this line is deduced): QObject::connect(vbar, "2""actionTriggered(int)", q, "1""_q_verticalScrollbarActionTriggered(int)"); | - |
769 | | - |
770 | QObject::connect(control, SIGNAL(microFocusChanged()), q, SLOT(updateMicroFocus())); executed (the execution status of this line is deduced): QObject::connect(control, "2""microFocusChanged()", q, "1""updateMicroFocus()"); | - |
771 | QObject::connect(control, SIGNAL(documentSizeChanged(QSizeF)), q, SLOT(_q_adjustScrollbars())); executed (the execution status of this line is deduced): QObject::connect(control, "2""documentSizeChanged(QSizeF)", q, "1""_q_adjustScrollbars()"); | - |
772 | QObject::connect(control, SIGNAL(blockCountChanged(int)), q, SIGNAL(blockCountChanged(int))); executed (the execution status of this line is deduced): QObject::connect(control, "2""blockCountChanged(int)", q, "2""blockCountChanged(int)"); | - |
773 | QObject::connect(control, SIGNAL(updateRequest(QRectF)), q, SLOT(_q_repaintContents(QRectF))); executed (the execution status of this line is deduced): QObject::connect(control, "2""updateRequest(QRectF)", q, "1""_q_repaintContents(QRectF)"); | - |
774 | QObject::connect(control, SIGNAL(modificationChanged(bool)), q, SIGNAL(modificationChanged(bool))); executed (the execution status of this line is deduced): QObject::connect(control, "2""modificationChanged(bool)", q, "2""modificationChanged(bool)"); | - |
775 | | - |
776 | QObject::connect(control, SIGNAL(textChanged()), q, SIGNAL(textChanged())); executed (the execution status of this line is deduced): QObject::connect(control, "2""textChanged()", q, "2""textChanged()"); | - |
777 | QObject::connect(control, SIGNAL(undoAvailable(bool)), q, SIGNAL(undoAvailable(bool))); executed (the execution status of this line is deduced): QObject::connect(control, "2""undoAvailable(bool)", q, "2""undoAvailable(bool)"); | - |
778 | QObject::connect(control, SIGNAL(redoAvailable(bool)), q, SIGNAL(redoAvailable(bool))); executed (the execution status of this line is deduced): QObject::connect(control, "2""redoAvailable(bool)", q, "2""redoAvailable(bool)"); | - |
779 | QObject::connect(control, SIGNAL(copyAvailable(bool)), q, SIGNAL(copyAvailable(bool))); executed (the execution status of this line is deduced): QObject::connect(control, "2""copyAvailable(bool)", q, "2""copyAvailable(bool)"); | - |
780 | QObject::connect(control, SIGNAL(selectionChanged()), q, SIGNAL(selectionChanged())); executed (the execution status of this line is deduced): QObject::connect(control, "2""selectionChanged()", q, "2""selectionChanged()"); | - |
781 | QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SLOT(_q_cursorPositionChanged())); executed (the execution status of this line is deduced): QObject::connect(control, "2""cursorPositionChanged()", q, "1""_q_cursorPositionChanged()"); | - |
782 | | - |
783 | QObject::connect(control, SIGNAL(textChanged()), q, SLOT(updateMicroFocus())); executed (the execution status of this line is deduced): QObject::connect(control, "2""textChanged()", q, "1""updateMicroFocus()"); | - |
784 | | - |
785 | // set a null page size initially to avoid any relayouting until the textedit | - |
786 | // is shown. relayoutDocument() will take care of setting the page size to the | - |
787 | // viewport dimensions later. | - |
788 | doc->setTextWidth(-1); executed (the execution status of this line is deduced): doc->setTextWidth(-1); | - |
789 | doc->documentLayout()->setPaintDevice(viewport); executed (the execution status of this line is deduced): doc->documentLayout()->setPaintDevice(viewport); | - |
790 | doc->setDefaultFont(q->font()); executed (the execution status of this line is deduced): doc->setDefaultFont(q->font()); | - |
791 | | - |
792 | | - |
793 | if (!txt.isEmpty()) partially evaluated: !txt.isEmpty() no Evaluation Count:0 | yes Evaluation Count:87 |
| 0-87 |
794 | control->setPlainText(txt); never executed: control->setPlainText(txt); | 0 |
795 | | - |
796 | hbar->setSingleStep(20); executed (the execution status of this line is deduced): hbar->setSingleStep(20); | - |
797 | vbar->setSingleStep(1); executed (the execution status of this line is deduced): vbar->setSingleStep(1); | - |
798 | | - |
799 | viewport->setBackgroundRole(QPalette::Base); executed (the execution status of this line is deduced): viewport->setBackgroundRole(QPalette::Base); | - |
800 | q->setAcceptDrops(true); executed (the execution status of this line is deduced): q->setAcceptDrops(true); | - |
801 | q->setFocusPolicy(Qt::WheelFocus); executed (the execution status of this line is deduced): q->setFocusPolicy(Qt::WheelFocus); | - |
802 | q->setAttribute(Qt::WA_KeyCompression); executed (the execution status of this line is deduced): q->setAttribute(Qt::WA_KeyCompression); | - |
803 | q->setAttribute(Qt::WA_InputMethodEnabled); executed (the execution status of this line is deduced): q->setAttribute(Qt::WA_InputMethodEnabled); | - |
804 | | - |
805 | #ifndef QT_NO_CURSOR | - |
806 | viewport->setCursor(Qt::IBeamCursor); executed (the execution status of this line is deduced): viewport->setCursor(Qt::IBeamCursor); | - |
807 | #endif | - |
808 | originalOffsetY = 0; executed (the execution status of this line is deduced): originalOffsetY = 0; | - |
809 | #ifdef Q_WS_WIN | - |
810 | setSingleFingerPanEnabled(true); | - |
811 | #endif | - |
812 | } executed: } Execution Count:87 | 87 |
813 | | - |
814 | void QPlainTextEditPrivate::_q_repaintContents(const QRectF &contentsRect) | - |
815 | { | - |
816 | Q_Q(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEdit * const q = q_func(); | - |
817 | if (!contentsRect.isValid()) { evaluated: !contentsRect.isValid() yes Evaluation Count:3 | yes Evaluation Count:753 |
| 3-753 |
818 | updateViewport(); executed (the execution status of this line is deduced): updateViewport(); | - |
819 | return; executed: return; Execution Count:3 | 3 |
820 | } | - |
821 | const int xOffset = horizontalOffset(); executed (the execution status of this line is deduced): const int xOffset = horizontalOffset(); | - |
822 | const int yOffset = (int)verticalOffset(); executed (the execution status of this line is deduced): const int yOffset = (int)verticalOffset(); | - |
823 | const QRect visibleRect(xOffset, yOffset, viewport->width(), viewport->height()); executed (the execution status of this line is deduced): const QRect visibleRect(xOffset, yOffset, viewport->width(), viewport->height()); | - |
824 | | - |
825 | QRect r = contentsRect.adjusted(-1, -1, 1, 1).intersected(visibleRect).toAlignedRect(); executed (the execution status of this line is deduced): QRect r = contentsRect.adjusted(-1, -1, 1, 1).intersected(visibleRect).toAlignedRect(); | - |
826 | if (r.isEmpty()) evaluated: r.isEmpty() yes Evaluation Count:6 | yes Evaluation Count:747 |
| 6-747 |
827 | return; executed: return; Execution Count:6 | 6 |
828 | | - |
829 | r.translate(-xOffset, -yOffset); executed (the execution status of this line is deduced): r.translate(-xOffset, -yOffset); | - |
830 | viewport->update(r); executed (the execution status of this line is deduced): viewport->update(r); | - |
831 | emit q->updateRequest(r, 0); executed (the execution status of this line is deduced): q->updateRequest(r, 0); | - |
832 | } executed: } Execution Count:747 | 747 |
833 | | - |
834 | void QPlainTextEditPrivate::pageUpDown(QTextCursor::MoveOperation op, QTextCursor::MoveMode moveMode, bool moveCursor) | - |
835 | { | - |
836 | | - |
837 | Q_Q(QPlainTextEdit); never executed (the execution status of this line is deduced): QPlainTextEdit * const q = q_func(); | - |
838 | | - |
839 | QTextCursor cursor = control->textCursor(); never executed (the execution status of this line is deduced): QTextCursor cursor = control->textCursor(); | - |
840 | if (moveCursor) { never evaluated: moveCursor | 0 |
841 | ensureCursorVisible(); never executed (the execution status of this line is deduced): ensureCursorVisible(); | - |
842 | if (!pageUpDownLastCursorYIsValid) never evaluated: !pageUpDownLastCursorYIsValid | 0 |
843 | pageUpDownLastCursorY = control->cursorRect(cursor).top() - verticalOffset(); never executed: pageUpDownLastCursorY = control->cursorRect(cursor).top() - verticalOffset(); | 0 |
844 | } | 0 |
845 | | - |
846 | qreal lastY = pageUpDownLastCursorY; never executed (the execution status of this line is deduced): qreal lastY = pageUpDownLastCursorY; | - |
847 | | - |
848 | | - |
849 | if (op == QTextCursor::Down) { never evaluated: op == QTextCursor::Down | 0 |
850 | QRectF visible = QRectF(viewport->rect()).translated(-q->contentOffset()); never executed (the execution status of this line is deduced): QRectF visible = QRectF(viewport->rect()).translated(-q->contentOffset()); | - |
851 | QTextBlock firstVisibleBlock = q->firstVisibleBlock(); never executed (the execution status of this line is deduced): QTextBlock firstVisibleBlock = q->firstVisibleBlock(); | - |
852 | QTextBlock block = firstVisibleBlock; never executed (the execution status of this line is deduced): QTextBlock block = firstVisibleBlock; | - |
853 | QRectF br = q->blockBoundingRect(block); never executed (the execution status of this line is deduced): QRectF br = q->blockBoundingRect(block); | - |
854 | qreal h = 0; never executed (the execution status of this line is deduced): qreal h = 0; | - |
855 | int atEnd = false; never executed (the execution status of this line is deduced): int atEnd = false; | - |
856 | while (h + br.height() <= visible.bottom()) { never evaluated: h + br.height() <= visible.bottom() | 0 |
857 | if (!block.next().isValid()) { never evaluated: !block.next().isValid() | 0 |
858 | atEnd = true; never executed (the execution status of this line is deduced): atEnd = true; | - |
859 | lastY = visible.bottom(); // set cursor to last line never executed (the execution status of this line is deduced): lastY = visible.bottom(); | - |
860 | break; | 0 |
861 | } | - |
862 | h += br.height(); never executed (the execution status of this line is deduced): h += br.height(); | - |
863 | block = block.next(); never executed (the execution status of this line is deduced): block = block.next(); | - |
864 | br = q->blockBoundingRect(block); never executed (the execution status of this line is deduced): br = q->blockBoundingRect(block); | - |
865 | } | 0 |
866 | | - |
867 | if (!atEnd) { | 0 |
868 | int line = 0; never executed (the execution status of this line is deduced): int line = 0; | - |
869 | qreal diff = visible.bottom() - h; never executed (the execution status of this line is deduced): qreal diff = visible.bottom() - h; | - |
870 | int lineCount = block.layout()->lineCount(); never executed (the execution status of this line is deduced): int lineCount = block.layout()->lineCount(); | - |
871 | while (line < lineCount - 1) { never evaluated: line < lineCount - 1 | 0 |
872 | if (block.layout()->lineAt(line).naturalTextRect().bottom() > diff) { never evaluated: block.layout()->lineAt(line).naturalTextRect().bottom() > diff | 0 |
873 | // the first line that did not completely fit the screen | - |
874 | break; | 0 |
875 | } | - |
876 | ++line; never executed (the execution status of this line is deduced): ++line; | - |
877 | } | 0 |
878 | setTopBlock(block.blockNumber(), line); never executed (the execution status of this line is deduced): setTopBlock(block.blockNumber(), line); | - |
879 | } | 0 |
880 | | - |
881 | if (moveCursor) { never evaluated: moveCursor | 0 |
882 | // move using movePosition to keep the cursor's x | - |
883 | lastY += verticalOffset(); never executed (the execution status of this line is deduced): lastY += verticalOffset(); | - |
884 | bool moved = false; never executed (the execution status of this line is deduced): bool moved = false; | - |
885 | do { | - |
886 | moved = cursor.movePosition(op, moveMode); never executed (the execution status of this line is deduced): moved = cursor.movePosition(op, moveMode); | - |
887 | } while (moved && control->cursorRect(cursor).top() < lastY); never executed: } never evaluated: moved never evaluated: control->cursorRect(cursor).top() < lastY | 0 |
888 | } | 0 |
889 | | - |
890 | } else if (op == QTextCursor::Up) { never executed: } never evaluated: op == QTextCursor::Up | 0 |
891 | | - |
892 | QRectF visible = QRectF(viewport->rect()).translated(-q->contentOffset()); never executed (the execution status of this line is deduced): QRectF visible = QRectF(viewport->rect()).translated(-q->contentOffset()); | - |
893 | visible.translate(0, -visible.height()); // previous page never executed (the execution status of this line is deduced): visible.translate(0, -visible.height()); | - |
894 | QTextBlock block = q->firstVisibleBlock(); never executed (the execution status of this line is deduced): QTextBlock block = q->firstVisibleBlock(); | - |
895 | qreal h = 0; never executed (the execution status of this line is deduced): qreal h = 0; | - |
896 | while (h >= visible.top()) { never evaluated: h >= visible.top() | 0 |
897 | if (!block.previous().isValid()) { never evaluated: !block.previous().isValid() | 0 |
898 | if (control->topBlock == 0 && topLine == 0) { never evaluated: control->topBlock == 0 never evaluated: topLine == 0 | 0 |
899 | lastY = 0; // set cursor to first line never executed (the execution status of this line is deduced): lastY = 0; | - |
900 | } | 0 |
901 | break; | 0 |
902 | } | - |
903 | block = block.previous(); never executed (the execution status of this line is deduced): block = block.previous(); | - |
904 | QRectF br = q->blockBoundingRect(block); never executed (the execution status of this line is deduced): QRectF br = q->blockBoundingRect(block); | - |
905 | h -= br.height(); never executed (the execution status of this line is deduced): h -= br.height(); | - |
906 | } | 0 |
907 | | - |
908 | int line = 0; never executed (the execution status of this line is deduced): int line = 0; | - |
909 | if (block.isValid()) { never evaluated: block.isValid() | 0 |
910 | qreal diff = visible.top() - h; never executed (the execution status of this line is deduced): qreal diff = visible.top() - h; | - |
911 | int lineCount = block.layout()->lineCount(); never executed (the execution status of this line is deduced): int lineCount = block.layout()->lineCount(); | - |
912 | while (line < lineCount) { never evaluated: line < lineCount | 0 |
913 | if (block.layout()->lineAt(line).naturalTextRect().top() >= diff) never evaluated: block.layout()->lineAt(line).naturalTextRect().top() >= diff | 0 |
914 | break; | 0 |
915 | ++line; never executed (the execution status of this line is deduced): ++line; | - |
916 | } | 0 |
917 | if (line == lineCount) { never evaluated: line == lineCount | 0 |
918 | if (block.next().isValid() && block.next() != q->firstVisibleBlock()) { never evaluated: block.next().isValid() never evaluated: block.next() != q->firstVisibleBlock() | 0 |
919 | block = block.next(); never executed (the execution status of this line is deduced): block = block.next(); | - |
920 | line = 0; never executed (the execution status of this line is deduced): line = 0; | - |
921 | } else { | 0 |
922 | --line; never executed (the execution status of this line is deduced): --line; | - |
923 | } | 0 |
924 | } | - |
925 | } | 0 |
926 | setTopBlock(block.blockNumber(), line); never executed (the execution status of this line is deduced): setTopBlock(block.blockNumber(), line); | - |
927 | | - |
928 | if (moveCursor) { never evaluated: moveCursor | 0 |
929 | cursor.setVisualNavigation(true); never executed (the execution status of this line is deduced): cursor.setVisualNavigation(true); | - |
930 | // move using movePosition to keep the cursor's x | - |
931 | lastY += verticalOffset(); never executed (the execution status of this line is deduced): lastY += verticalOffset(); | - |
932 | bool moved = false; never executed (the execution status of this line is deduced): bool moved = false; | - |
933 | do { | - |
934 | moved = cursor.movePosition(op, moveMode); never executed (the execution status of this line is deduced): moved = cursor.movePosition(op, moveMode); | - |
935 | } while (moved && control->cursorRect(cursor).top() > lastY); never executed: } never evaluated: moved never evaluated: control->cursorRect(cursor).top() > lastY | 0 |
936 | } | 0 |
937 | } | 0 |
938 | | - |
939 | if (moveCursor) { never evaluated: moveCursor | 0 |
940 | control->setTextCursor(cursor); never executed (the execution status of this line is deduced): control->setTextCursor(cursor); | - |
941 | pageUpDownLastCursorYIsValid = true; never executed (the execution status of this line is deduced): pageUpDownLastCursorYIsValid = true; | - |
942 | } | 0 |
943 | } | 0 |
944 | | - |
945 | #ifndef QT_NO_SCROLLBAR | - |
946 | | - |
947 | void QPlainTextEditPrivate::_q_adjustScrollbars() | - |
948 | { | - |
949 | Q_Q(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEdit * const q = q_func(); | - |
950 | QTextDocument *doc = control->document(); executed (the execution status of this line is deduced): QTextDocument *doc = control->document(); | - |
951 | QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(doc->documentLayout()); executed (the execution status of this line is deduced): QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(doc->documentLayout()); | - |
952 | Q_ASSERT(documentLayout); executed (the execution status of this line is deduced): qt_noop(); | - |
953 | bool documentSizeChangedBlocked = documentLayout->priv()->blockDocumentSizeChanged; executed (the execution status of this line is deduced): bool documentSizeChangedBlocked = documentLayout->priv()->blockDocumentSizeChanged; | - |
954 | documentLayout->priv()->blockDocumentSizeChanged = true; executed (the execution status of this line is deduced): documentLayout->priv()->blockDocumentSizeChanged = true; | - |
955 | qreal margin = doc->documentMargin(); executed (the execution status of this line is deduced): qreal margin = doc->documentMargin(); | - |
956 | | - |
957 | int vmax = 0; executed (the execution status of this line is deduced): int vmax = 0; | - |
958 | | - |
959 | int vSliderLength = 0; executed (the execution status of this line is deduced): int vSliderLength = 0; | - |
960 | if (!centerOnScroll && q->isVisible()) { partially evaluated: !centerOnScroll yes Evaluation Count:232 | no Evaluation Count:0 |
evaluated: q->isVisible() yes Evaluation Count:42 | yes Evaluation Count:190 |
| 0-232 |
961 | QTextBlock block = doc->lastBlock(); executed (the execution status of this line is deduced): QTextBlock block = doc->lastBlock(); | - |
962 | const qreal visible = viewport->rect().height() - margin - 1; executed (the execution status of this line is deduced): const qreal visible = viewport->rect().height() - margin - 1; | - |
963 | qreal y = 0; executed (the execution status of this line is deduced): qreal y = 0; | - |
964 | int visibleFromBottom = 0; executed (the execution status of this line is deduced): int visibleFromBottom = 0; | - |
965 | | - |
966 | while (block.isValid()) { evaluated: block.isValid() yes Evaluation Count:90 | yes Evaluation Count:16 |
| 16-90 |
967 | if (!block.isVisible()) { partially evaluated: !block.isVisible() no Evaluation Count:0 | yes Evaluation Count:90 |
| 0-90 |
968 | block = block.previous(); never executed (the execution status of this line is deduced): block = block.previous(); | - |
969 | continue; never executed: continue; | 0 |
970 | } | - |
971 | y += documentLayout->blockBoundingRect(block).height(); executed (the execution status of this line is deduced): y += documentLayout->blockBoundingRect(block).height(); | - |
972 | | - |
973 | QTextLayout *layout = block.layout(); executed (the execution status of this line is deduced): QTextLayout *layout = block.layout(); | - |
974 | int layoutLineCount = layout->lineCount(); executed (the execution status of this line is deduced): int layoutLineCount = layout->lineCount(); | - |
975 | if (y > visible) { evaluated: y > visible yes Evaluation Count:26 | yes Evaluation Count:64 |
| 26-64 |
976 | int lineNumber = 0; executed (the execution status of this line is deduced): int lineNumber = 0; | - |
977 | while (lineNumber < layoutLineCount) { evaluated: lineNumber < layoutLineCount yes Evaluation Count:48 | yes Evaluation Count:16 |
| 16-48 |
978 | QTextLine line = layout->lineAt(lineNumber); executed (the execution status of this line is deduced): QTextLine line = layout->lineAt(lineNumber); | - |
979 | const QRectF lr = line.naturalTextRect(); executed (the execution status of this line is deduced): const QRectF lr = line.naturalTextRect(); | - |
980 | if (lr.top() >= y - visible) evaluated: lr.top() >= y - visible yes Evaluation Count:10 | yes Evaluation Count:38 |
| 10-38 |
981 | break; executed: break; Execution Count:10 | 10 |
982 | ++lineNumber; executed (the execution status of this line is deduced): ++lineNumber; | - |
983 | } executed: } Execution Count:38 | 38 |
984 | if (lineNumber < layoutLineCount) evaluated: lineNumber < layoutLineCount yes Evaluation Count:10 | yes Evaluation Count:16 |
| 10-16 |
985 | visibleFromBottom += (layoutLineCount - lineNumber); executed: visibleFromBottom += (layoutLineCount - lineNumber); Execution Count:10 | 10 |
986 | break; executed: break; Execution Count:26 | 26 |
987 | | - |
988 | } | - |
989 | visibleFromBottom += layoutLineCount; executed (the execution status of this line is deduced): visibleFromBottom += layoutLineCount; | - |
990 | block = block.previous(); executed (the execution status of this line is deduced): block = block.previous(); | - |
991 | } executed: } Execution Count:64 | 64 |
992 | vmax = qMax(0, doc->lineCount() - visibleFromBottom); executed (the execution status of this line is deduced): vmax = qMax(0, doc->lineCount() - visibleFromBottom); | - |
993 | vSliderLength = visibleFromBottom; executed (the execution status of this line is deduced): vSliderLength = visibleFromBottom; | - |
994 | | - |
995 | } else { executed: } Execution Count:42 | 42 |
996 | vmax = qMax(0, doc->lineCount() - 1); executed (the execution status of this line is deduced): vmax = qMax(0, doc->lineCount() - 1); | - |
997 | vSliderLength = viewport->height() / q->fontMetrics().lineSpacing(); executed (the execution status of this line is deduced): vSliderLength = viewport->height() / q->fontMetrics().lineSpacing(); | - |
998 | } executed: } Execution Count:190 | 190 |
999 | | - |
1000 | | - |
1001 | | - |
1002 | QSizeF documentSize = documentLayout->documentSize(); executed (the execution status of this line is deduced): QSizeF documentSize = documentLayout->documentSize(); | - |
1003 | vbar->setRange(0, qMax(0, vmax)); executed (the execution status of this line is deduced): vbar->setRange(0, qMax(0, vmax)); | - |
1004 | vbar->setPageStep(vSliderLength); executed (the execution status of this line is deduced): vbar->setPageStep(vSliderLength); | - |
1005 | int visualTopLine = vmax; executed (the execution status of this line is deduced): int visualTopLine = vmax; | - |
1006 | QTextBlock firstVisibleBlock = q->firstVisibleBlock(); executed (the execution status of this line is deduced): QTextBlock firstVisibleBlock = q->firstVisibleBlock(); | - |
1007 | if (firstVisibleBlock.isValid()) partially evaluated: firstVisibleBlock.isValid() yes Evaluation Count:232 | no Evaluation Count:0 |
| 0-232 |
1008 | visualTopLine = firstVisibleBlock.firstLineNumber() + topLine; executed: visualTopLine = firstVisibleBlock.firstLineNumber() + topLine; Execution Count:232 | 232 |
1009 | bool vbarSignalsBlocked = vbar->blockSignals(true); executed (the execution status of this line is deduced): bool vbarSignalsBlocked = vbar->blockSignals(true); | - |
1010 | vbar->setValue(visualTopLine); executed (the execution status of this line is deduced): vbar->setValue(visualTopLine); | - |
1011 | vbar->blockSignals(vbarSignalsBlocked); executed (the execution status of this line is deduced): vbar->blockSignals(vbarSignalsBlocked); | - |
1012 | | - |
1013 | hbar->setRange(0, (int)documentSize.width() - viewport->width()); executed (the execution status of this line is deduced): hbar->setRange(0, (int)documentSize.width() - viewport->width()); | - |
1014 | hbar->setPageStep(viewport->width()); executed (the execution status of this line is deduced): hbar->setPageStep(viewport->width()); | - |
1015 | documentLayout->priv()->blockDocumentSizeChanged = documentSizeChangedBlocked; executed (the execution status of this line is deduced): documentLayout->priv()->blockDocumentSizeChanged = documentSizeChangedBlocked; | - |
1016 | setTopLine(vbar->value()); executed (the execution status of this line is deduced): setTopLine(vbar->value()); | - |
1017 | } executed: } Execution Count:232 | 232 |
1018 | | - |
1019 | #endif | - |
1020 | | - |
1021 | | - |
1022 | void QPlainTextEditPrivate::ensureViewportLayouted() | - |
1023 | { | - |
1024 | } | - |
1025 | | - |
1026 | /*! | - |
1027 | \class QPlainTextEdit | - |
1028 | \since 4.4 | - |
1029 | \brief The QPlainTextEdit class provides a widget that is used to edit and display | - |
1030 | plain text. | - |
1031 | | - |
1032 | \ingroup richtext-processing | - |
1033 | \inmodule QtWidgets | - |
1034 | | - |
1035 | \tableofcontents | - |
1036 | | - |
1037 | \section1 Introduction and Concepts | - |
1038 | | - |
1039 | QPlainTextEdit is an advanced viewer/editor supporting plain | - |
1040 | text. It is optimized to handle large documents and to respond | - |
1041 | quickly to user input. | - |
1042 | | - |
1043 | QPlainText uses very much the same technology and concepts as | - |
1044 | QTextEdit, but is optimized for plain text handling. | - |
1045 | | - |
1046 | QPlainTextEdit works on paragraphs and characters. A paragraph is | - |
1047 | a formatted string which is word-wrapped to fit into the width of | - |
1048 | the widget. By default when reading plain text, one newline | - |
1049 | signifies a paragraph. A document consists of zero or more | - |
1050 | paragraphs. Paragraphs are separated by hard line breaks. Each | - |
1051 | character within a paragraph has its own attributes, for example, | - |
1052 | font and color. | - |
1053 | | - |
1054 | The shape of the mouse cursor on a QPlainTextEdit is | - |
1055 | Qt::IBeamCursor by default. It can be changed through the | - |
1056 | viewport()'s cursor property. | - |
1057 | | - |
1058 | \section1 Using QPlainTextEdit as a Display Widget | - |
1059 | | - |
1060 | The text is set or replaced using setPlainText() which deletes the | - |
1061 | existing text and replaces it with the text passed to setPlainText(). | - |
1062 | | - |
1063 | Text can be inserted using the QTextCursor class or using the | - |
1064 | convenience functions insertPlainText(), appendPlainText() or | - |
1065 | paste(). | - |
1066 | | - |
1067 | By default, the text edit wraps words at whitespace to fit within | - |
1068 | the text edit widget. The setLineWrapMode() function is used to | - |
1069 | specify the kind of line wrap you want, \l WidgetWidth or \l | - |
1070 | NoWrap if you don't want any wrapping. If you use word wrap to | - |
1071 | the widget's width \l WidgetWidth, you can specify whether to | - |
1072 | break on whitespace or anywhere with setWordWrapMode(). | - |
1073 | | - |
1074 | The find() function can be used to find and select a given string | - |
1075 | within the text. | - |
1076 | | - |
1077 | If you want to limit the total number of paragraphs in a | - |
1078 | QPlainTextEdit, as it is for example useful in a log viewer, then | - |
1079 | you can use the maximumBlockCount property. The combination of | - |
1080 | setMaximumBlockCount() and appendPlainText() turns QPlainTextEdit | - |
1081 | into an efficient viewer for log text. The scrolling can be | - |
1082 | reduced with the centerOnScroll() property, making the log viewer | - |
1083 | even faster. Text can be formatted in a limited way, either using | - |
1084 | a syntax highlighter (see below), or by appending html-formatted | - |
1085 | text with appendHtml(). While QPlainTextEdit does not support | - |
1086 | complex rich text rendering with tables and floats, it does | - |
1087 | support limited paragraph-based formatting that you may need in a | - |
1088 | log viewer. | - |
1089 | | - |
1090 | \section2 Read-only Key Bindings | - |
1091 | | - |
1092 | When QPlainTextEdit is used read-only the key bindings are limited to | - |
1093 | navigation, and text may only be selected with the mouse: | - |
1094 | \table | - |
1095 | \header \li Keypresses \li Action | - |
1096 | \row \li Qt::UpArrow \li Moves one line up. | - |
1097 | \row \li Qt::DownArrow \li Moves one line down. | - |
1098 | \row \li Qt::LeftArrow \li Moves one character to the left. | - |
1099 | \row \li Qt::RightArrow \li Moves one character to the right. | - |
1100 | \row \li PageUp \li Moves one (viewport) page up. | - |
1101 | \row \li PageDown \li Moves one (viewport) page down. | - |
1102 | \row \li Home \li Moves to the beginning of the text. | - |
1103 | \row \li End \li Moves to the end of the text. | - |
1104 | \row \li Alt+Wheel | - |
1105 | \li Scrolls the page horizontally (the Wheel is the mouse wheel). | - |
1106 | \row \li Ctrl+Wheel \li Zooms the text. | - |
1107 | \row \li Ctrl+A \li Selects all text. | - |
1108 | \endtable | - |
1109 | | - |
1110 | | - |
1111 | \section1 Using QPlainTextEdit as an Editor | - |
1112 | | - |
1113 | All the information about using QPlainTextEdit as a display widget also | - |
1114 | applies here. | - |
1115 | | - |
1116 | Selection of text is handled by the QTextCursor class, which provides | - |
1117 | functionality for creating selections, retrieving the text contents or | - |
1118 | deleting selections. You can retrieve the object that corresponds with | - |
1119 | the user-visible cursor using the textCursor() method. If you want to set | - |
1120 | a selection in QPlainTextEdit just create one on a QTextCursor object and | - |
1121 | then make that cursor the visible cursor using setCursor(). The selection | - |
1122 | can be copied to the clipboard with copy(), or cut to the clipboard with | - |
1123 | cut(). The entire text can be selected using selectAll(). | - |
1124 | | - |
1125 | QPlainTextEdit holds a QTextDocument object which can be retrieved using the | - |
1126 | document() method. You can also set your own document object using setDocument(). | - |
1127 | QTextDocument emits a textChanged() signal if the text changes and it also | - |
1128 | provides a isModified() function which will return true if the text has been | - |
1129 | modified since it was either loaded or since the last call to setModified | - |
1130 | with false as argument. In addition it provides methods for undo and redo. | - |
1131 | | - |
1132 | \section2 Syntax Highlighting | - |
1133 | | - |
1134 | Just like QTextEdit, QPlainTextEdit works together with | - |
1135 | QSyntaxHighlighter. | - |
1136 | | - |
1137 | \section2 Editing Key Bindings | - |
1138 | | - |
1139 | The list of key bindings which are implemented for editing: | - |
1140 | \table | - |
1141 | \header \li Keypresses \li Action | - |
1142 | \row \li Backspace \li Deletes the character to the left of the cursor. | - |
1143 | \row \li Delete \li Deletes the character to the right of the cursor. | - |
1144 | \row \li Ctrl+C \li Copy the selected text to the clipboard. | - |
1145 | \row \li Ctrl+Insert \li Copy the selected text to the clipboard. | - |
1146 | \row \li Ctrl+K \li Deletes to the end of the line. | - |
1147 | \row \li Ctrl+V \li Pastes the clipboard text into text edit. | - |
1148 | \row \li Shift+Insert \li Pastes the clipboard text into text edit. | - |
1149 | \row \li Ctrl+X \li Deletes the selected text and copies it to the clipboard. | - |
1150 | \row \li Shift+Delete \li Deletes the selected text and copies it to the clipboard. | - |
1151 | \row \li Ctrl+Z \li Undoes the last operation. | - |
1152 | \row \li Ctrl+Y \li Redoes the last operation. | - |
1153 | \row \li LeftArrow \li Moves the cursor one character to the left. | - |
1154 | \row \li Ctrl+LeftArrow \li Moves the cursor one word to the left. | - |
1155 | \row \li RightArrow \li Moves the cursor one character to the right. | - |
1156 | \row \li Ctrl+RightArrow \li Moves the cursor one word to the right. | - |
1157 | \row \li UpArrow \li Moves the cursor one line up. | - |
1158 | \row \li Ctrl+UpArrow \li Moves the cursor one word up. | - |
1159 | \row \li DownArrow \li Moves the cursor one line down. | - |
1160 | \row \li Ctrl+Down Arrow \li Moves the cursor one word down. | - |
1161 | \row \li PageUp \li Moves the cursor one page up. | - |
1162 | \row \li PageDown \li Moves the cursor one page down. | - |
1163 | \row \li Home \li Moves the cursor to the beginning of the line. | - |
1164 | \row \li Ctrl+Home \li Moves the cursor to the beginning of the text. | - |
1165 | \row \li End \li Moves the cursor to the end of the line. | - |
1166 | \row \li Ctrl+End \li Moves the cursor to the end of the text. | - |
1167 | \row \li Alt+Wheel \li Scrolls the page horizontally (the Wheel is the mouse wheel). | - |
1168 | \row \li Ctrl+Wheel \li Zooms the text. | - |
1169 | \endtable | - |
1170 | | - |
1171 | To select (mark) text hold down the Shift key whilst pressing one | - |
1172 | of the movement keystrokes, for example, \e{Shift+Right Arrow} | - |
1173 | will select the character to the right, and \e{Shift+Ctrl+Right | - |
1174 | Arrow} will select the word to the right, etc. | - |
1175 | | - |
1176 | \section1 Differences to QTextEdit | - |
1177 | | - |
1178 | QPlainTextEdit is a thin class, implemented by using most of the | - |
1179 | technology that is behind QTextEdit and QTextDocument. Its | - |
1180 | performance benefits over QTextEdit stem mostly from using a | - |
1181 | different and simplified text layout called | - |
1182 | QPlainTextDocumentLayout on the text document (see | - |
1183 | QTextDocument::setDocumentLayout()). The plain text document layout | - |
1184 | does not support tables nor embedded frames, and \e{replaces a | - |
1185 | pixel-exact height calculation with a line-by-line respectively | - |
1186 | paragraph-by-paragraph scrolling approach}. This makes it possible | - |
1187 | to handle significantly larger documents, and still resize the | - |
1188 | editor with line wrap enabled in real time. It also makes for a | - |
1189 | fast log viewer (see setMaximumBlockCount()). | - |
1190 | | - |
1191 | | - |
1192 | \sa QTextDocument, QTextCursor, {Application Example}, | - |
1193 | {Code Editor Example}, {Syntax Highlighter Example}, | - |
1194 | {Rich Text Processing} | - |
1195 | | - |
1196 | */ | - |
1197 | | - |
1198 | /*! | - |
1199 | \property QPlainTextEdit::plainText | - |
1200 | | - |
1201 | This property gets and sets the plain text editor's contents. The previous | - |
1202 | contents are removed and undo/redo history is reset when this property is set. | - |
1203 | | - |
1204 | By default, for an editor with no contents, this property contains an empty string. | - |
1205 | */ | - |
1206 | | - |
1207 | /*! | - |
1208 | \property QPlainTextEdit::undoRedoEnabled | - |
1209 | \brief whether undo and redo are enabled | - |
1210 | | - |
1211 | Users are only able to undo or redo actions if this property is | - |
1212 | true, and if there is an action that can be undone (or redone). | - |
1213 | | - |
1214 | By default, this property is true. | - |
1215 | */ | - |
1216 | | - |
1217 | /*! | - |
1218 | \enum QPlainTextEdit::LineWrapMode | - |
1219 | | - |
1220 | \value NoWrap | - |
1221 | \value WidgetWidth | - |
1222 | */ | - |
1223 | | - |
1224 | | - |
1225 | /*! | - |
1226 | Constructs an empty QPlainTextEdit with parent \a | - |
1227 | parent. | - |
1228 | */ | - |
1229 | QPlainTextEdit::QPlainTextEdit(QWidget *parent) | - |
1230 | : QAbstractScrollArea(*new QPlainTextEditPrivate, parent) | - |
1231 | { | - |
1232 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
1233 | d->init(); executed (the execution status of this line is deduced): d->init(); | - |
1234 | } executed: } Execution Count:87 | 87 |
1235 | | - |
1236 | /*! | - |
1237 | \internal | - |
1238 | */ | - |
1239 | QPlainTextEdit::QPlainTextEdit(QPlainTextEditPrivate &dd, QWidget *parent) | - |
1240 | : QAbstractScrollArea(dd, parent) | - |
1241 | { | - |
1242 | Q_D(QPlainTextEdit); never executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
1243 | d->init(); never executed (the execution status of this line is deduced): d->init(); | - |
1244 | } | 0 |
1245 | | - |
1246 | /*! | - |
1247 | Constructs a QPlainTextEdit with parent \a parent. The text edit will display | - |
1248 | the plain text \a text. | - |
1249 | */ | - |
1250 | QPlainTextEdit::QPlainTextEdit(const QString &text, QWidget *parent) | - |
1251 | : QAbstractScrollArea(*new QPlainTextEditPrivate, parent) | - |
1252 | { | - |
1253 | Q_D(QPlainTextEdit); never executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
1254 | d->init(text); never executed (the execution status of this line is deduced): d->init(text); | - |
1255 | } | 0 |
1256 | | - |
1257 | | - |
1258 | /*! | - |
1259 | Destructor. | - |
1260 | */ | - |
1261 | QPlainTextEdit::~QPlainTextEdit() | - |
1262 | { | - |
1263 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
1264 | if (d->documentLayoutPtr) { evaluated: d->documentLayoutPtr yes Evaluation Count:19 | yes Evaluation Count:68 |
| 19-68 |
1265 | if (d->documentLayoutPtr->priv()->mainViewPrivate == d) partially evaluated: d->documentLayoutPtr->priv()->mainViewPrivate == d yes Evaluation Count:19 | no Evaluation Count:0 |
| 0-19 |
1266 | d->documentLayoutPtr->priv()->mainViewPrivate = 0; executed: d->documentLayoutPtr->priv()->mainViewPrivate = 0; Execution Count:19 | 19 |
1267 | } executed: } Execution Count:19 | 19 |
1268 | } executed: } Execution Count:87 | 87 |
1269 | | - |
1270 | /*! | - |
1271 | Makes \a document the new document of the text editor. | - |
1272 | | - |
1273 | The parent QObject of the provided document remains the owner | - |
1274 | of the object. If the current document is a child of the text | - |
1275 | editor, then it is deleted. | - |
1276 | | - |
1277 | The document must have a document layout that inherits | - |
1278 | QPlainTextDocumentLayout (see QTextDocument::setDocumentLayout()). | - |
1279 | | - |
1280 | \sa document() | - |
1281 | */ | - |
1282 | void QPlainTextEdit::setDocument(QTextDocument *document) | - |
1283 | { | - |
1284 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
1285 | QPlainTextDocumentLayout *documentLayout = 0; executed (the execution status of this line is deduced): QPlainTextDocumentLayout *documentLayout = 0; | - |
1286 | | - |
1287 | if (!document) { evaluated: !document yes Evaluation Count:1 | yes Evaluation Count:4 |
| 1-4 |
1288 | document = new QTextDocument(d->control); executed (the execution status of this line is deduced): document = new QTextDocument(d->control); | - |
1289 | documentLayout = new QPlainTextDocumentLayout(document); executed (the execution status of this line is deduced): documentLayout = new QPlainTextDocumentLayout(document); | - |
1290 | document->setDocumentLayout(documentLayout); executed (the execution status of this line is deduced): document->setDocumentLayout(documentLayout); | - |
1291 | } else { executed: } Execution Count:1 | 1 |
1292 | documentLayout = qobject_cast<QPlainTextDocumentLayout*>(document->documentLayout()); executed (the execution status of this line is deduced): documentLayout = qobject_cast<QPlainTextDocumentLayout*>(document->documentLayout()); | - |
1293 | if (!documentLayout) { partially evaluated: !documentLayout no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
1294 | qWarning("QPlainTextEdit::setDocument: Document set does not support QPlainTextDocumentLayout"); never executed (the execution status of this line is deduced): QMessageLogger("widgets/qplaintextedit.cpp", 1294, __PRETTY_FUNCTION__).warning("QPlainTextEdit::setDocument: Document set does not support QPlainTextDocumentLayout"); | - |
1295 | return; | 0 |
1296 | } | - |
1297 | } executed: } Execution Count:4 | 4 |
1298 | d->control->setDocument(document); executed (the execution status of this line is deduced): d->control->setDocument(document); | - |
1299 | if (!documentLayout->priv()->mainViewPrivate) partially evaluated: !documentLayout->priv()->mainViewPrivate yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
1300 | documentLayout->priv()->mainViewPrivate = d; executed: documentLayout->priv()->mainViewPrivate = d; Execution Count:5 | 5 |
1301 | d->documentLayoutPtr = documentLayout; executed (the execution status of this line is deduced): d->documentLayoutPtr = documentLayout; | - |
1302 | d->updateDefaultTextOption(); executed (the execution status of this line is deduced): d->updateDefaultTextOption(); | - |
1303 | d->relayoutDocument(); executed (the execution status of this line is deduced): d->relayoutDocument(); | - |
1304 | d->_q_adjustScrollbars(); executed (the execution status of this line is deduced): d->_q_adjustScrollbars(); | - |
1305 | } executed: } Execution Count:5 | 5 |
1306 | | - |
1307 | /*! | - |
1308 | Returns a pointer to the underlying document. | - |
1309 | | - |
1310 | \sa setDocument() | - |
1311 | */ | - |
1312 | QTextDocument *QPlainTextEdit::document() const | - |
1313 | { | - |
1314 | Q_D(const QPlainTextEdit); executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
1315 | return d->control->document(); executed: return d->control->document(); Execution Count:218 | 218 |
1316 | } | - |
1317 | | - |
1318 | /*! | - |
1319 | Sets the visible \a cursor. | - |
1320 | */ | - |
1321 | void QPlainTextEdit::setTextCursor(const QTextCursor &cursor) | - |
1322 | { | - |
1323 | doSetTextCursor(cursor); executed (the execution status of this line is deduced): doSetTextCursor(cursor); | - |
1324 | } executed: } Execution Count:16 | 16 |
1325 | | - |
1326 | /*! | - |
1327 | \internal | - |
1328 | | - |
1329 | This provides a hook for subclasses to intercept cursor changes. | - |
1330 | */ | - |
1331 | | - |
1332 | void QPlainTextEdit::doSetTextCursor(const QTextCursor &cursor) | - |
1333 | { | - |
1334 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
1335 | d->control->setTextCursor(cursor); executed (the execution status of this line is deduced): d->control->setTextCursor(cursor); | - |
1336 | } executed: } Execution Count:16 | 16 |
1337 | | - |
1338 | /*! | - |
1339 | Returns a copy of the QTextCursor that represents the currently visible cursor. | - |
1340 | Note that changes on the returned cursor do not affect QPlainTextEdit's cursor; use | - |
1341 | setTextCursor() to update the visible cursor. | - |
1342 | */ | - |
1343 | QTextCursor QPlainTextEdit::textCursor() const | - |
1344 | { | - |
1345 | Q_D(const QPlainTextEdit); executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
1346 | return d->control->textCursor(); executed: return d->control->textCursor(); Execution Count:323 | 323 |
1347 | } | - |
1348 | | - |
1349 | /*! | - |
1350 | Returns the reference of the anchor at position \a pos, or an | - |
1351 | empty string if no anchor exists at that point. | - |
1352 | | - |
1353 | \since 4.7 | - |
1354 | */ | - |
1355 | QString QPlainTextEdit::anchorAt(const QPoint &pos) const | - |
1356 | { | - |
1357 | Q_D(const QPlainTextEdit); never executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
1358 | int cursorPos = d->control->hitTest(pos + QPointF(d->horizontalOffset(), never executed (the execution status of this line is deduced): int cursorPos = d->control->hitTest(pos + QPointF(d->horizontalOffset(), | - |
1359 | d->verticalOffset()), never executed (the execution status of this line is deduced): d->verticalOffset()), | - |
1360 | Qt::ExactHit); never executed (the execution status of this line is deduced): Qt::ExactHit); | - |
1361 | if (cursorPos < 0) never evaluated: cursorPos < 0 | 0 |
1362 | return QString(); never executed: return QString(); | 0 |
1363 | | - |
1364 | QTextDocumentPrivate *pieceTable = document()->docHandle(); never executed (the execution status of this line is deduced): QTextDocumentPrivate *pieceTable = document()->docHandle(); | - |
1365 | QTextDocumentPrivate::FragmentIterator it = pieceTable->find(cursorPos); never executed (the execution status of this line is deduced): QTextDocumentPrivate::FragmentIterator it = pieceTable->find(cursorPos); | - |
1366 | QTextCharFormat fmt = pieceTable->formatCollection()->charFormat(it->format); never executed (the execution status of this line is deduced): QTextCharFormat fmt = pieceTable->formatCollection()->charFormat(it->format); | - |
1367 | return fmt.anchorHref(); never executed: return fmt.anchorHref(); | 0 |
1368 | } | - |
1369 | | - |
1370 | /*! | - |
1371 | Undoes the last operation. | - |
1372 | | - |
1373 | If there is no operation to undo, i.e. there is no undo step in | - |
1374 | the undo/redo history, nothing happens. | - |
1375 | | - |
1376 | \sa redo() | - |
1377 | */ | - |
1378 | void QPlainTextEdit::undo() | - |
1379 | { | - |
1380 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
1381 | d->control->undo(); executed (the execution status of this line is deduced): d->control->undo(); | - |
1382 | } executed: } Execution Count:5 | 5 |
1383 | | - |
1384 | void QPlainTextEdit::redo() | - |
1385 | { | - |
1386 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
1387 | d->control->redo(); executed (the execution status of this line is deduced): d->control->redo(); | - |
1388 | } executed: } Execution Count:5 | 5 |
1389 | | - |
1390 | /*! | - |
1391 | \fn void QPlainTextEdit::redo() | - |
1392 | | - |
1393 | Redoes the last operation. | - |
1394 | | - |
1395 | If there is no operation to redo, i.e. there is no redo step in | - |
1396 | the undo/redo history, nothing happens. | - |
1397 | | - |
1398 | \sa undo() | - |
1399 | */ | - |
1400 | | - |
1401 | #ifndef QT_NO_CLIPBOARD | - |
1402 | /*! | - |
1403 | Copies the selected text to the clipboard and deletes it from | - |
1404 | the text edit. | - |
1405 | | - |
1406 | If there is no selected text nothing happens. | - |
1407 | | - |
1408 | \sa copy(), paste() | - |
1409 | */ | - |
1410 | | - |
1411 | void QPlainTextEdit::cut() | - |
1412 | { | - |
1413 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
1414 | d->control->cut(); executed (the execution status of this line is deduced): d->control->cut(); | - |
1415 | } executed: } Execution Count:2 | 2 |
1416 | | - |
1417 | /*! | - |
1418 | Copies any selected text to the clipboard. | - |
1419 | | - |
1420 | \sa copyAvailable() | - |
1421 | */ | - |
1422 | | - |
1423 | void QPlainTextEdit::copy() | - |
1424 | { | - |
1425 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
1426 | d->control->copy(); executed (the execution status of this line is deduced): d->control->copy(); | - |
1427 | } executed: } Execution Count:2 | 2 |
1428 | | - |
1429 | /*! | - |
1430 | Pastes the text from the clipboard into the text edit at the | - |
1431 | current cursor position. | - |
1432 | | - |
1433 | If there is no text in the clipboard nothing happens. | - |
1434 | | - |
1435 | To change the behavior of this function, i.e. to modify what | - |
1436 | QPlainTextEdit can paste and how it is being pasted, reimplement the | - |
1437 | virtual canInsertFromMimeData() and insertFromMimeData() | - |
1438 | functions. | - |
1439 | | - |
1440 | \sa cut(), copy() | - |
1441 | */ | - |
1442 | | - |
1443 | void QPlainTextEdit::paste() | - |
1444 | { | - |
1445 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
1446 | d->control->paste(); executed (the execution status of this line is deduced): d->control->paste(); | - |
1447 | } executed: } Execution Count:3 | 3 |
1448 | #endif | - |
1449 | | - |
1450 | /*! | - |
1451 | Deletes all the text in the text edit. | - |
1452 | | - |
1453 | Note that the undo/redo history is cleared by this function. | - |
1454 | | - |
1455 | \sa cut(), setPlainText() | - |
1456 | */ | - |
1457 | void QPlainTextEdit::clear() | - |
1458 | { | - |
1459 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
1460 | // clears and sets empty content | - |
1461 | d->control->topBlock = d->topLine = d->topLineFracture = 0; executed (the execution status of this line is deduced): d->control->topBlock = d->topLine = d->topLineFracture = 0; | - |
1462 | d->control->clear(); executed (the execution status of this line is deduced): d->control->clear(); | - |
1463 | } executed: } Execution Count:11 | 11 |
1464 | | - |
1465 | | - |
1466 | /*! | - |
1467 | Selects all text. | - |
1468 | | - |
1469 | \sa copy(), cut(), textCursor() | - |
1470 | */ | - |
1471 | void QPlainTextEdit::selectAll() | - |
1472 | { | - |
1473 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
1474 | d->control->selectAll(); executed (the execution status of this line is deduced): d->control->selectAll(); | - |
1475 | } executed: } Execution Count:2 | 2 |
1476 | | - |
1477 | /*! \internal | - |
1478 | */ | - |
1479 | bool QPlainTextEdit::event(QEvent *e) | - |
1480 | { | - |
1481 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
1482 | | - |
1483 | #ifndef QT_NO_CONTEXTMENU | - |
1484 | if (e->type() == QEvent::ContextMenu partially evaluated: e->type() == QEvent::ContextMenu no Evaluation Count:0 | yes Evaluation Count:847 |
| 0-847 |
1485 | && static_cast<QContextMenuEvent *>(e)->reason() == QContextMenuEvent::Keyboard) { never evaluated: static_cast<QContextMenuEvent *>(e)->reason() == QContextMenuEvent::Keyboard | 0 |
1486 | ensureCursorVisible(); never executed (the execution status of this line is deduced): ensureCursorVisible(); | - |
1487 | const QPoint cursorPos = cursorRect().center(); never executed (the execution status of this line is deduced): const QPoint cursorPos = cursorRect().center(); | - |
1488 | QContextMenuEvent ce(QContextMenuEvent::Keyboard, cursorPos, d->viewport->mapToGlobal(cursorPos)); never executed (the execution status of this line is deduced): QContextMenuEvent ce(QContextMenuEvent::Keyboard, cursorPos, d->viewport->mapToGlobal(cursorPos)); | - |
1489 | ce.setAccepted(e->isAccepted()); never executed (the execution status of this line is deduced): ce.setAccepted(e->isAccepted()); | - |
1490 | const bool result = QAbstractScrollArea::event(&ce); never executed (the execution status of this line is deduced): const bool result = QAbstractScrollArea::event(&ce); | - |
1491 | e->setAccepted(ce.isAccepted()); never executed (the execution status of this line is deduced): e->setAccepted(ce.isAccepted()); | - |
1492 | return result; never executed: return result; | 0 |
1493 | } | - |
1494 | #endif // QT_NO_CONTEXTMENU | - |
1495 | if (e->type() == QEvent::ShortcutOverride evaluated: e->type() == QEvent::ShortcutOverride yes Evaluation Count:150 | yes Evaluation Count:697 |
| 150-697 |
1496 | || e->type() == QEvent::ToolTip) { partially evaluated: e->type() == QEvent::ToolTip no Evaluation Count:0 | yes Evaluation Count:697 |
| 0-697 |
1497 | d->sendControlEvent(e); executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
1498 | } executed: } Execution Count:150 | 150 |
1499 | #ifdef QT_KEYPAD_NAVIGATION | - |
1500 | else if (e->type() == QEvent::EnterEditFocus || e->type() == QEvent::LeaveEditFocus) { | - |
1501 | if (QApplication::keypadNavigationEnabled()) | - |
1502 | d->sendControlEvent(e); | - |
1503 | } | - |
1504 | #endif | - |
1505 | #ifndef QT_NO_GESTURES | - |
1506 | else if (e->type() == QEvent::Gesture) { partially evaluated: e->type() == QEvent::Gesture no Evaluation Count:0 | yes Evaluation Count:697 |
| 0-697 |
1507 | QGestureEvent *ge = static_cast<QGestureEvent *>(e); never executed (the execution status of this line is deduced): QGestureEvent *ge = static_cast<QGestureEvent *>(e); | - |
1508 | QPanGesture *g = static_cast<QPanGesture *>(ge->gesture(Qt::PanGesture)); never executed (the execution status of this line is deduced): QPanGesture *g = static_cast<QPanGesture *>(ge->gesture(Qt::PanGesture)); | - |
1509 | if (g) { | 0 |
1510 | QScrollBar *hBar = horizontalScrollBar(); never executed (the execution status of this line is deduced): QScrollBar *hBar = horizontalScrollBar(); | - |
1511 | QScrollBar *vBar = verticalScrollBar(); never executed (the execution status of this line is deduced): QScrollBar *vBar = verticalScrollBar(); | - |
1512 | if (g->state() == Qt::GestureStarted) never evaluated: g->state() == Qt::GestureStarted | 0 |
1513 | d->originalOffsetY = vBar->value(); never executed: d->originalOffsetY = vBar->value(); | 0 |
1514 | QPointF offset = g->offset(); never executed (the execution status of this line is deduced): QPointF offset = g->offset(); | - |
1515 | if (!offset.isNull()) { never evaluated: !offset.isNull() | 0 |
1516 | if (QApplication::isRightToLeft()) never evaluated: QApplication::isRightToLeft() | 0 |
1517 | offset.rx() *= -1; never executed: offset.rx() *= -1; | 0 |
1518 | // QPlainTextEdit scrolls by lines only in vertical direction | - |
1519 | QFontMetrics fm(document()->defaultFont()); never executed (the execution status of this line is deduced): QFontMetrics fm(document()->defaultFont()); | - |
1520 | int lineHeight = fm.height(); never executed (the execution status of this line is deduced): int lineHeight = fm.height(); | - |
1521 | int newX = hBar->value() - g->delta().x(); never executed (the execution status of this line is deduced): int newX = hBar->value() - g->delta().x(); | - |
1522 | int newY = d->originalOffsetY - offset.y()/lineHeight; never executed (the execution status of this line is deduced): int newY = d->originalOffsetY - offset.y()/lineHeight; | - |
1523 | hBar->setValue(newX); never executed (the execution status of this line is deduced): hBar->setValue(newX); | - |
1524 | vBar->setValue(newY); never executed (the execution status of this line is deduced): vBar->setValue(newY); | - |
1525 | } | 0 |
1526 | } | 0 |
1527 | return true; never executed: return true; | 0 |
1528 | } | - |
1529 | #endif // QT_NO_GESTURES | - |
1530 | return QAbstractScrollArea::event(e); executed: return QAbstractScrollArea::event(e); Execution Count:847 | 847 |
1531 | } | - |
1532 | | - |
1533 | /*! \internal | - |
1534 | */ | - |
1535 | | - |
1536 | void QPlainTextEdit::timerEvent(QTimerEvent *e) | - |
1537 | { | - |
1538 | Q_D(QPlainTextEdit); never executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
1539 | if (e->timerId() == d->autoScrollTimer.timerId()) { never evaluated: e->timerId() == d->autoScrollTimer.timerId() | 0 |
1540 | QRect visible = d->viewport->rect(); never executed (the execution status of this line is deduced): QRect visible = d->viewport->rect(); | - |
1541 | QPoint pos; never executed (the execution status of this line is deduced): QPoint pos; | - |
1542 | if (d->inDrag) { never evaluated: d->inDrag | 0 |
1543 | pos = d->autoScrollDragPos; never executed (the execution status of this line is deduced): pos = d->autoScrollDragPos; | - |
1544 | visible.adjust(qMin(visible.width()/3,20), qMin(visible.height()/3,20), never executed (the execution status of this line is deduced): visible.adjust(qMin(visible.width()/3,20), qMin(visible.height()/3,20), | - |
1545 | -qMin(visible.width()/3,20), -qMin(visible.height()/3,20)); never executed (the execution status of this line is deduced): -qMin(visible.width()/3,20), -qMin(visible.height()/3,20)); | - |
1546 | } else { | 0 |
1547 | const QPoint globalPos = QCursor::pos(); never executed (the execution status of this line is deduced): const QPoint globalPos = QCursor::pos(); | - |
1548 | pos = d->viewport->mapFromGlobal(globalPos); never executed (the execution status of this line is deduced): pos = d->viewport->mapFromGlobal(globalPos); | - |
1549 | QMouseEvent ev(QEvent::MouseMove, pos, d->viewport->mapTo(d->viewport->topLevelWidget(), pos), globalPos, never executed (the execution status of this line is deduced): QMouseEvent ev(QEvent::MouseMove, pos, d->viewport->mapTo(d->viewport->topLevelWidget(), pos), globalPos, | - |
1550 | Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); never executed (the execution status of this line is deduced): Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); | - |
1551 | mouseMoveEvent(&ev); never executed (the execution status of this line is deduced): mouseMoveEvent(&ev); | - |
1552 | } | 0 |
1553 | int deltaY = qMax(pos.y() - visible.top(), visible.bottom() - pos.y()) - visible.height(); never executed (the execution status of this line is deduced): int deltaY = qMax(pos.y() - visible.top(), visible.bottom() - pos.y()) - visible.height(); | - |
1554 | int deltaX = qMax(pos.x() - visible.left(), visible.right() - pos.x()) - visible.width(); never executed (the execution status of this line is deduced): int deltaX = qMax(pos.x() - visible.left(), visible.right() - pos.x()) - visible.width(); | - |
1555 | int delta = qMax(deltaX, deltaY); never executed (the execution status of this line is deduced): int delta = qMax(deltaX, deltaY); | - |
1556 | if (delta >= 0) { never evaluated: delta >= 0 | 0 |
1557 | if (delta < 7) never evaluated: delta < 7 | 0 |
1558 | delta = 7; never executed: delta = 7; | 0 |
1559 | int timeout = 4900 / (delta * delta); never executed (the execution status of this line is deduced): int timeout = 4900 / (delta * delta); | - |
1560 | d->autoScrollTimer.start(timeout, this); never executed (the execution status of this line is deduced): d->autoScrollTimer.start(timeout, this); | - |
1561 | | - |
1562 | if (deltaY > 0) never evaluated: deltaY > 0 | 0 |
1563 | d->vbar->triggerAction(pos.y() < visible.center().y() ? never executed: d->vbar->triggerAction(pos.y() < visible.center().y() ? QAbstractSlider::SliderSingleStepSub : QAbstractSlider::SliderSingleStepAdd); | 0 |
1564 | QAbstractSlider::SliderSingleStepSub never executed: d->vbar->triggerAction(pos.y() < visible.center().y() ? QAbstractSlider::SliderSingleStepSub : QAbstractSlider::SliderSingleStepAdd); | 0 |
1565 | : QAbstractSlider::SliderSingleStepAdd); never executed: d->vbar->triggerAction(pos.y() < visible.center().y() ? QAbstractSlider::SliderSingleStepSub : QAbstractSlider::SliderSingleStepAdd); | 0 |
1566 | if (deltaX > 0) never evaluated: deltaX > 0 | 0 |
1567 | d->hbar->triggerAction(pos.x() < visible.center().x() ? never executed: d->hbar->triggerAction(pos.x() < visible.center().x() ? QAbstractSlider::SliderSingleStepSub : QAbstractSlider::SliderSingleStepAdd); | 0 |
1568 | QAbstractSlider::SliderSingleStepSub never executed: d->hbar->triggerAction(pos.x() < visible.center().x() ? QAbstractSlider::SliderSingleStepSub : QAbstractSlider::SliderSingleStepAdd); | 0 |
1569 | : QAbstractSlider::SliderSingleStepAdd); never executed: d->hbar->triggerAction(pos.x() < visible.center().x() ? QAbstractSlider::SliderSingleStepSub : QAbstractSlider::SliderSingleStepAdd); | 0 |
1570 | } | 0 |
1571 | } | 0 |
1572 | #ifdef QT_KEYPAD_NAVIGATION | - |
1573 | else if (e->timerId() == d->deleteAllTimer.timerId()) { | - |
1574 | d->deleteAllTimer.stop(); | - |
1575 | clear(); | - |
1576 | } | - |
1577 | #endif | - |
1578 | } | 0 |
1579 | | - |
1580 | /*! | - |
1581 | Changes the text of the text edit to the string \a text. | - |
1582 | Any previous text is removed. | - |
1583 | | - |
1584 | \a text is interpreted as plain text. | - |
1585 | | - |
1586 | Note that the undo/redo history is cleared by this function. | - |
1587 | | - |
1588 | \sa toText() | - |
1589 | */ | - |
1590 | | - |
1591 | void QPlainTextEdit::setPlainText(const QString &text) | - |
1592 | { | - |
1593 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
1594 | d->control->setPlainText(text); executed (the execution status of this line is deduced): d->control->setPlainText(text); | - |
1595 | } executed: } Execution Count:59 | 59 |
1596 | | - |
1597 | /*! | - |
1598 | \fn QString QPlainTextEdit::toPlainText() const | - |
1599 | | - |
1600 | Returns the text of the text edit as plain text. | - |
1601 | | - |
1602 | \sa QPlainTextEdit::setPlainText() | - |
1603 | */ | - |
1604 | | - |
1605 | /*! \reimp | - |
1606 | */ | - |
1607 | void QPlainTextEdit::keyPressEvent(QKeyEvent *e) | - |
1608 | { | - |
1609 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
1610 | | - |
1611 | #ifdef QT_KEYPAD_NAVIGATION | - |
1612 | switch (e->key()) { | - |
1613 | case Qt::Key_Select: | - |
1614 | if (QApplication::keypadNavigationEnabled()) { | - |
1615 | if (!(d->control->textInteractionFlags() & Qt::LinksAccessibleByKeyboard)) | - |
1616 | setEditFocus(!hasEditFocus()); | - |
1617 | else { | - |
1618 | if (!hasEditFocus()) | - |
1619 | setEditFocus(true); | - |
1620 | else { | - |
1621 | QTextCursor cursor = d->control->textCursor(); | - |
1622 | QTextCharFormat charFmt = cursor.charFormat(); | - |
1623 | if (!cursor.hasSelection() || charFmt.anchorHref().isEmpty()) { | - |
1624 | setEditFocus(false); | - |
1625 | } | - |
1626 | } | - |
1627 | } | - |
1628 | } | - |
1629 | break; | - |
1630 | case Qt::Key_Back: | - |
1631 | case Qt::Key_No: | - |
1632 | if (!QApplication::keypadNavigationEnabled() | - |
1633 | || (QApplication::keypadNavigationEnabled() && !hasEditFocus())) { | - |
1634 | e->ignore(); | - |
1635 | return; | - |
1636 | } | - |
1637 | break; | - |
1638 | default: | - |
1639 | if (QApplication::keypadNavigationEnabled()) { | - |
1640 | if (!hasEditFocus() && !(e->modifiers() & Qt::ControlModifier)) { | - |
1641 | if (e->text()[0].isPrint()) { | - |
1642 | setEditFocus(true); | - |
1643 | clear(); | - |
1644 | } else { | - |
1645 | e->ignore(); | - |
1646 | return; | - |
1647 | } | - |
1648 | } | - |
1649 | } | - |
1650 | break; | - |
1651 | } | - |
1652 | #endif | - |
1653 | | - |
1654 | #ifndef QT_NO_SHORTCUT | - |
1655 | | - |
1656 | Qt::TextInteractionFlags tif = d->control->textInteractionFlags(); executed (the execution status of this line is deduced): Qt::TextInteractionFlags tif = d->control->textInteractionFlags(); | - |
1657 | | - |
1658 | if (tif & Qt::TextSelectableByKeyboard){ evaluated: tif & Qt::TextSelectableByKeyboard yes Evaluation Count:144 | yes Evaluation Count:5 |
| 5-144 |
1659 | if (e == QKeySequence::SelectPreviousPage) { partially evaluated: e == QKeySequence::SelectPreviousPage no Evaluation Count:0 | yes Evaluation Count:144 |
| 0-144 |
1660 | e->accept(); never executed (the execution status of this line is deduced): e->accept(); | - |
1661 | d->pageUpDown(QTextCursor::Up, QTextCursor::KeepAnchor); never executed (the execution status of this line is deduced): d->pageUpDown(QTextCursor::Up, QTextCursor::KeepAnchor); | - |
1662 | return; | 0 |
1663 | } else if (e ==QKeySequence::SelectNextPage) { partially evaluated: e ==QKeySequence::SelectNextPage no Evaluation Count:0 | yes Evaluation Count:144 |
| 0-144 |
1664 | e->accept(); never executed (the execution status of this line is deduced): e->accept(); | - |
1665 | d->pageUpDown(QTextCursor::Down, QTextCursor::KeepAnchor); never executed (the execution status of this line is deduced): d->pageUpDown(QTextCursor::Down, QTextCursor::KeepAnchor); | - |
1666 | return; | 0 |
1667 | } | - |
1668 | } | - |
1669 | if (tif & (Qt::TextSelectableByKeyboard | Qt::TextEditable)) { evaluated: tif & (Qt::TextSelectableByKeyboard | Qt::TextEditable) yes Evaluation Count:144 | yes Evaluation Count:5 |
| 5-144 |
1670 | if (e == QKeySequence::MoveToPreviousPage) { partially evaluated: e == QKeySequence::MoveToPreviousPage no Evaluation Count:0 | yes Evaluation Count:144 |
| 0-144 |
1671 | e->accept(); never executed (the execution status of this line is deduced): e->accept(); | - |
1672 | d->pageUpDown(QTextCursor::Up, QTextCursor::MoveAnchor); never executed (the execution status of this line is deduced): d->pageUpDown(QTextCursor::Up, QTextCursor::MoveAnchor); | - |
1673 | return; | 0 |
1674 | } else if (e == QKeySequence::MoveToNextPage) { partially evaluated: e == QKeySequence::MoveToNextPage no Evaluation Count:0 | yes Evaluation Count:144 |
| 0-144 |
1675 | e->accept(); never executed (the execution status of this line is deduced): e->accept(); | - |
1676 | d->pageUpDown(QTextCursor::Down, QTextCursor::MoveAnchor); never executed (the execution status of this line is deduced): d->pageUpDown(QTextCursor::Down, QTextCursor::MoveAnchor); | - |
1677 | return; | 0 |
1678 | } | - |
1679 | } | - |
1680 | | - |
1681 | if (!(tif & Qt::TextEditable)) { evaluated: !(tif & Qt::TextEditable) yes Evaluation Count:5 | yes Evaluation Count:144 |
| 5-144 |
1682 | switch (e->key()) { | - |
1683 | case Qt::Key_Space: | - |
1684 | e->accept(); never executed (the execution status of this line is deduced): e->accept(); | - |
1685 | if (e->modifiers() & Qt::ShiftModifier) never evaluated: e->modifiers() & Qt::ShiftModifier | 0 |
1686 | d->vbar->triggerAction(QAbstractSlider::SliderPageStepSub); never executed: d->vbar->triggerAction(QAbstractSlider::SliderPageStepSub); | 0 |
1687 | else | - |
1688 | d->vbar->triggerAction(QAbstractSlider::SliderPageStepAdd); never executed: d->vbar->triggerAction(QAbstractSlider::SliderPageStepAdd); | 0 |
1689 | break; | 0 |
1690 | default: | - |
1691 | d->sendControlEvent(e); executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
1692 | if (!e->isAccepted() && e->modifiers() == Qt::NoModifier) { evaluated: !e->isAccepted() yes Evaluation Count:3 | yes Evaluation Count:2 |
evaluated: e->modifiers() == Qt::NoModifier yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-3 |
1693 | if (e->key() == Qt::Key_Home) { partially evaluated: e->key() == Qt::Key_Home no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1694 | d->vbar->triggerAction(QAbstractSlider::SliderToMinimum); never executed (the execution status of this line is deduced): d->vbar->triggerAction(QAbstractSlider::SliderToMinimum); | - |
1695 | e->accept(); never executed (the execution status of this line is deduced): e->accept(); | - |
1696 | } else if (e->key() == Qt::Key_End) { never executed: } partially evaluated: e->key() == Qt::Key_End no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1697 | d->vbar->triggerAction(QAbstractSlider::SliderToMaximum); never executed (the execution status of this line is deduced): d->vbar->triggerAction(QAbstractSlider::SliderToMaximum); | - |
1698 | e->accept(); never executed (the execution status of this line is deduced): e->accept(); | - |
1699 | } | 0 |
1700 | } | - |
1701 | if (!e->isAccepted()) { evaluated: !e->isAccepted() yes Evaluation Count:3 | yes Evaluation Count:2 |
| 2-3 |
1702 | QAbstractScrollArea::keyPressEvent(e); executed (the execution status of this line is deduced): QAbstractScrollArea::keyPressEvent(e); | - |
1703 | } executed: } Execution Count:3 | 3 |
1704 | } executed: } Execution Count:5 | 5 |
1705 | return; executed: return; Execution Count:5 | 5 |
1706 | } | - |
1707 | #endif // QT_NO_SHORTCUT | - |
1708 | | - |
1709 | d->sendControlEvent(e); executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
1710 | #ifdef QT_KEYPAD_NAVIGATION | - |
1711 | if (!e->isAccepted()) { | - |
1712 | switch (e->key()) { | - |
1713 | case Qt::Key_Up: | - |
1714 | case Qt::Key_Down: | - |
1715 | if (QApplication::keypadNavigationEnabled()) { | - |
1716 | // Cursor position didn't change, so we want to leave | - |
1717 | // these keys to change focus. | - |
1718 | e->ignore(); | - |
1719 | return; | - |
1720 | } | - |
1721 | break; | - |
1722 | case Qt::Key_Left: | - |
1723 | case Qt::Key_Right: | - |
1724 | if (QApplication::keypadNavigationEnabled() | - |
1725 | && QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) { | - |
1726 | // Same as for Key_Up and Key_Down. | - |
1727 | e->ignore(); | - |
1728 | return; | - |
1729 | } | - |
1730 | break; | - |
1731 | case Qt::Key_Back: | - |
1732 | if (!e->isAutoRepeat()) { | - |
1733 | if (QApplication::keypadNavigationEnabled()) { | - |
1734 | if (document()->isEmpty()) { | - |
1735 | setEditFocus(false); | - |
1736 | e->accept(); | - |
1737 | } else if (!d->deleteAllTimer.isActive()) { | - |
1738 | e->accept(); | - |
1739 | d->deleteAllTimer.start(750, this); | - |
1740 | } | - |
1741 | } else { | - |
1742 | e->ignore(); | - |
1743 | return; | - |
1744 | } | - |
1745 | } | - |
1746 | break; | - |
1747 | default: break; | - |
1748 | } | - |
1749 | } | - |
1750 | #endif | - |
1751 | } executed: } Execution Count:144 | 144 |
1752 | | - |
1753 | /*! \reimp | - |
1754 | */ | - |
1755 | void QPlainTextEdit::keyReleaseEvent(QKeyEvent *e) | - |
1756 | { | - |
1757 | #ifdef QT_KEYPAD_NAVIGATION | - |
1758 | Q_D(QPlainTextEdit); | - |
1759 | if (QApplication::keypadNavigationEnabled()) { | - |
1760 | if (!e->isAutoRepeat() && e->key() == Qt::Key_Back | - |
1761 | && d->deleteAllTimer.isActive()) { | - |
1762 | d->deleteAllTimer.stop(); | - |
1763 | QTextCursor cursor = d->control->textCursor(); | - |
1764 | QTextBlockFormat blockFmt = cursor.blockFormat(); | - |
1765 | | - |
1766 | QTextList *list = cursor.currentList(); | - |
1767 | if (list && cursor.atBlockStart()) { | - |
1768 | list->remove(cursor.block()); | - |
1769 | } else if (cursor.atBlockStart() && blockFmt.indent() > 0) { | - |
1770 | blockFmt.setIndent(blockFmt.indent() - 1); | - |
1771 | cursor.setBlockFormat(blockFmt); | - |
1772 | } else { | - |
1773 | cursor.deletePreviousChar(); | - |
1774 | } | - |
1775 | setTextCursor(cursor); | - |
1776 | } | - |
1777 | } | - |
1778 | #else | - |
1779 | Q_UNUSED(e); executed (the execution status of this line is deduced): (void)e;; | - |
1780 | #endif | - |
1781 | } executed: } Execution Count:150 | 150 |
1782 | | - |
1783 | /*! | - |
1784 | Loads the resource specified by the given \a type and \a name. | - |
1785 | | - |
1786 | This function is an extension of QTextDocument::loadResource(). | - |
1787 | | - |
1788 | \sa QTextDocument::loadResource() | - |
1789 | */ | - |
1790 | QVariant QPlainTextEdit::loadResource(int type, const QUrl &name) | - |
1791 | { | - |
1792 | Q_UNUSED(type); executed (the execution status of this line is deduced): (void)type;; | - |
1793 | Q_UNUSED(name); executed (the execution status of this line is deduced): (void)name;; | - |
1794 | return QVariant(); executed: return QVariant(); Execution Count:1 | 1 |
1795 | } | - |
1796 | | - |
1797 | /*! \reimp | - |
1798 | */ | - |
1799 | void QPlainTextEdit::resizeEvent(QResizeEvent *e) | - |
1800 | { | - |
1801 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
1802 | if (e->oldSize().width() != e->size().width()) partially evaluated: e->oldSize().width() != e->size().width() yes Evaluation Count:20 | no Evaluation Count:0 |
| 0-20 |
1803 | d->relayoutDocument(); executed: d->relayoutDocument(); Execution Count:20 | 20 |
1804 | d->_q_adjustScrollbars(); executed (the execution status of this line is deduced): d->_q_adjustScrollbars(); | - |
1805 | } executed: } Execution Count:20 | 20 |
1806 | | - |
1807 | void QPlainTextEditPrivate::relayoutDocument() | - |
1808 | { | - |
1809 | QTextDocument *doc = control->document(); executed (the execution status of this line is deduced): QTextDocument *doc = control->document(); | - |
1810 | QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(doc->documentLayout()); executed (the execution status of this line is deduced): QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(doc->documentLayout()); | - |
1811 | Q_ASSERT(documentLayout); executed (the execution status of this line is deduced): qt_noop(); | - |
1812 | documentLayoutPtr = documentLayout; executed (the execution status of this line is deduced): documentLayoutPtr = documentLayout; | - |
1813 | | - |
1814 | int width = viewport->width(); executed (the execution status of this line is deduced): int width = viewport->width(); | - |
1815 | | - |
1816 | if (documentLayout->priv()->mainViewPrivate == 0 evaluated: documentLayout->priv()->mainViewPrivate == 0 yes Evaluation Count:15 | yes Evaluation Count:16 |
| 15-16 |
1817 | || documentLayout->priv()->mainViewPrivate == this partially evaluated: documentLayout->priv()->mainViewPrivate == this yes Evaluation Count:16 | no Evaluation Count:0 |
| 0-16 |
1818 | || width > documentLayout->textWidth()) { never evaluated: width > documentLayout->textWidth() | 0 |
1819 | documentLayout->priv()->mainViewPrivate = this; executed (the execution status of this line is deduced): documentLayout->priv()->mainViewPrivate = this; | - |
1820 | documentLayout->setTextWidth(width); executed (the execution status of this line is deduced): documentLayout->setTextWidth(width); | - |
1821 | } executed: } Execution Count:31 | 31 |
1822 | } executed: } Execution Count:31 | 31 |
1823 | | - |
1824 | static void fillBackground(QPainter *p, const QRectF &rect, QBrush brush, QRectF gradientRect = QRectF()) | - |
1825 | { | - |
1826 | p->save(); never executed (the execution status of this line is deduced): p->save(); | - |
1827 | if (brush.style() >= Qt::LinearGradientPattern && brush.style() <= Qt::ConicalGradientPattern) { never evaluated: brush.style() >= Qt::LinearGradientPattern never evaluated: brush.style() <= Qt::ConicalGradientPattern | 0 |
1828 | if (!gradientRect.isNull()) { never evaluated: !gradientRect.isNull() | 0 |
1829 | QTransform m = QTransform::fromTranslate(gradientRect.left(), gradientRect.top()); never executed (the execution status of this line is deduced): QTransform m = QTransform::fromTranslate(gradientRect.left(), gradientRect.top()); | - |
1830 | m.scale(gradientRect.width(), gradientRect.height()); never executed (the execution status of this line is deduced): m.scale(gradientRect.width(), gradientRect.height()); | - |
1831 | brush.setTransform(m); never executed (the execution status of this line is deduced): brush.setTransform(m); | - |
1832 | const_cast<QGradient *>(brush.gradient())->setCoordinateMode(QGradient::LogicalMode); never executed (the execution status of this line is deduced): const_cast<QGradient *>(brush.gradient())->setCoordinateMode(QGradient::LogicalMode); | - |
1833 | } | 0 |
1834 | } else { | 0 |
1835 | p->setBrushOrigin(rect.topLeft()); never executed (the execution status of this line is deduced): p->setBrushOrigin(rect.topLeft()); | - |
1836 | } | 0 |
1837 | p->fillRect(rect, brush); never executed (the execution status of this line is deduced): p->fillRect(rect, brush); | - |
1838 | p->restore(); never executed (the execution status of this line is deduced): p->restore(); | - |
1839 | } | 0 |
1840 | | - |
1841 | | - |
1842 | | - |
1843 | /*! \reimp | - |
1844 | */ | - |
1845 | void QPlainTextEdit::paintEvent(QPaintEvent *e) | - |
1846 | { | - |
1847 | QPainter painter(viewport()); executed (the execution status of this line is deduced): QPainter painter(viewport()); | - |
1848 | Q_ASSERT(qobject_cast<QPlainTextDocumentLayout*>(document()->documentLayout())); executed (the execution status of this line is deduced): qt_noop(); | - |
1849 | | - |
1850 | QPointF offset(contentOffset()); executed (the execution status of this line is deduced): QPointF offset(contentOffset()); | - |
1851 | | - |
1852 | QRect er = e->rect(); executed (the execution status of this line is deduced): QRect er = e->rect(); | - |
1853 | QRect viewportRect = viewport()->rect(); executed (the execution status of this line is deduced): QRect viewportRect = viewport()->rect(); | - |
1854 | | - |
1855 | bool editable = !isReadOnly(); executed (the execution status of this line is deduced): bool editable = !isReadOnly(); | - |
1856 | | - |
1857 | QTextBlock block = firstVisibleBlock(); executed (the execution status of this line is deduced): QTextBlock block = firstVisibleBlock(); | - |
1858 | qreal maximumWidth = document()->documentLayout()->documentSize().width(); executed (the execution status of this line is deduced): qreal maximumWidth = document()->documentLayout()->documentSize().width(); | - |
1859 | | - |
1860 | // Set a brush origin so that the WaveUnderline knows where the wave started | - |
1861 | painter.setBrushOrigin(offset); executed (the execution status of this line is deduced): painter.setBrushOrigin(offset); | - |
1862 | | - |
1863 | // keep right margin clean from full-width selection | - |
1864 | int maxX = offset.x() + qMax((qreal)viewportRect.width(), maximumWidth) executed (the execution status of this line is deduced): int maxX = offset.x() + qMax((qreal)viewportRect.width(), maximumWidth) | - |
1865 | - document()->documentMargin(); executed (the execution status of this line is deduced): - document()->documentMargin(); | - |
1866 | er.setRight(qMin(er.right(), maxX)); executed (the execution status of this line is deduced): er.setRight(qMin(er.right(), maxX)); | - |
1867 | painter.setClipRect(er); executed (the execution status of this line is deduced): painter.setClipRect(er); | - |
1868 | | - |
1869 | | - |
1870 | QAbstractTextDocumentLayout::PaintContext context = getPaintContext(); executed (the execution status of this line is deduced): QAbstractTextDocumentLayout::PaintContext context = getPaintContext(); | - |
1871 | | - |
1872 | while (block.isValid()) { evaluated: block.isValid() yes Evaluation Count:7 | yes Evaluation Count:1 |
| 1-7 |
1873 | | - |
1874 | QRectF r = blockBoundingRect(block).translated(offset); executed (the execution status of this line is deduced): QRectF r = blockBoundingRect(block).translated(offset); | - |
1875 | QTextLayout *layout = block.layout(); executed (the execution status of this line is deduced): QTextLayout *layout = block.layout(); | - |
1876 | | - |
1877 | if (!block.isVisible()) { partially evaluated: !block.isVisible() no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
1878 | offset.ry() += r.height(); never executed (the execution status of this line is deduced): offset.ry() += r.height(); | - |
1879 | block = block.next(); never executed (the execution status of this line is deduced): block = block.next(); | - |
1880 | continue; never executed: continue; | 0 |
1881 | } | - |
1882 | | - |
1883 | if (r.bottom() >= er.top() && r.top() <= er.bottom()) { partially evaluated: r.bottom() >= er.top() yes Evaluation Count:7 | no Evaluation Count:0 |
partially evaluated: r.top() <= er.bottom() yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
1884 | | - |
1885 | QTextBlockFormat blockFormat = block.blockFormat(); executed (the execution status of this line is deduced): QTextBlockFormat blockFormat = block.blockFormat(); | - |
1886 | | - |
1887 | QBrush bg = blockFormat.background(); executed (the execution status of this line is deduced): QBrush bg = blockFormat.background(); | - |
1888 | if (bg != Qt::NoBrush) { partially evaluated: bg != Qt::NoBrush no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
1889 | QRectF contentsRect = r; never executed (the execution status of this line is deduced): QRectF contentsRect = r; | - |
1890 | contentsRect.setWidth(qMax(r.width(), maximumWidth)); never executed (the execution status of this line is deduced): contentsRect.setWidth(qMax(r.width(), maximumWidth)); | - |
1891 | fillBackground(&painter, contentsRect, bg); never executed (the execution status of this line is deduced): fillBackground(&painter, contentsRect, bg); | - |
1892 | } | 0 |
1893 | | - |
1894 | | - |
1895 | QVector<QTextLayout::FormatRange> selections; executed (the execution status of this line is deduced): QVector<QTextLayout::FormatRange> selections; | - |
1896 | int blpos = block.position(); executed (the execution status of this line is deduced): int blpos = block.position(); | - |
1897 | int bllen = block.length(); executed (the execution status of this line is deduced): int bllen = block.length(); | - |
1898 | for (int i = 0; i < context.selections.size(); ++i) { partially evaluated: i < context.selections.size() no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
1899 | const QAbstractTextDocumentLayout::Selection &range = context.selections.at(i); never executed (the execution status of this line is deduced): const QAbstractTextDocumentLayout::Selection &range = context.selections.at(i); | - |
1900 | const int selStart = range.cursor.selectionStart() - blpos; never executed (the execution status of this line is deduced): const int selStart = range.cursor.selectionStart() - blpos; | - |
1901 | const int selEnd = range.cursor.selectionEnd() - blpos; never executed (the execution status of this line is deduced): const int selEnd = range.cursor.selectionEnd() - blpos; | - |
1902 | if (selStart < bllen && selEnd > 0 never evaluated: selStart < bllen never evaluated: selEnd > 0 | 0 |
1903 | && selEnd > selStart) { never evaluated: selEnd > selStart | 0 |
1904 | QTextLayout::FormatRange o; never executed (the execution status of this line is deduced): QTextLayout::FormatRange o; | - |
1905 | o.start = selStart; never executed (the execution status of this line is deduced): o.start = selStart; | - |
1906 | o.length = selEnd - selStart; never executed (the execution status of this line is deduced): o.length = selEnd - selStart; | - |
1907 | o.format = range.format; never executed (the execution status of this line is deduced): o.format = range.format; | - |
1908 | selections.append(o); never executed (the execution status of this line is deduced): selections.append(o); | - |
1909 | } else if (!range.cursor.hasSelection() && range.format.hasProperty(QTextFormat::FullWidthSelection) never executed: } never evaluated: !range.cursor.hasSelection() never evaluated: range.format.hasProperty(QTextFormat::FullWidthSelection) | 0 |
1910 | && block.contains(range.cursor.position())) { never evaluated: block.contains(range.cursor.position()) | 0 |
1911 | // for full width selections we don't require an actual selection, just | - |
1912 | // a position to specify the line. that's more convenience in usage. | - |
1913 | QTextLayout::FormatRange o; never executed (the execution status of this line is deduced): QTextLayout::FormatRange o; | - |
1914 | QTextLine l = layout->lineForTextPosition(range.cursor.position() - blpos); never executed (the execution status of this line is deduced): QTextLine l = layout->lineForTextPosition(range.cursor.position() - blpos); | - |
1915 | o.start = l.textStart(); never executed (the execution status of this line is deduced): o.start = l.textStart(); | - |
1916 | o.length = l.textLength(); never executed (the execution status of this line is deduced): o.length = l.textLength(); | - |
1917 | if (o.start + o.length == bllen - 1) never evaluated: o.start + o.length == bllen - 1 | 0 |
1918 | ++o.length; // include newline never executed: ++o.length; | 0 |
1919 | o.format = range.format; never executed (the execution status of this line is deduced): o.format = range.format; | - |
1920 | selections.append(o); never executed (the execution status of this line is deduced): selections.append(o); | - |
1921 | } | 0 |
1922 | } | - |
1923 | | - |
1924 | bool drawCursor = ((editable || (textInteractionFlags() & Qt::TextSelectableByKeyboard)) partially evaluated: editable yes Evaluation Count:7 | no Evaluation Count:0 |
never evaluated: (textInteractionFlags() & Qt::TextSelectableByKeyboard) | 0-7 |
1925 | && context.cursorPosition >= blpos evaluated: context.cursorPosition >= blpos yes Evaluation Count:6 | yes Evaluation Count:1 |
| 1-6 |
1926 | && context.cursorPosition < blpos + bllen); partially evaluated: context.cursorPosition < blpos + bllen yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
1927 | | - |
1928 | bool drawCursorAsBlock = drawCursor && overwriteMode() ; evaluated: drawCursor yes Evaluation Count:6 | yes Evaluation Count:1 |
partially evaluated: overwriteMode() no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
1929 | | - |
1930 | if (drawCursorAsBlock) { partially evaluated: drawCursorAsBlock no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
1931 | if (context.cursorPosition == blpos + bllen - 1) { never evaluated: context.cursorPosition == blpos + bllen - 1 | 0 |
1932 | drawCursorAsBlock = false; never executed (the execution status of this line is deduced): drawCursorAsBlock = false; | - |
1933 | } else { | 0 |
1934 | QTextLayout::FormatRange o; never executed (the execution status of this line is deduced): QTextLayout::FormatRange o; | - |
1935 | o.start = context.cursorPosition - blpos; never executed (the execution status of this line is deduced): o.start = context.cursorPosition - blpos; | - |
1936 | o.length = 1; never executed (the execution status of this line is deduced): o.length = 1; | - |
1937 | o.format.setForeground(palette().base()); never executed (the execution status of this line is deduced): o.format.setForeground(palette().base()); | - |
1938 | o.format.setBackground(palette().text()); never executed (the execution status of this line is deduced): o.format.setBackground(palette().text()); | - |
1939 | selections.append(o); never executed (the execution status of this line is deduced): selections.append(o); | - |
1940 | } | 0 |
1941 | } | - |
1942 | | - |
1943 | | - |
1944 | layout->draw(&painter, offset, selections, er); executed (the execution status of this line is deduced): layout->draw(&painter, offset, selections, er); | - |
1945 | if ((drawCursor && !drawCursorAsBlock) evaluated: drawCursor yes Evaluation Count:6 | yes Evaluation Count:1 |
partially evaluated: !drawCursorAsBlock yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
1946 | || (editable && context.cursorPosition < -1 partially evaluated: editable yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: context.cursorPosition < -1 no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1947 | && !layout->preeditAreaText().isEmpty())) { never evaluated: !layout->preeditAreaText().isEmpty() | 0 |
1948 | int cpos = context.cursorPosition; executed (the execution status of this line is deduced): int cpos = context.cursorPosition; | - |
1949 | if (cpos < -1) partially evaluated: cpos < -1 no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
1950 | cpos = layout->preeditAreaPosition() - (cpos + 2); never executed: cpos = layout->preeditAreaPosition() - (cpos + 2); | 0 |
1951 | else | - |
1952 | cpos -= blpos; executed: cpos -= blpos; Execution Count:6 | 6 |
1953 | layout->drawCursor(&painter, offset, cpos, cursorWidth()); executed (the execution status of this line is deduced): layout->drawCursor(&painter, offset, cpos, cursorWidth()); | - |
1954 | } executed: } Execution Count:6 | 6 |
1955 | } executed: } Execution Count:7 | 7 |
1956 | | - |
1957 | offset.ry() += r.height(); executed (the execution status of this line is deduced): offset.ry() += r.height(); | - |
1958 | if (offset.y() > viewportRect.height()) evaluated: offset.y() > viewportRect.height() yes Evaluation Count:6 | yes Evaluation Count:1 |
| 1-6 |
1959 | break; executed: break; Execution Count:6 | 6 |
1960 | block = block.next(); executed (the execution status of this line is deduced): block = block.next(); | - |
1961 | } executed: } Execution Count:1 | 1 |
1962 | | - |
1963 | if (backgroundVisible() && !block.isValid() && offset.y() <= er.bottom() partially evaluated: backgroundVisible() no Evaluation Count:0 | yes Evaluation Count:7 |
never evaluated: !block.isValid() never evaluated: offset.y() <= er.bottom() | 0-7 |
1964 | && (centerOnScroll() || verticalScrollBar()->maximum() == verticalScrollBar()->minimum())) { never evaluated: centerOnScroll() never evaluated: verticalScrollBar()->maximum() == verticalScrollBar()->minimum() | 0 |
1965 | painter.fillRect(QRect(QPoint((int)er.left(), (int)offset.y()), er.bottomRight()), palette().background()); never executed (the execution status of this line is deduced): painter.fillRect(QRect(QPoint((int)er.left(), (int)offset.y()), er.bottomRight()), palette().background()); | - |
1966 | } | 0 |
1967 | } executed: } Execution Count:7 | 7 |
1968 | | - |
1969 | | - |
1970 | void QPlainTextEditPrivate::updateDefaultTextOption() | - |
1971 | { | - |
1972 | QTextDocument *doc = control->document(); executed (the execution status of this line is deduced): QTextDocument *doc = control->document(); | - |
1973 | | - |
1974 | QTextOption opt = doc->defaultTextOption(); executed (the execution status of this line is deduced): QTextOption opt = doc->defaultTextOption(); | - |
1975 | QTextOption::WrapMode oldWrapMode = opt.wrapMode(); executed (the execution status of this line is deduced): QTextOption::WrapMode oldWrapMode = opt.wrapMode(); | - |
1976 | | - |
1977 | if (lineWrap == QPlainTextEdit::NoWrap) evaluated: lineWrap == QPlainTextEdit::NoWrap yes Evaluation Count:4 | yes Evaluation Count:9 |
| 4-9 |
1978 | opt.setWrapMode(QTextOption::NoWrap); executed: opt.setWrapMode(QTextOption::NoWrap); Execution Count:4 | 4 |
1979 | else | - |
1980 | opt.setWrapMode(wordWrap); executed: opt.setWrapMode(wordWrap); Execution Count:9 | 9 |
1981 | | - |
1982 | if (opt.wrapMode() != oldWrapMode) evaluated: opt.wrapMode() != oldWrapMode yes Evaluation Count:9 | yes Evaluation Count:4 |
| 4-9 |
1983 | doc->setDefaultTextOption(opt); executed: doc->setDefaultTextOption(opt); Execution Count:9 | 9 |
1984 | } executed: } Execution Count:13 | 13 |
1985 | | - |
1986 | | - |
1987 | /*! \reimp | - |
1988 | */ | - |
1989 | void QPlainTextEdit::mousePressEvent(QMouseEvent *e) | - |
1990 | { | - |
1991 | Q_D(QPlainTextEdit); never executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
1992 | #ifdef QT_KEYPAD_NAVIGATION | - |
1993 | if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) | - |
1994 | setEditFocus(true); | - |
1995 | #endif | - |
1996 | d->sendControlEvent(e); never executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
1997 | } | 0 |
1998 | | - |
1999 | /*! \reimp | - |
2000 | */ | - |
2001 | void QPlainTextEdit::mouseMoveEvent(QMouseEvent *e) | - |
2002 | { | - |
2003 | Q_D(QPlainTextEdit); never executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2004 | d->inDrag = false; // paranoia never executed (the execution status of this line is deduced): d->inDrag = false; | - |
2005 | const QPoint pos = e->pos(); never executed (the execution status of this line is deduced): const QPoint pos = e->pos(); | - |
2006 | d->sendControlEvent(e); never executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
2007 | if (!(e->buttons() & Qt::LeftButton)) never evaluated: !(e->buttons() & Qt::LeftButton) | 0 |
2008 | return; | 0 |
2009 | QRect visible = d->viewport->rect(); never executed (the execution status of this line is deduced): QRect visible = d->viewport->rect(); | - |
2010 | if (visible.contains(pos)) never evaluated: visible.contains(pos) | 0 |
2011 | d->autoScrollTimer.stop(); never executed: d->autoScrollTimer.stop(); | 0 |
2012 | else if (!d->autoScrollTimer.isActive()) never evaluated: !d->autoScrollTimer.isActive() | 0 |
2013 | d->autoScrollTimer.start(100, this); never executed: d->autoScrollTimer.start(100, this); | 0 |
2014 | } | - |
2015 | | - |
2016 | /*! \reimp | - |
2017 | */ | - |
2018 | void QPlainTextEdit::mouseReleaseEvent(QMouseEvent *e) | - |
2019 | { | - |
2020 | Q_D(QPlainTextEdit); never executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2021 | d->sendControlEvent(e); never executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
2022 | if (d->autoScrollTimer.isActive()) { never evaluated: d->autoScrollTimer.isActive() | 0 |
2023 | d->autoScrollTimer.stop(); never executed (the execution status of this line is deduced): d->autoScrollTimer.stop(); | - |
2024 | d->ensureCursorVisible(); never executed (the execution status of this line is deduced): d->ensureCursorVisible(); | - |
2025 | } | 0 |
2026 | | - |
2027 | if (!isReadOnly() && rect().contains(e->pos())) never evaluated: !isReadOnly() never evaluated: rect().contains(e->pos()) | 0 |
2028 | d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus); never executed: d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus); | 0 |
2029 | d->clickCausedFocus = 0; never executed (the execution status of this line is deduced): d->clickCausedFocus = 0; | - |
2030 | } | 0 |
2031 | | - |
2032 | /*! \reimp | - |
2033 | */ | - |
2034 | void QPlainTextEdit::mouseDoubleClickEvent(QMouseEvent *e) | - |
2035 | { | - |
2036 | Q_D(QPlainTextEdit); never executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2037 | d->sendControlEvent(e); never executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
2038 | } | 0 |
2039 | | - |
2040 | /*! \reimp | - |
2041 | */ | - |
2042 | bool QPlainTextEdit::focusNextPrevChild(bool next) | - |
2043 | { | - |
2044 | Q_D(const QPlainTextEdit); never executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
2045 | if (!d->tabChangesFocus && d->control->textInteractionFlags() & Qt::TextEditable) never evaluated: !d->tabChangesFocus never evaluated: d->control->textInteractionFlags() & Qt::TextEditable | 0 |
2046 | return false; never executed: return false; | 0 |
2047 | return QAbstractScrollArea::focusNextPrevChild(next); never executed: return QAbstractScrollArea::focusNextPrevChild(next); | 0 |
2048 | } | - |
2049 | | - |
2050 | #ifndef QT_NO_CONTEXTMENU | - |
2051 | /*! | - |
2052 | \fn void QPlainTextEdit::contextMenuEvent(QContextMenuEvent *event) | - |
2053 | | - |
2054 | Shows the standard context menu created with createStandardContextMenu(). | - |
2055 | | - |
2056 | If you do not want the text edit to have a context menu, you can set | - |
2057 | its \l contextMenuPolicy to Qt::NoContextMenu. If you want to | - |
2058 | customize the context menu, reimplement this function. If you want | - |
2059 | to extend the standard context menu, reimplement this function, call | - |
2060 | createStandardContextMenu() and extend the menu returned. | - |
2061 | | - |
2062 | Information about the event is passed in the \a event object. | - |
2063 | | - |
2064 | \snippet code/src_gui_widgets_qplaintextedit.cpp 0 | - |
2065 | */ | - |
2066 | void QPlainTextEdit::contextMenuEvent(QContextMenuEvent *e) | - |
2067 | { | - |
2068 | Q_D(QPlainTextEdit); never executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2069 | d->sendControlEvent(e); never executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
2070 | } | 0 |
2071 | #endif // QT_NO_CONTEXTMENU | - |
2072 | | - |
2073 | #ifndef QT_NO_DRAGANDDROP | - |
2074 | /*! \reimp | - |
2075 | */ | - |
2076 | void QPlainTextEdit::dragEnterEvent(QDragEnterEvent *e) | - |
2077 | { | - |
2078 | Q_D(QPlainTextEdit); never executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2079 | d->inDrag = true; never executed (the execution status of this line is deduced): d->inDrag = true; | - |
2080 | d->sendControlEvent(e); never executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
2081 | } | 0 |
2082 | | - |
2083 | /*! \reimp | - |
2084 | */ | - |
2085 | void QPlainTextEdit::dragLeaveEvent(QDragLeaveEvent *e) | - |
2086 | { | - |
2087 | Q_D(QPlainTextEdit); never executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2088 | d->inDrag = false; never executed (the execution status of this line is deduced): d->inDrag = false; | - |
2089 | d->autoScrollTimer.stop(); never executed (the execution status of this line is deduced): d->autoScrollTimer.stop(); | - |
2090 | d->sendControlEvent(e); never executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
2091 | } | 0 |
2092 | | - |
2093 | /*! \reimp | - |
2094 | */ | - |
2095 | void QPlainTextEdit::dragMoveEvent(QDragMoveEvent *e) | - |
2096 | { | - |
2097 | Q_D(QPlainTextEdit); never executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2098 | d->autoScrollDragPos = e->pos(); never executed (the execution status of this line is deduced): d->autoScrollDragPos = e->pos(); | - |
2099 | if (!d->autoScrollTimer.isActive()) never evaluated: !d->autoScrollTimer.isActive() | 0 |
2100 | d->autoScrollTimer.start(100, this); never executed: d->autoScrollTimer.start(100, this); | 0 |
2101 | d->sendControlEvent(e); never executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
2102 | } | 0 |
2103 | | - |
2104 | /*! \reimp | - |
2105 | */ | - |
2106 | void QPlainTextEdit::dropEvent(QDropEvent *e) | - |
2107 | { | - |
2108 | Q_D(QPlainTextEdit); never executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2109 | d->inDrag = false; never executed (the execution status of this line is deduced): d->inDrag = false; | - |
2110 | d->autoScrollTimer.stop(); never executed (the execution status of this line is deduced): d->autoScrollTimer.stop(); | - |
2111 | d->sendControlEvent(e); never executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
2112 | } | 0 |
2113 | | - |
2114 | #endif // QT_NO_DRAGANDDROP | - |
2115 | | - |
2116 | /*! \reimp | - |
2117 | */ | - |
2118 | void QPlainTextEdit::inputMethodEvent(QInputMethodEvent *e) | - |
2119 | { | - |
2120 | Q_D(QPlainTextEdit); never executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2121 | #ifdef QT_KEYPAD_NAVIGATION | - |
2122 | if (d->control->textInteractionFlags() & Qt::TextEditable | - |
2123 | && QApplication::keypadNavigationEnabled() | - |
2124 | && !hasEditFocus()) { | - |
2125 | setEditFocus(true); | - |
2126 | selectAll(); // so text is replaced rather than appended to | - |
2127 | } | - |
2128 | #endif | - |
2129 | d->sendControlEvent(e); never executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
2130 | ensureCursorVisible(); never executed (the execution status of this line is deduced): ensureCursorVisible(); | - |
2131 | } | 0 |
2132 | | - |
2133 | /*!\reimp | - |
2134 | */ | - |
2135 | void QPlainTextEdit::scrollContentsBy(int dx, int /*dy*/) | - |
2136 | { | - |
2137 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2138 | d->setTopLine(d->vbar->value(), dx); executed (the execution status of this line is deduced): d->setTopLine(d->vbar->value(), dx); | - |
2139 | } executed: } Execution Count:7 | 7 |
2140 | | - |
2141 | /*!\reimp | - |
2142 | */ | - |
2143 | QVariant QPlainTextEdit::inputMethodQuery(Qt::InputMethodQuery property) const | - |
2144 | { | - |
2145 | Q_D(const QPlainTextEdit); executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
2146 | QVariant v; executed (the execution status of this line is deduced): QVariant v; | - |
2147 | switch (property) { | - |
2148 | case Qt::ImHints: | - |
2149 | v = QWidget::inputMethodQuery(property); executed (the execution status of this line is deduced): v = QWidget::inputMethodQuery(property); | - |
2150 | break; executed: break; Execution Count:3 | 3 |
2151 | default: | - |
2152 | v = d->control->inputMethodQuery(property); executed (the execution status of this line is deduced): v = d->control->inputMethodQuery(property); | - |
2153 | const QPoint offset(-d->horizontalOffset(), -0); executed (the execution status of this line is deduced): const QPoint offset(-d->horizontalOffset(), -0); | - |
2154 | if (v.type() == QVariant::RectF) partially evaluated: v.type() == QVariant::RectF no Evaluation Count:0 | yes Evaluation Count:15 |
| 0-15 |
2155 | v = v.toRectF().toRect().translated(offset); never executed: v = v.toRectF().toRect().translated(offset); | 0 |
2156 | else if (v.type() == QVariant::PointF) partially evaluated: v.type() == QVariant::PointF no Evaluation Count:0 | yes Evaluation Count:15 |
| 0-15 |
2157 | v = v.toPointF().toPoint() + offset; never executed: v = v.toPointF().toPoint() + offset; | 0 |
2158 | else if (v.type() == QVariant::Rect) partially evaluated: v.type() == QVariant::Rect no Evaluation Count:0 | yes Evaluation Count:15 |
| 0-15 |
2159 | v = v.toRect().translated(offset); never executed: v = v.toRect().translated(offset); | 0 |
2160 | else if (v.type() == QVariant::Point) partially evaluated: v.type() == QVariant::Point no Evaluation Count:0 | yes Evaluation Count:15 |
| 0-15 |
2161 | v = v.toPoint() + offset; never executed: v = v.toPoint() + offset; | 0 |
2162 | } | - |
2163 | | - |
2164 | return v; executed: return v; Execution Count:18 | 18 |
2165 | } | - |
2166 | | - |
2167 | /*! \reimp | - |
2168 | */ | - |
2169 | void QPlainTextEdit::focusInEvent(QFocusEvent *e) | - |
2170 | { | - |
2171 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2172 | if (e->reason() == Qt::MouseFocusReason) { partially evaluated: e->reason() == Qt::MouseFocusReason no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
2173 | d->clickCausedFocus = 1; never executed (the execution status of this line is deduced): d->clickCausedFocus = 1; | - |
2174 | } | 0 |
2175 | QAbstractScrollArea::focusInEvent(e); executed (the execution status of this line is deduced): QAbstractScrollArea::focusInEvent(e); | - |
2176 | d->sendControlEvent(e); executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
2177 | } executed: } Execution Count:5 | 5 |
2178 | | - |
2179 | /*! \reimp | - |
2180 | */ | - |
2181 | void QPlainTextEdit::focusOutEvent(QFocusEvent *e) | - |
2182 | { | - |
2183 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2184 | QAbstractScrollArea::focusOutEvent(e); executed (the execution status of this line is deduced): QAbstractScrollArea::focusOutEvent(e); | - |
2185 | d->sendControlEvent(e); executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
2186 | } executed: } Execution Count:4 | 4 |
2187 | | - |
2188 | /*! \reimp | - |
2189 | */ | - |
2190 | void QPlainTextEdit::showEvent(QShowEvent *) | - |
2191 | { | - |
2192 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2193 | if (d->showCursorOnInitialShow) { evaluated: d->showCursorOnInitialShow yes Evaluation Count:14 | yes Evaluation Count:1 |
| 1-14 |
2194 | d->showCursorOnInitialShow = false; executed (the execution status of this line is deduced): d->showCursorOnInitialShow = false; | - |
2195 | ensureCursorVisible(); executed (the execution status of this line is deduced): ensureCursorVisible(); | - |
2196 | } executed: } Execution Count:14 | 14 |
2197 | } executed: } Execution Count:15 | 15 |
2198 | | - |
2199 | /*! \reimp | - |
2200 | */ | - |
2201 | void QPlainTextEdit::changeEvent(QEvent *e) | - |
2202 | { | - |
2203 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2204 | QAbstractScrollArea::changeEvent(e); executed (the execution status of this line is deduced): QAbstractScrollArea::changeEvent(e); | - |
2205 | if (e->type() == QEvent::ApplicationFontChange partially evaluated: e->type() == QEvent::ApplicationFontChange no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
2206 | || e->type() == QEvent::FontChange) { evaluated: e->type() == QEvent::FontChange yes Evaluation Count:1 | yes Evaluation Count:4 |
| 1-4 |
2207 | d->control->document()->setDefaultFont(font()); executed (the execution status of this line is deduced): d->control->document()->setDefaultFont(font()); | - |
2208 | } else if(e->type() == QEvent::ActivationChange) { executed: } Execution Count:1 evaluated: e->type() == QEvent::ActivationChange yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-3 |
2209 | if (!isActiveWindow()) partially evaluated: !isActiveWindow() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
2210 | d->autoScrollTimer.stop(); never executed: d->autoScrollTimer.stop(); | 0 |
2211 | } else if (e->type() == QEvent::EnabledChange) { executed: } Execution Count:1 partially evaluated: e->type() == QEvent::EnabledChange no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
2212 | e->setAccepted(isEnabled()); never executed (the execution status of this line is deduced): e->setAccepted(isEnabled()); | - |
2213 | d->sendControlEvent(e); never executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
2214 | } else if (e->type() == QEvent::PaletteChange) { never executed: } partially evaluated: e->type() == QEvent::PaletteChange no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
2215 | d->control->setPalette(palette()); never executed (the execution status of this line is deduced): d->control->setPalette(palette()); | - |
2216 | } else if (e->type() == QEvent::LayoutDirectionChange) { never executed: } evaluated: e->type() == QEvent::LayoutDirectionChange yes Evaluation Count:1 | yes Evaluation Count:2 |
| 0-2 |
2217 | d->sendControlEvent(e); executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
2218 | } executed: } Execution Count:1 | 1 |
2219 | } | - |
2220 | | - |
2221 | /*! \reimp | - |
2222 | */ | - |
2223 | #ifndef QT_NO_WHEELEVENT | - |
2224 | void QPlainTextEdit::wheelEvent(QWheelEvent *e) | - |
2225 | { | - |
2226 | QAbstractScrollArea::wheelEvent(e); never executed (the execution status of this line is deduced): QAbstractScrollArea::wheelEvent(e); | - |
2227 | updateMicroFocus(); never executed (the execution status of this line is deduced): updateMicroFocus(); | - |
2228 | } | 0 |
2229 | #endif | - |
2230 | | - |
2231 | #ifndef QT_NO_CONTEXTMENU | - |
2232 | /*! This function creates the standard context menu which is shown | - |
2233 | when the user clicks on the line edit with the right mouse | - |
2234 | button. It is called from the default contextMenuEvent() handler. | - |
2235 | The popup menu's ownership is transferred to the caller. | - |
2236 | */ | - |
2237 | | - |
2238 | QMenu *QPlainTextEdit::createStandardContextMenu() | - |
2239 | { | - |
2240 | Q_D(QPlainTextEdit); never executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2241 | return d->control->createStandardContextMenu(QPointF(), this); never executed: return d->control->createStandardContextMenu(QPointF(), this); | 0 |
2242 | } | - |
2243 | #endif // QT_NO_CONTEXTMENU | - |
2244 | | - |
2245 | /*! | - |
2246 | returns a QTextCursor at position \a pos (in viewport coordinates). | - |
2247 | */ | - |
2248 | QTextCursor QPlainTextEdit::cursorForPosition(const QPoint &pos) const | - |
2249 | { | - |
2250 | Q_D(const QPlainTextEdit); never executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
2251 | return d->control->cursorForPosition(d->mapToContents(pos)); never executed: return d->control->cursorForPosition(d->mapToContents(pos)); | 0 |
2252 | } | - |
2253 | | - |
2254 | /*! | - |
2255 | returns a rectangle (in viewport coordinates) that includes the | - |
2256 | \a cursor. | - |
2257 | */ | - |
2258 | QRect QPlainTextEdit::cursorRect(const QTextCursor &cursor) const | - |
2259 | { | - |
2260 | Q_D(const QPlainTextEdit); never executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
2261 | if (cursor.isNull()) never evaluated: cursor.isNull() | 0 |
2262 | return QRect(); never executed: return QRect(); | 0 |
2263 | | - |
2264 | QRect r = d->control->cursorRect(cursor).toRect(); never executed (the execution status of this line is deduced): QRect r = d->control->cursorRect(cursor).toRect(); | - |
2265 | r.translate(-d->horizontalOffset(),-(int)d->verticalOffset()); never executed (the execution status of this line is deduced): r.translate(-d->horizontalOffset(),-(int)d->verticalOffset()); | - |
2266 | return r; never executed: return r; | 0 |
2267 | } | - |
2268 | | - |
2269 | /*! | - |
2270 | returns a rectangle (in viewport coordinates) that includes the | - |
2271 | cursor of the text edit. | - |
2272 | */ | - |
2273 | QRect QPlainTextEdit::cursorRect() const | - |
2274 | { | - |
2275 | Q_D(const QPlainTextEdit); executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
2276 | QRect r = d->control->cursorRect().toRect(); executed (the execution status of this line is deduced): QRect r = d->control->cursorRect().toRect(); | - |
2277 | r.translate(-d->horizontalOffset(),-(int)d->verticalOffset()); executed (the execution status of this line is deduced): r.translate(-d->horizontalOffset(),-(int)d->verticalOffset()); | - |
2278 | return r; executed: return r; Execution Count:369 | 369 |
2279 | } | - |
2280 | | - |
2281 | | - |
2282 | /*! | - |
2283 | \property QPlainTextEdit::overwriteMode | - |
2284 | \brief whether text entered by the user will overwrite existing text | - |
2285 | | - |
2286 | As with many text editors, the plain text editor widget can be configured | - |
2287 | to insert or overwrite existing text with new text entered by the user. | - |
2288 | | - |
2289 | If this property is true, existing text is overwritten, character-for-character | - |
2290 | by new text; otherwise, text is inserted at the cursor position, displacing | - |
2291 | existing text. | - |
2292 | | - |
2293 | By default, this property is false (new text does not overwrite existing text). | - |
2294 | */ | - |
2295 | | - |
2296 | bool QPlainTextEdit::overwriteMode() const | - |
2297 | { | - |
2298 | Q_D(const QPlainTextEdit); executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
2299 | return d->control->overwriteMode(); executed: return d->control->overwriteMode(); Execution Count:9 | 9 |
2300 | } | - |
2301 | | - |
2302 | void QPlainTextEdit::setOverwriteMode(bool overwrite) | - |
2303 | { | - |
2304 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2305 | d->control->setOverwriteMode(overwrite); executed (the execution status of this line is deduced): d->control->setOverwriteMode(overwrite); | - |
2306 | } executed: } Execution Count:5 | 5 |
2307 | | - |
2308 | /*! | - |
2309 | \property QPlainTextEdit::tabStopWidth | - |
2310 | \brief the tab stop width in pixels | - |
2311 | | - |
2312 | By default, this property contains a value of 80. | - |
2313 | */ | - |
2314 | | - |
2315 | int QPlainTextEdit::tabStopWidth() const | - |
2316 | { | - |
2317 | Q_D(const QPlainTextEdit); executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
2318 | return qRound(d->control->document()->defaultTextOption().tabStop()); executed: return qRound(d->control->document()->defaultTextOption().tabStop()); Execution Count:3 | 3 |
2319 | } | - |
2320 | | - |
2321 | void QPlainTextEdit::setTabStopWidth(int width) | - |
2322 | { | - |
2323 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2324 | QTextOption opt = d->control->document()->defaultTextOption(); executed (the execution status of this line is deduced): QTextOption opt = d->control->document()->defaultTextOption(); | - |
2325 | if (opt.tabStop() == width || width < 0) partially evaluated: opt.tabStop() == width no Evaluation Count:0 | yes Evaluation Count:3 |
evaluated: width < 0 yes Evaluation Count:1 | yes Evaluation Count:2 |
| 0-3 |
2326 | return; executed: return; Execution Count:1 | 1 |
2327 | opt.setTabStop(width); executed (the execution status of this line is deduced): opt.setTabStop(width); | - |
2328 | d->control->document()->setDefaultTextOption(opt); executed (the execution status of this line is deduced): d->control->document()->setDefaultTextOption(opt); | - |
2329 | } executed: } Execution Count:2 | 2 |
2330 | | - |
2331 | /*! | - |
2332 | \property QPlainTextEdit::cursorWidth | - |
2333 | | - |
2334 | This property specifies the width of the cursor in pixels. The default value is 1. | - |
2335 | */ | - |
2336 | int QPlainTextEdit::cursorWidth() const | - |
2337 | { | - |
2338 | Q_D(const QPlainTextEdit); executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
2339 | return d->control->cursorWidth(); executed: return d->control->cursorWidth(); Execution Count:6 | 6 |
2340 | } | - |
2341 | | - |
2342 | void QPlainTextEdit::setCursorWidth(int width) | - |
2343 | { | - |
2344 | Q_D(QPlainTextEdit); never executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2345 | d->control->setCursorWidth(width); never executed (the execution status of this line is deduced): d->control->setCursorWidth(width); | - |
2346 | } | 0 |
2347 | | - |
2348 | | - |
2349 | | - |
2350 | /*! | - |
2351 | This function allows temporarily marking certain regions in the document | - |
2352 | with a given color, specified as \a selections. This can be useful for | - |
2353 | example in a programming editor to mark a whole line of text with a given | - |
2354 | background color to indicate the existence of a breakpoint. | - |
2355 | | - |
2356 | \sa QTextEdit::ExtraSelection, extraSelections() | - |
2357 | */ | - |
2358 | void QPlainTextEdit::setExtraSelections(const QList<QTextEdit::ExtraSelection> &selections) | - |
2359 | { | - |
2360 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2361 | d->control->setExtraSelections(selections); executed (the execution status of this line is deduced): d->control->setExtraSelections(selections); | - |
2362 | } executed: } Execution Count:2 | 2 |
2363 | | - |
2364 | /*! | - |
2365 | Returns previously set extra selections. | - |
2366 | | - |
2367 | \sa setExtraSelections() | - |
2368 | */ | - |
2369 | QList<QTextEdit::ExtraSelection> QPlainTextEdit::extraSelections() const | - |
2370 | { | - |
2371 | Q_D(const QPlainTextEdit); executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
2372 | return d->control->extraSelections(); executed: return d->control->extraSelections(); Execution Count:1 | 1 |
2373 | } | - |
2374 | | - |
2375 | /*! | - |
2376 | This function returns a new MIME data object to represent the contents | - |
2377 | of the text edit's current selection. It is called when the selection needs | - |
2378 | to be encapsulated into a new QMimeData object; for example, when a drag | - |
2379 | and drop operation is started, or when data is copied to the clipboard. | - |
2380 | | - |
2381 | If you reimplement this function, note that the ownership of the returned | - |
2382 | QMimeData object is passed to the caller. The selection can be retrieved | - |
2383 | by using the textCursor() function. | - |
2384 | */ | - |
2385 | QMimeData *QPlainTextEdit::createMimeDataFromSelection() const | - |
2386 | { | - |
2387 | Q_D(const QPlainTextEdit); executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
2388 | return d->control->QWidgetTextControl::createMimeDataFromSelection(); executed: return d->control->QWidgetTextControl::createMimeDataFromSelection(); Execution Count:7 | 7 |
2389 | } | - |
2390 | | - |
2391 | /*! | - |
2392 | This function returns true if the contents of the MIME data object, specified | - |
2393 | by \a source, can be decoded and inserted into the document. It is called | - |
2394 | for example when during a drag operation the mouse enters this widget and it | - |
2395 | is necessary to determine whether it is possible to accept the drag. | - |
2396 | */ | - |
2397 | bool QPlainTextEdit::canInsertFromMimeData(const QMimeData *source) const | - |
2398 | { | - |
2399 | Q_D(const QPlainTextEdit); executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
2400 | return d->control->QWidgetTextControl::canInsertFromMimeData(source); executed: return d->control->QWidgetTextControl::canInsertFromMimeData(source); Execution Count:9 | 9 |
2401 | } | - |
2402 | | - |
2403 | /*! | - |
2404 | This function inserts the contents of the MIME data object, specified | - |
2405 | by \a source, into the text edit at the current cursor position. It is | - |
2406 | called whenever text is inserted as the result of a clipboard paste | - |
2407 | operation, or when the text edit accepts data from a drag and drop | - |
2408 | operation. | - |
2409 | */ | - |
2410 | void QPlainTextEdit::insertFromMimeData(const QMimeData *source) | - |
2411 | { | - |
2412 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2413 | d->control->QWidgetTextControl::insertFromMimeData(source); executed (the execution status of this line is deduced): d->control->QWidgetTextControl::insertFromMimeData(source); | - |
2414 | } executed: } Execution Count:3 | 3 |
2415 | | - |
2416 | /*! | - |
2417 | \property QPlainTextEdit::readOnly | - |
2418 | \brief whether the text edit is read-only | - |
2419 | | - |
2420 | In a read-only text edit the user can only navigate through the | - |
2421 | text and select text; modifying the text is not possible. | - |
2422 | | - |
2423 | This property's default is false. | - |
2424 | */ | - |
2425 | | - |
2426 | bool QPlainTextEdit::isReadOnly() const | - |
2427 | { | - |
2428 | Q_D(const QPlainTextEdit); executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
2429 | return !(d->control->textInteractionFlags() & Qt::TextEditable); executed: return !(d->control->textInteractionFlags() & Qt::TextEditable); Execution Count:10 | 10 |
2430 | } | - |
2431 | | - |
2432 | void QPlainTextEdit::setReadOnly(bool ro) | - |
2433 | { | - |
2434 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2435 | Qt::TextInteractionFlags flags = Qt::NoTextInteraction; executed (the execution status of this line is deduced): Qt::TextInteractionFlags flags = Qt::NoTextInteraction; | - |
2436 | if (ro) { partially evaluated: ro yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
2437 | flags = Qt::TextSelectableByMouse; executed (the execution status of this line is deduced): flags = Qt::TextSelectableByMouse; | - |
2438 | } else { executed: } Execution Count:2 | 2 |
2439 | flags = Qt::TextEditorInteraction; never executed (the execution status of this line is deduced): flags = Qt::TextEditorInteraction; | - |
2440 | } | 0 |
2441 | setAttribute(Qt::WA_InputMethodEnabled, shouldEnableInputMethod(this)); executed (the execution status of this line is deduced): setAttribute(Qt::WA_InputMethodEnabled, shouldEnableInputMethod(this)); | - |
2442 | d->control->setTextInteractionFlags(flags); executed (the execution status of this line is deduced): d->control->setTextInteractionFlags(flags); | - |
2443 | } executed: } Execution Count:2 | 2 |
2444 | | - |
2445 | /*! | - |
2446 | \property QPlainTextEdit::textInteractionFlags | - |
2447 | | - |
2448 | Specifies how the label should interact with user input if it displays text. | - |
2449 | | - |
2450 | If the flags contain either Qt::LinksAccessibleByKeyboard or Qt::TextSelectableByKeyboard | - |
2451 | then the focus policy is also automatically set to Qt::ClickFocus. | - |
2452 | | - |
2453 | The default value depends on whether the QPlainTextEdit is read-only | - |
2454 | or editable. | - |
2455 | */ | - |
2456 | | - |
2457 | void QPlainTextEdit::setTextInteractionFlags(Qt::TextInteractionFlags flags) | - |
2458 | { | - |
2459 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2460 | d->control->setTextInteractionFlags(flags); executed (the execution status of this line is deduced): d->control->setTextInteractionFlags(flags); | - |
2461 | } executed: } Execution Count:1 | 1 |
2462 | | - |
2463 | Qt::TextInteractionFlags QPlainTextEdit::textInteractionFlags() const | - |
2464 | { | - |
2465 | Q_D(const QPlainTextEdit); never executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
2466 | return d->control->textInteractionFlags(); never executed: return d->control->textInteractionFlags(); | 0 |
2467 | } | - |
2468 | | - |
2469 | /*! | - |
2470 | Merges the properties specified in \a modifier into the current character | - |
2471 | format by calling QTextCursor::mergeCharFormat on the editor's cursor. | - |
2472 | If the editor has a selection then the properties of \a modifier are | - |
2473 | directly applied to the selection. | - |
2474 | | - |
2475 | \sa QTextCursor::mergeCharFormat() | - |
2476 | */ | - |
2477 | void QPlainTextEdit::mergeCurrentCharFormat(const QTextCharFormat &modifier) | - |
2478 | { | - |
2479 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2480 | d->control->mergeCurrentCharFormat(modifier); executed (the execution status of this line is deduced): d->control->mergeCurrentCharFormat(modifier); | - |
2481 | } executed: } Execution Count:4 | 4 |
2482 | | - |
2483 | /*! | - |
2484 | Sets the char format that is be used when inserting new text to \a | - |
2485 | format by calling QTextCursor::setCharFormat() on the editor's | - |
2486 | cursor. If the editor has a selection then the char format is | - |
2487 | directly applied to the selection. | - |
2488 | */ | - |
2489 | void QPlainTextEdit::setCurrentCharFormat(const QTextCharFormat &format) | - |
2490 | { | - |
2491 | Q_D(QPlainTextEdit); never executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2492 | d->control->setCurrentCharFormat(format); never executed (the execution status of this line is deduced): d->control->setCurrentCharFormat(format); | - |
2493 | } | 0 |
2494 | | - |
2495 | /*! | - |
2496 | Returns the char format that is used when inserting new text. | - |
2497 | */ | - |
2498 | QTextCharFormat QPlainTextEdit::currentCharFormat() const | - |
2499 | { | - |
2500 | Q_D(const QPlainTextEdit); never executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
2501 | return d->control->currentCharFormat(); never executed: return d->control->currentCharFormat(); | 0 |
2502 | } | - |
2503 | | - |
2504 | | - |
2505 | | - |
2506 | /*! | - |
2507 | Convenience slot that inserts \a text at the current | - |
2508 | cursor position. | - |
2509 | | - |
2510 | It is equivalent to | - |
2511 | | - |
2512 | \snippet code/src_gui_widgets_qplaintextedit.cpp 1 | - |
2513 | */ | - |
2514 | void QPlainTextEdit::insertPlainText(const QString &text) | - |
2515 | { | - |
2516 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2517 | d->control->insertPlainText(text); executed (the execution status of this line is deduced): d->control->insertPlainText(text); | - |
2518 | } executed: } Execution Count:1 | 1 |
2519 | | - |
2520 | | - |
2521 | /*! | - |
2522 | Moves the cursor by performing the given \a operation. | - |
2523 | | - |
2524 | If \a mode is QTextCursor::KeepAnchor, the cursor selects the text it moves over. | - |
2525 | This is the same effect that the user achieves when they hold down the Shift key | - |
2526 | and move the cursor with the cursor keys. | - |
2527 | | - |
2528 | \sa QTextCursor::movePosition() | - |
2529 | */ | - |
2530 | void QPlainTextEdit::moveCursor(QTextCursor::MoveOperation operation, QTextCursor::MoveMode mode) | - |
2531 | { | - |
2532 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2533 | d->control->moveCursor(operation, mode); executed (the execution status of this line is deduced): d->control->moveCursor(operation, mode); | - |
2534 | } executed: } Execution Count:10 | 10 |
2535 | | - |
2536 | /*! | - |
2537 | Returns whether text can be pasted from the clipboard into the textedit. | - |
2538 | */ | - |
2539 | bool QPlainTextEdit::canPaste() const | - |
2540 | { | - |
2541 | Q_D(const QPlainTextEdit); executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
2542 | return d->control->canPaste(); executed: return d->control->canPaste(); Execution Count:10 | 10 |
2543 | } | - |
2544 | | - |
2545 | /*! | - |
2546 | Convenience function to print the text edit's document to the given \a printer. This | - |
2547 | is equivalent to calling the print method on the document directly except that this | - |
2548 | function also supports QPrinter::Selection as print range. | - |
2549 | | - |
2550 | \sa QTextDocument::print() | - |
2551 | */ | - |
2552 | #ifndef QT_NO_PRINTER | - |
2553 | void QPlainTextEdit::print(QPagedPaintDevice *printer) const | - |
2554 | { | - |
2555 | Q_D(const QPlainTextEdit); never executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
2556 | d->control->print(printer); never executed (the execution status of this line is deduced): d->control->print(printer); | - |
2557 | } | 0 |
2558 | #endif | - |
2559 | | - |
2560 | /*! \property QPlainTextEdit::tabChangesFocus | - |
2561 | \brief whether \uicontrol Tab changes focus or is accepted as input | - |
2562 | | - |
2563 | In some occasions text edits should not allow the user to input | - |
2564 | tabulators or change indentation using the \uicontrol Tab key, as this breaks | - |
2565 | the focus chain. The default is false. | - |
2566 | | - |
2567 | */ | - |
2568 | | - |
2569 | bool QPlainTextEdit::tabChangesFocus() const | - |
2570 | { | - |
2571 | Q_D(const QPlainTextEdit); executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
2572 | return d->tabChangesFocus; executed: return d->tabChangesFocus; Execution Count:2 | 2 |
2573 | } | - |
2574 | | - |
2575 | void QPlainTextEdit::setTabChangesFocus(bool b) | - |
2576 | { | - |
2577 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2578 | d->tabChangesFocus = b; executed (the execution status of this line is deduced): d->tabChangesFocus = b; | - |
2579 | } executed: } Execution Count:2 | 2 |
2580 | | - |
2581 | /*! | - |
2582 | \property QPlainTextEdit::documentTitle | - |
2583 | \brief the title of the document parsed from the text. | - |
2584 | | - |
2585 | By default, this property contains an empty string. | - |
2586 | */ | - |
2587 | | - |
2588 | /*! | - |
2589 | \property QPlainTextEdit::lineWrapMode | - |
2590 | \brief the line wrap mode | - |
2591 | | - |
2592 | The default mode is WidgetWidth which causes words to be | - |
2593 | wrapped at the right edge of the text edit. Wrapping occurs at | - |
2594 | whitespace, keeping whole words intact. If you want wrapping to | - |
2595 | occur within words use setWordWrapMode(). | - |
2596 | */ | - |
2597 | | - |
2598 | QPlainTextEdit::LineWrapMode QPlainTextEdit::lineWrapMode() const | - |
2599 | { | - |
2600 | Q_D(const QPlainTextEdit); executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
2601 | return d->lineWrap; executed: return d->lineWrap; Execution Count:4 | 4 |
2602 | } | - |
2603 | | - |
2604 | void QPlainTextEdit::setLineWrapMode(LineWrapMode wrap) | - |
2605 | { | - |
2606 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2607 | if (d->lineWrap == wrap) partially evaluated: d->lineWrap == wrap no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
2608 | return; | 0 |
2609 | d->lineWrap = wrap; executed (the execution status of this line is deduced): d->lineWrap = wrap; | - |
2610 | d->updateDefaultTextOption(); executed (the execution status of this line is deduced): d->updateDefaultTextOption(); | - |
2611 | d->relayoutDocument(); executed (the execution status of this line is deduced): d->relayoutDocument(); | - |
2612 | d->_q_adjustScrollbars(); executed (the execution status of this line is deduced): d->_q_adjustScrollbars(); | - |
2613 | ensureCursorVisible(); executed (the execution status of this line is deduced): ensureCursorVisible(); | - |
2614 | } executed: } Execution Count:6 | 6 |
2615 | | - |
2616 | /*! | - |
2617 | \property QPlainTextEdit::wordWrapMode | - |
2618 | \brief the mode QPlainTextEdit will use when wrapping text by words | - |
2619 | | - |
2620 | By default, this property is set to QTextOption::WrapAtWordBoundaryOrAnywhere. | - |
2621 | | - |
2622 | \sa QTextOption::WrapMode | - |
2623 | */ | - |
2624 | | - |
2625 | QTextOption::WrapMode QPlainTextEdit::wordWrapMode() const | - |
2626 | { | - |
2627 | Q_D(const QPlainTextEdit); executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
2628 | return d->wordWrap; executed: return d->wordWrap; Execution Count:2 | 2 |
2629 | } | - |
2630 | | - |
2631 | void QPlainTextEdit::setWordWrapMode(QTextOption::WrapMode mode) | - |
2632 | { | - |
2633 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2634 | if (mode == d->wordWrap) partially evaluated: mode == d->wordWrap no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
2635 | return; | 0 |
2636 | d->wordWrap = mode; executed (the execution status of this line is deduced): d->wordWrap = mode; | - |
2637 | d->updateDefaultTextOption(); executed (the execution status of this line is deduced): d->updateDefaultTextOption(); | - |
2638 | } executed: } Execution Count:2 | 2 |
2639 | | - |
2640 | /*! | - |
2641 | \property QPlainTextEdit::backgroundVisible | - |
2642 | \brief whether the palette background is visible outside the document area | - |
2643 | | - |
2644 | If set to true, the plain text edit paints the palette background | - |
2645 | on the viewport area not covered by the text document. Otherwise, | - |
2646 | if set to false, it won't. The feature makes it possible for | - |
2647 | the user to visually distinguish between the area of the document, | - |
2648 | painted with the base color of the palette, and the empty | - |
2649 | area not covered by any document. | - |
2650 | | - |
2651 | The default is false. | - |
2652 | */ | - |
2653 | | - |
2654 | bool QPlainTextEdit::backgroundVisible() const | - |
2655 | { | - |
2656 | Q_D(const QPlainTextEdit); executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
2657 | return d->backgroundVisible; executed: return d->backgroundVisible; Execution Count:7 | 7 |
2658 | } | - |
2659 | | - |
2660 | void QPlainTextEdit::setBackgroundVisible(bool visible) | - |
2661 | { | - |
2662 | Q_D(QPlainTextEdit); never executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2663 | if (visible == d->backgroundVisible) never evaluated: visible == d->backgroundVisible | 0 |
2664 | return; | 0 |
2665 | d->backgroundVisible = visible; never executed (the execution status of this line is deduced): d->backgroundVisible = visible; | - |
2666 | d->updateViewport(); never executed (the execution status of this line is deduced): d->updateViewport(); | - |
2667 | } | 0 |
2668 | | - |
2669 | /*! | - |
2670 | \property QPlainTextEdit::centerOnScroll | - |
2671 | \brief whether the cursor should be centered on screen | - |
2672 | | - |
2673 | If set to true, the plain text edit scrolls the document | - |
2674 | vertically to make the cursor visible at the center of the | - |
2675 | viewport. This also allows the text edit to scroll below the end | - |
2676 | of the document. Otherwise, if set to false, the plain text edit | - |
2677 | scrolls the smallest amount possible to ensure the cursor is | - |
2678 | visible. The same algorithm is applied to any new line appended | - |
2679 | through appendPlainText(). | - |
2680 | | - |
2681 | The default is false. | - |
2682 | | - |
2683 | \sa centerCursor(), ensureCursorVisible() | - |
2684 | */ | - |
2685 | | - |
2686 | bool QPlainTextEdit::centerOnScroll() const | - |
2687 | { | - |
2688 | Q_D(const QPlainTextEdit); never executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
2689 | return d->centerOnScroll; never executed: return d->centerOnScroll; | 0 |
2690 | } | - |
2691 | | - |
2692 | void QPlainTextEdit::setCenterOnScroll(bool enabled) | - |
2693 | { | - |
2694 | Q_D(QPlainTextEdit); never executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2695 | if (enabled == d->centerOnScroll) never evaluated: enabled == d->centerOnScroll | 0 |
2696 | return; | 0 |
2697 | d->centerOnScroll = enabled; never executed (the execution status of this line is deduced): d->centerOnScroll = enabled; | - |
2698 | } | 0 |
2699 | | - |
2700 | | - |
2701 | | - |
2702 | /*! | - |
2703 | Finds the next occurrence of the string, \a exp, using the given | - |
2704 | \a options. Returns true if \a exp was found and changes the | - |
2705 | cursor to select the match; otherwise returns false. | - |
2706 | */ | - |
2707 | bool QPlainTextEdit::find(const QString &exp, QTextDocument::FindFlags options) | - |
2708 | { | - |
2709 | Q_D(QPlainTextEdit); never executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2710 | return d->control->find(exp, options); never executed: return d->control->find(exp, options); | 0 |
2711 | } | - |
2712 | | - |
2713 | /*! | - |
2714 | \fn void QPlainTextEdit::copyAvailable(bool yes) | - |
2715 | | - |
2716 | This signal is emitted when text is selected or de-selected in the | - |
2717 | text edit. | - |
2718 | | - |
2719 | When text is selected this signal will be emitted with \a yes set | - |
2720 | to true. If no text has been selected or if the selected text is | - |
2721 | de-selected this signal is emitted with \a yes set to false. | - |
2722 | | - |
2723 | If \a yes is true then copy() can be used to copy the selection to | - |
2724 | the clipboard. If \a yes is false then copy() does nothing. | - |
2725 | | - |
2726 | \sa selectionChanged() | - |
2727 | */ | - |
2728 | | - |
2729 | | - |
2730 | /*! | - |
2731 | \fn void QPlainTextEdit::selectionChanged() | - |
2732 | | - |
2733 | This signal is emitted whenever the selection changes. | - |
2734 | | - |
2735 | \sa copyAvailable() | - |
2736 | */ | - |
2737 | | - |
2738 | /*! | - |
2739 | \fn void QPlainTextEdit::cursorPositionChanged() | - |
2740 | | - |
2741 | This signal is emitted whenever the position of the | - |
2742 | cursor changed. | - |
2743 | */ | - |
2744 | | - |
2745 | | - |
2746 | | - |
2747 | /*! | - |
2748 | \fn void QPlainTextEdit::updateRequest(const QRect &rect, int dy) | - |
2749 | | - |
2750 | This signal is emitted when the text document needs an update of | - |
2751 | the specified \a rect. If the text is scrolled, \a rect will cover | - |
2752 | the entire viewport area. If the text is scrolled vertically, \a | - |
2753 | dy carries the amount of pixels the viewport was scrolled. | - |
2754 | | - |
2755 | The purpose of the signal is to support extra widgets in plain | - |
2756 | text edit subclasses that e.g. show line numbers, breakpoints, or | - |
2757 | other extra information. | - |
2758 | */ | - |
2759 | | - |
2760 | /*! \fn void QPlainTextEdit::blockCountChanged(int newBlockCount); | - |
2761 | | - |
2762 | This signal is emitted whenever the block count changes. The new | - |
2763 | block count is passed in \a newBlockCount. | - |
2764 | */ | - |
2765 | | - |
2766 | /*! \fn void QPlainTextEdit::modificationChanged(bool changed); | - |
2767 | | - |
2768 | This signal is emitted whenever the content of the document | - |
2769 | changes in a way that affects the modification state. If \a | - |
2770 | changed is true, the document has been modified; otherwise it is | - |
2771 | false. | - |
2772 | | - |
2773 | For example, calling setModified(false) on a document and then | - |
2774 | inserting text causes the signal to get emitted. If you undo that | - |
2775 | operation, causing the document to return to its original | - |
2776 | unmodified state, the signal will get emitted again. | - |
2777 | */ | - |
2778 | | - |
2779 | | - |
2780 | | - |
2781 | | - |
2782 | void QPlainTextEditPrivate::append(const QString &text, Qt::TextFormat format) | - |
2783 | { | - |
2784 | Q_Q(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEdit * const q = q_func(); | - |
2785 | | - |
2786 | QTextDocument *document = control->document(); executed (the execution status of this line is deduced): QTextDocument *document = control->document(); | - |
2787 | QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(document->documentLayout()); executed (the execution status of this line is deduced): QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(document->documentLayout()); | - |
2788 | Q_ASSERT(documentLayout); executed (the execution status of this line is deduced): qt_noop(); | - |
2789 | | - |
2790 | int maximumBlockCount = document->maximumBlockCount(); executed (the execution status of this line is deduced): int maximumBlockCount = document->maximumBlockCount(); | - |
2791 | if (maximumBlockCount) partially evaluated: maximumBlockCount no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
2792 | document->setMaximumBlockCount(0); never executed: document->setMaximumBlockCount(0); | 0 |
2793 | | - |
2794 | const bool atBottom = q->isVisible() partially evaluated: q->isVisible() no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
2795 | && (control->blockBoundingRect(document->lastBlock()).bottom() - verticalOffset() never evaluated: (control->blockBoundingRect(document->lastBlock()).bottom() - verticalOffset() <= viewport->rect().bottom()) | 0 |
2796 | <= viewport->rect().bottom()); never evaluated: (control->blockBoundingRect(document->lastBlock()).bottom() - verticalOffset() <= viewport->rect().bottom()) | 0 |
2797 | | - |
2798 | if (!q->isVisible()) partially evaluated: !q->isVisible() yes Evaluation Count:13 | no Evaluation Count:0 |
| 0-13 |
2799 | showCursorOnInitialShow = true; executed: showCursorOnInitialShow = true; Execution Count:13 | 13 |
2800 | | - |
2801 | bool documentSizeChangedBlocked = documentLayout->priv()->blockDocumentSizeChanged; executed (the execution status of this line is deduced): bool documentSizeChangedBlocked = documentLayout->priv()->blockDocumentSizeChanged; | - |
2802 | documentLayout->priv()->blockDocumentSizeChanged = true; executed (the execution status of this line is deduced): documentLayout->priv()->blockDocumentSizeChanged = true; | - |
2803 | | - |
2804 | if (format == Qt::RichText) evaluated: format == Qt::RichText yes Evaluation Count:4 | yes Evaluation Count:9 |
| 4-9 |
2805 | control->appendHtml(text); executed: control->appendHtml(text); Execution Count:4 | 4 |
2806 | else if (format == Qt::PlainText) partially evaluated: format == Qt::PlainText yes Evaluation Count:9 | no Evaluation Count:0 |
| 0-9 |
2807 | control->appendPlainText(text); executed: control->appendPlainText(text); Execution Count:9 | 9 |
2808 | else | - |
2809 | control->append(text); never executed: control->append(text); | 0 |
2810 | | - |
2811 | if (maximumBlockCount > 0) { partially evaluated: maximumBlockCount > 0 no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
2812 | if (document->blockCount() > maximumBlockCount) { never evaluated: document->blockCount() > maximumBlockCount | 0 |
2813 | bool blockUpdate = false; never executed (the execution status of this line is deduced): bool blockUpdate = false; | - |
2814 | if (control->topBlock) { never evaluated: control->topBlock | 0 |
2815 | control->topBlock--; never executed (the execution status of this line is deduced): control->topBlock--; | - |
2816 | blockUpdate = true; never executed (the execution status of this line is deduced): blockUpdate = true; | - |
2817 | emit q->updateRequest(viewport->rect(), 0); never executed (the execution status of this line is deduced): q->updateRequest(viewport->rect(), 0); | - |
2818 | } | 0 |
2819 | | - |
2820 | bool updatesBlocked = documentLayout->priv()->blockUpdate; never executed (the execution status of this line is deduced): bool updatesBlocked = documentLayout->priv()->blockUpdate; | - |
2821 | documentLayout->priv()->blockUpdate = blockUpdate; never executed (the execution status of this line is deduced): documentLayout->priv()->blockUpdate = blockUpdate; | - |
2822 | QTextCursor cursor(document); never executed (the execution status of this line is deduced): QTextCursor cursor(document); | - |
2823 | cursor.movePosition(QTextCursor::NextBlock, QTextCursor::KeepAnchor); never executed (the execution status of this line is deduced): cursor.movePosition(QTextCursor::NextBlock, QTextCursor::KeepAnchor); | - |
2824 | cursor.removeSelectedText(); never executed (the execution status of this line is deduced): cursor.removeSelectedText(); | - |
2825 | documentLayout->priv()->blockUpdate = updatesBlocked; never executed (the execution status of this line is deduced): documentLayout->priv()->blockUpdate = updatesBlocked; | - |
2826 | } | 0 |
2827 | document->setMaximumBlockCount(maximumBlockCount); never executed (the execution status of this line is deduced): document->setMaximumBlockCount(maximumBlockCount); | - |
2828 | } | 0 |
2829 | | - |
2830 | documentLayout->priv()->blockDocumentSizeChanged = documentSizeChangedBlocked; executed (the execution status of this line is deduced): documentLayout->priv()->blockDocumentSizeChanged = documentSizeChangedBlocked; | - |
2831 | _q_adjustScrollbars(); executed (the execution status of this line is deduced): _q_adjustScrollbars(); | - |
2832 | | - |
2833 | | - |
2834 | if (atBottom) { partially evaluated: atBottom no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
2835 | const bool needScroll = !centerOnScroll never evaluated: !centerOnScroll | 0 |
2836 | || control->blockBoundingRect(document->lastBlock()).bottom() - verticalOffset() never evaluated: control->blockBoundingRect(document->lastBlock()).bottom() - verticalOffset() > viewport->rect().bottom() | 0 |
2837 | > viewport->rect().bottom(); never evaluated: control->blockBoundingRect(document->lastBlock()).bottom() - verticalOffset() > viewport->rect().bottom() | 0 |
2838 | if (needScroll) never evaluated: needScroll | 0 |
2839 | vbar->setValue(vbar->maximum()); never executed: vbar->setValue(vbar->maximum()); | 0 |
2840 | } | 0 |
2841 | } executed: } Execution Count:13 | 13 |
2842 | | - |
2843 | | - |
2844 | /*! | - |
2845 | Appends a new paragraph with \a text to the end of the text edit. | - |
2846 | | - |
2847 | \sa appendHtml() | - |
2848 | */ | - |
2849 | | - |
2850 | void QPlainTextEdit::appendPlainText(const QString &text) | - |
2851 | { | - |
2852 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2853 | d->append(text, Qt::PlainText); executed (the execution status of this line is deduced): d->append(text, Qt::PlainText); | - |
2854 | } executed: } Execution Count:9 | 9 |
2855 | | - |
2856 | /*! | - |
2857 | Appends a new paragraph with \a html to the end of the text edit. | - |
2858 | | - |
2859 | appendPlainText() | - |
2860 | */ | - |
2861 | | - |
2862 | void QPlainTextEdit::appendHtml(const QString &html) | - |
2863 | { | - |
2864 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2865 | d->append(html, Qt::RichText); executed (the execution status of this line is deduced): d->append(html, Qt::RichText); | - |
2866 | } executed: } Execution Count:4 | 4 |
2867 | | - |
2868 | void QPlainTextEditPrivate::ensureCursorVisible(bool center) | - |
2869 | { | - |
2870 | Q_Q(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEdit * const q = q_func(); | - |
2871 | QRect visible = viewport->rect(); executed (the execution status of this line is deduced): QRect visible = viewport->rect(); | - |
2872 | QRect cr = q->cursorRect(); executed (the execution status of this line is deduced): QRect cr = q->cursorRect(); | - |
2873 | if (cr.top() < visible.top() || cr.bottom() > visible.bottom()) { evaluated: cr.top() < visible.top() yes Evaluation Count:1 | yes Evaluation Count:368 |
evaluated: cr.bottom() > visible.bottom() yes Evaluation Count:11 | yes Evaluation Count:357 |
| 1-368 |
2874 | ensureVisible(control->textCursor().position(), center); executed (the execution status of this line is deduced): ensureVisible(control->textCursor().position(), center); | - |
2875 | } executed: } Execution Count:12 | 12 |
2876 | | - |
2877 | const bool rtl = q->isRightToLeft(); executed (the execution status of this line is deduced): const bool rtl = q->isRightToLeft(); | - |
2878 | if (cr.left() < visible.left() || cr.right() > visible.right()) { evaluated: cr.left() < visible.left() yes Evaluation Count:3 | yes Evaluation Count:366 |
evaluated: cr.right() > visible.right() yes Evaluation Count:2 | yes Evaluation Count:364 |
| 2-366 |
2879 | int x = cr.center().x() + horizontalOffset() - visible.width()/2; executed (the execution status of this line is deduced): int x = cr.center().x() + horizontalOffset() - visible.width()/2; | - |
2880 | hbar->setValue(rtl ? hbar->maximum() - x : x); executed (the execution status of this line is deduced): hbar->setValue(rtl ? hbar->maximum() - x : x); | - |
2881 | } executed: } Execution Count:5 | 5 |
2882 | } executed: } Execution Count:369 | 369 |
2883 | | - |
2884 | /*! | - |
2885 | Ensures that the cursor is visible by scrolling the text edit if | - |
2886 | necessary. | - |
2887 | | - |
2888 | \sa centerCursor(), centerOnScroll | - |
2889 | */ | - |
2890 | void QPlainTextEdit::ensureCursorVisible() | - |
2891 | { | - |
2892 | Q_D(QPlainTextEdit); executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2893 | d->ensureCursorVisible(d->centerOnScroll); executed (the execution status of this line is deduced): d->ensureCursorVisible(d->centerOnScroll); | - |
2894 | } executed: } Execution Count:369 | 369 |
2895 | | - |
2896 | | - |
2897 | /*! Scrolls the document in order to center the cursor vertically. | - |
2898 | | - |
2899 | \sa ensureCursorVisible(), centerOnScroll | - |
2900 | */ | - |
2901 | void QPlainTextEdit::centerCursor() | - |
2902 | { | - |
2903 | Q_D(QPlainTextEdit); never executed (the execution status of this line is deduced): QPlainTextEditPrivate * const d = d_func(); | - |
2904 | d->ensureVisible(textCursor().position(), true, true); never executed (the execution status of this line is deduced): d->ensureVisible(textCursor().position(), true, true); | - |
2905 | } | 0 |
2906 | | - |
2907 | /*! | - |
2908 | Returns the first visible block. | - |
2909 | | - |
2910 | \sa blockBoundingRect() | - |
2911 | */ | - |
2912 | QTextBlock QPlainTextEdit::firstVisibleBlock() const | - |
2913 | { | - |
2914 | Q_D(const QPlainTextEdit); executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
2915 | return d->control->firstVisibleBlock(); executed: return d->control->firstVisibleBlock(); Execution Count:239 | 239 |
2916 | } | - |
2917 | | - |
2918 | /*! Returns the content's origin in viewport coordinates. | - |
2919 | | - |
2920 | The origin of the content of a plain text edit is always the top | - |
2921 | left corner of the first visible text block. The content offset | - |
2922 | is different from (0,0) when the text has been scrolled | - |
2923 | horizontally, or when the first visible block has been scrolled | - |
2924 | partially off the screen, i.e. the visible text does not start | - |
2925 | with the first line of the first visible block, or when the first | - |
2926 | visible block is the very first block and the editor displays a | - |
2927 | margin. | - |
2928 | | - |
2929 | \sa firstVisibleBlock(), horizontalScrollBar(), verticalScrollBar() | - |
2930 | */ | - |
2931 | QPointF QPlainTextEdit::contentOffset() const | - |
2932 | { | - |
2933 | Q_D(const QPlainTextEdit); executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
2934 | return QPointF(-d->horizontalOffset(), -d->verticalOffset()); executed: return QPointF(-d->horizontalOffset(), -d->verticalOffset()); Execution Count:19 | 19 |
2935 | } | - |
2936 | | - |
2937 | | - |
2938 | /*! Returns the bounding rectangle of the text \a block in content | - |
2939 | coordinates. Translate the rectangle with the contentOffset() to get | - |
2940 | visual coordinates on the viewport. | - |
2941 | | - |
2942 | \sa firstVisibleBlock(), blockBoundingRect() | - |
2943 | */ | - |
2944 | QRectF QPlainTextEdit::blockBoundingGeometry(const QTextBlock &block) const | - |
2945 | { | - |
2946 | Q_D(const QPlainTextEdit); executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
2947 | return d->control->blockBoundingRect(block); executed: return d->control->blockBoundingRect(block); Execution Count:11 | 11 |
2948 | } | - |
2949 | | - |
2950 | /*! | - |
2951 | Returns the bounding rectangle of the text \a block in the block's own coordinates. | - |
2952 | | - |
2953 | \sa blockBoundingGeometry() | - |
2954 | */ | - |
2955 | QRectF QPlainTextEdit::blockBoundingRect(const QTextBlock &block) const | - |
2956 | { | - |
2957 | QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(document()->documentLayout()); executed (the execution status of this line is deduced): QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(document()->documentLayout()); | - |
2958 | Q_ASSERT(documentLayout); executed (the execution status of this line is deduced): qt_noop(); | - |
2959 | return documentLayout->blockBoundingRect(block); executed: return documentLayout->blockBoundingRect(block); Execution Count:47 | 47 |
2960 | } | - |
2961 | | - |
2962 | /*! | - |
2963 | \property QPlainTextEdit::blockCount | - |
2964 | \brief the number of text blocks in the document. | - |
2965 | | - |
2966 | By default, in an empty document, this property contains a value of 1. | - |
2967 | */ | - |
2968 | int QPlainTextEdit::blockCount() const | - |
2969 | { | - |
2970 | return document()->blockCount(); never executed: return document()->blockCount(); | 0 |
2971 | } | - |
2972 | | - |
2973 | /*! Returns the paint context for the viewport(), useful only when | - |
2974 | reimplementing paintEvent(). | - |
2975 | */ | - |
2976 | QAbstractTextDocumentLayout::PaintContext QPlainTextEdit::getPaintContext() const | - |
2977 | { | - |
2978 | Q_D(const QPlainTextEdit); executed (the execution status of this line is deduced): const QPlainTextEditPrivate * const d = d_func(); | - |
2979 | return d->control->getPaintContext(d->viewport); executed: return d->control->getPaintContext(d->viewport); Execution Count:7 | 7 |
2980 | } | - |
2981 | | - |
2982 | /*! | - |
2983 | \property QPlainTextEdit::maximumBlockCount | - |
2984 | \brief the limit for blocks in the document. | - |
2985 | | - |
2986 | Specifies the maximum number of blocks the document may have. If there are | - |
2987 | more blocks in the document that specified with this property blocks are removed | - |
2988 | from the beginning of the document. | - |
2989 | | - |
2990 | A negative or zero value specifies that the document may contain an unlimited | - |
2991 | amount of blocks. | - |
2992 | | - |
2993 | The default value is 0. | - |
2994 | | - |
2995 | Note that setting this property will apply the limit immediately to the document | - |
2996 | contents. Setting this property also disables the undo redo history. | - |
2997 | | - |
2998 | */ | - |
2999 | | - |
3000 | | - |
3001 | /*! | - |
3002 | \fn void QPlainTextEdit::textChanged() | - |
3003 | | - |
3004 | This signal is emitted whenever the document's content changes; for | - |
3005 | example, when text is inserted or deleted, or when formatting is applied. | - |
3006 | */ | - |
3007 | | - |
3008 | /*! | - |
3009 | \fn void QPlainTextEdit::undoAvailable(bool available) | - |
3010 | | - |
3011 | This signal is emitted whenever undo operations become available | - |
3012 | (\a available is true) or unavailable (\a available is false). | - |
3013 | */ | - |
3014 | | - |
3015 | /*! | - |
3016 | \fn void QPlainTextEdit::redoAvailable(bool available) | - |
3017 | | - |
3018 | This signal is emitted whenever redo operations become available | - |
3019 | (\a available is true) or unavailable (\a available is false). | - |
3020 | */ | - |
3021 | | - |
3022 | QT_END_NAMESPACE | - |
3023 | | - |
3024 | #include "moc_qplaintextedit.cpp" | - |
3025 | #include "moc_qplaintextedit_p.cpp" | - |
3026 | | - |
3027 | #endif // QT_NO_TEXTEDIT | - |
3028 | | - |
| | |