Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qplaintextedit.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||
6 | - | |||||||||||||||||||||||||
7 | - | |||||||||||||||||||||||||
8 | - | |||||||||||||||||||||||||
9 | static inline bool shouldEnableInputMethod(QPlainTextEdit *plaintextedit) | - | ||||||||||||||||||||||||
10 | { | - | ||||||||||||||||||||||||
11 | return never executed: !plaintextedit->isReadOnly();return !plaintextedit->isReadOnly(); never executed: return !plaintextedit->isReadOnly(); | 0 | ||||||||||||||||||||||||
12 | } | - | ||||||||||||||||||||||||
13 | - | |||||||||||||||||||||||||
14 | class QPlainTextDocumentLayoutPrivate : public QAbstractTextDocumentLayoutPrivate | - | ||||||||||||||||||||||||
15 | { | - | ||||||||||||||||||||||||
16 | inline QPlainTextDocumentLayout* q_func() { return static_cast<QPlainTextDocumentLayout *>(q_ptr); } inline const QPlainTextDocumentLayout* q_func() const { return static_cast<const QPlainTextDocumentLayout *>(q_ptr); } friend class QPlainTextDocumentLayout; | - | ||||||||||||||||||||||||
17 | public: | - | ||||||||||||||||||||||||
18 | QPlainTextDocumentLayoutPrivate() { | - | ||||||||||||||||||||||||
19 | mainViewPrivate = 0; | - | ||||||||||||||||||||||||
20 | width = 0; | - | ||||||||||||||||||||||||
21 | maximumWidth = 0; | - | ||||||||||||||||||||||||
22 | maximumWidthBlockNumber = 0; | - | ||||||||||||||||||||||||
23 | blockCount = 1; | - | ||||||||||||||||||||||||
24 | blockUpdate = blockDocumentSizeChanged = false; | - | ||||||||||||||||||||||||
25 | cursorWidth = 1; | - | ||||||||||||||||||||||||
26 | textLayoutFlags = 0; | - | ||||||||||||||||||||||||
27 | } never executed: end of block | 0 | ||||||||||||||||||||||||
28 | - | |||||||||||||||||||||||||
29 | qreal width; | - | ||||||||||||||||||||||||
30 | qreal maximumWidth; | - | ||||||||||||||||||||||||
31 | int maximumWidthBlockNumber; | - | ||||||||||||||||||||||||
32 | int blockCount; | - | ||||||||||||||||||||||||
33 | QPlainTextEditPrivate *mainViewPrivate; | - | ||||||||||||||||||||||||
34 | bool blockUpdate; | - | ||||||||||||||||||||||||
35 | bool blockDocumentSizeChanged; | - | ||||||||||||||||||||||||
36 | int cursorWidth; | - | ||||||||||||||||||||||||
37 | int textLayoutFlags; | - | ||||||||||||||||||||||||
38 | - | |||||||||||||||||||||||||
39 | void layoutBlock(const QTextBlock &block); | - | ||||||||||||||||||||||||
40 | qreal blockWidth(const QTextBlock &block); | - | ||||||||||||||||||||||||
41 | - | |||||||||||||||||||||||||
42 | void relayout(); | - | ||||||||||||||||||||||||
43 | }; | - | ||||||||||||||||||||||||
44 | QPlainTextDocumentLayout::QPlainTextDocumentLayout(QTextDocument *document) | - | ||||||||||||||||||||||||
45 | :QAbstractTextDocumentLayout(* new QPlainTextDocumentLayoutPrivate, document) { | - | ||||||||||||||||||||||||
46 | } never executed: end of block | 0 | ||||||||||||||||||||||||
47 | - | |||||||||||||||||||||||||
48 | - | |||||||||||||||||||||||||
49 | - | |||||||||||||||||||||||||
50 | QPlainTextDocumentLayout::~QPlainTextDocumentLayout() {} | - | ||||||||||||||||||||||||
51 | - | |||||||||||||||||||||||||
52 | - | |||||||||||||||||||||||||
53 | - | |||||||||||||||||||||||||
54 | - | |||||||||||||||||||||||||
55 | - | |||||||||||||||||||||||||
56 | void QPlainTextDocumentLayout::draw(QPainter *, const PaintContext &) | - | ||||||||||||||||||||||||
57 | { | - | ||||||||||||||||||||||||
58 | } | - | ||||||||||||||||||||||||
59 | - | |||||||||||||||||||||||||
60 | - | |||||||||||||||||||||||||
61 | - | |||||||||||||||||||||||||
62 | - | |||||||||||||||||||||||||
63 | int QPlainTextDocumentLayout::hitTest(const QPointF &, Qt::HitTestAccuracy ) const | - | ||||||||||||||||||||||||
64 | { | - | ||||||||||||||||||||||||
65 | - | |||||||||||||||||||||||||
66 | - | |||||||||||||||||||||||||
67 | - | |||||||||||||||||||||||||
68 | - | |||||||||||||||||||||||||
69 | - | |||||||||||||||||||||||||
70 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
71 | } | - | ||||||||||||||||||||||||
72 | - | |||||||||||||||||||||||||
73 | - | |||||||||||||||||||||||||
74 | - | |||||||||||||||||||||||||
75 | - | |||||||||||||||||||||||||
76 | int QPlainTextDocumentLayout::pageCount() const | - | ||||||||||||||||||||||||
77 | { return never executed: 1;return 1; never executed: }return 1; | 0 | ||||||||||||||||||||||||
78 | - | |||||||||||||||||||||||||
79 | - | |||||||||||||||||||||||||
80 | - | |||||||||||||||||||||||||
81 | - | |||||||||||||||||||||||||
82 | QSizeF QPlainTextDocumentLayout::documentSize() const | - | ||||||||||||||||||||||||
83 | { | - | ||||||||||||||||||||||||
84 | const QPlainTextDocumentLayoutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
85 | return never executed: QSizeF(d->maximumWidth, document()->lineCount());return QSizeF(d->maximumWidth, document()->lineCount()); never executed: return QSizeF(d->maximumWidth, document()->lineCount()); | 0 | ||||||||||||||||||||||||
86 | } | - | ||||||||||||||||||||||||
87 | - | |||||||||||||||||||||||||
88 | - | |||||||||||||||||||||||||
89 | - | |||||||||||||||||||||||||
90 | - | |||||||||||||||||||||||||
91 | QRectF QPlainTextDocumentLayout::frameBoundingRect(QTextFrame *) const | - | ||||||||||||||||||||||||
92 | { | - | ||||||||||||||||||||||||
93 | const QPlainTextDocumentLayoutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
94 | return never executed: QRectF(0, 0, qMax(d->width, d->maximumWidth), qreal(2147483647));return QRectF(0, 0, qMax(d->width, d->maximumWidth), qreal(2147483647)); never executed: return QRectF(0, 0, qMax(d->width, d->maximumWidth), qreal(2147483647)); | 0 | ||||||||||||||||||||||||
95 | } | - | ||||||||||||||||||||||||
96 | - | |||||||||||||||||||||||||
97 | - | |||||||||||||||||||||||||
98 | - | |||||||||||||||||||||||||
99 | - | |||||||||||||||||||||||||
100 | QRectF QPlainTextDocumentLayout::blockBoundingRect(const QTextBlock &block) const | - | ||||||||||||||||||||||||
101 | { | - | ||||||||||||||||||||||||
102 | if (!block.isValid()
never executed: QRectF();return QRectF(); never executed: }return QRectF(); | 0 | ||||||||||||||||||||||||
103 | QTextLayout *tl = block.layout(); | - | ||||||||||||||||||||||||
104 | if (!tl->lineCount()
| 0 | ||||||||||||||||||||||||
105 | const_cast< never executed: QPlainTextDocumentLayout*>(this)->layoutBlock(block);const_cast<QPlainTextDocumentLayout*>(this)->layoutBlock(block); never executed: const_cast<QPlainTextDocumentLayout*>(this)->layoutBlock(block); | 0 | ||||||||||||||||||||||||
106 | QRectF br; | - | ||||||||||||||||||||||||
107 | if (block.isVisible()
| 0 | ||||||||||||||||||||||||
108 | br = QRectF(QPointF(0, 0), tl->boundingRect().bottomRight()); | - | ||||||||||||||||||||||||
109 | if (tl->lineCount() == 1
| 0 | ||||||||||||||||||||||||
110 | br.setWidth(qMax(br.width(), tl->lineAt(0).naturalTextWidth())); never executed: br.setWidth(qMax(br.width(), tl->lineAt(0).naturalTextWidth())); | 0 | ||||||||||||||||||||||||
111 | qreal margin = document()->documentMargin(); | - | ||||||||||||||||||||||||
112 | br.adjust(0, 0, margin, 0); | - | ||||||||||||||||||||||||
113 | if (!block.next().isValid()
| 0 | ||||||||||||||||||||||||
114 | br.adjust(0, 0, 0, margin); never executed: br.adjust(0, 0, 0, margin); | 0 | ||||||||||||||||||||||||
115 | } never executed: end of block | 0 | ||||||||||||||||||||||||
116 | return never executed: br;return br; never executed: return br; | 0 | ||||||||||||||||||||||||
117 | - | |||||||||||||||||||||||||
118 | } | - | ||||||||||||||||||||||||
119 | - | |||||||||||||||||||||||||
120 | - | |||||||||||||||||||||||||
121 | - | |||||||||||||||||||||||||
122 | - | |||||||||||||||||||||||||
123 | void QPlainTextDocumentLayout::ensureBlockLayout(const QTextBlock &block) const | - | ||||||||||||||||||||||||
124 | { | - | ||||||||||||||||||||||||
125 | if (!block.isValid()
| 0 | ||||||||||||||||||||||||
126 | return; never executed: return; | 0 | ||||||||||||||||||||||||
127 | QTextLayout *tl = block.layout(); | - | ||||||||||||||||||||||||
128 | if (!tl->lineCount()
| 0 | ||||||||||||||||||||||||
129 | const_cast< never executed: QPlainTextDocumentLayout*>(this)->layoutBlock(block);const_cast<QPlainTextDocumentLayout*>(this)->layoutBlock(block); never executed: const_cast<QPlainTextDocumentLayout*>(this)->layoutBlock(block); | 0 | ||||||||||||||||||||||||
130 | } never executed: end of block | 0 | ||||||||||||||||||||||||
131 | - | |||||||||||||||||||||||||
132 | - | |||||||||||||||||||||||||
133 | - | |||||||||||||||||||||||||
134 | - | |||||||||||||||||||||||||
135 | - | |||||||||||||||||||||||||
136 | - | |||||||||||||||||||||||||
137 | void QPlainTextDocumentLayout::setCursorWidth(int width) | - | ||||||||||||||||||||||||
138 | { | - | ||||||||||||||||||||||||
139 | QPlainTextDocumentLayoutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
140 | d->cursorWidth = width; | - | ||||||||||||||||||||||||
141 | } never executed: end of block | 0 | ||||||||||||||||||||||||
142 | - | |||||||||||||||||||||||||
143 | int QPlainTextDocumentLayout::cursorWidth() const | - | ||||||||||||||||||||||||
144 | { | - | ||||||||||||||||||||||||
145 | const QPlainTextDocumentLayoutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
146 | return never executed: d->cursorWidth;return d->cursorWidth; never executed: return d->cursorWidth; | 0 | ||||||||||||||||||||||||
147 | } | - | ||||||||||||||||||||||||
148 | - | |||||||||||||||||||||||||
149 | QPlainTextDocumentLayoutPrivate *QPlainTextDocumentLayout::priv() const | - | ||||||||||||||||||||||||
150 | { | - | ||||||||||||||||||||||||
151 | const QPlainTextDocumentLayoutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
152 | return never executed: const_cast<QPlainTextDocumentLayoutPrivate*>(d);return const_cast<QPlainTextDocumentLayoutPrivate*>(d); never executed: return const_cast<QPlainTextDocumentLayoutPrivate*>(d); | 0 | ||||||||||||||||||||||||
153 | } | - | ||||||||||||||||||||||||
154 | - | |||||||||||||||||||||||||
155 | - | |||||||||||||||||||||||||
156 | - | |||||||||||||||||||||||||
157 | - | |||||||||||||||||||||||||
158 | - | |||||||||||||||||||||||||
159 | - | |||||||||||||||||||||||||
160 | void QPlainTextDocumentLayout::requestUpdate() | - | ||||||||||||||||||||||||
161 | { | - | ||||||||||||||||||||||||
162 | update(QRectF(0., -document()->documentMargin(), 1000000000., 1000000000.)); | - | ||||||||||||||||||||||||
163 | } never executed: end of block | 0 | ||||||||||||||||||||||||
164 | - | |||||||||||||||||||||||||
165 | - | |||||||||||||||||||||||||
166 | void QPlainTextDocumentLayout::setTextWidth(qreal newWidth) | - | ||||||||||||||||||||||||
167 | { | - | ||||||||||||||||||||||||
168 | QPlainTextDocumentLayoutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
169 | d->width = d->maximumWidth = newWidth; | - | ||||||||||||||||||||||||
170 | d->relayout(); | - | ||||||||||||||||||||||||
171 | } never executed: end of block | 0 | ||||||||||||||||||||||||
172 | - | |||||||||||||||||||||||||
173 | qreal QPlainTextDocumentLayout::textWidth() const | - | ||||||||||||||||||||||||
174 | { | - | ||||||||||||||||||||||||
175 | const QPlainTextDocumentLayoutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
176 | return never executed: d->width;return d->width; never executed: return d->width; | 0 | ||||||||||||||||||||||||
177 | } | - | ||||||||||||||||||||||||
178 | - | |||||||||||||||||||||||||
179 | void QPlainTextDocumentLayoutPrivate::relayout() | - | ||||||||||||||||||||||||
180 | { | - | ||||||||||||||||||||||||
181 | QPlainTextDocumentLayout * const q = q_func(); | - | ||||||||||||||||||||||||
182 | QTextBlock block = q->document()->firstBlock(); | - | ||||||||||||||||||||||||
183 | while (block.isValid()
| 0 | ||||||||||||||||||||||||
184 | block.layout()->clearLayout(); | - | ||||||||||||||||||||||||
185 | block.setLineCount(block.isVisible() ? 1 : 0); | - | ||||||||||||||||||||||||
186 | block = block.next(); | - | ||||||||||||||||||||||||
187 | } never executed: end of block | 0 | ||||||||||||||||||||||||
188 | q->update(); | - | ||||||||||||||||||||||||
189 | } never executed: end of block | 0 | ||||||||||||||||||||||||
190 | - | |||||||||||||||||||||||||
191 | - | |||||||||||||||||||||||||
192 | - | |||||||||||||||||||||||||
193 | - | |||||||||||||||||||||||||
194 | void QPlainTextDocumentLayout::documentChanged(int from, int charsRemoved, int charsAdded) | - | ||||||||||||||||||||||||
195 | { | - | ||||||||||||||||||||||||
196 | QPlainTextDocumentLayoutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
197 | QTextDocument *doc = document(); | - | ||||||||||||||||||||||||
198 | int newBlockCount = doc->blockCount(); | - | ||||||||||||||||||||||||
199 | int charsChanged = charsRemoved + charsAdded; | - | ||||||||||||||||||||||||
200 | - | |||||||||||||||||||||||||
201 | QTextBlock changeStartBlock = doc->findBlock(from); | - | ||||||||||||||||||||||||
202 | QTextBlock changeEndBlock = doc->findBlock(qMax(0, from + charsChanged - 1)); | - | ||||||||||||||||||||||||
203 | - | |||||||||||||||||||||||||
204 | if (changeStartBlock == changeEndBlock
| 0 | ||||||||||||||||||||||||
205 | QTextBlock block = changeStartBlock; | - | ||||||||||||||||||||||||
206 | if (block.isValid()
| 0 | ||||||||||||||||||||||||
207 | QRectF oldBr = blockBoundingRect(block); | - | ||||||||||||||||||||||||
208 | layoutBlock(block); | - | ||||||||||||||||||||||||
209 | QRectF newBr = blockBoundingRect(block); | - | ||||||||||||||||||||||||
210 | if (newBr.height() == oldBr.height()
| 0 | ||||||||||||||||||||||||
211 | if (!d->blockUpdate
| 0 | ||||||||||||||||||||||||
212 | updateBlock(block); never executed: updateBlock(block); | 0 | ||||||||||||||||||||||||
213 | return; never executed: return; | 0 | ||||||||||||||||||||||||
214 | } | - | ||||||||||||||||||||||||
215 | } never executed: end of block | 0 | ||||||||||||||||||||||||
216 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
217 | QTextBlock block = changeStartBlock; | - | ||||||||||||||||||||||||
218 | do { | - | ||||||||||||||||||||||||
219 | block.clearLayout(); | - | ||||||||||||||||||||||||
220 | if (block == changeEndBlock
| 0 | ||||||||||||||||||||||||
221 | break; never executed: break; | 0 | ||||||||||||||||||||||||
222 | block = block.next(); | - | ||||||||||||||||||||||||
223 | } never executed: while(block.isValid()end of block
| 0 | ||||||||||||||||||||||||
224 | } never executed: end of block | 0 | ||||||||||||||||||||||||
225 | - | |||||||||||||||||||||||||
226 | if (newBlockCount != d->blockCount
| 0 | ||||||||||||||||||||||||
227 | - | |||||||||||||||||||||||||
228 | int changeEnd = changeEndBlock.blockNumber(); | - | ||||||||||||||||||||||||
229 | int blockDiff = newBlockCount - d->blockCount; | - | ||||||||||||||||||||||||
230 | int oldChangeEnd = changeEnd - blockDiff; | - | ||||||||||||||||||||||||
231 | - | |||||||||||||||||||||||||
232 | if (d->maximumWidthBlockNumber > oldChangeEnd
| 0 | ||||||||||||||||||||||||
233 | d->maximumWidthBlockNumber += blockDiff; never executed: d->maximumWidthBlockNumber += blockDiff; | 0 | ||||||||||||||||||||||||
234 | - | |||||||||||||||||||||||||
235 | d->blockCount = newBlockCount; | - | ||||||||||||||||||||||||
236 | if (d->blockCount == 1
| 0 | ||||||||||||||||||||||||
237 | d->maximumWidth = blockWidth(doc->firstBlock()); never executed: d->maximumWidth = blockWidth(doc->firstBlock()); | 0 | ||||||||||||||||||||||||
238 | - | |||||||||||||||||||||||||
239 | if (!d->blockDocumentSizeChanged
| 0 | ||||||||||||||||||||||||
240 | documentSizeChanged(documentSize()); never executed: documentSizeChanged(documentSize()); | 0 | ||||||||||||||||||||||||
241 | - | |||||||||||||||||||||||||
242 | if (blockDiff == 1
| 0 | ||||||||||||||||||||||||
243 | if (!d->blockUpdate
| 0 | ||||||||||||||||||||||||
244 | QTextBlock b = changeStartBlock; | - | ||||||||||||||||||||||||
245 | for(;;) { | - | ||||||||||||||||||||||||
246 | updateBlock(b); | - | ||||||||||||||||||||||||
247 | if (b == changeEndBlock
| 0 | ||||||||||||||||||||||||
248 | break; never executed: break; | 0 | ||||||||||||||||||||||||
249 | b = b.next(); | - | ||||||||||||||||||||||||
250 | } never executed: end of block | 0 | ||||||||||||||||||||||||
251 | } never executed: end of block | 0 | ||||||||||||||||||||||||
252 | return; never executed: return; | 0 | ||||||||||||||||||||||||
253 | } | - | ||||||||||||||||||||||||
254 | } never executed: end of block | 0 | ||||||||||||||||||||||||
255 | - | |||||||||||||||||||||||||
256 | if (!d->blockUpdate
| 0 | ||||||||||||||||||||||||
257 | update(QRectF(0., -doc->documentMargin(), 1000000000., 1000000000.)); never executed: update(QRectF(0., -doc->documentMargin(), 1000000000., 1000000000.)); | 0 | ||||||||||||||||||||||||
258 | } never executed: end of block | 0 | ||||||||||||||||||||||||
259 | - | |||||||||||||||||||||||||
260 | - | |||||||||||||||||||||||||
261 | void QPlainTextDocumentLayout::layoutBlock(const QTextBlock &block) | - | ||||||||||||||||||||||||
262 | { | - | ||||||||||||||||||||||||
263 | QPlainTextDocumentLayoutPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
264 | QTextDocument *doc = document(); | - | ||||||||||||||||||||||||
265 | qreal margin = doc->documentMargin(); | - | ||||||||||||||||||||||||
266 | qreal blockMaximumWidth = 0; | - | ||||||||||||||||||||||||
267 | - | |||||||||||||||||||||||||
268 | qreal height = 0; | - | ||||||||||||||||||||||||
269 | QTextLayout *tl = block.layout(); | - | ||||||||||||||||||||||||
270 | QTextOption option = doc->defaultTextOption(); | - | ||||||||||||||||||||||||
271 | tl->setTextOption(option); | - | ||||||||||||||||||||||||
272 | - | |||||||||||||||||||||||||
273 | int extraMargin = 0; | - | ||||||||||||||||||||||||
274 | if (option.flags() & QTextOption::AddSpaceForLineAndParagraphSeparators
| 0 | ||||||||||||||||||||||||
275 | QFontMetrics fm(block.charFormat().font()); | - | ||||||||||||||||||||||||
276 | extraMargin += fm.width(QChar(0x21B5)); | - | ||||||||||||||||||||||||
277 | } never executed: end of block | 0 | ||||||||||||||||||||||||
278 | tl->beginLayout(); | - | ||||||||||||||||||||||||
279 | qreal availableWidth = d->width; | - | ||||||||||||||||||||||||
280 | if (availableWidth <= 0
| 0 | ||||||||||||||||||||||||
281 | availableWidth = qreal(2147483647); | - | ||||||||||||||||||||||||
282 | } never executed: end of block | 0 | ||||||||||||||||||||||||
283 | availableWidth -= 2*margin + extraMargin; | - | ||||||||||||||||||||||||
284 | while (1) { | - | ||||||||||||||||||||||||
285 | QTextLine line = tl->createLine(); | - | ||||||||||||||||||||||||
286 | if (!line.isValid()
| 0 | ||||||||||||||||||||||||
287 | break; never executed: break; | 0 | ||||||||||||||||||||||||
288 | line.setLeadingIncluded(true); | - | ||||||||||||||||||||||||
289 | line.setLineWidth(availableWidth); | - | ||||||||||||||||||||||||
290 | line.setPosition(QPointF(margin, height)); | - | ||||||||||||||||||||||||
291 | height += line.height(); | - | ||||||||||||||||||||||||
292 | blockMaximumWidth = qMax(blockMaximumWidth, line.naturalTextWidth() + 2*margin); | - | ||||||||||||||||||||||||
293 | } never executed: end of block | 0 | ||||||||||||||||||||||||
294 | tl->endLayout(); | - | ||||||||||||||||||||||||
295 | - | |||||||||||||||||||||||||
296 | int previousLineCount = doc->lineCount(); | - | ||||||||||||||||||||||||
297 | const_cast<QTextBlock&>(block).setLineCount(block.isVisible() ? tl->lineCount() : 0); | - | ||||||||||||||||||||||||
298 | int lineCount = doc->lineCount(); | - | ||||||||||||||||||||||||
299 | - | |||||||||||||||||||||||||
300 | bool emitDocumentSizeChanged = previousLineCount != lineCount; | - | ||||||||||||||||||||||||
301 | if (blockMaximumWidth > d->maximumWidth
| 0 | ||||||||||||||||||||||||
302 | - | |||||||||||||||||||||||||
303 | d->maximumWidth = blockMaximumWidth; | - | ||||||||||||||||||||||||
304 | d->maximumWidthBlockNumber = block.blockNumber(); | - | ||||||||||||||||||||||||
305 | emitDocumentSizeChanged = true; | - | ||||||||||||||||||||||||
306 | } never executed: else if (block.blockNumber() == d->maximumWidthBlockNumberend of block
| 0 | ||||||||||||||||||||||||
307 | - | |||||||||||||||||||||||||
308 | QTextBlock b = doc->firstBlock(); | - | ||||||||||||||||||||||||
309 | d->maximumWidth = 0; | - | ||||||||||||||||||||||||
310 | QTextBlock maximumBlock; | - | ||||||||||||||||||||||||
311 | while (b.isValid()
| 0 | ||||||||||||||||||||||||
312 | qreal blockMaximumWidth = blockWidth(b); | - | ||||||||||||||||||||||||
313 | if (blockMaximumWidth > d->maximumWidth
| 0 | ||||||||||||||||||||||||
314 | d->maximumWidth = blockMaximumWidth; | - | ||||||||||||||||||||||||
315 | maximumBlock = b; | - | ||||||||||||||||||||||||
316 | } never executed: end of block | 0 | ||||||||||||||||||||||||
317 | b = b.next(); | - | ||||||||||||||||||||||||
318 | } never executed: end of block | 0 | ||||||||||||||||||||||||
319 | if (maximumBlock.isValid()
| 0 | ||||||||||||||||||||||||
320 | d->maximumWidthBlockNumber = maximumBlock.blockNumber(); | - | ||||||||||||||||||||||||
321 | emitDocumentSizeChanged = true; | - | ||||||||||||||||||||||||
322 | } never executed: end of block | 0 | ||||||||||||||||||||||||
323 | } never executed: end of block | 0 | ||||||||||||||||||||||||
324 | if (emitDocumentSizeChanged
| 0 | ||||||||||||||||||||||||
325 | documentSizeChanged(documentSize()); never executed: documentSizeChanged(documentSize()); | 0 | ||||||||||||||||||||||||
326 | } never executed: end of block | 0 | ||||||||||||||||||||||||
327 | - | |||||||||||||||||||||||||
328 | qreal QPlainTextDocumentLayout::blockWidth(const QTextBlock &block) | - | ||||||||||||||||||||||||
329 | { | - | ||||||||||||||||||||||||
330 | QTextLayout *layout = block.layout(); | - | ||||||||||||||||||||||||
331 | if (!layout->lineCount()
| 0 | ||||||||||||||||||||||||
332 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
333 | qreal blockWidth = 0; | - | ||||||||||||||||||||||||
334 | for (int i = 0; i < layout->lineCount()
| 0 | ||||||||||||||||||||||||
335 | QTextLine line = layout->lineAt(i); | - | ||||||||||||||||||||||||
336 | blockWidth = qMax(line.naturalTextWidth() + 8, blockWidth); | - | ||||||||||||||||||||||||
337 | } never executed: end of block | 0 | ||||||||||||||||||||||||
338 | return never executed: blockWidth;return blockWidth; never executed: return blockWidth; | 0 | ||||||||||||||||||||||||
339 | } | - | ||||||||||||||||||||||||
340 | - | |||||||||||||||||||||||||
341 | - | |||||||||||||||||||||||||
342 | QPlainTextEditControl::QPlainTextEditControl(QPlainTextEdit *parent) | - | ||||||||||||||||||||||||
343 | : QWidgetTextControl(parent), textEdit(parent), | - | ||||||||||||||||||||||||
344 | topBlock(0) | - | ||||||||||||||||||||||||
345 | { | - | ||||||||||||||||||||||||
346 | setAcceptRichText(false); | - | ||||||||||||||||||||||||
347 | } never executed: end of block | 0 | ||||||||||||||||||||||||
348 | - | |||||||||||||||||||||||||
349 | void QPlainTextEditPrivate::_q_cursorPositionChanged() | - | ||||||||||||||||||||||||
350 | { | - | ||||||||||||||||||||||||
351 | pageUpDownLastCursorYIsValid = false; | - | ||||||||||||||||||||||||
352 | QPlainTextEdit * const q = q_func(); | - | ||||||||||||||||||||||||
353 | - | |||||||||||||||||||||||||
354 | QAccessibleTextCursorEvent ev(q, q->textCursor().position()); | - | ||||||||||||||||||||||||
355 | QAccessible::updateAccessibility(&ev); | - | ||||||||||||||||||||||||
356 | - | |||||||||||||||||||||||||
357 | q->cursorPositionChanged(); | - | ||||||||||||||||||||||||
358 | } never executed: end of block | 0 | ||||||||||||||||||||||||
359 | - | |||||||||||||||||||||||||
360 | void QPlainTextEditPrivate::_q_verticalScrollbarActionTriggered(int action) { | - | ||||||||||||||||||||||||
361 | if (action == QAbstractSlider::SliderPageStepAdd
| 0 | ||||||||||||||||||||||||
362 | pageUpDown(QTextCursor::Down, QTextCursor::MoveAnchor, false); | - | ||||||||||||||||||||||||
363 | } never executed: else if (action == QAbstractSlider::SliderPageStepSubend of block
| 0 | ||||||||||||||||||||||||
364 | pageUpDown(QTextCursor::Up, QTextCursor::MoveAnchor, false); | - | ||||||||||||||||||||||||
365 | } never executed: end of block | 0 | ||||||||||||||||||||||||
366 | } never executed: end of block | 0 | ||||||||||||||||||||||||
367 | - | |||||||||||||||||||||||||
368 | QMimeData *QPlainTextEditControl::createMimeDataFromSelection() const { | - | ||||||||||||||||||||||||
369 | QPlainTextEdit *ed = qobject_cast<QPlainTextEdit *>(parent()); | - | ||||||||||||||||||||||||
370 | if (!ed
| 0 | ||||||||||||||||||||||||
371 | return never executed: QWidgetTextControl::createMimeDataFromSelection();return QWidgetTextControl::createMimeDataFromSelection(); never executed: return QWidgetTextControl::createMimeDataFromSelection(); | 0 | ||||||||||||||||||||||||
372 | return never executed: ed->createMimeDataFromSelection();return ed->createMimeDataFromSelection(); never executed: return ed->createMimeDataFromSelection(); | 0 | ||||||||||||||||||||||||
373 | } | - | ||||||||||||||||||||||||
374 | bool QPlainTextEditControl::canInsertFromMimeData(const QMimeData *source) const { | - | ||||||||||||||||||||||||
375 | QPlainTextEdit *ed = qobject_cast<QPlainTextEdit *>(parent()); | - | ||||||||||||||||||||||||
376 | if (!ed
| 0 | ||||||||||||||||||||||||
377 | return never executed: QWidgetTextControl::canInsertFromMimeData(source);return QWidgetTextControl::canInsertFromMimeData(source); never executed: return QWidgetTextControl::canInsertFromMimeData(source); | 0 | ||||||||||||||||||||||||
378 | return never executed: ed->canInsertFromMimeData(source);return ed->canInsertFromMimeData(source); never executed: return ed->canInsertFromMimeData(source); | 0 | ||||||||||||||||||||||||
379 | } | - | ||||||||||||||||||||||||
380 | void QPlainTextEditControl::insertFromMimeData(const QMimeData *source) { | - | ||||||||||||||||||||||||
381 | QPlainTextEdit *ed = qobject_cast<QPlainTextEdit *>(parent()); | - | ||||||||||||||||||||||||
382 | if (!ed
| 0 | ||||||||||||||||||||||||
383 | QWidgetTextControl::insertFromMimeData(source); never executed: QWidgetTextControl::insertFromMimeData(source); | 0 | ||||||||||||||||||||||||
384 | else | - | ||||||||||||||||||||||||
385 | ed->insertFromMimeData(source); never executed: ed->insertFromMimeData(source); | 0 | ||||||||||||||||||||||||
386 | } | - | ||||||||||||||||||||||||
387 | - | |||||||||||||||||||||||||
388 | qreal QPlainTextEditPrivate::verticalOffset(int topBlock, int topLine) const | - | ||||||||||||||||||||||||
389 | { | - | ||||||||||||||||||||||||
390 | qreal offset = 0; | - | ||||||||||||||||||||||||
391 | QTextDocument *doc = control->document(); | - | ||||||||||||||||||||||||
392 | - | |||||||||||||||||||||||||
393 | if (topLine
| 0 | ||||||||||||||||||||||||
394 | QTextBlock currentBlock = doc->findBlockByNumber(topBlock); | - | ||||||||||||||||||||||||
395 | QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(doc->documentLayout()); | - | ||||||||||||||||||||||||
396 | ((!(documentLayout)) ? qt_assert("documentLayout",__FILE__,481) : qt_noop()); | - | ||||||||||||||||||||||||
397 | QRectF r = documentLayout->blockBoundingRect(currentBlock); | - | ||||||||||||||||||||||||
398 | (void)r;; | - | ||||||||||||||||||||||||
399 | QTextLayout *layout = currentBlock.layout(); | - | ||||||||||||||||||||||||
400 | if (layout
| 0 | ||||||||||||||||||||||||
401 | QTextLine line = layout->lineAt(topLine - 1); | - | ||||||||||||||||||||||||
402 | const QRectF lr = line.naturalTextRect(); | - | ||||||||||||||||||||||||
403 | offset = lr.bottom(); | - | ||||||||||||||||||||||||
404 | } never executed: end of block | 0 | ||||||||||||||||||||||||
405 | } never executed: end of block | 0 | ||||||||||||||||||||||||
406 | if (topBlock == 0
| 0 | ||||||||||||||||||||||||
407 | offset -= doc->documentMargin(); never executed: offset -= doc->documentMargin(); | 0 | ||||||||||||||||||||||||
408 | return never executed: offset;return offset; never executed: return offset; | 0 | ||||||||||||||||||||||||
409 | } | - | ||||||||||||||||||||||||
410 | - | |||||||||||||||||||||||||
411 | - | |||||||||||||||||||||||||
412 | qreal QPlainTextEditPrivate::verticalOffset() const { | - | ||||||||||||||||||||||||
413 | return never executed: verticalOffset(control->topBlock, topLine) + topLineFracture;return verticalOffset(control->topBlock, topLine) + topLineFracture; never executed: return verticalOffset(control->topBlock, topLine) + topLineFracture; | 0 | ||||||||||||||||||||||||
414 | } | - | ||||||||||||||||||||||||
415 | - | |||||||||||||||||||||||||
416 | - | |||||||||||||||||||||||||
417 | QTextBlock QPlainTextEditControl::firstVisibleBlock() const | - | ||||||||||||||||||||||||
418 | { | - | ||||||||||||||||||||||||
419 | return never executed: document()->findBlockByNumber(topBlock);return document()->findBlockByNumber(topBlock); never executed: return document()->findBlockByNumber(topBlock); | 0 | ||||||||||||||||||||||||
420 | } | - | ||||||||||||||||||||||||
421 | - | |||||||||||||||||||||||||
422 | - | |||||||||||||||||||||||||
423 | - | |||||||||||||||||||||||||
424 | int QPlainTextEditControl::hitTest(const QPointF &point, Qt::HitTestAccuracy ) const { | - | ||||||||||||||||||||||||
425 | int currentBlockNumber = topBlock; | - | ||||||||||||||||||||||||
426 | QTextBlock currentBlock = document()->findBlockByNumber(currentBlockNumber); | - | ||||||||||||||||||||||||
427 | if (!currentBlock.isValid()
| 0 | ||||||||||||||||||||||||
428 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
429 | - | |||||||||||||||||||||||||
430 | QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(document()->documentLayout()); | - | ||||||||||||||||||||||||
431 | ((!(documentLayout)) ? qt_assert("documentLayout",__FILE__,516) : qt_noop()); | - | ||||||||||||||||||||||||
432 | - | |||||||||||||||||||||||||
433 | QPointF offset; | - | ||||||||||||||||||||||||
434 | QRectF r = documentLayout->blockBoundingRect(currentBlock); | - | ||||||||||||||||||||||||
435 | while (currentBlock.next().isValid()
| 0 | ||||||||||||||||||||||||
436 | offset.ry() += r.height(); | - | ||||||||||||||||||||||||
437 | currentBlock = currentBlock.next(); | - | ||||||||||||||||||||||||
438 | ++currentBlockNumber; | - | ||||||||||||||||||||||||
439 | r = documentLayout->blockBoundingRect(currentBlock); | - | ||||||||||||||||||||||||
440 | } never executed: end of block | 0 | ||||||||||||||||||||||||
441 | while (currentBlock.previous().isValid()
| 0 | ||||||||||||||||||||||||
442 | offset.ry() -= r.height(); | - | ||||||||||||||||||||||||
443 | currentBlock = currentBlock.previous(); | - | ||||||||||||||||||||||||
444 | --currentBlockNumber; | - | ||||||||||||||||||||||||
445 | r = documentLayout->blockBoundingRect(currentBlock); | - | ||||||||||||||||||||||||
446 | } never executed: end of block | 0 | ||||||||||||||||||||||||
447 | - | |||||||||||||||||||||||||
448 | - | |||||||||||||||||||||||||
449 | if (!currentBlock.isValid()
| 0 | ||||||||||||||||||||||||
450 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
451 | QTextLayout *layout = currentBlock.layout(); | - | ||||||||||||||||||||||||
452 | int off = 0; | - | ||||||||||||||||||||||||
453 | QPointF pos = point - offset; | - | ||||||||||||||||||||||||
454 | for (int i = 0; i < layout->lineCount()
| 0 | ||||||||||||||||||||||||
455 | QTextLine line = layout->lineAt(i); | - | ||||||||||||||||||||||||
456 | const QRectF lr = line.naturalTextRect(); | - | ||||||||||||||||||||||||
457 | if (lr.top() > pos.y()
| 0 | ||||||||||||||||||||||||
458 | off = qMin(off, line.textStart()); | - | ||||||||||||||||||||||||
459 | } never executed: else if (lr.bottom() <= pos.y()end of block
| 0 | ||||||||||||||||||||||||
460 | off = qMax(off, line.textStart() + line.textLength()); | - | ||||||||||||||||||||||||
461 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
462 | off = line.xToCursor(pos.x(), overwriteMode() ? | - | ||||||||||||||||||||||||
463 | QTextLine::CursorOnCharacter : QTextLine::CursorBetweenCharacters); | - | ||||||||||||||||||||||||
464 | break; never executed: break; | 0 | ||||||||||||||||||||||||
465 | } | - | ||||||||||||||||||||||||
466 | } | - | ||||||||||||||||||||||||
467 | - | |||||||||||||||||||||||||
468 | return never executed: currentBlock.position() + off;return currentBlock.position() + off; never executed: return currentBlock.position() + off; | 0 | ||||||||||||||||||||||||
469 | } | - | ||||||||||||||||||||||||
470 | - | |||||||||||||||||||||||||
471 | QRectF QPlainTextEditControl::blockBoundingRect(const QTextBlock &block) const { | - | ||||||||||||||||||||||||
472 | int currentBlockNumber = topBlock; | - | ||||||||||||||||||||||||
473 | int blockNumber = block.blockNumber(); | - | ||||||||||||||||||||||||
474 | QTextBlock currentBlock = document()->findBlockByNumber(currentBlockNumber); | - | ||||||||||||||||||||||||
475 | if (!currentBlock.isValid()
| 0 | ||||||||||||||||||||||||
476 | return never executed: QRectF();return QRectF(); never executed: return QRectF(); | 0 | ||||||||||||||||||||||||
477 | ((!(currentBlock.blockNumber() == currentBlockNumber)) ? qt_assert("currentBlock.blockNumber() == currentBlockNumber",__FILE__,562) : qt_noop()); | - | ||||||||||||||||||||||||
478 | QTextDocument *doc = document(); | - | ||||||||||||||||||||||||
479 | QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(doc->documentLayout()); | - | ||||||||||||||||||||||||
480 | ((!(documentLayout)) ? qt_assert("documentLayout",__FILE__,565) : qt_noop()); | - | ||||||||||||||||||||||||
481 | - | |||||||||||||||||||||||||
482 | QPointF offset; | - | ||||||||||||||||||||||||
483 | if (!block.isValid()
| 0 | ||||||||||||||||||||||||
484 | return never executed: QRectF();return QRectF(); never executed: return QRectF(); | 0 | ||||||||||||||||||||||||
485 | QRectF r = documentLayout->blockBoundingRect(currentBlock); | - | ||||||||||||||||||||||||
486 | int maxVerticalOffset = r.height(); | - | ||||||||||||||||||||||||
487 | while (currentBlockNumber < blockNumber
| 0 | ||||||||||||||||||||||||
488 | offset.ry() += r.height(); | - | ||||||||||||||||||||||||
489 | currentBlock = currentBlock.next(); | - | ||||||||||||||||||||||||
490 | ++currentBlockNumber; | - | ||||||||||||||||||||||||
491 | if (!currentBlock.isVisible()
| 0 | ||||||||||||||||||||||||
492 | currentBlock = doc->findBlockByLineNumber(currentBlock.firstLineNumber()); | - | ||||||||||||||||||||||||
493 | currentBlockNumber = currentBlock.blockNumber(); | - | ||||||||||||||||||||||||
494 | } never executed: end of block | 0 | ||||||||||||||||||||||||
495 | r = documentLayout->blockBoundingRect(currentBlock); | - | ||||||||||||||||||||||||
496 | } never executed: end of block | 0 | ||||||||||||||||||||||||
497 | while (currentBlockNumber > blockNumber
| 0 | ||||||||||||||||||||||||
498 | currentBlock = currentBlock.previous(); | - | ||||||||||||||||||||||||
499 | --currentBlockNumber; | - | ||||||||||||||||||||||||
500 | while (!currentBlock.isVisible()
| 0 | ||||||||||||||||||||||||
501 | currentBlock = currentBlock.previous(); | - | ||||||||||||||||||||||||
502 | --currentBlockNumber; | - | ||||||||||||||||||||||||
503 | } never executed: end of block | 0 | ||||||||||||||||||||||||
504 | if (!currentBlock.isValid()
| 0 | ||||||||||||||||||||||||
505 | break; never executed: break; | 0 | ||||||||||||||||||||||||
506 | - | |||||||||||||||||||||||||
507 | r = documentLayout->blockBoundingRect(currentBlock); | - | ||||||||||||||||||||||||
508 | offset.ry() -= r.height(); | - | ||||||||||||||||||||||||
509 | } never executed: end of block | 0 | ||||||||||||||||||||||||
510 | - | |||||||||||||||||||||||||
511 | if (currentBlockNumber != blockNumber
| 0 | ||||||||||||||||||||||||
512 | - | |||||||||||||||||||||||||
513 | - | |||||||||||||||||||||||||
514 | r = documentLayout->blockBoundingRect(block); | - | ||||||||||||||||||||||||
515 | if (currentBlockNumber > blockNumber
| 0 | ||||||||||||||||||||||||
516 | offset.ry() -= r.height(); never executed: offset.ry() -= r.height(); | 0 | ||||||||||||||||||||||||
517 | } never executed: end of block | 0 | ||||||||||||||||||||||||
518 | r.translate(offset); | - | ||||||||||||||||||||||||
519 | return never executed: r;return r; never executed: return r; | 0 | ||||||||||||||||||||||||
520 | } | - | ||||||||||||||||||||||||
521 | - | |||||||||||||||||||||||||
522 | QString QPlainTextEditControl::anchorAt(const QPointF &pos) const | - | ||||||||||||||||||||||||
523 | { | - | ||||||||||||||||||||||||
524 | return never executed: textEdit->anchorAt(pos.toPoint());return textEdit->anchorAt(pos.toPoint()); never executed: return textEdit->anchorAt(pos.toPoint()); | 0 | ||||||||||||||||||||||||
525 | } | - | ||||||||||||||||||||||||
526 | - | |||||||||||||||||||||||||
527 | void QPlainTextEditPrivate::setTopLine(int visualTopLine, int dx) | - | ||||||||||||||||||||||||
528 | { | - | ||||||||||||||||||||||||
529 | QTextDocument *doc = control->document(); | - | ||||||||||||||||||||||||
530 | QTextBlock block = doc->findBlockByLineNumber(visualTopLine); | - | ||||||||||||||||||||||||
531 | int blockNumber = block.blockNumber(); | - | ||||||||||||||||||||||||
532 | int lineNumber = visualTopLine - block.firstLineNumber(); | - | ||||||||||||||||||||||||
533 | setTopBlock(blockNumber, lineNumber, dx); | - | ||||||||||||||||||||||||
534 | } never executed: end of block | 0 | ||||||||||||||||||||||||
535 | - | |||||||||||||||||||||||||
536 | void QPlainTextEditPrivate::setTopBlock(int blockNumber, int lineNumber, int dx) | - | ||||||||||||||||||||||||
537 | { | - | ||||||||||||||||||||||||
538 | QPlainTextEdit * const q = q_func(); | - | ||||||||||||||||||||||||
539 | blockNumber = qMax(0, blockNumber); | - | ||||||||||||||||||||||||
540 | lineNumber = qMax(0, lineNumber); | - | ||||||||||||||||||||||||
541 | QTextDocument *doc = control->document(); | - | ||||||||||||||||||||||||
542 | QTextBlock block = doc->findBlockByNumber(blockNumber); | - | ||||||||||||||||||||||||
543 | - | |||||||||||||||||||||||||
544 | int newTopLine = block.firstLineNumber() + lineNumber; | - | ||||||||||||||||||||||||
545 | int maxTopLine = vbar->maximum(); | - | ||||||||||||||||||||||||
546 | - | |||||||||||||||||||||||||
547 | if (newTopLine > maxTopLine
| 0 | ||||||||||||||||||||||||
548 | block = doc->findBlockByLineNumber(maxTopLine); | - | ||||||||||||||||||||||||
549 | blockNumber = block.blockNumber(); | - | ||||||||||||||||||||||||
550 | lineNumber = maxTopLine - block.firstLineNumber(); | - | ||||||||||||||||||||||||
551 | } never executed: end of block | 0 | ||||||||||||||||||||||||
552 | - | |||||||||||||||||||||||||
553 | { | - | ||||||||||||||||||||||||
554 | const QSignalBlocker blocker(vbar); | - | ||||||||||||||||||||||||
555 | vbar->setValue(newTopLine); | - | ||||||||||||||||||||||||
556 | } | - | ||||||||||||||||||||||||
557 | - | |||||||||||||||||||||||||
558 | if (!dx
| 0 | ||||||||||||||||||||||||
559 | return; never executed: return; | 0 | ||||||||||||||||||||||||
560 | - | |||||||||||||||||||||||||
561 | if (viewport->updatesEnabled()
| 0 | ||||||||||||||||||||||||
562 | int dy = 0; | - | ||||||||||||||||||||||||
563 | if (doc->findBlockByNumber(control->topBlock).isValid()
| 0 | ||||||||||||||||||||||||
564 | qreal realdy = -q->blockBoundingGeometry(block).y() | - | ||||||||||||||||||||||||
565 | + verticalOffset() - verticalOffset(blockNumber, lineNumber); | - | ||||||||||||||||||||||||
566 | dy = (int)realdy; | - | ||||||||||||||||||||||||
567 | topLineFracture = realdy - dy; | - | ||||||||||||||||||||||||
568 | } never executed: end of block | 0 | ||||||||||||||||||||||||
569 | control->topBlock = blockNumber; | - | ||||||||||||||||||||||||
570 | topLine = lineNumber; | - | ||||||||||||||||||||||||
571 | - | |||||||||||||||||||||||||
572 | { | - | ||||||||||||||||||||||||
573 | const QSignalBlocker blocker(vbar); | - | ||||||||||||||||||||||||
574 | vbar->setValue(block.firstLineNumber() + lineNumber); | - | ||||||||||||||||||||||||
575 | } | - | ||||||||||||||||||||||||
576 | - | |||||||||||||||||||||||||
577 | if (dx
| 0 | ||||||||||||||||||||||||
578 | viewport->scroll(q->isRightToLeft() ? -dx : dx, dy); | - | ||||||||||||||||||||||||
579 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
580 | viewport->update(); | - | ||||||||||||||||||||||||
581 | topLineFracture = 0; | - | ||||||||||||||||||||||||
582 | } never executed: end of block | 0 | ||||||||||||||||||||||||
583 | q->updateRequest(viewport->rect(), dy); | - | ||||||||||||||||||||||||
584 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
585 | control->topBlock = blockNumber; | - | ||||||||||||||||||||||||
586 | topLine = lineNumber; | - | ||||||||||||||||||||||||
587 | topLineFracture = 0; | - | ||||||||||||||||||||||||
588 | } never executed: end of block | 0 | ||||||||||||||||||||||||
589 | - | |||||||||||||||||||||||||
590 | } | - | ||||||||||||||||||||||||
591 | - | |||||||||||||||||||||||||
592 | - | |||||||||||||||||||||||||
593 | - | |||||||||||||||||||||||||
594 | void QPlainTextEditPrivate::ensureVisible(int position, bool center, bool forceCenter) { | - | ||||||||||||||||||||||||
595 | QPlainTextEdit * const q = q_func(); | - | ||||||||||||||||||||||||
596 | QRectF visible = QRectF(viewport->rect()).translated(-q->contentOffset()); | - | ||||||||||||||||||||||||
597 | QTextBlock block = control->document()->findBlock(position); | - | ||||||||||||||||||||||||
598 | if (!block.isValid()
| 0 | ||||||||||||||||||||||||
599 | return; never executed: return; | 0 | ||||||||||||||||||||||||
600 | QRectF br = control->blockBoundingRect(block); | - | ||||||||||||||||||||||||
601 | if (!br.isValid()
| 0 | ||||||||||||||||||||||||
602 | return; never executed: return; | 0 | ||||||||||||||||||||||||
603 | QTextLine line = block.layout()->lineForTextPosition(position - block.position()); | - | ||||||||||||||||||||||||
604 | ((!(line.isValid())) ? qt_assert("line.isValid()",__FILE__,689) : qt_noop()); | - | ||||||||||||||||||||||||
605 | QRectF lr = line.naturalTextRect().translated(br.topLeft()); | - | ||||||||||||||||||||||||
606 | - | |||||||||||||||||||||||||
607 | if (lr.bottom() >= visible.bottom()
| 0 | ||||||||||||||||||||||||
608 | - | |||||||||||||||||||||||||
609 | qreal height = visible.height(); | - | ||||||||||||||||||||||||
610 | if (center
| 0 | ||||||||||||||||||||||||
611 | height /= 2; never executed: height /= 2; | 0 | ||||||||||||||||||||||||
612 | - | |||||||||||||||||||||||||
613 | qreal h = center
| 0 | ||||||||||||||||||||||||
614 | - | |||||||||||||||||||||||||
615 | QTextBlock previousVisibleBlock = block; | - | ||||||||||||||||||||||||
616 | while (h < height
| 0 | ||||||||||||||||||||||||
617 | previousVisibleBlock = block; | - | ||||||||||||||||||||||||
618 | do { | - | ||||||||||||||||||||||||
619 | block = block.previous(); | - | ||||||||||||||||||||||||
620 | } never executed: while (!block.isVisible()end of block
| 0 | ||||||||||||||||||||||||
621 | h += q->blockBoundingRect(block).height(); | - | ||||||||||||||||||||||||
622 | } never executed: end of block | 0 | ||||||||||||||||||||||||
623 | - | |||||||||||||||||||||||||
624 | int l = 0; | - | ||||||||||||||||||||||||
625 | int lineCount = block.layout()->lineCount(); | - | ||||||||||||||||||||||||
626 | qreal voffset = verticalOffset(block.blockNumber(), 0); | - | ||||||||||||||||||||||||
627 | while (l < lineCount
| 0 | ||||||||||||||||||||||||
628 | QRectF lineRect = block.layout()->lineAt(l).naturalTextRect(); | - | ||||||||||||||||||||||||
629 | if (h - voffset - lineRect.top() <= height
| 0 | ||||||||||||||||||||||||
630 | break; never executed: break; | 0 | ||||||||||||||||||||||||
631 | ++l; | - | ||||||||||||||||||||||||
632 | } never executed: end of block | 0 | ||||||||||||||||||||||||
633 | - | |||||||||||||||||||||||||
634 | if (l >= lineCount
| 0 | ||||||||||||||||||||||||
635 | block = previousVisibleBlock; | - | ||||||||||||||||||||||||
636 | l = 0; | - | ||||||||||||||||||||||||
637 | } never executed: end of block | 0 | ||||||||||||||||||||||||
638 | setTopBlock(block.blockNumber(), l); | - | ||||||||||||||||||||||||
639 | } never executed: else if (lr.top() < visible.top()end of block
| 0 | ||||||||||||||||||||||||
640 | setTopBlock(block.blockNumber(), line.lineNumber()); | - | ||||||||||||||||||||||||
641 | } never executed: end of block | 0 | ||||||||||||||||||||||||
642 | - | |||||||||||||||||||||||||
643 | } never executed: end of block | 0 | ||||||||||||||||||||||||
644 | - | |||||||||||||||||||||||||
645 | - | |||||||||||||||||||||||||
646 | void QPlainTextEditPrivate::updateViewport() | - | ||||||||||||||||||||||||
647 | { | - | ||||||||||||||||||||||||
648 | QPlainTextEdit * const q = q_func(); | - | ||||||||||||||||||||||||
649 | viewport->update(); | - | ||||||||||||||||||||||||
650 | q->updateRequest(viewport->rect(), 0); | - | ||||||||||||||||||||||||
651 | } never executed: end of block | 0 | ||||||||||||||||||||||||
652 | - | |||||||||||||||||||||||||
653 | QPlainTextEditPrivate::QPlainTextEditPrivate() | - | ||||||||||||||||||||||||
654 | : control(0), | - | ||||||||||||||||||||||||
655 | tabChangesFocus(false), | - | ||||||||||||||||||||||||
656 | lineWrap(QPlainTextEdit::WidgetWidth), | - | ||||||||||||||||||||||||
657 | wordWrap(QTextOption::WrapAtWordBoundaryOrAnywhere), | - | ||||||||||||||||||||||||
658 | clickCausedFocus(0),topLine(0),topLineFracture(0), | - | ||||||||||||||||||||||||
659 | pageUpDownLastCursorYIsValid(false) | - | ||||||||||||||||||||||||
660 | { | - | ||||||||||||||||||||||||
661 | showCursorOnInitialShow = true; | - | ||||||||||||||||||||||||
662 | backgroundVisible = false; | - | ||||||||||||||||||||||||
663 | centerOnScroll = false; | - | ||||||||||||||||||||||||
664 | inDrag = false; | - | ||||||||||||||||||||||||
665 | } never executed: end of block | 0 | ||||||||||||||||||||||||
666 | - | |||||||||||||||||||||||||
667 | - | |||||||||||||||||||||||||
668 | void QPlainTextEditPrivate::init(const QString &txt) | - | ||||||||||||||||||||||||
669 | { | - | ||||||||||||||||||||||||
670 | QPlainTextEdit * const q = q_func(); | - | ||||||||||||||||||||||||
671 | control = new QPlainTextEditControl(q); | - | ||||||||||||||||||||||||
672 | - | |||||||||||||||||||||||||
673 | QTextDocument *doc = new QTextDocument(control); | - | ||||||||||||||||||||||||
674 | QAbstractTextDocumentLayout *layout = new QPlainTextDocumentLayout(doc); | - | ||||||||||||||||||||||||
675 | doc->setDocumentLayout(layout); | - | ||||||||||||||||||||||||
676 | control->setDocument(doc); | - | ||||||||||||||||||||||||
677 | - | |||||||||||||||||||||||||
678 | control->setPalette(q->palette()); | - | ||||||||||||||||||||||||
679 | - | |||||||||||||||||||||||||
680 | QObject::connect(vbar, qFlagLocation("2""actionTriggered(int)" "\0" __FILE__ ":" "765"), q, qFlagLocation("1""_q_verticalScrollbarActionTriggered(int)" "\0" __FILE__ ":" "765")); | - | ||||||||||||||||||||||||
681 | - | |||||||||||||||||||||||||
682 | QObject::connect(control, qFlagLocation("2""microFocusChanged()" "\0" __FILE__ ":" "767"), q, qFlagLocation("1""updateMicroFocus()" "\0" __FILE__ ":" "767")); | - | ||||||||||||||||||||||||
683 | QObject::connect(control, qFlagLocation("2""documentSizeChanged(QSizeF)" "\0" __FILE__ ":" "768"), q, qFlagLocation("1""_q_adjustScrollbars()" "\0" __FILE__ ":" "768")); | - | ||||||||||||||||||||||||
684 | QObject::connect(control, qFlagLocation("2""blockCountChanged(int)" "\0" __FILE__ ":" "769"), q, qFlagLocation("2""blockCountChanged(int)" "\0" __FILE__ ":" "769")); | - | ||||||||||||||||||||||||
685 | QObject::connect(control, qFlagLocation("2""updateRequest(QRectF)" "\0" __FILE__ ":" "770"), q, qFlagLocation("1""_q_repaintContents(QRectF)" "\0" __FILE__ ":" "770")); | - | ||||||||||||||||||||||||
686 | QObject::connect(control, qFlagLocation("2""modificationChanged(bool)" "\0" __FILE__ ":" "771"), q, qFlagLocation("2""modificationChanged(bool)" "\0" __FILE__ ":" "771")); | - | ||||||||||||||||||||||||
687 | - | |||||||||||||||||||||||||
688 | QObject::connect(control, qFlagLocation("2""textChanged()" "\0" __FILE__ ":" "773"), q, qFlagLocation("2""textChanged()" "\0" __FILE__ ":" "773")); | - | ||||||||||||||||||||||||
689 | QObject::connect(control, qFlagLocation("2""undoAvailable(bool)" "\0" __FILE__ ":" "774"), q, qFlagLocation("2""undoAvailable(bool)" "\0" __FILE__ ":" "774")); | - | ||||||||||||||||||||||||
690 | QObject::connect(control, qFlagLocation("2""redoAvailable(bool)" "\0" __FILE__ ":" "775"), q, qFlagLocation("2""redoAvailable(bool)" "\0" __FILE__ ":" "775")); | - | ||||||||||||||||||||||||
691 | QObject::connect(control, qFlagLocation("2""copyAvailable(bool)" "\0" __FILE__ ":" "776"), q, qFlagLocation("2""copyAvailable(bool)" "\0" __FILE__ ":" "776")); | - | ||||||||||||||||||||||||
692 | QObject::connect(control, qFlagLocation("2""selectionChanged()" "\0" __FILE__ ":" "777"), q, qFlagLocation("2""selectionChanged()" "\0" __FILE__ ":" "777")); | - | ||||||||||||||||||||||||
693 | QObject::connect(control, qFlagLocation("2""cursorPositionChanged()" "\0" __FILE__ ":" "778"), q, qFlagLocation("1""_q_cursorPositionChanged()" "\0" __FILE__ ":" "778")); | - | ||||||||||||||||||||||||
694 | - | |||||||||||||||||||||||||
695 | QObject::connect(control, qFlagLocation("2""textChanged()" "\0" __FILE__ ":" "780"), q, qFlagLocation("1""updateMicroFocus()" "\0" __FILE__ ":" "780")); | - | ||||||||||||||||||||||||
696 | - | |||||||||||||||||||||||||
697 | - | |||||||||||||||||||||||||
698 | - | |||||||||||||||||||||||||
699 | - | |||||||||||||||||||||||||
700 | doc->setTextWidth(-1); | - | ||||||||||||||||||||||||
701 | doc->documentLayout()->setPaintDevice(viewport); | - | ||||||||||||||||||||||||
702 | doc->setDefaultFont(q->font()); | - | ||||||||||||||||||||||||
703 | - | |||||||||||||||||||||||||
704 | - | |||||||||||||||||||||||||
705 | if (!txt.isEmpty()
| 0 | ||||||||||||||||||||||||
706 | control->setPlainText(txt); never executed: control->setPlainText(txt); | 0 | ||||||||||||||||||||||||
707 | - | |||||||||||||||||||||||||
708 | hbar->setSingleStep(20); | - | ||||||||||||||||||||||||
709 | vbar->setSingleStep(1); | - | ||||||||||||||||||||||||
710 | - | |||||||||||||||||||||||||
711 | viewport->setBackgroundRole(QPalette::Base); | - | ||||||||||||||||||||||||
712 | q->setAcceptDrops(true); | - | ||||||||||||||||||||||||
713 | q->setFocusPolicy(Qt::StrongFocus); | - | ||||||||||||||||||||||||
714 | q->setAttribute(Qt::WA_KeyCompression); | - | ||||||||||||||||||||||||
715 | q->setAttribute(Qt::WA_InputMethodEnabled); | - | ||||||||||||||||||||||||
716 | q->setInputMethodHints(Qt::ImhMultiLine); | - | ||||||||||||||||||||||||
717 | - | |||||||||||||||||||||||||
718 | - | |||||||||||||||||||||||||
719 | viewport->setCursor(Qt::IBeamCursor); | - | ||||||||||||||||||||||||
720 | - | |||||||||||||||||||||||||
721 | originalOffsetY = 0; | - | ||||||||||||||||||||||||
722 | - | |||||||||||||||||||||||||
723 | - | |||||||||||||||||||||||||
724 | - | |||||||||||||||||||||||||
725 | } never executed: end of block | 0 | ||||||||||||||||||||||||
726 | - | |||||||||||||||||||||||||
727 | void QPlainTextEditPrivate::_q_repaintContents(const QRectF &contentsRect) | - | ||||||||||||||||||||||||
728 | { | - | ||||||||||||||||||||||||
729 | QPlainTextEdit * const q = q_func(); | - | ||||||||||||||||||||||||
730 | if (!contentsRect.isValid()
| 0 | ||||||||||||||||||||||||
731 | updateViewport(); | - | ||||||||||||||||||||||||
732 | return; never executed: return; | 0 | ||||||||||||||||||||||||
733 | } | - | ||||||||||||||||||||||||
734 | const int xOffset = horizontalOffset(); | - | ||||||||||||||||||||||||
735 | const int yOffset = (int)verticalOffset(); | - | ||||||||||||||||||||||||
736 | const QRect visibleRect(xOffset, yOffset, viewport->width(), viewport->height()); | - | ||||||||||||||||||||||||
737 | - | |||||||||||||||||||||||||
738 | QRect r = contentsRect.adjusted(-1, -1, 1, 1).intersected(visibleRect).toAlignedRect(); | - | ||||||||||||||||||||||||
739 | if (r.isEmpty()
| 0 | ||||||||||||||||||||||||
740 | return; never executed: return; | 0 | ||||||||||||||||||||||||
741 | - | |||||||||||||||||||||||||
742 | r.translate(-xOffset, -yOffset); | - | ||||||||||||||||||||||||
743 | viewport->update(r); | - | ||||||||||||||||||||||||
744 | q->updateRequest(r, 0); | - | ||||||||||||||||||||||||
745 | } never executed: end of block | 0 | ||||||||||||||||||||||||
746 | - | |||||||||||||||||||||||||
747 | void QPlainTextEditPrivate::pageUpDown(QTextCursor::MoveOperation op, QTextCursor::MoveMode moveMode, bool moveCursor) | - | ||||||||||||||||||||||||
748 | { | - | ||||||||||||||||||||||||
749 | - | |||||||||||||||||||||||||
750 | QPlainTextEdit * const q = q_func(); | - | ||||||||||||||||||||||||
751 | - | |||||||||||||||||||||||||
752 | QTextCursor cursor = control->textCursor(); | - | ||||||||||||||||||||||||
753 | if (moveCursor
| 0 | ||||||||||||||||||||||||
754 | ensureCursorVisible(); | - | ||||||||||||||||||||||||
755 | if (!pageUpDownLastCursorYIsValid
| 0 | ||||||||||||||||||||||||
756 | pageUpDownLastCursorY = control->cursorRect(cursor).top() - verticalOffset(); never executed: pageUpDownLastCursorY = control->cursorRect(cursor).top() - verticalOffset(); | 0 | ||||||||||||||||||||||||
757 | } never executed: end of block | 0 | ||||||||||||||||||||||||
758 | - | |||||||||||||||||||||||||
759 | qreal lastY = pageUpDownLastCursorY; | - | ||||||||||||||||||||||||
760 | - | |||||||||||||||||||||||||
761 | - | |||||||||||||||||||||||||
762 | if (op == QTextCursor::Down
| 0 | ||||||||||||||||||||||||
763 | QRectF visible = QRectF(viewport->rect()).translated(-q->contentOffset()); | - | ||||||||||||||||||||||||
764 | QTextBlock firstVisibleBlock = q->firstVisibleBlock(); | - | ||||||||||||||||||||||||
765 | QTextBlock block = firstVisibleBlock; | - | ||||||||||||||||||||||||
766 | QRectF br = q->blockBoundingRect(block); | - | ||||||||||||||||||||||||
767 | qreal h = 0; | - | ||||||||||||||||||||||||
768 | int atEnd = false; | - | ||||||||||||||||||||||||
769 | while (h + br.height() <= visible.bottom()
| 0 | ||||||||||||||||||||||||
770 | if (!block.next().isValid()
| 0 | ||||||||||||||||||||||||
771 | atEnd = true; | - | ||||||||||||||||||||||||
772 | lastY = visible.bottom(); | - | ||||||||||||||||||||||||
773 | break; never executed: break; | 0 | ||||||||||||||||||||||||
774 | } | - | ||||||||||||||||||||||||
775 | h += br.height(); | - | ||||||||||||||||||||||||
776 | block = block.next(); | - | ||||||||||||||||||||||||
777 | br = q->blockBoundingRect(block); | - | ||||||||||||||||||||||||
778 | } never executed: end of block | 0 | ||||||||||||||||||||||||
779 | - | |||||||||||||||||||||||||
780 | if (!atEnd
| 0 | ||||||||||||||||||||||||
781 | int line = 0; | - | ||||||||||||||||||||||||
782 | qreal diff = visible.bottom() - h; | - | ||||||||||||||||||||||||
783 | int lineCount = block.layout()->lineCount(); | - | ||||||||||||||||||||||||
784 | while (line < lineCount - 1
| 0 | ||||||||||||||||||||||||
785 | if (block.layout()->lineAt(line).naturalTextRect().bottom() > diff
| 0 | ||||||||||||||||||||||||
786 | - | |||||||||||||||||||||||||
787 | break; never executed: break; | 0 | ||||||||||||||||||||||||
788 | } | - | ||||||||||||||||||||||||
789 | ++line; | - | ||||||||||||||||||||||||
790 | } never executed: end of block | 0 | ||||||||||||||||||||||||
791 | setTopBlock(block.blockNumber(), line); | - | ||||||||||||||||||||||||
792 | } never executed: end of block | 0 | ||||||||||||||||||||||||
793 | - | |||||||||||||||||||||||||
794 | if (moveCursor
| 0 | ||||||||||||||||||||||||
795 | - | |||||||||||||||||||||||||
796 | lastY += verticalOffset(); | - | ||||||||||||||||||||||||
797 | bool moved = false; | - | ||||||||||||||||||||||||
798 | do { | - | ||||||||||||||||||||||||
799 | moved = cursor.movePosition(op, moveMode); | - | ||||||||||||||||||||||||
800 | } never executed: while (movedend of block
| 0 | ||||||||||||||||||||||||
801 | } never executed: end of block | 0 | ||||||||||||||||||||||||
802 | - | |||||||||||||||||||||||||
803 | } never executed: else if (op == QTextCursor::Upend of block
| 0 | ||||||||||||||||||||||||
804 | - | |||||||||||||||||||||||||
805 | QRectF visible = QRectF(viewport->rect()).translated(-q->contentOffset()); | - | ||||||||||||||||||||||||
806 | visible.translate(0, -visible.height()); | - | ||||||||||||||||||||||||
807 | QTextBlock block = q->firstVisibleBlock(); | - | ||||||||||||||||||||||||
808 | qreal h = 0; | - | ||||||||||||||||||||||||
809 | while (h >= visible.top()
| 0 | ||||||||||||||||||||||||
810 | if (!block.previous().isValid()
| 0 | ||||||||||||||||||||||||
811 | if (control->topBlock == 0
| 0 | ||||||||||||||||||||||||
812 | lastY = 0; | - | ||||||||||||||||||||||||
813 | } never executed: end of block | 0 | ||||||||||||||||||||||||
814 | break; never executed: break; | 0 | ||||||||||||||||||||||||
815 | } | - | ||||||||||||||||||||||||
816 | block = block.previous(); | - | ||||||||||||||||||||||||
817 | QRectF br = q->blockBoundingRect(block); | - | ||||||||||||||||||||||||
818 | h -= br.height(); | - | ||||||||||||||||||||||||
819 | } never executed: end of block | 0 | ||||||||||||||||||||||||
820 | - | |||||||||||||||||||||||||
821 | int line = 0; | - | ||||||||||||||||||||||||
822 | if (block.isValid()
| 0 | ||||||||||||||||||||||||
823 | qreal diff = visible.top() - h; | - | ||||||||||||||||||||||||
824 | int lineCount = block.layout()->lineCount(); | - | ||||||||||||||||||||||||
825 | while (line < lineCount
| 0 | ||||||||||||||||||||||||
826 | if (block.layout()->lineAt(line).naturalTextRect().top() >= diff
| 0 | ||||||||||||||||||||||||
827 | break; never executed: break; | 0 | ||||||||||||||||||||||||
828 | ++line; | - | ||||||||||||||||||||||||
829 | } never executed: end of block | 0 | ||||||||||||||||||||||||
830 | if (line == lineCount
| 0 | ||||||||||||||||||||||||
831 | if (block.next().isValid()
| 0 | ||||||||||||||||||||||||
832 | block = block.next(); | - | ||||||||||||||||||||||||
833 | line = 0; | - | ||||||||||||||||||||||||
834 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
835 | --line; | - | ||||||||||||||||||||||||
836 | } never executed: end of block | 0 | ||||||||||||||||||||||||
837 | } | - | ||||||||||||||||||||||||
838 | } never executed: end of block | 0 | ||||||||||||||||||||||||
839 | setTopBlock(block.blockNumber(), line); | - | ||||||||||||||||||||||||
840 | - | |||||||||||||||||||||||||
841 | if (moveCursor
| 0 | ||||||||||||||||||||||||
842 | cursor.setVisualNavigation(true); | - | ||||||||||||||||||||||||
843 | - | |||||||||||||||||||||||||
844 | lastY += verticalOffset(); | - | ||||||||||||||||||||||||
845 | bool moved = false; | - | ||||||||||||||||||||||||
846 | do { | - | ||||||||||||||||||||||||
847 | moved = cursor.movePosition(op, moveMode); | - | ||||||||||||||||||||||||
848 | } never executed: while (movedend of block
| 0 | ||||||||||||||||||||||||
849 | } never executed: end of block | 0 | ||||||||||||||||||||||||
850 | } never executed: end of block | 0 | ||||||||||||||||||||||||
851 | - | |||||||||||||||||||||||||
852 | if (moveCursor
| 0 | ||||||||||||||||||||||||
853 | control->setTextCursor(cursor); | - | ||||||||||||||||||||||||
854 | pageUpDownLastCursorYIsValid = true; | - | ||||||||||||||||||||||||
855 | } never executed: end of block | 0 | ||||||||||||||||||||||||
856 | } never executed: end of block | 0 | ||||||||||||||||||||||||
857 | - | |||||||||||||||||||||||||
858 | - | |||||||||||||||||||||||||
859 | - | |||||||||||||||||||||||||
860 | void QPlainTextEditPrivate::_q_adjustScrollbars() | - | ||||||||||||||||||||||||
861 | { | - | ||||||||||||||||||||||||
862 | QPlainTextEdit * const q = q_func(); | - | ||||||||||||||||||||||||
863 | QTextDocument *doc = control->document(); | - | ||||||||||||||||||||||||
864 | QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(doc->documentLayout()); | - | ||||||||||||||||||||||||
865 | ((!(documentLayout)) ? qt_assert("documentLayout",__FILE__,950) : qt_noop()); | - | ||||||||||||||||||||||||
866 | bool documentSizeChangedBlocked = documentLayout->priv()->blockDocumentSizeChanged; | - | ||||||||||||||||||||||||
867 | documentLayout->priv()->blockDocumentSizeChanged = true; | - | ||||||||||||||||||||||||
868 | qreal margin = doc->documentMargin(); | - | ||||||||||||||||||||||||
869 | - | |||||||||||||||||||||||||
870 | int vmax = 0; | - | ||||||||||||||||||||||||
871 | - | |||||||||||||||||||||||||
872 | int vSliderLength = 0; | - | ||||||||||||||||||||||||
873 | if (!centerOnScroll
| 0 | ||||||||||||||||||||||||
874 | QTextBlock block = doc->lastBlock(); | - | ||||||||||||||||||||||||
875 | const qreal visible = viewport->rect().height() - margin - 1; | - | ||||||||||||||||||||||||
876 | qreal y = 0; | - | ||||||||||||||||||||||||
877 | int visibleFromBottom = 0; | - | ||||||||||||||||||||||||
878 | - | |||||||||||||||||||||||||
879 | while (block.isValid()
| 0 | ||||||||||||||||||||||||
880 | if (!block.isVisible()
| 0 | ||||||||||||||||||||||||
881 | block = block.previous(); | - | ||||||||||||||||||||||||
882 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
883 | } | - | ||||||||||||||||||||||||
884 | y += documentLayout->blockBoundingRect(block).height(); | - | ||||||||||||||||||||||||
885 | - | |||||||||||||||||||||||||
886 | QTextLayout *layout = block.layout(); | - | ||||||||||||||||||||||||
887 | int layoutLineCount = layout->lineCount(); | - | ||||||||||||||||||||||||
888 | if (y > visible
| 0 | ||||||||||||||||||||||||
889 | int lineNumber = 0; | - | ||||||||||||||||||||||||
890 | while (lineNumber < layoutLineCount
| 0 | ||||||||||||||||||||||||
891 | QTextLine line = layout->lineAt(lineNumber); | - | ||||||||||||||||||||||||
892 | const QRectF lr = line.naturalTextRect(); | - | ||||||||||||||||||||||||
893 | if (lr.top() >= y - visible
| 0 | ||||||||||||||||||||||||
894 | break; never executed: break; | 0 | ||||||||||||||||||||||||
895 | ++lineNumber; | - | ||||||||||||||||||||||||
896 | } never executed: end of block | 0 | ||||||||||||||||||||||||
897 | if (lineNumber < layoutLineCount
| 0 | ||||||||||||||||||||||||
898 | visibleFromBottom += (layoutLineCount - lineNumber); never executed: visibleFromBottom += (layoutLineCount - lineNumber); | 0 | ||||||||||||||||||||||||
899 | break; never executed: break; | 0 | ||||||||||||||||||||||||
900 | - | |||||||||||||||||||||||||
901 | } | - | ||||||||||||||||||||||||
902 | visibleFromBottom += layoutLineCount; | - | ||||||||||||||||||||||||
903 | block = block.previous(); | - | ||||||||||||||||||||||||
904 | } never executed: end of block | 0 | ||||||||||||||||||||||||
905 | vmax = qMax(0, doc->lineCount() - visibleFromBottom); | - | ||||||||||||||||||||||||
906 | vSliderLength = visibleFromBottom; | - | ||||||||||||||||||||||||
907 | - | |||||||||||||||||||||||||
908 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
909 | vmax = qMax(0, doc->lineCount() - 1); | - | ||||||||||||||||||||||||
910 | int lineSpacing = q->fontMetrics().lineSpacing(); | - | ||||||||||||||||||||||||
911 | vSliderLength = lineSpacing != 0
| 0 | ||||||||||||||||||||||||
912 | } never executed: end of block | 0 | ||||||||||||||||||||||||
913 | - | |||||||||||||||||||||||||
914 | - | |||||||||||||||||||||||||
915 | - | |||||||||||||||||||||||||
916 | QSizeF documentSize = documentLayout->documentSize(); | - | ||||||||||||||||||||||||
917 | vbar->setRange(0, qMax(0, vmax)); | - | ||||||||||||||||||||||||
918 | vbar->setPageStep(vSliderLength); | - | ||||||||||||||||||||||||
919 | int visualTopLine = vmax; | - | ||||||||||||||||||||||||
920 | QTextBlock firstVisibleBlock = q->firstVisibleBlock(); | - | ||||||||||||||||||||||||
921 | if (firstVisibleBlock.isValid()
| 0 | ||||||||||||||||||||||||
922 | visualTopLine = firstVisibleBlock.firstLineNumber() + topLine; never executed: visualTopLine = firstVisibleBlock.firstLineNumber() + topLine; | 0 | ||||||||||||||||||||||||
923 | - | |||||||||||||||||||||||||
924 | { | - | ||||||||||||||||||||||||
925 | const QSignalBlocker blocker(vbar); | - | ||||||||||||||||||||||||
926 | vbar->setValue(visualTopLine); | - | ||||||||||||||||||||||||
927 | } | - | ||||||||||||||||||||||||
928 | - | |||||||||||||||||||||||||
929 | hbar->setRange(0, (int)documentSize.width() - viewport->width()); | - | ||||||||||||||||||||||||
930 | hbar->setPageStep(viewport->width()); | - | ||||||||||||||||||||||||
931 | documentLayout->priv()->blockDocumentSizeChanged = documentSizeChangedBlocked; | - | ||||||||||||||||||||||||
932 | setTopLine(vbar->value()); | - | ||||||||||||||||||||||||
933 | } never executed: end of block | 0 | ||||||||||||||||||||||||
934 | - | |||||||||||||||||||||||||
935 | - | |||||||||||||||||||||||||
936 | - | |||||||||||||||||||||||||
937 | - | |||||||||||||||||||||||||
938 | void QPlainTextEditPrivate::ensureViewportLayouted() | - | ||||||||||||||||||||||||
939 | { | - | ||||||||||||||||||||||||
940 | } | - | ||||||||||||||||||||||||
941 | QPlainTextEdit::QPlainTextEdit(QWidget *parent) | - | ||||||||||||||||||||||||
942 | : QAbstractScrollArea(*new QPlainTextEditPrivate, parent) | - | ||||||||||||||||||||||||
943 | { | - | ||||||||||||||||||||||||
944 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
945 | d->init(); | - | ||||||||||||||||||||||||
946 | } never executed: end of block | 0 | ||||||||||||||||||||||||
947 | - | |||||||||||||||||||||||||
948 | - | |||||||||||||||||||||||||
949 | - | |||||||||||||||||||||||||
950 | - | |||||||||||||||||||||||||
951 | QPlainTextEdit::QPlainTextEdit(QPlainTextEditPrivate &dd, QWidget *parent) | - | ||||||||||||||||||||||||
952 | : QAbstractScrollArea(dd, parent) | - | ||||||||||||||||||||||||
953 | { | - | ||||||||||||||||||||||||
954 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
955 | d->init(); | - | ||||||||||||||||||||||||
956 | } never executed: end of block | 0 | ||||||||||||||||||||||||
957 | - | |||||||||||||||||||||||||
958 | - | |||||||||||||||||||||||||
959 | - | |||||||||||||||||||||||||
960 | - | |||||||||||||||||||||||||
961 | - | |||||||||||||||||||||||||
962 | QPlainTextEdit::QPlainTextEdit(const QString &text, QWidget *parent) | - | ||||||||||||||||||||||||
963 | : QAbstractScrollArea(*new QPlainTextEditPrivate, parent) | - | ||||||||||||||||||||||||
964 | { | - | ||||||||||||||||||||||||
965 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
966 | d->init(text); | - | ||||||||||||||||||||||||
967 | } never executed: end of block | 0 | ||||||||||||||||||||||||
968 | - | |||||||||||||||||||||||||
969 | - | |||||||||||||||||||||||||
970 | - | |||||||||||||||||||||||||
971 | - | |||||||||||||||||||||||||
972 | - | |||||||||||||||||||||||||
973 | QPlainTextEdit::~QPlainTextEdit() | - | ||||||||||||||||||||||||
974 | { | - | ||||||||||||||||||||||||
975 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
976 | if (d->documentLayoutPtr
| 0 | ||||||||||||||||||||||||
977 | if (d->documentLayoutPtr->priv()->mainViewPrivate == d
| 0 | ||||||||||||||||||||||||
978 | d->documentLayoutPtr->priv()->mainViewPrivate = 0; never executed: d->documentLayoutPtr->priv()->mainViewPrivate = 0; | 0 | ||||||||||||||||||||||||
979 | } never executed: end of block | 0 | ||||||||||||||||||||||||
980 | } never executed: end of block | 0 | ||||||||||||||||||||||||
981 | void QPlainTextEdit::setDocument(QTextDocument *document) | - | ||||||||||||||||||||||||
982 | { | - | ||||||||||||||||||||||||
983 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
984 | QPlainTextDocumentLayout *documentLayout = 0; | - | ||||||||||||||||||||||||
985 | - | |||||||||||||||||||||||||
986 | if (!document
| 0 | ||||||||||||||||||||||||
987 | document = new QTextDocument(d->control); | - | ||||||||||||||||||||||||
988 | documentLayout = new QPlainTextDocumentLayout(document); | - | ||||||||||||||||||||||||
989 | document->setDocumentLayout(documentLayout); | - | ||||||||||||||||||||||||
990 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
991 | documentLayout = qobject_cast<QPlainTextDocumentLayout*>(document->documentLayout()); | - | ||||||||||||||||||||||||
992 | if (!documentLayout
| 0 | ||||||||||||||||||||||||
993 | QMessageLogger(__FILE__, 1295, __PRETTY_FUNCTION__).warning("QPlainTextEdit::setDocument: Document set does not support QPlainTextDocumentLayout"); | - | ||||||||||||||||||||||||
994 | return; never executed: return; | 0 | ||||||||||||||||||||||||
995 | } | - | ||||||||||||||||||||||||
996 | } never executed: end of block | 0 | ||||||||||||||||||||||||
997 | d->control->setDocument(document); | - | ||||||||||||||||||||||||
998 | if (!documentLayout->priv()->mainViewPrivate
| 0 | ||||||||||||||||||||||||
999 | documentLayout->priv()->mainViewPrivate = d; never executed: documentLayout->priv()->mainViewPrivate = d; | 0 | ||||||||||||||||||||||||
1000 | d->documentLayoutPtr = documentLayout; | - | ||||||||||||||||||||||||
1001 | d->updateDefaultTextOption(); | - | ||||||||||||||||||||||||
1002 | d->relayoutDocument(); | - | ||||||||||||||||||||||||
1003 | d->_q_adjustScrollbars(); | - | ||||||||||||||||||||||||
1004 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1005 | - | |||||||||||||||||||||||||
1006 | - | |||||||||||||||||||||||||
1007 | - | |||||||||||||||||||||||||
1008 | - | |||||||||||||||||||||||||
1009 | - | |||||||||||||||||||||||||
1010 | - | |||||||||||||||||||||||||
1011 | QTextDocument *QPlainTextEdit::document() const | - | ||||||||||||||||||||||||
1012 | { | - | ||||||||||||||||||||||||
1013 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1014 | return never executed: d->control->document();return d->control->document(); never executed: return d->control->document(); | 0 | ||||||||||||||||||||||||
1015 | } | - | ||||||||||||||||||||||||
1016 | void QPlainTextEdit::setPlaceholderText(const QString &placeholderText) | - | ||||||||||||||||||||||||
1017 | { | - | ||||||||||||||||||||||||
1018 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1019 | if (d->placeholderText != placeholderText
| 0 | ||||||||||||||||||||||||
1020 | d->placeholderText = placeholderText; | - | ||||||||||||||||||||||||
1021 | if (d->control->document()->isEmpty()
| 0 | ||||||||||||||||||||||||
1022 | d->viewport->update(); never executed: d->viewport->update(); | 0 | ||||||||||||||||||||||||
1023 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1024 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1025 | - | |||||||||||||||||||||||||
1026 | QString QPlainTextEdit::placeholderText() const | - | ||||||||||||||||||||||||
1027 | { | - | ||||||||||||||||||||||||
1028 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1029 | return never executed: d->placeholderText;return d->placeholderText; never executed: return d->placeholderText; | 0 | ||||||||||||||||||||||||
1030 | } | - | ||||||||||||||||||||||||
1031 | - | |||||||||||||||||||||||||
1032 | - | |||||||||||||||||||||||||
1033 | - | |||||||||||||||||||||||||
1034 | - | |||||||||||||||||||||||||
1035 | void QPlainTextEdit::setTextCursor(const QTextCursor &cursor) | - | ||||||||||||||||||||||||
1036 | { | - | ||||||||||||||||||||||||
1037 | doSetTextCursor(cursor); | - | ||||||||||||||||||||||||
1038 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1039 | - | |||||||||||||||||||||||||
1040 | - | |||||||||||||||||||||||||
1041 | - | |||||||||||||||||||||||||
1042 | - | |||||||||||||||||||||||||
1043 | - | |||||||||||||||||||||||||
1044 | - | |||||||||||||||||||||||||
1045 | - | |||||||||||||||||||||||||
1046 | void QPlainTextEdit::doSetTextCursor(const QTextCursor &cursor) | - | ||||||||||||||||||||||||
1047 | { | - | ||||||||||||||||||||||||
1048 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1049 | d->control->setTextCursor(cursor); | - | ||||||||||||||||||||||||
1050 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1051 | - | |||||||||||||||||||||||||
1052 | - | |||||||||||||||||||||||||
1053 | - | |||||||||||||||||||||||||
1054 | - | |||||||||||||||||||||||||
1055 | - | |||||||||||||||||||||||||
1056 | - | |||||||||||||||||||||||||
1057 | QTextCursor QPlainTextEdit::textCursor() const | - | ||||||||||||||||||||||||
1058 | { | - | ||||||||||||||||||||||||
1059 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1060 | return never executed: d->control->textCursor();return d->control->textCursor(); never executed: return d->control->textCursor(); | 0 | ||||||||||||||||||||||||
1061 | } | - | ||||||||||||||||||||||||
1062 | - | |||||||||||||||||||||||||
1063 | - | |||||||||||||||||||||||||
1064 | - | |||||||||||||||||||||||||
1065 | - | |||||||||||||||||||||||||
1066 | - | |||||||||||||||||||||||||
1067 | - | |||||||||||||||||||||||||
1068 | - | |||||||||||||||||||||||||
1069 | QString QPlainTextEdit::anchorAt(const QPoint &pos) const | - | ||||||||||||||||||||||||
1070 | { | - | ||||||||||||||||||||||||
1071 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1072 | int cursorPos = d->control->hitTest(pos + QPointF(d->horizontalOffset(), | - | ||||||||||||||||||||||||
1073 | d->verticalOffset()), | - | ||||||||||||||||||||||||
1074 | Qt::ExactHit); | - | ||||||||||||||||||||||||
1075 | if (cursorPos < 0
| 0 | ||||||||||||||||||||||||
1076 | return never executed: QString();return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||
1077 | - | |||||||||||||||||||||||||
1078 | QTextDocumentPrivate *pieceTable = document()->docHandle(); | - | ||||||||||||||||||||||||
1079 | QTextDocumentPrivate::FragmentIterator it = pieceTable->find(cursorPos); | - | ||||||||||||||||||||||||
1080 | QTextCharFormat fmt = pieceTable->formatCollection()->charFormat(it->format); | - | ||||||||||||||||||||||||
1081 | return never executed: fmt.anchorHref();return fmt.anchorHref(); never executed: return fmt.anchorHref(); | 0 | ||||||||||||||||||||||||
1082 | } | - | ||||||||||||||||||||||||
1083 | void QPlainTextEdit::undo() | - | ||||||||||||||||||||||||
1084 | { | - | ||||||||||||||||||||||||
1085 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1086 | d->control->undo(); | - | ||||||||||||||||||||||||
1087 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1088 | - | |||||||||||||||||||||||||
1089 | void QPlainTextEdit::redo() | - | ||||||||||||||||||||||||
1090 | { | - | ||||||||||||||||||||||||
1091 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1092 | d->control->redo(); | - | ||||||||||||||||||||||||
1093 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1094 | void QPlainTextEdit::cut() | - | ||||||||||||||||||||||||
1095 | { | - | ||||||||||||||||||||||||
1096 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1097 | d->control->cut(); | - | ||||||||||||||||||||||||
1098 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1099 | - | |||||||||||||||||||||||||
1100 | - | |||||||||||||||||||||||||
1101 | - | |||||||||||||||||||||||||
1102 | - | |||||||||||||||||||||||||
1103 | - | |||||||||||||||||||||||||
1104 | - | |||||||||||||||||||||||||
1105 | - | |||||||||||||||||||||||||
1106 | void QPlainTextEdit::copy() | - | ||||||||||||||||||||||||
1107 | { | - | ||||||||||||||||||||||||
1108 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1109 | d->control->copy(); | - | ||||||||||||||||||||||||
1110 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1111 | void QPlainTextEdit::paste() | - | ||||||||||||||||||||||||
1112 | { | - | ||||||||||||||||||||||||
1113 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1114 | d->control->paste(); | - | ||||||||||||||||||||||||
1115 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1116 | void QPlainTextEdit::clear() | - | ||||||||||||||||||||||||
1117 | { | - | ||||||||||||||||||||||||
1118 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1119 | - | |||||||||||||||||||||||||
1120 | d->control->topBlock = d->topLine = d->topLineFracture = 0; | - | ||||||||||||||||||||||||
1121 | d->control->clear(); | - | ||||||||||||||||||||||||
1122 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1123 | - | |||||||||||||||||||||||||
1124 | - | |||||||||||||||||||||||||
1125 | - | |||||||||||||||||||||||||
1126 | - | |||||||||||||||||||||||||
1127 | - | |||||||||||||||||||||||||
1128 | - | |||||||||||||||||||||||||
1129 | - | |||||||||||||||||||||||||
1130 | void QPlainTextEdit::selectAll() | - | ||||||||||||||||||||||||
1131 | { | - | ||||||||||||||||||||||||
1132 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1133 | d->control->selectAll(); | - | ||||||||||||||||||||||||
1134 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1135 | - | |||||||||||||||||||||||||
1136 | - | |||||||||||||||||||||||||
1137 | - | |||||||||||||||||||||||||
1138 | bool QPlainTextEdit::event(QEvent *e) | - | ||||||||||||||||||||||||
1139 | { | - | ||||||||||||||||||||||||
1140 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1141 | - | |||||||||||||||||||||||||
1142 | - | |||||||||||||||||||||||||
1143 | if (e->type() == QEvent::ContextMenu
| 0 | ||||||||||||||||||||||||
1144 | && static_cast<
| 0 | ||||||||||||||||||||||||
1145 | ensureCursorVisible(); | - | ||||||||||||||||||||||||
1146 | const QPoint cursorPos = cursorRect().center(); | - | ||||||||||||||||||||||||
1147 | QContextMenuEvent ce(QContextMenuEvent::Keyboard, cursorPos, d->viewport->mapToGlobal(cursorPos)); | - | ||||||||||||||||||||||||
1148 | ce.setAccepted(e->isAccepted()); | - | ||||||||||||||||||||||||
1149 | const bool result = QAbstractScrollArea::event(&ce); | - | ||||||||||||||||||||||||
1150 | e->setAccepted(ce.isAccepted()); | - | ||||||||||||||||||||||||
1151 | return never executed: result;return result; never executed: return result; | 0 | ||||||||||||||||||||||||
1152 | } | - | ||||||||||||||||||||||||
1153 | - | |||||||||||||||||||||||||
1154 | if (e->type() == QEvent::ShortcutOverride
| 0 | ||||||||||||||||||||||||
1155 | || e->type() == QEvent::ToolTip
| 0 | ||||||||||||||||||||||||
1156 | d->sendControlEvent(e); | - | ||||||||||||||||||||||||
1157 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1158 | - | |||||||||||||||||||||||||
1159 | - | |||||||||||||||||||||||||
1160 | - | |||||||||||||||||||||||||
1161 | - | |||||||||||||||||||||||||
1162 | - | |||||||||||||||||||||||||
1163 | - | |||||||||||||||||||||||||
1164 | - | |||||||||||||||||||||||||
1165 | else if (e->type() == QEvent::Gesture
| 0 | ||||||||||||||||||||||||
1166 | QGestureEvent *ge = static_cast<QGestureEvent *>(e); | - | ||||||||||||||||||||||||
1167 | QPanGesture *g = static_cast<QPanGesture *>(ge->gesture(Qt::PanGesture)); | - | ||||||||||||||||||||||||
1168 | if (g
| 0 | ||||||||||||||||||||||||
1169 | QScrollBar *hBar = horizontalScrollBar(); | - | ||||||||||||||||||||||||
1170 | QScrollBar *vBar = verticalScrollBar(); | - | ||||||||||||||||||||||||
1171 | if (g->state() == Qt::GestureStarted
| 0 | ||||||||||||||||||||||||
1172 | d->originalOffsetY = vBar->value(); never executed: d->originalOffsetY = vBar->value(); | 0 | ||||||||||||||||||||||||
1173 | QPointF offset = g->offset(); | - | ||||||||||||||||||||||||
1174 | if (!offset.isNull()
| 0 | ||||||||||||||||||||||||
1175 | if (QApplication::isRightToLeft()
| 0 | ||||||||||||||||||||||||
1176 | offset.rx() *= -1; never executed: offset.rx() *= -1; | 0 | ||||||||||||||||||||||||
1177 | - | |||||||||||||||||||||||||
1178 | QFontMetrics fm(document()->defaultFont()); | - | ||||||||||||||||||||||||
1179 | int lineHeight = fm.height(); | - | ||||||||||||||||||||||||
1180 | int newX = hBar->value() - g->delta().x(); | - | ||||||||||||||||||||||||
1181 | int newY = d->originalOffsetY - offset.y()/lineHeight; | - | ||||||||||||||||||||||||
1182 | hBar->setValue(newX); | - | ||||||||||||||||||||||||
1183 | vBar->setValue(newY); | - | ||||||||||||||||||||||||
1184 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1185 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1186 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||||||||
1187 | } | - | ||||||||||||||||||||||||
1188 | - | |||||||||||||||||||||||||
1189 | return never executed: QAbstractScrollArea::event(e);return QAbstractScrollArea::event(e); never executed: return QAbstractScrollArea::event(e); | 0 | ||||||||||||||||||||||||
1190 | } | - | ||||||||||||||||||||||||
1191 | - | |||||||||||||||||||||||||
1192 | - | |||||||||||||||||||||||||
1193 | - | |||||||||||||||||||||||||
1194 | - | |||||||||||||||||||||||||
1195 | void QPlainTextEdit::timerEvent(QTimerEvent *e) | - | ||||||||||||||||||||||||
1196 | { | - | ||||||||||||||||||||||||
1197 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1198 | if (e->timerId() == d->autoScrollTimer.timerId()
| 0 | ||||||||||||||||||||||||
1199 | QRect visible = d->viewport->rect(); | - | ||||||||||||||||||||||||
1200 | QPoint pos; | - | ||||||||||||||||||||||||
1201 | if (d->inDrag
| 0 | ||||||||||||||||||||||||
1202 | pos = d->autoScrollDragPos; | - | ||||||||||||||||||||||||
1203 | visible.adjust(qMin(visible.width()/3,20), qMin(visible.height()/3,20), | - | ||||||||||||||||||||||||
1204 | -qMin(visible.width()/3,20), -qMin(visible.height()/3,20)); | - | ||||||||||||||||||||||||
1205 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1206 | const QPoint globalPos = QCursor::pos(); | - | ||||||||||||||||||||||||
1207 | pos = d->viewport->mapFromGlobal(globalPos); | - | ||||||||||||||||||||||||
1208 | QMouseEvent ev(QEvent::MouseMove, pos, d->viewport->mapTo(d->viewport->topLevelWidget(), pos), globalPos, | - | ||||||||||||||||||||||||
1209 | Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); | - | ||||||||||||||||||||||||
1210 | mouseMoveEvent(&ev); | - | ||||||||||||||||||||||||
1211 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1212 | int deltaY = qMax(pos.y() - visible.top(), visible.bottom() - pos.y()) - visible.height(); | - | ||||||||||||||||||||||||
1213 | int deltaX = qMax(pos.x() - visible.left(), visible.right() - pos.x()) - visible.width(); | - | ||||||||||||||||||||||||
1214 | int delta = qMax(deltaX, deltaY); | - | ||||||||||||||||||||||||
1215 | if (delta >= 0
| 0 | ||||||||||||||||||||||||
1216 | if (delta < 7
| 0 | ||||||||||||||||||||||||
1217 | delta = 7; never executed: delta = 7; | 0 | ||||||||||||||||||||||||
1218 | int timeout = 4900 / (delta * delta); | - | ||||||||||||||||||||||||
1219 | d->autoScrollTimer.start(timeout, this); | - | ||||||||||||||||||||||||
1220 | - | |||||||||||||||||||||||||
1221 | if (deltaY > 0
| 0 | ||||||||||||||||||||||||
1222 | d->vbar->triggerAction(pos.y() < visible.center().y() ? never executed: d->vbar->triggerAction(pos.y() < visible.center().y() ? QAbstractSlider::SliderSingleStepSub : QAbstractSlider::SliderSingleStepAdd); | 0 | ||||||||||||||||||||||||
1223 | QAbstractSlider::SliderSingleStepSub never executed: d->vbar->triggerAction(pos.y() < visible.center().y() ? QAbstractSlider::SliderSingleStepSub : QAbstractSlider::SliderSingleStepAdd); | 0 | ||||||||||||||||||||||||
1224 | : QAbstractSlider::SliderSingleStepAdd); never executed: d->vbar->triggerAction(pos.y() < visible.center().y() ? QAbstractSlider::SliderSingleStepSub : QAbstractSlider::SliderSingleStepAdd); | 0 | ||||||||||||||||||||||||
1225 | if (deltaX > 0
| 0 | ||||||||||||||||||||||||
1226 | d->hbar->triggerAction(pos.x() < visible.center().x() ? never executed: d->hbar->triggerAction(pos.x() < visible.center().x() ? QAbstractSlider::SliderSingleStepSub : QAbstractSlider::SliderSingleStepAdd); | 0 | ||||||||||||||||||||||||
1227 | QAbstractSlider::SliderSingleStepSub never executed: d->hbar->triggerAction(pos.x() < visible.center().x() ? QAbstractSlider::SliderSingleStepSub : QAbstractSlider::SliderSingleStepAdd); | 0 | ||||||||||||||||||||||||
1228 | : QAbstractSlider::SliderSingleStepAdd); never executed: d->hbar->triggerAction(pos.x() < visible.center().x() ? QAbstractSlider::SliderSingleStepSub : QAbstractSlider::SliderSingleStepAdd); | 0 | ||||||||||||||||||||||||
1229 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1230 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1231 | - | |||||||||||||||||||||||||
1232 | - | |||||||||||||||||||||||||
1233 | - | |||||||||||||||||||||||||
1234 | - | |||||||||||||||||||||||||
1235 | - | |||||||||||||||||||||||||
1236 | - | |||||||||||||||||||||||||
1237 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1238 | void QPlainTextEdit::setPlainText(const QString &text) | - | ||||||||||||||||||||||||
1239 | { | - | ||||||||||||||||||||||||
1240 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1241 | d->control->setPlainText(text); | - | ||||||||||||||||||||||||
1242 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1243 | void QPlainTextEdit::keyPressEvent(QKeyEvent *e) | - | ||||||||||||||||||||||||
1244 | { | - | ||||||||||||||||||||||||
1245 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1246 | Qt::TextInteractionFlags tif = d->control->textInteractionFlags(); | - | ||||||||||||||||||||||||
1247 | - | |||||||||||||||||||||||||
1248 | if (tif & Qt::TextSelectableByKeyboard
| 0 | ||||||||||||||||||||||||
1249 | if (e == QKeySequence::SelectPreviousPage
| 0 | ||||||||||||||||||||||||
1250 | e->accept(); | - | ||||||||||||||||||||||||
1251 | d->pageUpDown(QTextCursor::Up, QTextCursor::KeepAnchor); | - | ||||||||||||||||||||||||
1252 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1253 | } else if (e ==QKeySequence::SelectNextPage
| 0 | ||||||||||||||||||||||||
1254 | e->accept(); | - | ||||||||||||||||||||||||
1255 | d->pageUpDown(QTextCursor::Down, QTextCursor::KeepAnchor); | - | ||||||||||||||||||||||||
1256 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1257 | } | - | ||||||||||||||||||||||||
1258 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1259 | if (tif & (Qt::TextSelectableByKeyboard | Qt::TextEditable)
| 0 | ||||||||||||||||||||||||
1260 | if (e == QKeySequence::MoveToPreviousPage
| 0 | ||||||||||||||||||||||||
1261 | e->accept(); | - | ||||||||||||||||||||||||
1262 | d->pageUpDown(QTextCursor::Up, QTextCursor::MoveAnchor); | - | ||||||||||||||||||||||||
1263 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1264 | } else if (e == QKeySequence::MoveToNextPage
| 0 | ||||||||||||||||||||||||
1265 | e->accept(); | - | ||||||||||||||||||||||||
1266 | d->pageUpDown(QTextCursor::Down, QTextCursor::MoveAnchor); | - | ||||||||||||||||||||||||
1267 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1268 | } | - | ||||||||||||||||||||||||
1269 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1270 | - | |||||||||||||||||||||||||
1271 | if (!(tif & Qt::TextEditable)
| 0 | ||||||||||||||||||||||||
1272 | switch (e->key()) { | - | ||||||||||||||||||||||||
1273 | case never executed: Qt::Key_Space:case Qt::Key_Space: never executed: case Qt::Key_Space: | 0 | ||||||||||||||||||||||||
1274 | e->accept(); | - | ||||||||||||||||||||||||
1275 | if (e->modifiers() & Qt::ShiftModifier
| 0 | ||||||||||||||||||||||||
1276 | d->vbar->triggerAction(QAbstractSlider::SliderPageStepSub); never executed: d->vbar->triggerAction(QAbstractSlider::SliderPageStepSub); | 0 | ||||||||||||||||||||||||
1277 | else | - | ||||||||||||||||||||||||
1278 | d->vbar->triggerAction(QAbstractSlider::SliderPageStepAdd); never executed: d->vbar->triggerAction(QAbstractSlider::SliderPageStepAdd); | 0 | ||||||||||||||||||||||||
1279 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1280 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||
1281 | d->sendControlEvent(e); | - | ||||||||||||||||||||||||
1282 | if (!e->isAccepted()
| 0 | ||||||||||||||||||||||||
1283 | if (e->key() == Qt::Key_Home
| 0 | ||||||||||||||||||||||||
1284 | d->vbar->triggerAction(QAbstractSlider::SliderToMinimum); | - | ||||||||||||||||||||||||
1285 | e->accept(); | - | ||||||||||||||||||||||||
1286 | } never executed: else if (e->key() == Qt::Key_Endend of block
| 0 | ||||||||||||||||||||||||
1287 | d->vbar->triggerAction(QAbstractSlider::SliderToMaximum); | - | ||||||||||||||||||||||||
1288 | e->accept(); | - | ||||||||||||||||||||||||
1289 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1290 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1291 | if (!e->isAccepted()
| 0 | ||||||||||||||||||||||||
1292 | QAbstractScrollArea::keyPressEvent(e); | - | ||||||||||||||||||||||||
1293 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1294 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1295 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1296 | } | - | ||||||||||||||||||||||||
1297 | - | |||||||||||||||||||||||||
1298 | - | |||||||||||||||||||||||||
1299 | d->sendControlEvent(e); | - | ||||||||||||||||||||||||
1300 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1301 | - | |||||||||||||||||||||||||
1302 | - | |||||||||||||||||||||||||
1303 | - | |||||||||||||||||||||||||
1304 | void QPlainTextEdit::keyReleaseEvent(QKeyEvent *e) | - | ||||||||||||||||||||||||
1305 | { | - | ||||||||||||||||||||||||
1306 | QWidget::keyReleaseEvent(e); | - | ||||||||||||||||||||||||
1307 | - | |||||||||||||||||||||||||
1308 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1309 | QVariant QPlainTextEdit::loadResource(int type, const QUrl &name) | - | ||||||||||||||||||||||||
1310 | { | - | ||||||||||||||||||||||||
1311 | (void)type;; | - | ||||||||||||||||||||||||
1312 | (void)name;; | - | ||||||||||||||||||||||||
1313 | return never executed: QVariant();return QVariant(); never executed: return QVariant(); | 0 | ||||||||||||||||||||||||
1314 | } | - | ||||||||||||||||||||||||
1315 | - | |||||||||||||||||||||||||
1316 | - | |||||||||||||||||||||||||
1317 | - | |||||||||||||||||||||||||
1318 | void QPlainTextEdit::resizeEvent(QResizeEvent *e) | - | ||||||||||||||||||||||||
1319 | { | - | ||||||||||||||||||||||||
1320 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1321 | if (e->oldSize().width() != e->size().width()
| 0 | ||||||||||||||||||||||||
1322 | d->relayoutDocument(); never executed: d->relayoutDocument(); | 0 | ||||||||||||||||||||||||
1323 | d->_q_adjustScrollbars(); | - | ||||||||||||||||||||||||
1324 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1325 | - | |||||||||||||||||||||||||
1326 | void QPlainTextEditPrivate::relayoutDocument() | - | ||||||||||||||||||||||||
1327 | { | - | ||||||||||||||||||||||||
1328 | QTextDocument *doc = control->document(); | - | ||||||||||||||||||||||||
1329 | QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(doc->documentLayout()); | - | ||||||||||||||||||||||||
1330 | ((!(documentLayout)) ? qt_assert("documentLayout",__FILE__,1841) : qt_noop()); | - | ||||||||||||||||||||||||
1331 | documentLayoutPtr = documentLayout; | - | ||||||||||||||||||||||||
1332 | - | |||||||||||||||||||||||||
1333 | int width = viewport->width(); | - | ||||||||||||||||||||||||
1334 | - | |||||||||||||||||||||||||
1335 | if (documentLayout->priv()->mainViewPrivate == 0
| 0 | ||||||||||||||||||||||||
1336 | || documentLayout->priv()->mainViewPrivate == this
| 0 | ||||||||||||||||||||||||
1337 | || width > documentLayout->textWidth()
| 0 | ||||||||||||||||||||||||
1338 | documentLayout->priv()->mainViewPrivate = this; | - | ||||||||||||||||||||||||
1339 | documentLayout->setTextWidth(width); | - | ||||||||||||||||||||||||
1340 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1341 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1342 | - | |||||||||||||||||||||||||
1343 | static void fillBackground(QPainter *p, const QRectF &rect, QBrush brush, QRectF gradientRect = QRectF()) | - | ||||||||||||||||||||||||
1344 | { | - | ||||||||||||||||||||||||
1345 | p->save(); | - | ||||||||||||||||||||||||
1346 | if (brush.style() >= Qt::LinearGradientPattern
| 0 | ||||||||||||||||||||||||
1347 | if (!gradientRect.isNull()
| 0 | ||||||||||||||||||||||||
1348 | QTransform m = QTransform::fromTranslate(gradientRect.left(), gradientRect.top()); | - | ||||||||||||||||||||||||
1349 | m.scale(gradientRect.width(), gradientRect.height()); | - | ||||||||||||||||||||||||
1350 | brush.setTransform(m); | - | ||||||||||||||||||||||||
1351 | const_cast<QGradient *>(brush.gradient())->setCoordinateMode(QGradient::LogicalMode); | - | ||||||||||||||||||||||||
1352 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1353 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1354 | p->setBrushOrigin(rect.topLeft()); | - | ||||||||||||||||||||||||
1355 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1356 | p->fillRect(rect, brush); | - | ||||||||||||||||||||||||
1357 | p->restore(); | - | ||||||||||||||||||||||||
1358 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1359 | - | |||||||||||||||||||||||||
1360 | - | |||||||||||||||||||||||||
1361 | - | |||||||||||||||||||||||||
1362 | - | |||||||||||||||||||||||||
1363 | - | |||||||||||||||||||||||||
1364 | void QPlainTextEdit::paintEvent(QPaintEvent *e) | - | ||||||||||||||||||||||||
1365 | { | - | ||||||||||||||||||||||||
1366 | QPainter painter(viewport()); | - | ||||||||||||||||||||||||
1367 | ((!(qobject_cast<QPlainTextDocumentLayout*>(document()->documentLayout()))) ? qt_assert("qobject_cast<QPlainTextDocumentLayout*>(document()->documentLayout())",__FILE__,1878) : qt_noop()); | - | ||||||||||||||||||||||||
1368 | - | |||||||||||||||||||||||||
1369 | QPointF offset(contentOffset()); | - | ||||||||||||||||||||||||
1370 | - | |||||||||||||||||||||||||
1371 | QRect er = e->rect(); | - | ||||||||||||||||||||||||
1372 | QRect viewportRect = viewport()->rect(); | - | ||||||||||||||||||||||||
1373 | - | |||||||||||||||||||||||||
1374 | bool editable = !isReadOnly(); | - | ||||||||||||||||||||||||
1375 | - | |||||||||||||||||||||||||
1376 | QTextBlock block = firstVisibleBlock(); | - | ||||||||||||||||||||||||
1377 | qreal maximumWidth = document()->documentLayout()->documentSize().width(); | - | ||||||||||||||||||||||||
1378 | - | |||||||||||||||||||||||||
1379 | - | |||||||||||||||||||||||||
1380 | painter.setBrushOrigin(offset); | - | ||||||||||||||||||||||||
1381 | - | |||||||||||||||||||||||||
1382 | - | |||||||||||||||||||||||||
1383 | int maxX = offset.x() + qMax((qreal)viewportRect.width(), maximumWidth) | - | ||||||||||||||||||||||||
1384 | - document()->documentMargin(); | - | ||||||||||||||||||||||||
1385 | er.setRight(qMin(er.right(), maxX)); | - | ||||||||||||||||||||||||
1386 | painter.setClipRect(er); | - | ||||||||||||||||||||||||
1387 | - | |||||||||||||||||||||||||
1388 | - | |||||||||||||||||||||||||
1389 | QAbstractTextDocumentLayout::PaintContext context = getPaintContext(); | - | ||||||||||||||||||||||||
1390 | - | |||||||||||||||||||||||||
1391 | while (block.isValid()
| 0 | ||||||||||||||||||||||||
1392 | - | |||||||||||||||||||||||||
1393 | QRectF r = blockBoundingRect(block).translated(offset); | - | ||||||||||||||||||||||||
1394 | QTextLayout *layout = block.layout(); | - | ||||||||||||||||||||||||
1395 | - | |||||||||||||||||||||||||
1396 | if (!block.isVisible()
| 0 | ||||||||||||||||||||||||
1397 | offset.ry() += r.height(); | - | ||||||||||||||||||||||||
1398 | block = block.next(); | - | ||||||||||||||||||||||||
1399 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
1400 | } | - | ||||||||||||||||||||||||
1401 | - | |||||||||||||||||||||||||
1402 | if (r.bottom() >= er.top()
| 0 | ||||||||||||||||||||||||
1403 | - | |||||||||||||||||||||||||
1404 | QTextBlockFormat blockFormat = block.blockFormat(); | - | ||||||||||||||||||||||||
1405 | - | |||||||||||||||||||||||||
1406 | QBrush bg = blockFormat.background(); | - | ||||||||||||||||||||||||
1407 | if (bg != Qt::NoBrush
| 0 | ||||||||||||||||||||||||
1408 | QRectF contentsRect = r; | - | ||||||||||||||||||||||||
1409 | contentsRect.setWidth(qMax(r.width(), maximumWidth)); | - | ||||||||||||||||||||||||
1410 | fillBackground(&painter, contentsRect, bg); | - | ||||||||||||||||||||||||
1411 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1412 | - | |||||||||||||||||||||||||
1413 | - | |||||||||||||||||||||||||
1414 | QVector<QTextLayout::FormatRange> selections; | - | ||||||||||||||||||||||||
1415 | int blpos = block.position(); | - | ||||||||||||||||||||||||
1416 | int bllen = block.length(); | - | ||||||||||||||||||||||||
1417 | for (int i = 0; i < context.selections.size()
| 0 | ||||||||||||||||||||||||
1418 | const QAbstractTextDocumentLayout::Selection &range = context.selections.at(i); | - | ||||||||||||||||||||||||
1419 | const int selStart = range.cursor.selectionStart() - blpos; | - | ||||||||||||||||||||||||
1420 | const int selEnd = range.cursor.selectionEnd() - blpos; | - | ||||||||||||||||||||||||
1421 | if (selStart < bllen
| 0 | ||||||||||||||||||||||||
1422 | && selEnd > selStart
| 0 | ||||||||||||||||||||||||
1423 | QTextLayout::FormatRange o; | - | ||||||||||||||||||||||||
1424 | o.start = selStart; | - | ||||||||||||||||||||||||
1425 | o.length = selEnd - selStart; | - | ||||||||||||||||||||||||
1426 | o.format = range.format; | - | ||||||||||||||||||||||||
1427 | selections.append(o); | - | ||||||||||||||||||||||||
1428 | } never executed: else if (!range.cursor.hasSelection()end of block
| 0 | ||||||||||||||||||||||||
1429 | && block.contains(range.cursor.position())
| 0 | ||||||||||||||||||||||||
1430 | - | |||||||||||||||||||||||||
1431 | - | |||||||||||||||||||||||||
1432 | QTextLayout::FormatRange o; | - | ||||||||||||||||||||||||
1433 | QTextLine l = layout->lineForTextPosition(range.cursor.position() - blpos); | - | ||||||||||||||||||||||||
1434 | o.start = l.textStart(); | - | ||||||||||||||||||||||||
1435 | o.length = l.textLength(); | - | ||||||||||||||||||||||||
1436 | if (o.start + o.length == bllen - 1
| 0 | ||||||||||||||||||||||||
1437 | ++ never executed: o.length;++o.length; never executed: ++o.length; | 0 | ||||||||||||||||||||||||
1438 | o.format = range.format; | - | ||||||||||||||||||||||||
1439 | selections.append(o); | - | ||||||||||||||||||||||||
1440 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1441 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1442 | - | |||||||||||||||||||||||||
1443 | bool drawCursor = ((editable
| 0 | ||||||||||||||||||||||||
1444 | && context.cursorPosition >= blpos
| 0 | ||||||||||||||||||||||||
1445 | && context.cursorPosition < blpos + bllen
| 0 | ||||||||||||||||||||||||
1446 | - | |||||||||||||||||||||||||
1447 | bool drawCursorAsBlock = drawCursor
| 0 | ||||||||||||||||||||||||
1448 | - | |||||||||||||||||||||||||
1449 | if (drawCursorAsBlock
| 0 | ||||||||||||||||||||||||
1450 | if (context.cursorPosition == blpos + bllen - 1
| 0 | ||||||||||||||||||||||||
1451 | drawCursorAsBlock = false; | - | ||||||||||||||||||||||||
1452 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1453 | QTextLayout::FormatRange o; | - | ||||||||||||||||||||||||
1454 | o.start = context.cursorPosition - blpos; | - | ||||||||||||||||||||||||
1455 | o.length = 1; | - | ||||||||||||||||||||||||
1456 | o.format.setForeground(palette().base()); | - | ||||||||||||||||||||||||
1457 | o.format.setBackground(palette().text()); | - | ||||||||||||||||||||||||
1458 | selections.append(o); | - | ||||||||||||||||||||||||
1459 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1460 | } | - | ||||||||||||||||||||||||
1461 | - | |||||||||||||||||||||||||
1462 | - | |||||||||||||||||||||||||
1463 | if (!placeholderText().isEmpty()
| 0 | ||||||||||||||||||||||||
1464 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1465 | QColor col = d->control->palette().text().color(); | - | ||||||||||||||||||||||||
1466 | col.setAlpha(128); | - | ||||||||||||||||||||||||
1467 | painter.setPen(col); | - | ||||||||||||||||||||||||
1468 | const int margin = int(document()->documentMargin()); | - | ||||||||||||||||||||||||
1469 | painter.drawText(r.adjusted(margin, 0, 0, 0), Qt::AlignTop | Qt::TextWordWrap, placeholderText()); | - | ||||||||||||||||||||||||
1470 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1471 | layout->draw(&painter, offset, selections, er); | - | ||||||||||||||||||||||||
1472 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1473 | if ((drawCursor
| 0 | ||||||||||||||||||||||||
1474 | || (editable
| 0 | ||||||||||||||||||||||||
1475 | && !layout->preeditAreaText().isEmpty()
| 0 | ||||||||||||||||||||||||
1476 | int cpos = context.cursorPosition; | - | ||||||||||||||||||||||||
1477 | if (cpos < -1
| 0 | ||||||||||||||||||||||||
1478 | cpos = layout->preeditAreaPosition() - (cpos + 2); never executed: cpos = layout->preeditAreaPosition() - (cpos + 2); | 0 | ||||||||||||||||||||||||
1479 | else | - | ||||||||||||||||||||||||
1480 | cpos -= blpos; never executed: cpos -= blpos; | 0 | ||||||||||||||||||||||||
1481 | layout->drawCursor(&painter, offset, cpos, cursorWidth()); | - | ||||||||||||||||||||||||
1482 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1483 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1484 | - | |||||||||||||||||||||||||
1485 | offset.ry() += r.height(); | - | ||||||||||||||||||||||||
1486 | if (offset.y() > viewportRect.height()
| 0 | ||||||||||||||||||||||||
1487 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1488 | block = block.next(); | - | ||||||||||||||||||||||||
1489 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1490 | - | |||||||||||||||||||||||||
1491 | if (backgroundVisible()
| 0 | ||||||||||||||||||||||||
1492 | && (centerOnScroll()
| 0 | ||||||||||||||||||||||||
1493 | painter.fillRect(QRect(QPoint((int)er.left(), (int)offset.y()), er.bottomRight()), palette().background()); | - | ||||||||||||||||||||||||
1494 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1495 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1496 | - | |||||||||||||||||||||||||
1497 | - | |||||||||||||||||||||||||
1498 | void QPlainTextEditPrivate::updateDefaultTextOption() | - | ||||||||||||||||||||||||
1499 | { | - | ||||||||||||||||||||||||
1500 | QTextDocument *doc = control->document(); | - | ||||||||||||||||||||||||
1501 | - | |||||||||||||||||||||||||
1502 | QTextOption opt = doc->defaultTextOption(); | - | ||||||||||||||||||||||||
1503 | QTextOption::WrapMode oldWrapMode = opt.wrapMode(); | - | ||||||||||||||||||||||||
1504 | - | |||||||||||||||||||||||||
1505 | if (lineWrap == QPlainTextEdit::NoWrap
| 0 | ||||||||||||||||||||||||
1506 | opt.setWrapMode(QTextOption::NoWrap); never executed: opt.setWrapMode(QTextOption::NoWrap); | 0 | ||||||||||||||||||||||||
1507 | else | - | ||||||||||||||||||||||||
1508 | opt.setWrapMode(wordWrap); never executed: opt.setWrapMode(wordWrap); | 0 | ||||||||||||||||||||||||
1509 | - | |||||||||||||||||||||||||
1510 | if (opt.wrapMode() != oldWrapMode
| 0 | ||||||||||||||||||||||||
1511 | doc->setDefaultTextOption(opt); never executed: doc->setDefaultTextOption(opt); | 0 | ||||||||||||||||||||||||
1512 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1513 | - | |||||||||||||||||||||||||
1514 | - | |||||||||||||||||||||||||
1515 | - | |||||||||||||||||||||||||
1516 | - | |||||||||||||||||||||||||
1517 | void QPlainTextEdit::mousePressEvent(QMouseEvent *e) | - | ||||||||||||||||||||||||
1518 | { | - | ||||||||||||||||||||||||
1519 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1520 | - | |||||||||||||||||||||||||
1521 | - | |||||||||||||||||||||||||
1522 | - | |||||||||||||||||||||||||
1523 | - | |||||||||||||||||||||||||
1524 | d->sendControlEvent(e); | - | ||||||||||||||||||||||||
1525 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1526 | - | |||||||||||||||||||||||||
1527 | - | |||||||||||||||||||||||||
1528 | - | |||||||||||||||||||||||||
1529 | void QPlainTextEdit::mouseMoveEvent(QMouseEvent *e) | - | ||||||||||||||||||||||||
1530 | { | - | ||||||||||||||||||||||||
1531 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1532 | d->inDrag = false; | - | ||||||||||||||||||||||||
1533 | const QPoint pos = e->pos(); | - | ||||||||||||||||||||||||
1534 | d->sendControlEvent(e); | - | ||||||||||||||||||||||||
1535 | if (!(e->buttons() & Qt::LeftButton)
| 0 | ||||||||||||||||||||||||
1536 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1537 | if (e->source() == Qt::MouseEventNotSynthesized
| 0 | ||||||||||||||||||||||||
1538 | const QRect visible = d->viewport->rect(); | - | ||||||||||||||||||||||||
1539 | if (visible.contains(pos)
| 0 | ||||||||||||||||||||||||
1540 | d->autoScrollTimer.stop(); never executed: d->autoScrollTimer.stop(); | 0 | ||||||||||||||||||||||||
1541 | else if (!d->autoScrollTimer.isActive()
| 0 | ||||||||||||||||||||||||
1542 | d->autoScrollTimer.start(100, this); never executed: d->autoScrollTimer.start(100, this); | 0 | ||||||||||||||||||||||||
1543 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1544 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1545 | - | |||||||||||||||||||||||||
1546 | - | |||||||||||||||||||||||||
1547 | - | |||||||||||||||||||||||||
1548 | void QPlainTextEdit::mouseReleaseEvent(QMouseEvent *e) | - | ||||||||||||||||||||||||
1549 | { | - | ||||||||||||||||||||||||
1550 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1551 | d->sendControlEvent(e); | - | ||||||||||||||||||||||||
1552 | if (e->source() == Qt::MouseEventNotSynthesized
| 0 | ||||||||||||||||||||||||
1553 | d->autoScrollTimer.stop(); | - | ||||||||||||||||||||||||
1554 | d->ensureCursorVisible(); | - | ||||||||||||||||||||||||
1555 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1556 | - | |||||||||||||||||||||||||
1557 | if (!isReadOnly()
| 0 | ||||||||||||||||||||||||
1558 | d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus); never executed: d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus); | 0 | ||||||||||||||||||||||||
1559 | d->clickCausedFocus = 0; | - | ||||||||||||||||||||||||
1560 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1561 | - | |||||||||||||||||||||||||
1562 | - | |||||||||||||||||||||||||
1563 | - | |||||||||||||||||||||||||
1564 | void QPlainTextEdit::mouseDoubleClickEvent(QMouseEvent *e) | - | ||||||||||||||||||||||||
1565 | { | - | ||||||||||||||||||||||||
1566 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1567 | d->sendControlEvent(e); | - | ||||||||||||||||||||||||
1568 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1569 | - | |||||||||||||||||||||||||
1570 | - | |||||||||||||||||||||||||
1571 | - | |||||||||||||||||||||||||
1572 | bool QPlainTextEdit::focusNextPrevChild(bool next) | - | ||||||||||||||||||||||||
1573 | { | - | ||||||||||||||||||||||||
1574 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1575 | if (!d->tabChangesFocus
| 0 | ||||||||||||||||||||||||
1576 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||||||||
1577 | return never executed: QAbstractScrollArea::focusNextPrevChild(next);return QAbstractScrollArea::focusNextPrevChild(next); never executed: return QAbstractScrollArea::focusNextPrevChild(next); | 0 | ||||||||||||||||||||||||
1578 | } | - | ||||||||||||||||||||||||
1579 | void QPlainTextEdit::contextMenuEvent(QContextMenuEvent *e) | - | ||||||||||||||||||||||||
1580 | { | - | ||||||||||||||||||||||||
1581 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1582 | d->sendControlEvent(e); | - | ||||||||||||||||||||||||
1583 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1584 | - | |||||||||||||||||||||||||
1585 | - | |||||||||||||||||||||||||
1586 | - | |||||||||||||||||||||||||
1587 | - | |||||||||||||||||||||||||
1588 | - | |||||||||||||||||||||||||
1589 | void QPlainTextEdit::dragEnterEvent(QDragEnterEvent *e) | - | ||||||||||||||||||||||||
1590 | { | - | ||||||||||||||||||||||||
1591 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1592 | d->inDrag = true; | - | ||||||||||||||||||||||||
1593 | d->sendControlEvent(e); | - | ||||||||||||||||||||||||
1594 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1595 | - | |||||||||||||||||||||||||
1596 | - | |||||||||||||||||||||||||
1597 | - | |||||||||||||||||||||||||
1598 | void QPlainTextEdit::dragLeaveEvent(QDragLeaveEvent *e) | - | ||||||||||||||||||||||||
1599 | { | - | ||||||||||||||||||||||||
1600 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1601 | d->inDrag = false; | - | ||||||||||||||||||||||||
1602 | d->autoScrollTimer.stop(); | - | ||||||||||||||||||||||||
1603 | d->sendControlEvent(e); | - | ||||||||||||||||||||||||
1604 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1605 | - | |||||||||||||||||||||||||
1606 | - | |||||||||||||||||||||||||
1607 | - | |||||||||||||||||||||||||
1608 | void QPlainTextEdit::dragMoveEvent(QDragMoveEvent *e) | - | ||||||||||||||||||||||||
1609 | { | - | ||||||||||||||||||||||||
1610 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1611 | d->autoScrollDragPos = e->pos(); | - | ||||||||||||||||||||||||
1612 | if (!d->autoScrollTimer.isActive()
| 0 | ||||||||||||||||||||||||
1613 | d->autoScrollTimer.start(100, this); never executed: d->autoScrollTimer.start(100, this); | 0 | ||||||||||||||||||||||||
1614 | d->sendControlEvent(e); | - | ||||||||||||||||||||||||
1615 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1616 | - | |||||||||||||||||||||||||
1617 | - | |||||||||||||||||||||||||
1618 | - | |||||||||||||||||||||||||
1619 | void QPlainTextEdit::dropEvent(QDropEvent *e) | - | ||||||||||||||||||||||||
1620 | { | - | ||||||||||||||||||||||||
1621 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1622 | d->inDrag = false; | - | ||||||||||||||||||||||||
1623 | d->autoScrollTimer.stop(); | - | ||||||||||||||||||||||||
1624 | d->sendControlEvent(e); | - | ||||||||||||||||||||||||
1625 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1626 | - | |||||||||||||||||||||||||
1627 | - | |||||||||||||||||||||||||
1628 | - | |||||||||||||||||||||||||
1629 | - | |||||||||||||||||||||||||
1630 | - | |||||||||||||||||||||||||
1631 | void QPlainTextEdit::inputMethodEvent(QInputMethodEvent *e) | - | ||||||||||||||||||||||||
1632 | { | - | ||||||||||||||||||||||||
1633 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1634 | d->sendControlEvent(e); | - | ||||||||||||||||||||||||
1635 | ensureCursorVisible(); | - | ||||||||||||||||||||||||
1636 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1637 | - | |||||||||||||||||||||||||
1638 | - | |||||||||||||||||||||||||
1639 | - | |||||||||||||||||||||||||
1640 | void QPlainTextEdit::scrollContentsBy(int dx, int ) | - | ||||||||||||||||||||||||
1641 | { | - | ||||||||||||||||||||||||
1642 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1643 | d->setTopLine(d->vbar->value(), dx); | - | ||||||||||||||||||||||||
1644 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1645 | - | |||||||||||||||||||||||||
1646 | - | |||||||||||||||||||||||||
1647 | - | |||||||||||||||||||||||||
1648 | QVariant QPlainTextEdit::inputMethodQuery(Qt::InputMethodQuery property) const | - | ||||||||||||||||||||||||
1649 | { | - | ||||||||||||||||||||||||
1650 | return never executed: inputMethodQuery(property, QVariant());return inputMethodQuery(property, QVariant()); never executed: return inputMethodQuery(property, QVariant()); | 0 | ||||||||||||||||||||||||
1651 | } | - | ||||||||||||||||||||||||
1652 | - | |||||||||||||||||||||||||
1653 | - | |||||||||||||||||||||||||
1654 | - | |||||||||||||||||||||||||
1655 | QVariant QPlainTextEdit::inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const | - | ||||||||||||||||||||||||
1656 | { | - | ||||||||||||||||||||||||
1657 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1658 | if (query == Qt::ImHints
| 0 | ||||||||||||||||||||||||
1659 | return never executed: QWidget::inputMethodQuery(query);return QWidget::inputMethodQuery(query); never executed: return QWidget::inputMethodQuery(query); | 0 | ||||||||||||||||||||||||
1660 | const QVariant v = d->control->inputMethodQuery(query, argument); | - | ||||||||||||||||||||||||
1661 | const QPointF offset = contentOffset(); | - | ||||||||||||||||||||||||
1662 | switch (v.type()) { | - | ||||||||||||||||||||||||
1663 | case never executed: QVariant::RectF:case QVariant::RectF: never executed: case QVariant::RectF: | 0 | ||||||||||||||||||||||||
1664 | return never executed: v.toRectF().translated(offset);return v.toRectF().translated(offset); never executed: return v.toRectF().translated(offset); | 0 | ||||||||||||||||||||||||
1665 | case never executed: QVariant::PointF:case QVariant::PointF: never executed: case QVariant::PointF: | 0 | ||||||||||||||||||||||||
1666 | return never executed: v.toPointF() + offset;return v.toPointF() + offset; never executed: return v.toPointF() + offset; | 0 | ||||||||||||||||||||||||
1667 | case never executed: QVariant::Rect:case QVariant::Rect: never executed: case QVariant::Rect: | 0 | ||||||||||||||||||||||||
1668 | return never executed: v.toRect().translated(offset.toPoint());return v.toRect().translated(offset.toPoint()); never executed: return v.toRect().translated(offset.toPoint()); | 0 | ||||||||||||||||||||||||
1669 | case never executed: QVariant::Point:case QVariant::Point: never executed: case QVariant::Point: | 0 | ||||||||||||||||||||||||
1670 | return never executed: v.toPoint() + offset.toPoint();return v.toPoint() + offset.toPoint(); never executed: return v.toPoint() + offset.toPoint(); | 0 | ||||||||||||||||||||||||
1671 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||
1672 | break; never executed: break; | 0 | ||||||||||||||||||||||||
1673 | } | - | ||||||||||||||||||||||||
1674 | return never executed: v;return v; never executed: return v; | 0 | ||||||||||||||||||||||||
1675 | } | - | ||||||||||||||||||||||||
1676 | - | |||||||||||||||||||||||||
1677 | - | |||||||||||||||||||||||||
1678 | - | |||||||||||||||||||||||||
1679 | void QPlainTextEdit::focusInEvent(QFocusEvent *e) | - | ||||||||||||||||||||||||
1680 | { | - | ||||||||||||||||||||||||
1681 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1682 | if (e->reason() == Qt::MouseFocusReason
| 0 | ||||||||||||||||||||||||
1683 | d->clickCausedFocus = 1; | - | ||||||||||||||||||||||||
1684 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1685 | QAbstractScrollArea::focusInEvent(e); | - | ||||||||||||||||||||||||
1686 | d->sendControlEvent(e); | - | ||||||||||||||||||||||||
1687 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1688 | - | |||||||||||||||||||||||||
1689 | - | |||||||||||||||||||||||||
1690 | - | |||||||||||||||||||||||||
1691 | void QPlainTextEdit::focusOutEvent(QFocusEvent *e) | - | ||||||||||||||||||||||||
1692 | { | - | ||||||||||||||||||||||||
1693 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1694 | QAbstractScrollArea::focusOutEvent(e); | - | ||||||||||||||||||||||||
1695 | d->sendControlEvent(e); | - | ||||||||||||||||||||||||
1696 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1697 | - | |||||||||||||||||||||||||
1698 | - | |||||||||||||||||||||||||
1699 | - | |||||||||||||||||||||||||
1700 | void QPlainTextEdit::showEvent(QShowEvent *) | - | ||||||||||||||||||||||||
1701 | { | - | ||||||||||||||||||||||||
1702 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1703 | if (d->showCursorOnInitialShow
| 0 | ||||||||||||||||||||||||
1704 | d->showCursorOnInitialShow = false; | - | ||||||||||||||||||||||||
1705 | ensureCursorVisible(); | - | ||||||||||||||||||||||||
1706 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1707 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1708 | - | |||||||||||||||||||||||||
1709 | - | |||||||||||||||||||||||||
1710 | - | |||||||||||||||||||||||||
1711 | void QPlainTextEdit::changeEvent(QEvent *e) | - | ||||||||||||||||||||||||
1712 | { | - | ||||||||||||||||||||||||
1713 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1714 | QAbstractScrollArea::changeEvent(e); | - | ||||||||||||||||||||||||
1715 | if (e->type() == QEvent::ApplicationFontChange
| 0 | ||||||||||||||||||||||||
1716 | || e->type() == QEvent::FontChange
| 0 | ||||||||||||||||||||||||
1717 | d->control->document()->setDefaultFont(font()); | - | ||||||||||||||||||||||||
1718 | } never executed: else if(e->type() == QEvent::ActivationChangeend of block
| 0 | ||||||||||||||||||||||||
1719 | if (!isActiveWindow()
| 0 | ||||||||||||||||||||||||
1720 | d->autoScrollTimer.stop(); never executed: d->autoScrollTimer.stop(); | 0 | ||||||||||||||||||||||||
1721 | } never executed: else if (e->type() == QEvent::EnabledChangeend of block
| 0 | ||||||||||||||||||||||||
1722 | e->setAccepted(isEnabled()); | - | ||||||||||||||||||||||||
1723 | d->sendControlEvent(e); | - | ||||||||||||||||||||||||
1724 | } never executed: else if (e->type() == QEvent::PaletteChangeend of block
| 0 | ||||||||||||||||||||||||
1725 | d->control->setPalette(palette()); | - | ||||||||||||||||||||||||
1726 | } never executed: else if (e->type() == QEvent::LayoutDirectionChangeend of block
| 0 | ||||||||||||||||||||||||
1727 | d->sendControlEvent(e); | - | ||||||||||||||||||||||||
1728 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1729 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1730 | - | |||||||||||||||||||||||||
1731 | - | |||||||||||||||||||||||||
1732 | - | |||||||||||||||||||||||||
1733 | - | |||||||||||||||||||||||||
1734 | void QPlainTextEdit::wheelEvent(QWheelEvent *e) | - | ||||||||||||||||||||||||
1735 | { | - | ||||||||||||||||||||||||
1736 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1737 | if (!(d->control->textInteractionFlags() & Qt::TextEditable)
| 0 | ||||||||||||||||||||||||
1738 | if (e->modifiers() & Qt::ControlModifier
| 0 | ||||||||||||||||||||||||
1739 | float delta = e->angleDelta().y() / 120.f; | - | ||||||||||||||||||||||||
1740 | zoomInF(delta); | - | ||||||||||||||||||||||||
1741 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1742 | } | - | ||||||||||||||||||||||||
1743 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1744 | QAbstractScrollArea::wheelEvent(e); | - | ||||||||||||||||||||||||
1745 | updateMicroFocus(); | - | ||||||||||||||||||||||||
1746 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1747 | void QPlainTextEdit::zoomIn(int range) | - | ||||||||||||||||||||||||
1748 | { | - | ||||||||||||||||||||||||
1749 | zoomInF(range); | - | ||||||||||||||||||||||||
1750 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1751 | void QPlainTextEdit::zoomOut(int range) | - | ||||||||||||||||||||||||
1752 | { | - | ||||||||||||||||||||||||
1753 | zoomInF(-range); | - | ||||||||||||||||||||||||
1754 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1755 | - | |||||||||||||||||||||||||
1756 | - | |||||||||||||||||||||||||
1757 | - | |||||||||||||||||||||||||
1758 | - | |||||||||||||||||||||||||
1759 | void QPlainTextEdit::zoomInF(float range) | - | ||||||||||||||||||||||||
1760 | { | - | ||||||||||||||||||||||||
1761 | if (range == 0.f
| 0 | ||||||||||||||||||||||||
1762 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1763 | QFont f = font(); | - | ||||||||||||||||||||||||
1764 | const float newSize = f.pointSizeF() + range; | - | ||||||||||||||||||||||||
1765 | if (newSize <= 0
| 0 | ||||||||||||||||||||||||
1766 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1767 | f.setPointSizeF(newSize); | - | ||||||||||||||||||||||||
1768 | setFont(f); | - | ||||||||||||||||||||||||
1769 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1770 | QMenu *QPlainTextEdit::createStandardContextMenu() | - | ||||||||||||||||||||||||
1771 | { | - | ||||||||||||||||||||||||
1772 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1773 | return never executed: d->control->createStandardContextMenu(QPointF(), this);return d->control->createStandardContextMenu(QPointF(), this); never executed: return d->control->createStandardContextMenu(QPointF(), this); | 0 | ||||||||||||||||||||||||
1774 | } | - | ||||||||||||||||||||||||
1775 | QMenu *QPlainTextEdit::createStandardContextMenu(const QPoint &position) | - | ||||||||||||||||||||||||
1776 | { | - | ||||||||||||||||||||||||
1777 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1778 | return never executed: d->control->createStandardContextMenu(position, this);return d->control->createStandardContextMenu(position, this); never executed: return d->control->createStandardContextMenu(position, this); | 0 | ||||||||||||||||||||||||
1779 | } | - | ||||||||||||||||||||||||
1780 | - | |||||||||||||||||||||||||
1781 | - | |||||||||||||||||||||||||
1782 | - | |||||||||||||||||||||||||
1783 | - | |||||||||||||||||||||||||
1784 | - | |||||||||||||||||||||||||
1785 | QTextCursor QPlainTextEdit::cursorForPosition(const QPoint &pos) const | - | ||||||||||||||||||||||||
1786 | { | - | ||||||||||||||||||||||||
1787 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1788 | return never executed: d->control->cursorForPosition(d->mapToContents(pos));return d->control->cursorForPosition(d->mapToContents(pos)); never executed: return d->control->cursorForPosition(d->mapToContents(pos)); | 0 | ||||||||||||||||||||||||
1789 | } | - | ||||||||||||||||||||||||
1790 | - | |||||||||||||||||||||||||
1791 | - | |||||||||||||||||||||||||
1792 | - | |||||||||||||||||||||||||
1793 | - | |||||||||||||||||||||||||
1794 | - | |||||||||||||||||||||||||
1795 | QRect QPlainTextEdit::cursorRect(const QTextCursor &cursor) const | - | ||||||||||||||||||||||||
1796 | { | - | ||||||||||||||||||||||||
1797 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1798 | if (cursor.isNull()
| 0 | ||||||||||||||||||||||||
1799 | return never executed: QRect();return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||||||||
1800 | - | |||||||||||||||||||||||||
1801 | QRect r = d->control->cursorRect(cursor).toRect(); | - | ||||||||||||||||||||||||
1802 | r.translate(-d->horizontalOffset(),-(int)d->verticalOffset()); | - | ||||||||||||||||||||||||
1803 | return never executed: r;return r; never executed: return r; | 0 | ||||||||||||||||||||||||
1804 | } | - | ||||||||||||||||||||||||
1805 | - | |||||||||||||||||||||||||
1806 | - | |||||||||||||||||||||||||
1807 | - | |||||||||||||||||||||||||
1808 | - | |||||||||||||||||||||||||
1809 | - | |||||||||||||||||||||||||
1810 | QRect QPlainTextEdit::cursorRect() const | - | ||||||||||||||||||||||||
1811 | { | - | ||||||||||||||||||||||||
1812 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1813 | QRect r = d->control->cursorRect().toRect(); | - | ||||||||||||||||||||||||
1814 | r.translate(-d->horizontalOffset(),-(int)d->verticalOffset()); | - | ||||||||||||||||||||||||
1815 | return never executed: r;return r; never executed: return r; | 0 | ||||||||||||||||||||||||
1816 | } | - | ||||||||||||||||||||||||
1817 | bool QPlainTextEdit::overwriteMode() const | - | ||||||||||||||||||||||||
1818 | { | - | ||||||||||||||||||||||||
1819 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1820 | return never executed: d->control->overwriteMode();return d->control->overwriteMode(); never executed: return d->control->overwriteMode(); | 0 | ||||||||||||||||||||||||
1821 | } | - | ||||||||||||||||||||||||
1822 | - | |||||||||||||||||||||||||
1823 | void QPlainTextEdit::setOverwriteMode(bool overwrite) | - | ||||||||||||||||||||||||
1824 | { | - | ||||||||||||||||||||||||
1825 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1826 | d->control->setOverwriteMode(overwrite); | - | ||||||||||||||||||||||||
1827 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1828 | int QPlainTextEdit::tabStopWidth() const | - | ||||||||||||||||||||||||
1829 | { | - | ||||||||||||||||||||||||
1830 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1831 | return never executed: qRound(d->control->document()->defaultTextOption().tabStop());return qRound(d->control->document()->defaultTextOption().tabStop()); never executed: return qRound(d->control->document()->defaultTextOption().tabStop()); | 0 | ||||||||||||||||||||||||
1832 | } | - | ||||||||||||||||||||||||
1833 | - | |||||||||||||||||||||||||
1834 | void QPlainTextEdit::setTabStopWidth(int width) | - | ||||||||||||||||||||||||
1835 | { | - | ||||||||||||||||||||||||
1836 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1837 | QTextOption opt = d->control->document()->defaultTextOption(); | - | ||||||||||||||||||||||||
1838 | if (opt.tabStop() == width
| 0 | ||||||||||||||||||||||||
1839 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1840 | opt.setTabStop(width); | - | ||||||||||||||||||||||||
1841 | d->control->document()->setDefaultTextOption(opt); | - | ||||||||||||||||||||||||
1842 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1843 | - | |||||||||||||||||||||||||
1844 | - | |||||||||||||||||||||||||
1845 | - | |||||||||||||||||||||||||
1846 | - | |||||||||||||||||||||||||
1847 | - | |||||||||||||||||||||||||
1848 | - | |||||||||||||||||||||||||
1849 | int QPlainTextEdit::cursorWidth() const | - | ||||||||||||||||||||||||
1850 | { | - | ||||||||||||||||||||||||
1851 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1852 | return never executed: d->control->cursorWidth();return d->control->cursorWidth(); never executed: return d->control->cursorWidth(); | 0 | ||||||||||||||||||||||||
1853 | } | - | ||||||||||||||||||||||||
1854 | - | |||||||||||||||||||||||||
1855 | void QPlainTextEdit::setCursorWidth(int width) | - | ||||||||||||||||||||||||
1856 | { | - | ||||||||||||||||||||||||
1857 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1858 | d->control->setCursorWidth(width); | - | ||||||||||||||||||||||||
1859 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1860 | void QPlainTextEdit::setExtraSelections(const QList<QTextEdit::ExtraSelection> &selections) | - | ||||||||||||||||||||||||
1861 | { | - | ||||||||||||||||||||||||
1862 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1863 | d->control->setExtraSelections(selections); | - | ||||||||||||||||||||||||
1864 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1865 | - | |||||||||||||||||||||||||
1866 | - | |||||||||||||||||||||||||
1867 | - | |||||||||||||||||||||||||
1868 | - | |||||||||||||||||||||||||
1869 | - | |||||||||||||||||||||||||
1870 | - | |||||||||||||||||||||||||
1871 | QList<QTextEdit::ExtraSelection> QPlainTextEdit::extraSelections() const | - | ||||||||||||||||||||||||
1872 | { | - | ||||||||||||||||||||||||
1873 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1874 | return never executed: d->control->extraSelections();return d->control->extraSelections(); never executed: return d->control->extraSelections(); | 0 | ||||||||||||||||||||||||
1875 | } | - | ||||||||||||||||||||||||
1876 | QMimeData *QPlainTextEdit::createMimeDataFromSelection() const | - | ||||||||||||||||||||||||
1877 | { | - | ||||||||||||||||||||||||
1878 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1879 | return never executed: d->control->QWidgetTextControl::createMimeDataFromSelection();return d->control->QWidgetTextControl::createMimeDataFromSelection(); never executed: return d->control->QWidgetTextControl::createMimeDataFromSelection(); | 0 | ||||||||||||||||||||||||
1880 | } | - | ||||||||||||||||||||||||
1881 | - | |||||||||||||||||||||||||
1882 | - | |||||||||||||||||||||||||
1883 | - | |||||||||||||||||||||||||
1884 | - | |||||||||||||||||||||||||
1885 | - | |||||||||||||||||||||||||
1886 | - | |||||||||||||||||||||||||
1887 | - | |||||||||||||||||||||||||
1888 | bool QPlainTextEdit::canInsertFromMimeData(const QMimeData *source) const | - | ||||||||||||||||||||||||
1889 | { | - | ||||||||||||||||||||||||
1890 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1891 | return never executed: d->control->QWidgetTextControl::canInsertFromMimeData(source);return d->control->QWidgetTextControl::canInsertFromMimeData(source); never executed: return d->control->QWidgetTextControl::canInsertFromMimeData(source); | 0 | ||||||||||||||||||||||||
1892 | } | - | ||||||||||||||||||||||||
1893 | void QPlainTextEdit::insertFromMimeData(const QMimeData *source) | - | ||||||||||||||||||||||||
1894 | { | - | ||||||||||||||||||||||||
1895 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1896 | d->control->QWidgetTextControl::insertFromMimeData(source); | - | ||||||||||||||||||||||||
1897 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1898 | bool QPlainTextEdit::isReadOnly() const | - | ||||||||||||||||||||||||
1899 | { | - | ||||||||||||||||||||||||
1900 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1901 | return never executed: !(d->control->textInteractionFlags() & Qt::TextEditable);return !(d->control->textInteractionFlags() & Qt::TextEditable); never executed: return !(d->control->textInteractionFlags() & Qt::TextEditable); | 0 | ||||||||||||||||||||||||
1902 | } | - | ||||||||||||||||||||||||
1903 | - | |||||||||||||||||||||||||
1904 | void QPlainTextEdit::setReadOnly(bool ro) | - | ||||||||||||||||||||||||
1905 | { | - | ||||||||||||||||||||||||
1906 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1907 | Qt::TextInteractionFlags flags = Qt::NoTextInteraction; | - | ||||||||||||||||||||||||
1908 | if (ro
| 0 | ||||||||||||||||||||||||
1909 | flags = Qt::TextSelectableByMouse; | - | ||||||||||||||||||||||||
1910 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
1911 | flags = Qt::TextEditorInteraction; | - | ||||||||||||||||||||||||
1912 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1913 | setAttribute(Qt::WA_InputMethodEnabled, shouldEnableInputMethod(this)); | - | ||||||||||||||||||||||||
1914 | d->control->setTextInteractionFlags(flags); | - | ||||||||||||||||||||||||
1915 | QEvent event(QEvent::ReadOnlyChange); | - | ||||||||||||||||||||||||
1916 | QApplication::sendEvent(this, &event); | - | ||||||||||||||||||||||||
1917 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1918 | void QPlainTextEdit::setTextInteractionFlags(Qt::TextInteractionFlags flags) | - | ||||||||||||||||||||||||
1919 | { | - | ||||||||||||||||||||||||
1920 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1921 | d->control->setTextInteractionFlags(flags); | - | ||||||||||||||||||||||||
1922 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1923 | - | |||||||||||||||||||||||||
1924 | Qt::TextInteractionFlags QPlainTextEdit::textInteractionFlags() const | - | ||||||||||||||||||||||||
1925 | { | - | ||||||||||||||||||||||||
1926 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1927 | return never executed: d->control->textInteractionFlags();return d->control->textInteractionFlags(); never executed: return d->control->textInteractionFlags(); | 0 | ||||||||||||||||||||||||
1928 | } | - | ||||||||||||||||||||||||
1929 | void QPlainTextEdit::mergeCurrentCharFormat(const QTextCharFormat &modifier) | - | ||||||||||||||||||||||||
1930 | { | - | ||||||||||||||||||||||||
1931 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1932 | d->control->mergeCurrentCharFormat(modifier); | - | ||||||||||||||||||||||||
1933 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1934 | - | |||||||||||||||||||||||||
1935 | - | |||||||||||||||||||||||||
1936 | - | |||||||||||||||||||||||||
1937 | - | |||||||||||||||||||||||||
1938 | - | |||||||||||||||||||||||||
1939 | - | |||||||||||||||||||||||||
1940 | - | |||||||||||||||||||||||||
1941 | void QPlainTextEdit::setCurrentCharFormat(const QTextCharFormat &format) | - | ||||||||||||||||||||||||
1942 | { | - | ||||||||||||||||||||||||
1943 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1944 | d->control->setCurrentCharFormat(format); | - | ||||||||||||||||||||||||
1945 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1946 | - | |||||||||||||||||||||||||
1947 | - | |||||||||||||||||||||||||
1948 | - | |||||||||||||||||||||||||
1949 | - | |||||||||||||||||||||||||
1950 | QTextCharFormat QPlainTextEdit::currentCharFormat() const | - | ||||||||||||||||||||||||
1951 | { | - | ||||||||||||||||||||||||
1952 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1953 | return never executed: d->control->currentCharFormat();return d->control->currentCharFormat(); never executed: return d->control->currentCharFormat(); | 0 | ||||||||||||||||||||||||
1954 | } | - | ||||||||||||||||||||||||
1955 | void QPlainTextEdit::insertPlainText(const QString &text) | - | ||||||||||||||||||||||||
1956 | { | - | ||||||||||||||||||||||||
1957 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1958 | d->control->insertPlainText(text); | - | ||||||||||||||||||||||||
1959 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1960 | void QPlainTextEdit::moveCursor(QTextCursor::MoveOperation operation, QTextCursor::MoveMode mode) | - | ||||||||||||||||||||||||
1961 | { | - | ||||||||||||||||||||||||
1962 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1963 | d->control->moveCursor(operation, mode); | - | ||||||||||||||||||||||||
1964 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1965 | - | |||||||||||||||||||||||||
1966 | - | |||||||||||||||||||||||||
1967 | - | |||||||||||||||||||||||||
1968 | - | |||||||||||||||||||||||||
1969 | bool QPlainTextEdit::canPaste() const | - | ||||||||||||||||||||||||
1970 | { | - | ||||||||||||||||||||||||
1971 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1972 | return never executed: d->control->canPaste();return d->control->canPaste(); never executed: return d->control->canPaste(); | 0 | ||||||||||||||||||||||||
1973 | } | - | ||||||||||||||||||||||||
1974 | void QPlainTextEdit::print(QPagedPaintDevice *printer) const | - | ||||||||||||||||||||||||
1975 | { | - | ||||||||||||||||||||||||
1976 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1977 | d->control->print(printer); | - | ||||||||||||||||||||||||
1978 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1979 | bool QPlainTextEdit::tabChangesFocus() const | - | ||||||||||||||||||||||||
1980 | { | - | ||||||||||||||||||||||||
1981 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1982 | return never executed: d->tabChangesFocus;return d->tabChangesFocus; never executed: return d->tabChangesFocus; | 0 | ||||||||||||||||||||||||
1983 | } | - | ||||||||||||||||||||||||
1984 | - | |||||||||||||||||||||||||
1985 | void QPlainTextEdit::setTabChangesFocus(bool b) | - | ||||||||||||||||||||||||
1986 | { | - | ||||||||||||||||||||||||
1987 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1988 | d->tabChangesFocus = b; | - | ||||||||||||||||||||||||
1989 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1990 | QPlainTextEdit::LineWrapMode QPlainTextEdit::lineWrapMode() const | - | ||||||||||||||||||||||||
1991 | { | - | ||||||||||||||||||||||||
1992 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1993 | return never executed: d->lineWrap;return d->lineWrap; never executed: return d->lineWrap; | 0 | ||||||||||||||||||||||||
1994 | } | - | ||||||||||||||||||||||||
1995 | - | |||||||||||||||||||||||||
1996 | void QPlainTextEdit::setLineWrapMode(LineWrapMode wrap) | - | ||||||||||||||||||||||||
1997 | { | - | ||||||||||||||||||||||||
1998 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
1999 | if (d->lineWrap == wrap
| 0 | ||||||||||||||||||||||||
2000 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2001 | d->lineWrap = wrap; | - | ||||||||||||||||||||||||
2002 | d->updateDefaultTextOption(); | - | ||||||||||||||||||||||||
2003 | d->relayoutDocument(); | - | ||||||||||||||||||||||||
2004 | d->_q_adjustScrollbars(); | - | ||||||||||||||||||||||||
2005 | ensureCursorVisible(); | - | ||||||||||||||||||||||||
2006 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2007 | QTextOption::WrapMode QPlainTextEdit::wordWrapMode() const | - | ||||||||||||||||||||||||
2008 | { | - | ||||||||||||||||||||||||
2009 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2010 | return never executed: d->wordWrap;return d->wordWrap; never executed: return d->wordWrap; | 0 | ||||||||||||||||||||||||
2011 | } | - | ||||||||||||||||||||||||
2012 | - | |||||||||||||||||||||||||
2013 | void QPlainTextEdit::setWordWrapMode(QTextOption::WrapMode mode) | - | ||||||||||||||||||||||||
2014 | { | - | ||||||||||||||||||||||||
2015 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2016 | if (mode == d->wordWrap
| 0 | ||||||||||||||||||||||||
2017 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2018 | d->wordWrap = mode; | - | ||||||||||||||||||||||||
2019 | d->updateDefaultTextOption(); | - | ||||||||||||||||||||||||
2020 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2021 | bool QPlainTextEdit::backgroundVisible() const | - | ||||||||||||||||||||||||
2022 | { | - | ||||||||||||||||||||||||
2023 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2024 | return never executed: d->backgroundVisible;return d->backgroundVisible; never executed: return d->backgroundVisible; | 0 | ||||||||||||||||||||||||
2025 | } | - | ||||||||||||||||||||||||
2026 | - | |||||||||||||||||||||||||
2027 | void QPlainTextEdit::setBackgroundVisible(bool visible) | - | ||||||||||||||||||||||||
2028 | { | - | ||||||||||||||||||||||||
2029 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2030 | if (visible == d->backgroundVisible
| 0 | ||||||||||||||||||||||||
2031 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2032 | d->backgroundVisible = visible; | - | ||||||||||||||||||||||||
2033 | d->updateViewport(); | - | ||||||||||||||||||||||||
2034 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2035 | bool QPlainTextEdit::centerOnScroll() const | - | ||||||||||||||||||||||||
2036 | { | - | ||||||||||||||||||||||||
2037 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2038 | return never executed: d->centerOnScroll;return d->centerOnScroll; never executed: return d->centerOnScroll; | 0 | ||||||||||||||||||||||||
2039 | } | - | ||||||||||||||||||||||||
2040 | - | |||||||||||||||||||||||||
2041 | void QPlainTextEdit::setCenterOnScroll(bool enabled) | - | ||||||||||||||||||||||||
2042 | { | - | ||||||||||||||||||||||||
2043 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2044 | if (enabled == d->centerOnScroll
| 0 | ||||||||||||||||||||||||
2045 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2046 | d->centerOnScroll = enabled; | - | ||||||||||||||||||||||||
2047 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2048 | bool QPlainTextEdit::find(const QString &exp, QTextDocument::FindFlags options) | - | ||||||||||||||||||||||||
2049 | { | - | ||||||||||||||||||||||||
2050 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2051 | return never executed: d->control->find(exp, options);return d->control->find(exp, options); never executed: return d->control->find(exp, options); | 0 | ||||||||||||||||||||||||
2052 | } | - | ||||||||||||||||||||||||
2053 | bool QPlainTextEdit::find(const QRegExp &exp, QTextDocument::FindFlags options) | - | ||||||||||||||||||||||||
2054 | { | - | ||||||||||||||||||||||||
2055 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2056 | return never executed: d->control->find(exp, options);return d->control->find(exp, options); never executed: return d->control->find(exp, options); | 0 | ||||||||||||||||||||||||
2057 | } | - | ||||||||||||||||||||||||
2058 | void QPlainTextEditPrivate::append(const QString &text, Qt::TextFormat format) | - | ||||||||||||||||||||||||
2059 | { | - | ||||||||||||||||||||||||
2060 | QPlainTextEdit * const q = q_func(); | - | ||||||||||||||||||||||||
2061 | - | |||||||||||||||||||||||||
2062 | QTextDocument *document = control->document(); | - | ||||||||||||||||||||||||
2063 | QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(document->documentLayout()); | - | ||||||||||||||||||||||||
2064 | ((!(documentLayout)) ? qt_assert("documentLayout",__FILE__,2929) : qt_noop()); | - | ||||||||||||||||||||||||
2065 | - | |||||||||||||||||||||||||
2066 | int maximumBlockCount = document->maximumBlockCount(); | - | ||||||||||||||||||||||||
2067 | if (maximumBlockCount
| 0 | ||||||||||||||||||||||||
2068 | document->setMaximumBlockCount(0); never executed: document->setMaximumBlockCount(0); | 0 | ||||||||||||||||||||||||
2069 | - | |||||||||||||||||||||||||
2070 | const bool atBottom = q->isVisible()
| 0 | ||||||||||||||||||||||||
2071 | && (
| 0 | ||||||||||||||||||||||||
2072 | <= viewport->rect().bottom())
| 0 | ||||||||||||||||||||||||
2073 | - | |||||||||||||||||||||||||
2074 | if (!q->isVisible()
| 0 | ||||||||||||||||||||||||
2075 | showCursorOnInitialShow = true; never executed: showCursorOnInitialShow = true; | 0 | ||||||||||||||||||||||||
2076 | - | |||||||||||||||||||||||||
2077 | bool documentSizeChangedBlocked = documentLayout->priv()->blockDocumentSizeChanged; | - | ||||||||||||||||||||||||
2078 | documentLayout->priv()->blockDocumentSizeChanged = true; | - | ||||||||||||||||||||||||
2079 | - | |||||||||||||||||||||||||
2080 | if (format == Qt::RichText
| 0 | ||||||||||||||||||||||||
2081 | control->appendHtml(text); never executed: control->appendHtml(text); | 0 | ||||||||||||||||||||||||
2082 | else if (format == Qt::PlainText
| 0 | ||||||||||||||||||||||||
2083 | control->appendPlainText(text); never executed: control->appendPlainText(text); | 0 | ||||||||||||||||||||||||
2084 | else | - | ||||||||||||||||||||||||
2085 | control->append(text); never executed: control->append(text); | 0 | ||||||||||||||||||||||||
2086 | - | |||||||||||||||||||||||||
2087 | if (maximumBlockCount > 0
| 0 | ||||||||||||||||||||||||
2088 | if (document->blockCount() > maximumBlockCount
| 0 | ||||||||||||||||||||||||
2089 | bool blockUpdate = false; | - | ||||||||||||||||||||||||
2090 | if (control->topBlock
| 0 | ||||||||||||||||||||||||
2091 | control->topBlock--; | - | ||||||||||||||||||||||||
2092 | blockUpdate = true; | - | ||||||||||||||||||||||||
2093 | q->updateRequest(viewport->rect(), 0); | - | ||||||||||||||||||||||||
2094 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2095 | - | |||||||||||||||||||||||||
2096 | bool updatesBlocked = documentLayout->priv()->blockUpdate; | - | ||||||||||||||||||||||||
2097 | documentLayout->priv()->blockUpdate = blockUpdate; | - | ||||||||||||||||||||||||
2098 | QTextCursor cursor(document); | - | ||||||||||||||||||||||||
2099 | cursor.movePosition(QTextCursor::NextBlock, QTextCursor::KeepAnchor); | - | ||||||||||||||||||||||||
2100 | cursor.removeSelectedText(); | - | ||||||||||||||||||||||||
2101 | documentLayout->priv()->blockUpdate = updatesBlocked; | - | ||||||||||||||||||||||||
2102 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2103 | document->setMaximumBlockCount(maximumBlockCount); | - | ||||||||||||||||||||||||
2104 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2105 | - | |||||||||||||||||||||||||
2106 | documentLayout->priv()->blockDocumentSizeChanged = documentSizeChangedBlocked; | - | ||||||||||||||||||||||||
2107 | _q_adjustScrollbars(); | - | ||||||||||||||||||||||||
2108 | - | |||||||||||||||||||||||||
2109 | - | |||||||||||||||||||||||||
2110 | if (atBottom
| 0 | ||||||||||||||||||||||||
2111 | const bool needScroll = !centerOnScroll
| 0 | ||||||||||||||||||||||||
2112 | || control->blockBoundingRect(document->lastBlock()).bottom() - verticalOffset()
| 0 | ||||||||||||||||||||||||
2113 | > viewport->rect().bottom()
| 0 | ||||||||||||||||||||||||
2114 | if (needScroll
| 0 | ||||||||||||||||||||||||
2115 | vbar->setValue(vbar->maximum()); never executed: vbar->setValue(vbar->maximum()); | 0 | ||||||||||||||||||||||||
2116 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2117 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2118 | void QPlainTextEdit::appendPlainText(const QString &text) | - | ||||||||||||||||||||||||
2119 | { | - | ||||||||||||||||||||||||
2120 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2121 | d->append(text, Qt::PlainText); | - | ||||||||||||||||||||||||
2122 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2123 | - | |||||||||||||||||||||||||
2124 | - | |||||||||||||||||||||||||
2125 | - | |||||||||||||||||||||||||
2126 | - | |||||||||||||||||||||||||
2127 | - | |||||||||||||||||||||||||
2128 | - | |||||||||||||||||||||||||
2129 | - | |||||||||||||||||||||||||
2130 | void QPlainTextEdit::appendHtml(const QString &html) | - | ||||||||||||||||||||||||
2131 | { | - | ||||||||||||||||||||||||
2132 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2133 | d->append(html, Qt::RichText); | - | ||||||||||||||||||||||||
2134 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2135 | - | |||||||||||||||||||||||||
2136 | void QPlainTextEditPrivate::ensureCursorVisible(bool center) | - | ||||||||||||||||||||||||
2137 | { | - | ||||||||||||||||||||||||
2138 | QPlainTextEdit * const q = q_func(); | - | ||||||||||||||||||||||||
2139 | QRect visible = viewport->rect(); | - | ||||||||||||||||||||||||
2140 | QRect cr = q->cursorRect(); | - | ||||||||||||||||||||||||
2141 | if (cr.top() < visible.top()
| 0 | ||||||||||||||||||||||||
2142 | ensureVisible(control->textCursor().position(), center); | - | ||||||||||||||||||||||||
2143 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2144 | - | |||||||||||||||||||||||||
2145 | const bool rtl = q->isRightToLeft(); | - | ||||||||||||||||||||||||
2146 | if (cr.left() < visible.left()
| 0 | ||||||||||||||||||||||||
2147 | int x = cr.center().x() + horizontalOffset() - visible.width()/2; | - | ||||||||||||||||||||||||
2148 | hbar->setValue(rtl ? hbar->maximum() - x : x); | - | ||||||||||||||||||||||||
2149 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2150 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2151 | - | |||||||||||||||||||||||||
2152 | - | |||||||||||||||||||||||||
2153 | - | |||||||||||||||||||||||||
2154 | - | |||||||||||||||||||||||||
2155 | - | |||||||||||||||||||||||||
2156 | - | |||||||||||||||||||||||||
2157 | - | |||||||||||||||||||||||||
2158 | void QPlainTextEdit::ensureCursorVisible() | - | ||||||||||||||||||||||||
2159 | { | - | ||||||||||||||||||||||||
2160 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2161 | d->ensureCursorVisible(d->centerOnScroll); | - | ||||||||||||||||||||||||
2162 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2163 | - | |||||||||||||||||||||||||
2164 | - | |||||||||||||||||||||||||
2165 | - | |||||||||||||||||||||||||
2166 | - | |||||||||||||||||||||||||
2167 | - | |||||||||||||||||||||||||
2168 | - | |||||||||||||||||||||||||
2169 | void QPlainTextEdit::centerCursor() | - | ||||||||||||||||||||||||
2170 | { | - | ||||||||||||||||||||||||
2171 | QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2172 | d->ensureVisible(textCursor().position(), true, true); | - | ||||||||||||||||||||||||
2173 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2174 | - | |||||||||||||||||||||||||
2175 | - | |||||||||||||||||||||||||
2176 | - | |||||||||||||||||||||||||
2177 | - | |||||||||||||||||||||||||
2178 | - | |||||||||||||||||||||||||
2179 | - | |||||||||||||||||||||||||
2180 | QTextBlock QPlainTextEdit::firstVisibleBlock() const | - | ||||||||||||||||||||||||
2181 | { | - | ||||||||||||||||||||||||
2182 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2183 | return never executed: d->control->firstVisibleBlock();return d->control->firstVisibleBlock(); never executed: return d->control->firstVisibleBlock(); | 0 | ||||||||||||||||||||||||
2184 | } | - | ||||||||||||||||||||||||
2185 | QPointF QPlainTextEdit::contentOffset() const | - | ||||||||||||||||||||||||
2186 | { | - | ||||||||||||||||||||||||
2187 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2188 | return never executed: QPointF(-d->horizontalOffset(), -d->verticalOffset());return QPointF(-d->horizontalOffset(), -d->verticalOffset()); never executed: return QPointF(-d->horizontalOffset(), -d->verticalOffset()); | 0 | ||||||||||||||||||||||||
2189 | } | - | ||||||||||||||||||||||||
2190 | QRectF QPlainTextEdit::blockBoundingGeometry(const QTextBlock &block) const | - | ||||||||||||||||||||||||
2191 | { | - | ||||||||||||||||||||||||
2192 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2193 | return never executed: d->control->blockBoundingRect(block);return d->control->blockBoundingRect(block); never executed: return d->control->blockBoundingRect(block); | 0 | ||||||||||||||||||||||||
2194 | } | - | ||||||||||||||||||||||||
2195 | - | |||||||||||||||||||||||||
2196 | - | |||||||||||||||||||||||||
2197 | - | |||||||||||||||||||||||||
2198 | - | |||||||||||||||||||||||||
2199 | - | |||||||||||||||||||||||||
2200 | - | |||||||||||||||||||||||||
2201 | QRectF QPlainTextEdit::blockBoundingRect(const QTextBlock &block) const | - | ||||||||||||||||||||||||
2202 | { | - | ||||||||||||||||||||||||
2203 | QPlainTextDocumentLayout *documentLayout = qobject_cast<QPlainTextDocumentLayout*>(document()->documentLayout()); | - | ||||||||||||||||||||||||
2204 | ((!(documentLayout)) ? qt_assert("documentLayout",__FILE__,3099) : qt_noop()); | - | ||||||||||||||||||||||||
2205 | return never executed: documentLayout->blockBoundingRect(block);return documentLayout->blockBoundingRect(block); never executed: return documentLayout->blockBoundingRect(block); | 0 | ||||||||||||||||||||||||
2206 | } | - | ||||||||||||||||||||||||
2207 | - | |||||||||||||||||||||||||
2208 | - | |||||||||||||||||||||||||
2209 | - | |||||||||||||||||||||||||
2210 | - | |||||||||||||||||||||||||
2211 | - | |||||||||||||||||||||||||
2212 | - | |||||||||||||||||||||||||
2213 | - | |||||||||||||||||||||||||
2214 | int QPlainTextEdit::blockCount() const | - | ||||||||||||||||||||||||
2215 | { | - | ||||||||||||||||||||||||
2216 | return never executed: document()->blockCount();return document()->blockCount(); never executed: return document()->blockCount(); | 0 | ||||||||||||||||||||||||
2217 | } | - | ||||||||||||||||||||||||
2218 | - | |||||||||||||||||||||||||
2219 | - | |||||||||||||||||||||||||
2220 | - | |||||||||||||||||||||||||
2221 | - | |||||||||||||||||||||||||
2222 | QAbstractTextDocumentLayout::PaintContext QPlainTextEdit::getPaintContext() const | - | ||||||||||||||||||||||||
2223 | { | - | ||||||||||||||||||||||||
2224 | const QPlainTextEditPrivate * const d = d_func(); | - | ||||||||||||||||||||||||
2225 | return never executed: d->control->getPaintContext(d->viewport);return d->control->getPaintContext(d->viewport); never executed: return d->control->getPaintContext(d->viewport); | 0 | ||||||||||||||||||||||||
2226 | } | - | ||||||||||||||||||||||||
2227 | - | |||||||||||||||||||||||||
2228 | - | |||||||||||||||||||||||||
Switch to Source code | Preprocessed file |