Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "qtextedit_p.h" | - |
43 | #include "qlineedit.h" | - |
44 | #include "qtextbrowser.h" | - |
45 | | - |
46 | #ifndef QT_NO_TEXTEDIT | - |
47 | #include <qfont.h> | - |
48 | #include <qpainter.h> | - |
49 | #include <qevent.h> | - |
50 | #include <qdebug.h> | - |
51 | #include <qdrag.h> | - |
52 | #include <qclipboard.h> | - |
53 | #include <qmenu.h> | - |
54 | #include <qstyle.h> | - |
55 | #include <qtimer.h> | - |
56 | #ifndef QT_NO_ACCESSIBILITY | - |
57 | #include <qaccessible.h> | - |
58 | #endif | - |
59 | #include "private/qtextdocumentlayout_p.h" | - |
60 | #include "qtextdocument.h" | - |
61 | #include "private/qtextdocument_p.h" | - |
62 | #include "qtextlist.h" | - |
63 | #include "private/qwidgettextcontrol_p.h" | - |
64 | | - |
65 | #include <qtextformat.h> | - |
66 | #include <qdatetime.h> | - |
67 | #include <qapplication.h> | - |
68 | #include <limits.h> | - |
69 | #include <qtexttable.h> | - |
70 | #include <qvariant.h> | - |
71 | | - |
72 | #endif | - |
73 | | - |
74 | QT_BEGIN_NAMESPACE | - |
75 | | - |
76 | | - |
77 | #ifndef QT_NO_TEXTEDIT | - |
78 | static inline bool shouldEnableInputMethod(QTextEdit *textedit) | - |
79 | { | - |
80 | return !textedit->isReadOnly(); executed: return !textedit->isReadOnly(); Execution Count:7 | 7 |
81 | } | - |
82 | | - |
83 | class QTextEditControl : public QWidgetTextControl | - |
84 | { | - |
85 | public: | - |
86 | inline QTextEditControl(QObject *parent) : QWidgetTextControl(parent) {} executed: } Execution Count:77 | 77 |
87 | | - |
88 | virtual QMimeData *createMimeDataFromSelection() const { | - |
89 | QTextEdit *ed = qobject_cast<QTextEdit *>(parent()); never executed (the execution status of this line is deduced): QTextEdit *ed = qobject_cast<QTextEdit *>(parent()); | - |
90 | if (!ed) | 0 |
91 | return QWidgetTextControl::createMimeDataFromSelection(); never executed: return QWidgetTextControl::createMimeDataFromSelection(); | 0 |
92 | return ed->createMimeDataFromSelection(); never executed: return ed->createMimeDataFromSelection(); | 0 |
93 | } | - |
94 | virtual bool canInsertFromMimeData(const QMimeData *source) const { | - |
95 | QTextEdit *ed = qobject_cast<QTextEdit *>(parent()); never executed (the execution status of this line is deduced): QTextEdit *ed = qobject_cast<QTextEdit *>(parent()); | - |
96 | if (!ed) | 0 |
97 | return QWidgetTextControl::canInsertFromMimeData(source); never executed: return QWidgetTextControl::canInsertFromMimeData(source); | 0 |
98 | return ed->canInsertFromMimeData(source); never executed: return ed->canInsertFromMimeData(source); | 0 |
99 | } | - |
100 | virtual void insertFromMimeData(const QMimeData *source) { | - |
101 | QTextEdit *ed = qobject_cast<QTextEdit *>(parent()); never executed (the execution status of this line is deduced): QTextEdit *ed = qobject_cast<QTextEdit *>(parent()); | - |
102 | if (!ed) | 0 |
103 | QWidgetTextControl::insertFromMimeData(source); never executed: QWidgetTextControl::insertFromMimeData(source); | 0 |
104 | else | - |
105 | ed->insertFromMimeData(source); never executed: ed->insertFromMimeData(source); | 0 |
106 | } | - |
107 | }; | - |
108 | | - |
109 | QTextEditPrivate::QTextEditPrivate() | - |
110 | : control(0), | - |
111 | autoFormatting(QTextEdit::AutoNone), tabChangesFocus(false), | - |
112 | lineWrap(QTextEdit::WidgetWidth), lineWrapColumnOrWidth(0), | - |
113 | wordWrap(QTextOption::WrapAtWordBoundaryOrAnywhere), clickCausedFocus(0), | - |
114 | textFormat(Qt::AutoText) | - |
115 | { | - |
116 | ignoreAutomaticScrollbarAdjustment = false; executed (the execution status of this line is deduced): ignoreAutomaticScrollbarAdjustment = false; | - |
117 | preferRichText = false; executed (the execution status of this line is deduced): preferRichText = false; | - |
118 | showCursorOnInitialShow = true; executed (the execution status of this line is deduced): showCursorOnInitialShow = true; | - |
119 | inDrag = false; executed (the execution status of this line is deduced): inDrag = false; | - |
120 | } executed: } Execution Count:77 | 77 |
121 | | - |
122 | void QTextEditPrivate::createAutoBulletList() | - |
123 | { | - |
124 | QTextCursor cursor = control->textCursor(); never executed (the execution status of this line is deduced): QTextCursor cursor = control->textCursor(); | - |
125 | cursor.beginEditBlock(); never executed (the execution status of this line is deduced): cursor.beginEditBlock(); | - |
126 | | - |
127 | QTextBlockFormat blockFmt = cursor.blockFormat(); never executed (the execution status of this line is deduced): QTextBlockFormat blockFmt = cursor.blockFormat(); | - |
128 | | - |
129 | QTextListFormat listFmt; never executed (the execution status of this line is deduced): QTextListFormat listFmt; | - |
130 | listFmt.setStyle(QTextListFormat::ListDisc); never executed (the execution status of this line is deduced): listFmt.setStyle(QTextListFormat::ListDisc); | - |
131 | listFmt.setIndent(blockFmt.indent() + 1); never executed (the execution status of this line is deduced): listFmt.setIndent(blockFmt.indent() + 1); | - |
132 | | - |
133 | blockFmt.setIndent(0); never executed (the execution status of this line is deduced): blockFmt.setIndent(0); | - |
134 | cursor.setBlockFormat(blockFmt); never executed (the execution status of this line is deduced): cursor.setBlockFormat(blockFmt); | - |
135 | | - |
136 | cursor.createList(listFmt); never executed (the execution status of this line is deduced): cursor.createList(listFmt); | - |
137 | | - |
138 | cursor.endEditBlock(); never executed (the execution status of this line is deduced): cursor.endEditBlock(); | - |
139 | control->setTextCursor(cursor); never executed (the execution status of this line is deduced): control->setTextCursor(cursor); | - |
140 | } | 0 |
141 | | - |
142 | void QTextEditPrivate::init(const QString &html) | - |
143 | { | - |
144 | Q_Q(QTextEdit); executed (the execution status of this line is deduced): QTextEdit * const q = q_func(); | - |
145 | control = new QTextEditControl(q); executed (the execution status of this line is deduced): control = new QTextEditControl(q); | - |
146 | control->setPalette(q->palette()); executed (the execution status of this line is deduced): control->setPalette(q->palette()); | - |
147 | | - |
148 | QObject::connect(control, SIGNAL(microFocusChanged()), q, SLOT(updateMicroFocus())); executed (the execution status of this line is deduced): QObject::connect(control, "2""microFocusChanged()", q, "1""updateMicroFocus()"); | - |
149 | QObject::connect(control, SIGNAL(documentSizeChanged(QSizeF)), q, SLOT(_q_adjustScrollbars())); executed (the execution status of this line is deduced): QObject::connect(control, "2""documentSizeChanged(QSizeF)", q, "1""_q_adjustScrollbars()"); | - |
150 | QObject::connect(control, SIGNAL(updateRequest(QRectF)), q, SLOT(_q_repaintContents(QRectF))); executed (the execution status of this line is deduced): QObject::connect(control, "2""updateRequest(QRectF)", q, "1""_q_repaintContents(QRectF)"); | - |
151 | QObject::connect(control, SIGNAL(visibilityRequest(QRectF)), q, SLOT(_q_ensureVisible(QRectF))); executed (the execution status of this line is deduced): QObject::connect(control, "2""visibilityRequest(QRectF)", q, "1""_q_ensureVisible(QRectF)"); | - |
152 | QObject::connect(control, SIGNAL(currentCharFormatChanged(QTextCharFormat)), executed (the execution status of this line is deduced): QObject::connect(control, "2""currentCharFormatChanged(QTextCharFormat)", | - |
153 | q, SLOT(_q_currentCharFormatChanged(QTextCharFormat))); executed (the execution status of this line is deduced): q, "1""_q_currentCharFormatChanged(QTextCharFormat)"); | - |
154 | | - |
155 | QObject::connect(control, SIGNAL(textChanged()), q, SIGNAL(textChanged())); executed (the execution status of this line is deduced): QObject::connect(control, "2""textChanged()", q, "2""textChanged()"); | - |
156 | QObject::connect(control, SIGNAL(undoAvailable(bool)), q, SIGNAL(undoAvailable(bool))); executed (the execution status of this line is deduced): QObject::connect(control, "2""undoAvailable(bool)", q, "2""undoAvailable(bool)"); | - |
157 | QObject::connect(control, SIGNAL(redoAvailable(bool)), q, SIGNAL(redoAvailable(bool))); executed (the execution status of this line is deduced): QObject::connect(control, "2""redoAvailable(bool)", q, "2""redoAvailable(bool)"); | - |
158 | QObject::connect(control, SIGNAL(copyAvailable(bool)), q, SIGNAL(copyAvailable(bool))); executed (the execution status of this line is deduced): QObject::connect(control, "2""copyAvailable(bool)", q, "2""copyAvailable(bool)"); | - |
159 | QObject::connect(control, SIGNAL(selectionChanged()), q, SIGNAL(selectionChanged())); executed (the execution status of this line is deduced): QObject::connect(control, "2""selectionChanged()", q, "2""selectionChanged()"); | - |
160 | QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SLOT(_q_cursorPositionChanged())); executed (the execution status of this line is deduced): QObject::connect(control, "2""cursorPositionChanged()", q, "1""_q_cursorPositionChanged()"); | - |
161 | | - |
162 | QObject::connect(control, SIGNAL(textChanged()), q, SLOT(updateMicroFocus())); executed (the execution status of this line is deduced): QObject::connect(control, "2""textChanged()", q, "1""updateMicroFocus()"); | - |
163 | | - |
164 | QTextDocument *doc = control->document(); executed (the execution status of this line is deduced): QTextDocument *doc = control->document(); | - |
165 | // set a null page size initially to avoid any relayouting until the textedit | - |
166 | // is shown. relayoutDocument() will take care of setting the page size to the | - |
167 | // viewport dimensions later. | - |
168 | doc->setPageSize(QSize(0, 0)); executed (the execution status of this line is deduced): doc->setPageSize(QSize(0, 0)); | - |
169 | doc->documentLayout()->setPaintDevice(viewport); executed (the execution status of this line is deduced): doc->documentLayout()->setPaintDevice(viewport); | - |
170 | doc->setDefaultFont(q->font()); executed (the execution status of this line is deduced): doc->setDefaultFont(q->font()); | - |
171 | doc->setUndoRedoEnabled(false); // flush undo buffer. executed (the execution status of this line is deduced): doc->setUndoRedoEnabled(false); | - |
172 | doc->setUndoRedoEnabled(true); executed (the execution status of this line is deduced): doc->setUndoRedoEnabled(true); | - |
173 | | - |
174 | if (!html.isEmpty()) evaluated: !html.isEmpty() yes Evaluation Count:6 | yes Evaluation Count:71 |
| 6-71 |
175 | control->setHtml(html); executed: control->setHtml(html); Execution Count:6 | 6 |
176 | | - |
177 | hbar->setSingleStep(20); executed (the execution status of this line is deduced): hbar->setSingleStep(20); | - |
178 | vbar->setSingleStep(20); executed (the execution status of this line is deduced): vbar->setSingleStep(20); | - |
179 | | - |
180 | viewport->setBackgroundRole(QPalette::Base); executed (the execution status of this line is deduced): viewport->setBackgroundRole(QPalette::Base); | - |
181 | q->setAcceptDrops(true); executed (the execution status of this line is deduced): q->setAcceptDrops(true); | - |
182 | q->setFocusPolicy(Qt::WheelFocus); executed (the execution status of this line is deduced): q->setFocusPolicy(Qt::WheelFocus); | - |
183 | q->setAttribute(Qt::WA_KeyCompression); executed (the execution status of this line is deduced): q->setAttribute(Qt::WA_KeyCompression); | - |
184 | q->setAttribute(Qt::WA_InputMethodEnabled); executed (the execution status of this line is deduced): q->setAttribute(Qt::WA_InputMethodEnabled); | - |
185 | | - |
186 | #ifndef QT_NO_CURSOR | - |
187 | viewport->setCursor(Qt::IBeamCursor); executed (the execution status of this line is deduced): viewport->setCursor(Qt::IBeamCursor); | - |
188 | #endif | - |
189 | #ifdef Q_WS_WIN | - |
190 | setSingleFingerPanEnabled(true); | - |
191 | #endif | - |
192 | } executed: } Execution Count:77 | 77 |
193 | | - |
194 | void QTextEditPrivate::_q_repaintContents(const QRectF &contentsRect) | - |
195 | { | - |
196 | if (!contentsRect.isValid()) { evaluated: !contentsRect.isValid() yes Evaluation Count:2 | yes Evaluation Count:590 |
| 2-590 |
197 | viewport->update(); executed (the execution status of this line is deduced): viewport->update(); | - |
198 | return; executed: return; Execution Count:2 | 2 |
199 | } | - |
200 | const int xOffset = horizontalOffset(); executed (the execution status of this line is deduced): const int xOffset = horizontalOffset(); | - |
201 | const int yOffset = verticalOffset(); executed (the execution status of this line is deduced): const int yOffset = verticalOffset(); | - |
202 | const QRectF visibleRect(xOffset, yOffset, viewport->width(), viewport->height()); executed (the execution status of this line is deduced): const QRectF visibleRect(xOffset, yOffset, viewport->width(), viewport->height()); | - |
203 | | - |
204 | QRect r = contentsRect.intersected(visibleRect).toAlignedRect(); executed (the execution status of this line is deduced): QRect r = contentsRect.intersected(visibleRect).toAlignedRect(); | - |
205 | if (r.isEmpty()) evaluated: r.isEmpty() yes Evaluation Count:2 | yes Evaluation Count:588 |
| 2-588 |
206 | return; executed: return; Execution Count:2 | 2 |
207 | | - |
208 | r.translate(-xOffset, -yOffset); executed (the execution status of this line is deduced): r.translate(-xOffset, -yOffset); | - |
209 | viewport->update(r); executed (the execution status of this line is deduced): viewport->update(r); | - |
210 | } executed: } Execution Count:588 | 588 |
211 | | - |
212 | void QTextEditPrivate::_q_cursorPositionChanged() | - |
213 | { | - |
214 | Q_Q(QTextEdit); executed (the execution status of this line is deduced): QTextEdit * const q = q_func(); | - |
215 | emit q->cursorPositionChanged(); executed (the execution status of this line is deduced): q->cursorPositionChanged(); | - |
216 | #ifndef QT_NO_ACCESSIBILITY | - |
217 | QAccessibleTextCursorEvent event(q, q->textCursor().position()); executed (the execution status of this line is deduced): QAccessibleTextCursorEvent event(q, q->textCursor().position()); | - |
218 | QAccessible::updateAccessibility(&event); executed (the execution status of this line is deduced): QAccessible::updateAccessibility(&event); | - |
219 | #endif | - |
220 | } executed: } Execution Count:115 | 115 |
221 | | - |
222 | void QTextEditPrivate::pageUpDown(QTextCursor::MoveOperation op, QTextCursor::MoveMode moveMode) | - |
223 | { | - |
224 | QTextCursor cursor = control->textCursor(); never executed (the execution status of this line is deduced): QTextCursor cursor = control->textCursor(); | - |
225 | bool moved = false; never executed (the execution status of this line is deduced): bool moved = false; | - |
226 | qreal lastY = control->cursorRect(cursor).top(); never executed (the execution status of this line is deduced): qreal lastY = control->cursorRect(cursor).top(); | - |
227 | qreal distance = 0; never executed (the execution status of this line is deduced): qreal distance = 0; | - |
228 | // move using movePosition to keep the cursor's x | - |
229 | do { | - |
230 | qreal y = control->cursorRect(cursor).top(); never executed (the execution status of this line is deduced): qreal y = control->cursorRect(cursor).top(); | - |
231 | distance += qAbs(y - lastY); never executed (the execution status of this line is deduced): distance += qAbs(y - lastY); | - |
232 | lastY = y; never executed (the execution status of this line is deduced): lastY = y; | - |
233 | moved = cursor.movePosition(op, moveMode); never executed (the execution status of this line is deduced): moved = cursor.movePosition(op, moveMode); | - |
234 | } while (moved && distance < viewport->height()); never executed: } never evaluated: moved never evaluated: distance < viewport->height() | 0 |
235 | | - |
236 | if (moved) { | 0 |
237 | if (op == QTextCursor::Up) { never evaluated: op == QTextCursor::Up | 0 |
238 | cursor.movePosition(QTextCursor::Down, moveMode); never executed (the execution status of this line is deduced): cursor.movePosition(QTextCursor::Down, moveMode); | - |
239 | vbar->triggerAction(QAbstractSlider::SliderPageStepSub); never executed (the execution status of this line is deduced): vbar->triggerAction(QAbstractSlider::SliderPageStepSub); | - |
240 | } else { | 0 |
241 | cursor.movePosition(QTextCursor::Up, moveMode); never executed (the execution status of this line is deduced): cursor.movePosition(QTextCursor::Up, moveMode); | - |
242 | vbar->triggerAction(QAbstractSlider::SliderPageStepAdd); never executed (the execution status of this line is deduced): vbar->triggerAction(QAbstractSlider::SliderPageStepAdd); | - |
243 | } | 0 |
244 | } | - |
245 | control->setTextCursor(cursor); never executed (the execution status of this line is deduced): control->setTextCursor(cursor); | - |
246 | } | 0 |
247 | | - |
248 | #ifndef QT_NO_SCROLLBAR | - |
249 | static QSize documentSize(QWidgetTextControl *control) | - |
250 | { | - |
251 | QTextDocument *doc = control->document(); executed (the execution status of this line is deduced): QTextDocument *doc = control->document(); | - |
252 | QAbstractTextDocumentLayout *layout = doc->documentLayout(); executed (the execution status of this line is deduced): QAbstractTextDocumentLayout *layout = doc->documentLayout(); | - |
253 | | - |
254 | QSize docSize; executed (the execution status of this line is deduced): QSize docSize; | - |
255 | | - |
256 | if (QTextDocumentLayout *tlayout = qobject_cast<QTextDocumentLayout *>(layout)) { partially evaluated: QTextDocumentLayout *tlayout = qobject_cast<QTextDocumentLayout *>(layout) yes Evaluation Count:429 | no Evaluation Count:0 |
| 0-429 |
257 | docSize = tlayout->dynamicDocumentSize().toSize(); executed (the execution status of this line is deduced): docSize = tlayout->dynamicDocumentSize().toSize(); | - |
258 | int percentageDone = tlayout->layoutStatus(); executed (the execution status of this line is deduced): int percentageDone = tlayout->layoutStatus(); | - |
259 | // extrapolate height | - |
260 | if (percentageDone > 0) partially evaluated: percentageDone > 0 yes Evaluation Count:429 | no Evaluation Count:0 |
| 0-429 |
261 | docSize.setHeight(docSize.height() * 100 / percentageDone); executed: docSize.setHeight(docSize.height() * 100 / percentageDone); Execution Count:429 | 429 |
262 | } else { executed: } Execution Count:429 | 429 |
263 | docSize = layout->documentSize().toSize(); never executed (the execution status of this line is deduced): docSize = layout->documentSize().toSize(); | - |
264 | } | 0 |
265 | | - |
266 | return docSize; executed: return docSize; Execution Count:429 | 429 |
267 | } | - |
268 | | - |
269 | void QTextEditPrivate::_q_adjustScrollbars() | - |
270 | { | - |
271 | if (ignoreAutomaticScrollbarAdjustment) evaluated: ignoreAutomaticScrollbarAdjustment yes Evaluation Count:161 | yes Evaluation Count:207 |
| 161-207 |
272 | return; executed: return; Execution Count:161 | 161 |
273 | ignoreAutomaticScrollbarAdjustment = true; // avoid recursion, #106108 executed (the execution status of this line is deduced): ignoreAutomaticScrollbarAdjustment = true; | - |
274 | | - |
275 | QSize viewportSize = viewport->size(); executed (the execution status of this line is deduced): QSize viewportSize = viewport->size(); | - |
276 | QSize docSize = documentSize(control); executed (the execution status of this line is deduced): QSize docSize = documentSize(control); | - |
277 | | - |
278 | // due to the recursion guard we have to repeat this step a few times, | - |
279 | // as adding/removing a scroll bar will cause the document or viewport | - |
280 | // size to change | - |
281 | // ideally we should loop until the viewport size and doc size stabilize, | - |
282 | // but in corner cases they might fluctuate, so we need to limit the | - |
283 | // number of iterations | - |
284 | for (int i = 0; i < 4; ++i) { partially evaluated: i < 4 yes Evaluation Count:222 | no Evaluation Count:0 |
| 0-222 |
285 | hbar->setRange(0, docSize.width() - viewportSize.width()); executed (the execution status of this line is deduced): hbar->setRange(0, docSize.width() - viewportSize.width()); | - |
286 | hbar->setPageStep(viewportSize.width()); executed (the execution status of this line is deduced): hbar->setPageStep(viewportSize.width()); | - |
287 | | - |
288 | vbar->setRange(0, docSize.height() - viewportSize.height()); executed (the execution status of this line is deduced): vbar->setRange(0, docSize.height() - viewportSize.height()); | - |
289 | vbar->setPageStep(viewportSize.height()); executed (the execution status of this line is deduced): vbar->setPageStep(viewportSize.height()); | - |
290 | | - |
291 | // if we are in left-to-right mode widening the document due to | - |
292 | // lazy layouting does not require a repaint. If in right-to-left | - |
293 | // the scroll bar has the value zero and it visually has the maximum | - |
294 | // value (it is visually at the right), then widening the document | - |
295 | // keeps it at value zero but visually adjusts it to the new maximum | - |
296 | // on the right, hence we need an update. | - |
297 | if (q_func()->isRightToLeft()) partially evaluated: q_func()->isRightToLeft() no Evaluation Count:0 | yes Evaluation Count:222 |
| 0-222 |
298 | viewport->update(); never executed: viewport->update(); | 0 |
299 | | - |
300 | _q_showOrHideScrollBars(); executed (the execution status of this line is deduced): _q_showOrHideScrollBars(); | - |
301 | | - |
302 | const QSize oldViewportSize = viewportSize; executed (the execution status of this line is deduced): const QSize oldViewportSize = viewportSize; | - |
303 | const QSize oldDocSize = docSize; executed (the execution status of this line is deduced): const QSize oldDocSize = docSize; | - |
304 | | - |
305 | // make sure the document is layouted if the viewport width changes | - |
306 | viewportSize = viewport->size(); executed (the execution status of this line is deduced): viewportSize = viewport->size(); | - |
307 | if (viewportSize.width() != oldViewportSize.width()) evaluated: viewportSize.width() != oldViewportSize.width() yes Evaluation Count:15 | yes Evaluation Count:207 |
| 15-207 |
308 | relayoutDocument(); executed: relayoutDocument(); Execution Count:15 | 15 |
309 | | - |
310 | docSize = documentSize(control); executed (the execution status of this line is deduced): docSize = documentSize(control); | - |
311 | if (viewportSize == oldViewportSize && docSize == oldDocSize) evaluated: viewportSize == oldViewportSize yes Evaluation Count:207 | yes Evaluation Count:15 |
partially evaluated: docSize == oldDocSize yes Evaluation Count:207 | no Evaluation Count:0 |
| 0-207 |
312 | break; executed: break; Execution Count:207 | 207 |
313 | } executed: } Execution Count:15 | 15 |
314 | ignoreAutomaticScrollbarAdjustment = false; executed (the execution status of this line is deduced): ignoreAutomaticScrollbarAdjustment = false; | - |
315 | } executed: } Execution Count:207 | 207 |
316 | #endif | - |
317 | | - |
318 | // rect is in content coordinates | - |
319 | void QTextEditPrivate::_q_ensureVisible(const QRectF &_rect) | - |
320 | { | - |
321 | const QRect rect = _rect.toRect(); executed (the execution status of this line is deduced): const QRect rect = _rect.toRect(); | - |
322 | if ((vbar->isVisible() && vbar->maximum() < rect.bottom()) evaluated: vbar->isVisible() yes Evaluation Count:12 | yes Evaluation Count:181 |
evaluated: vbar->maximum() < rect.bottom() yes Evaluation Count:2 | yes Evaluation Count:10 |
| 2-181 |
323 | || (hbar->isVisible() && hbar->maximum() < rect.right())) evaluated: hbar->isVisible() yes Evaluation Count:2 | yes Evaluation Count:189 |
partially evaluated: hbar->maximum() < rect.right() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-189 |
324 | _q_adjustScrollbars(); executed: _q_adjustScrollbars(); Execution Count:4 | 4 |
325 | const int visibleWidth = viewport->width(); executed (the execution status of this line is deduced): const int visibleWidth = viewport->width(); | - |
326 | const int visibleHeight = viewport->height(); executed (the execution status of this line is deduced): const int visibleHeight = viewport->height(); | - |
327 | const bool rtl = q_func()->isRightToLeft(); executed (the execution status of this line is deduced): const bool rtl = q_func()->isRightToLeft(); | - |
328 | | - |
329 | if (rect.x() < horizontalOffset()) { evaluated: rect.x() < horizontalOffset() yes Evaluation Count:167 | yes Evaluation Count:26 |
| 26-167 |
330 | if (rtl) partially evaluated: rtl no Evaluation Count:0 | yes Evaluation Count:167 |
| 0-167 |
331 | hbar->setValue(hbar->maximum() - rect.x()); never executed: hbar->setValue(hbar->maximum() - rect.x()); | 0 |
332 | else | - |
333 | hbar->setValue(rect.x()); executed: hbar->setValue(rect.x()); Execution Count:167 | 167 |
334 | } else if (rect.x() + rect.width() > horizontalOffset() + visibleWidth) { partially evaluated: rect.x() + rect.width() > horizontalOffset() + visibleWidth no Evaluation Count:0 | yes Evaluation Count:26 |
| 0-26 |
335 | if (rtl) | 0 |
336 | hbar->setValue(hbar->maximum() - (rect.x() + rect.width() - visibleWidth)); never executed: hbar->setValue(hbar->maximum() - (rect.x() + rect.width() - visibleWidth)); | 0 |
337 | else | - |
338 | hbar->setValue(rect.x() + rect.width() - visibleWidth); never executed: hbar->setValue(rect.x() + rect.width() - visibleWidth); | 0 |
339 | } | - |
340 | | - |
341 | if (rect.y() < verticalOffset()) partially evaluated: rect.y() < verticalOffset() no Evaluation Count:0 | yes Evaluation Count:193 |
| 0-193 |
342 | vbar->setValue(rect.y()); never executed: vbar->setValue(rect.y()); | 0 |
343 | else if (rect.y() + rect.height() > verticalOffset() + visibleHeight) evaluated: rect.y() + rect.height() > verticalOffset() + visibleHeight yes Evaluation Count:4 | yes Evaluation Count:189 |
| 4-189 |
344 | vbar->setValue(rect.y() + rect.height() - visibleHeight); executed: vbar->setValue(rect.y() + rect.height() - visibleHeight); Execution Count:4 | 4 |
345 | } | - |
346 | | - |
347 | /*! | - |
348 | \class QTextEdit | - |
349 | \brief The QTextEdit class provides a widget that is used to edit and display | - |
350 | both plain and rich text. | - |
351 | | - |
352 | \ingroup richtext-processing | - |
353 | \inmodule QtWidgets | - |
354 | | - |
355 | \tableofcontents | - |
356 | | - |
357 | \section1 Introduction and Concepts | - |
358 | | - |
359 | QTextEdit is an advanced WYSIWYG viewer/editor supporting rich | - |
360 | text formatting using HTML-style tags. It is optimized to handle | - |
361 | large documents and to respond quickly to user input. | - |
362 | | - |
363 | QTextEdit works on paragraphs and characters. A paragraph is a | - |
364 | formatted string which is word-wrapped to fit into the width of | - |
365 | the widget. By default when reading plain text, one newline | - |
366 | signifies a paragraph. A document consists of zero or more | - |
367 | paragraphs. The words in the paragraph are aligned in accordance | - |
368 | with the paragraph's alignment. Paragraphs are separated by hard | - |
369 | line breaks. Each character within a paragraph has its own | - |
370 | attributes, for example, font and color. | - |
371 | | - |
372 | QTextEdit can display images, lists and tables. If the text is | - |
373 | too large to view within the text edit's viewport, scroll bars will | - |
374 | appear. The text edit can load both plain text and rich text files. | - |
375 | Rich text is described using a subset of HTML 4 markup, refer to the | - |
376 | \l {Supported HTML Subset} page for more information. | - |
377 | | - |
378 | If you just need to display a small piece of rich text use QLabel. | - |
379 | | - |
380 | The rich text support in Qt is designed to provide a fast, portable and | - |
381 | efficient way to add reasonable online help facilities to | - |
382 | applications, and to provide a basis for rich text editors. If | - |
383 | you find the HTML support insufficient for your needs you may consider | - |
384 | the use of Qt WebKit, which provides a full-featured web browser | - |
385 | widget. | - |
386 | | - |
387 | The shape of the mouse cursor on a QTextEdit is Qt::IBeamCursor by default. | - |
388 | It can be changed through the viewport()'s cursor property. | - |
389 | | - |
390 | \section1 Using QTextEdit as a Display Widget | - |
391 | | - |
392 | QTextEdit can display a large HTML subset, including tables and | - |
393 | images. | - |
394 | | - |
395 | The text is set or replaced using setHtml() which deletes any | - |
396 | existing text and replaces it with the text passed in the | - |
397 | setHtml() call. If you call setHtml() with legacy HTML, and then | - |
398 | call toHtml(), the text that is returned may have different markup, | - |
399 | but will render the same. The entire text can be deleted with clear(). | - |
400 | | - |
401 | Text itself can be inserted using the QTextCursor class or using the | - |
402 | convenience functions insertHtml(), insertPlainText(), append() or | - |
403 | paste(). QTextCursor is also able to insert complex objects like tables | - |
404 | or lists into the document, and it deals with creating selections | - |
405 | and applying changes to selected text. | - |
406 | | - |
407 | By default the text edit wraps words at whitespace to fit within | - |
408 | the text edit widget. The setLineWrapMode() function is used to | - |
409 | specify the kind of line wrap you want, or \l NoWrap if you don't | - |
410 | want any wrapping. Call setLineWrapMode() to set a fixed pixel width | - |
411 | \l FixedPixelWidth, or character column (e.g. 80 column) \l | - |
412 | FixedColumnWidth with the pixels or columns specified with | - |
413 | setLineWrapColumnOrWidth(). If you use word wrap to the widget's width | - |
414 | \l WidgetWidth, you can specify whether to break on whitespace or | - |
415 | anywhere with setWordWrapMode(). | - |
416 | | - |
417 | The find() function can be used to find and select a given string | - |
418 | within the text. | - |
419 | | - |
420 | If you want to limit the total number of paragraphs in a QTextEdit, | - |
421 | as for example it is often useful in a log viewer, then you can use | - |
422 | QTextDocument's maximumBlockCount property for that. | - |
423 | | - |
424 | \section2 Read-only Key Bindings | - |
425 | | - |
426 | When QTextEdit is used read-only the key bindings are limited to | - |
427 | navigation, and text may only be selected with the mouse: | - |
428 | \table | - |
429 | \header \li Keypresses \li Action | - |
430 | \row \li Up \li Moves one line up. | - |
431 | \row \li Down \li Moves one line down. | - |
432 | \row \li Left \li Moves one character to the left. | - |
433 | \row \li Right \li Moves one character to the right. | - |
434 | \row \li PageUp \li Moves one (viewport) page up. | - |
435 | \row \li PageDown \li Moves one (viewport) page down. | - |
436 | \row \li Home \li Moves to the beginning of the text. | - |
437 | \row \li End \li Moves to the end of the text. | - |
438 | \row \li Alt+Wheel | - |
439 | \li Scrolls the page horizontally (the Wheel is the mouse wheel). | - |
440 | \row \li Ctrl+Wheel \li Zooms the text. | - |
441 | \row \li Ctrl+A \li Selects all text. | - |
442 | \endtable | - |
443 | | - |
444 | The text edit may be able to provide some meta-information. For | - |
445 | example, the documentTitle() function will return the text from | - |
446 | within HTML \c{<title>} tags. | - |
447 | | - |
448 | \section1 Using QTextEdit as an Editor | - |
449 | | - |
450 | All the information about using QTextEdit as a display widget also | - |
451 | applies here. | - |
452 | | - |
453 | The current char format's attributes are set with setFontItalic(), | - |
454 | setFontWeight(), setFontUnderline(), setFontFamily(), | - |
455 | setFontPointSize(), setTextColor() and setCurrentFont(). The current | - |
456 | paragraph's alignment is set with setAlignment(). | - |
457 | | - |
458 | Selection of text is handled by the QTextCursor class, which provides | - |
459 | functionality for creating selections, retrieving the text contents or | - |
460 | deleting selections. You can retrieve the object that corresponds with | - |
461 | the user-visible cursor using the textCursor() method. If you want to set | - |
462 | a selection in QTextEdit just create one on a QTextCursor object and | - |
463 | then make that cursor the visible cursor using setTextCursor(). The selection | - |
464 | can be copied to the clipboard with copy(), or cut to the clipboard with | - |
465 | cut(). The entire text can be selected using selectAll(). | - |
466 | | - |
467 | When the cursor is moved and the underlying formatting attributes change, | - |
468 | the currentCharFormatChanged() signal is emitted to reflect the new attributes | - |
469 | at the new cursor position. | - |
470 | | - |
471 | The textChanged() signal is emitted whenever the text changes (as a result | - |
472 | of setText() or through the editor itself). | - |
473 | | - |
474 | QTextEdit holds a QTextDocument object which can be retrieved using the | - |
475 | document() method. You can also set your own document object using setDocument(). | - |
476 | | - |
477 | QTextDocument provides an \l {QTextDocument::isModified()}{isModified()} | - |
478 | function which will return true if the text has been modified since it was | - |
479 | either loaded or since the last call to setModified with false as argument. | - |
480 | In addition it provides methods for undo and redo. | - |
481 | | - |
482 | \section2 Drag and Drop | - |
483 | | - |
484 | QTextEdit also supports custom drag and drop behavior. By default, | - |
485 | QTextEdit will insert plain text, HTML and rich text when the user drops | - |
486 | data of these MIME types onto a document. Reimplement | - |
487 | canInsertFromMimeData() and insertFromMimeData() to add support for | - |
488 | additional MIME types. | - |
489 | | - |
490 | For example, to allow the user to drag and drop an image onto a QTextEdit, | - |
491 | you could the implement these functions in the following way: | - |
492 | | - |
493 | \snippet textdocument-imagedrop/textedit.cpp 0 | - |
494 | | - |
495 | We add support for image MIME types by returning true. For all other | - |
496 | MIME types, we use the default implementation. | - |
497 | | - |
498 | \snippet textdocument-imagedrop/textedit.cpp 1 | - |
499 | | - |
500 | We unpack the image from the QVariant held by the MIME source and insert | - |
501 | it into the document as a resource. | - |
502 | | - |
503 | \section2 Editing Key Bindings | - |
504 | | - |
505 | The list of key bindings which are implemented for editing: | - |
506 | \table | - |
507 | \header \li Keypresses \li Action | - |
508 | \row \li Backspace \li Deletes the character to the left of the cursor. | - |
509 | \row \li Delete \li Deletes the character to the right of the cursor. | - |
510 | \row \li Ctrl+C \li Copy the selected text to the clipboard. | - |
511 | \row \li Ctrl+Insert \li Copy the selected text to the clipboard. | - |
512 | \row \li Ctrl+K \li Deletes to the end of the line. | - |
513 | \row \li Ctrl+V \li Pastes the clipboard text into text edit. | - |
514 | \row \li Shift+Insert \li Pastes the clipboard text into text edit. | - |
515 | \row \li Ctrl+X \li Deletes the selected text and copies it to the clipboard. | - |
516 | \row \li Shift+Delete \li Deletes the selected text and copies it to the clipboard. | - |
517 | \row \li Ctrl+Z \li Undoes the last operation. | - |
518 | \row \li Ctrl+Y \li Redoes the last operation. | - |
519 | \row \li Left \li Moves the cursor one character to the left. | - |
520 | \row \li Ctrl+Left \li Moves the cursor one word to the left. | - |
521 | \row \li Right \li Moves the cursor one character to the right. | - |
522 | \row \li Ctrl+Right \li Moves the cursor one word to the right. | - |
523 | \row \li Up \li Moves the cursor one line up. | - |
524 | \row \li Down \li Moves the cursor one line down. | - |
525 | \row \li PageUp \li Moves the cursor one page up. | - |
526 | \row \li PageDown \li Moves the cursor one page down. | - |
527 | \row \li Home \li Moves the cursor to the beginning of the line. | - |
528 | \row \li Ctrl+Home \li Moves the cursor to the beginning of the text. | - |
529 | \row \li End \li Moves the cursor to the end of the line. | - |
530 | \row \li Ctrl+End \li Moves the cursor to the end of the text. | - |
531 | \row \li Alt+Wheel \li Scrolls the page horizontally (the Wheel is the mouse wheel). | - |
532 | \endtable | - |
533 | | - |
534 | To select (mark) text hold down the Shift key whilst pressing one | - |
535 | of the movement keystrokes, for example, \e{Shift+Right} | - |
536 | will select the character to the right, and \e{Shift+Ctrl+Right} will select the word to the right, etc. | - |
537 | | - |
538 | \sa QTextDocument, QTextCursor, {Application Example}, | - |
539 | {Syntax Highlighter Example}, {Rich Text Processing} | - |
540 | */ | - |
541 | | - |
542 | /*! | - |
543 | \property QTextEdit::plainText | - |
544 | \since 4.3 | - |
545 | | - |
546 | This property gets and sets the text editor's contents as plain | - |
547 | text. Previous contents are removed and undo/redo history is reset | - |
548 | when the property is set. | - |
549 | | - |
550 | If the text edit has another content type, it will not be replaced | - |
551 | by plain text if you call toPlainText(). The only exception to this | - |
552 | is the non-break space, \e{nbsp;}, that will be converted into | - |
553 | standard space. | - |
554 | | - |
555 | By default, for an editor with no contents, this property contains | - |
556 | an empty string. | - |
557 | | - |
558 | \sa html | - |
559 | */ | - |
560 | | - |
561 | /*! | - |
562 | \property QTextEdit::undoRedoEnabled | - |
563 | \brief whether undo and redo are enabled | - |
564 | | - |
565 | Users are only able to undo or redo actions if this property is | - |
566 | true, and if there is an action that can be undone (or redone). | - |
567 | */ | - |
568 | | - |
569 | /*! | - |
570 | \enum QTextEdit::LineWrapMode | - |
571 | | - |
572 | \value NoWrap | - |
573 | \value WidgetWidth | - |
574 | \value FixedPixelWidth | - |
575 | \value FixedColumnWidth | - |
576 | */ | - |
577 | | - |
578 | /*! | - |
579 | \enum QTextEdit::AutoFormattingFlag | - |
580 | | - |
581 | \value AutoNone Don't do any automatic formatting. | - |
582 | \value AutoBulletList Automatically create bullet lists (e.g. when | - |
583 | the user enters an asterisk ('*') in the left most column, or | - |
584 | presses Enter in an existing list item. | - |
585 | \value AutoAll Apply all automatic formatting. Currently only | - |
586 | automatic bullet lists are supported. | - |
587 | */ | - |
588 | | - |
589 | | - |
590 | /*! | - |
591 | Constructs an empty QTextEdit with parent \a | - |
592 | parent. | - |
593 | */ | - |
594 | QTextEdit::QTextEdit(QWidget *parent) | - |
595 | : QAbstractScrollArea(*new QTextEditPrivate, parent) | - |
596 | { | - |
597 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
598 | d->init(); executed (the execution status of this line is deduced): d->init(); | - |
599 | } executed: } Execution Count:47 | 47 |
600 | | - |
601 | /*! | - |
602 | \internal | - |
603 | */ | - |
604 | QTextEdit::QTextEdit(QTextEditPrivate &dd, QWidget *parent) | - |
605 | : QAbstractScrollArea(dd, parent) | - |
606 | { | - |
607 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
608 | d->init(); executed (the execution status of this line is deduced): d->init(); | - |
609 | } executed: } Execution Count:24 | 24 |
610 | | - |
611 | /*! | - |
612 | Constructs a QTextEdit with parent \a parent. The text edit will display | - |
613 | the text \a text. The text is interpreted as html. | - |
614 | */ | - |
615 | QTextEdit::QTextEdit(const QString &text, QWidget *parent) | - |
616 | : QAbstractScrollArea(*new QTextEditPrivate, parent) | - |
617 | { | - |
618 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
619 | d->init(text); executed (the execution status of this line is deduced): d->init(text); | - |
620 | } executed: } Execution Count:6 | 6 |
621 | | - |
622 | | - |
623 | | - |
624 | /*! | - |
625 | Destructor. | - |
626 | */ | - |
627 | QTextEdit::~QTextEdit() | - |
628 | { | - |
629 | } | - |
630 | | - |
631 | /*! | - |
632 | Returns the point size of the font of the current format. | - |
633 | | - |
634 | \sa setFontFamily(), setCurrentFont(), setFontPointSize() | - |
635 | */ | - |
636 | qreal QTextEdit::fontPointSize() const | - |
637 | { | - |
638 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
639 | return d->control->textCursor().charFormat().fontPointSize(); never executed: return d->control->textCursor().charFormat().fontPointSize(); | 0 |
640 | } | - |
641 | | - |
642 | /*! | - |
643 | Returns the font family of the current format. | - |
644 | | - |
645 | \sa setFontFamily(), setCurrentFont(), setFontPointSize() | - |
646 | */ | - |
647 | QString QTextEdit::fontFamily() const | - |
648 | { | - |
649 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
650 | return d->control->textCursor().charFormat().fontFamily(); never executed: return d->control->textCursor().charFormat().fontFamily(); | 0 |
651 | } | - |
652 | | - |
653 | /*! | - |
654 | Returns the font weight of the current format. | - |
655 | | - |
656 | \sa setFontWeight(), setCurrentFont(), setFontPointSize(), QFont::Weight | - |
657 | */ | - |
658 | int QTextEdit::fontWeight() const | - |
659 | { | - |
660 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
661 | return d->control->textCursor().charFormat().fontWeight(); never executed: return d->control->textCursor().charFormat().fontWeight(); | 0 |
662 | } | - |
663 | | - |
664 | /*! | - |
665 | Returns true if the font of the current format is underlined; otherwise returns | - |
666 | false. | - |
667 | | - |
668 | \sa setFontUnderline() | - |
669 | */ | - |
670 | bool QTextEdit::fontUnderline() const | - |
671 | { | - |
672 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
673 | return d->control->textCursor().charFormat().fontUnderline(); never executed: return d->control->textCursor().charFormat().fontUnderline(); | 0 |
674 | } | - |
675 | | - |
676 | /*! | - |
677 | Returns true if the font of the current format is italic; otherwise returns | - |
678 | false. | - |
679 | | - |
680 | \sa setFontItalic() | - |
681 | */ | - |
682 | bool QTextEdit::fontItalic() const | - |
683 | { | - |
684 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
685 | return d->control->textCursor().charFormat().fontItalic(); never executed: return d->control->textCursor().charFormat().fontItalic(); | 0 |
686 | } | - |
687 | | - |
688 | /*! | - |
689 | Returns the text color of the current format. | - |
690 | | - |
691 | \sa setTextColor() | - |
692 | */ | - |
693 | QColor QTextEdit::textColor() const | - |
694 | { | - |
695 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
696 | return d->control->textCursor().charFormat().foreground().color(); never executed: return d->control->textCursor().charFormat().foreground().color(); | 0 |
697 | } | - |
698 | | - |
699 | /*! | - |
700 | \since 4.4 | - |
701 | | - |
702 | Returns the text background color of the current format. | - |
703 | | - |
704 | \sa setTextBackgroundColor() | - |
705 | */ | - |
706 | QColor QTextEdit::textBackgroundColor() const | - |
707 | { | - |
708 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
709 | return d->control->textCursor().charFormat().background().color(); never executed: return d->control->textCursor().charFormat().background().color(); | 0 |
710 | } | - |
711 | | - |
712 | /*! | - |
713 | Returns the font of the current format. | - |
714 | | - |
715 | \sa setCurrentFont(), setFontFamily(), setFontPointSize() | - |
716 | */ | - |
717 | QFont QTextEdit::currentFont() const | - |
718 | { | - |
719 | Q_D(const QTextEdit); executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
720 | return d->control->textCursor().charFormat().font(); executed: return d->control->textCursor().charFormat().font(); Execution Count:10 | 10 |
721 | } | - |
722 | | - |
723 | /*! | - |
724 | Sets the alignment of the current paragraph to \a a. Valid | - |
725 | alignments are Qt::AlignLeft, Qt::AlignRight, | - |
726 | Qt::AlignJustify and Qt::AlignCenter (which centers | - |
727 | horizontally). | - |
728 | */ | - |
729 | void QTextEdit::setAlignment(Qt::Alignment a) | - |
730 | { | - |
731 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
732 | QTextBlockFormat fmt; never executed (the execution status of this line is deduced): QTextBlockFormat fmt; | - |
733 | fmt.setAlignment(a); never executed (the execution status of this line is deduced): fmt.setAlignment(a); | - |
734 | QTextCursor cursor = d->control->textCursor(); never executed (the execution status of this line is deduced): QTextCursor cursor = d->control->textCursor(); | - |
735 | cursor.mergeBlockFormat(fmt); never executed (the execution status of this line is deduced): cursor.mergeBlockFormat(fmt); | - |
736 | d->control->setTextCursor(cursor); never executed (the execution status of this line is deduced): d->control->setTextCursor(cursor); | - |
737 | } | 0 |
738 | | - |
739 | /*! | - |
740 | Returns the alignment of the current paragraph. | - |
741 | | - |
742 | \sa setAlignment() | - |
743 | */ | - |
744 | Qt::Alignment QTextEdit::alignment() const | - |
745 | { | - |
746 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
747 | return d->control->textCursor().blockFormat().alignment(); never executed: return d->control->textCursor().blockFormat().alignment(); | 0 |
748 | } | - |
749 | | - |
750 | /*! | - |
751 | \property QTextEdit::document | - |
752 | \brief the underlying document of the text editor. | - |
753 | | - |
754 | \note The editor \e{does not take ownership of the document} unless it | - |
755 | is the document's parent object. The parent object of the provided document | - |
756 | remains the owner of the object. The editor does not delete any previously | - |
757 | assigned document, even if it is a child of the editor. | - |
758 | */ | - |
759 | void QTextEdit::setDocument(QTextDocument *document) | - |
760 | { | - |
761 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
762 | d->control->setDocument(document); executed (the execution status of this line is deduced): d->control->setDocument(document); | - |
763 | d->updateDefaultTextOption(); executed (the execution status of this line is deduced): d->updateDefaultTextOption(); | - |
764 | d->relayoutDocument(); executed (the execution status of this line is deduced): d->relayoutDocument(); | - |
765 | } executed: } Execution Count:4 | 4 |
766 | | - |
767 | QTextDocument *QTextEdit::document() const | - |
768 | { | - |
769 | Q_D(const QTextEdit); executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
770 | return d->control->document(); executed: return d->control->document(); Execution Count:232 | 232 |
771 | } | - |
772 | | - |
773 | /*! | - |
774 | Sets the visible \a cursor. | - |
775 | */ | - |
776 | void QTextEdit::setTextCursor(const QTextCursor &cursor) | - |
777 | { | - |
778 | doSetTextCursor(cursor); executed (the execution status of this line is deduced): doSetTextCursor(cursor); | - |
779 | } executed: } Execution Count:2 | 2 |
780 | | - |
781 | /*! | - |
782 | \internal | - |
783 | | - |
784 | This provides a hook for subclasses to intercept cursor changes. | - |
785 | */ | - |
786 | | - |
787 | void QTextEdit::doSetTextCursor(const QTextCursor &cursor) | - |
788 | { | - |
789 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
790 | d->control->setTextCursor(cursor); executed (the execution status of this line is deduced): d->control->setTextCursor(cursor); | - |
791 | } executed: } Execution Count:2 | 2 |
792 | | - |
793 | /*! | - |
794 | Returns a copy of the QTextCursor that represents the currently visible cursor. | - |
795 | Note that changes on the returned cursor do not affect QTextEdit's cursor; use | - |
796 | setTextCursor() to update the visible cursor. | - |
797 | */ | - |
798 | QTextCursor QTextEdit::textCursor() const | - |
799 | { | - |
800 | Q_D(const QTextEdit); executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
801 | return d->control->textCursor(); executed: return d->control->textCursor(); Execution Count:232 | 232 |
802 | } | - |
803 | | - |
804 | /*! | - |
805 | Sets the font family of the current format to \a fontFamily. | - |
806 | | - |
807 | \sa fontFamily(), setCurrentFont() | - |
808 | */ | - |
809 | void QTextEdit::setFontFamily(const QString &fontFamily) | - |
810 | { | - |
811 | QTextCharFormat fmt; never executed (the execution status of this line is deduced): QTextCharFormat fmt; | - |
812 | fmt.setFontFamily(fontFamily); never executed (the execution status of this line is deduced): fmt.setFontFamily(fontFamily); | - |
813 | mergeCurrentCharFormat(fmt); never executed (the execution status of this line is deduced): mergeCurrentCharFormat(fmt); | - |
814 | } | 0 |
815 | | - |
816 | /*! | - |
817 | Sets the point size of the current format to \a s. | - |
818 | | - |
819 | Note that if \a s is zero or negative, the behavior of this | - |
820 | function is not defined. | - |
821 | | - |
822 | \sa fontPointSize(), setCurrentFont(), setFontFamily() | - |
823 | */ | - |
824 | void QTextEdit::setFontPointSize(qreal s) | - |
825 | { | - |
826 | QTextCharFormat fmt; never executed (the execution status of this line is deduced): QTextCharFormat fmt; | - |
827 | fmt.setFontPointSize(s); never executed (the execution status of this line is deduced): fmt.setFontPointSize(s); | - |
828 | mergeCurrentCharFormat(fmt); never executed (the execution status of this line is deduced): mergeCurrentCharFormat(fmt); | - |
829 | } | 0 |
830 | | - |
831 | /*! | - |
832 | \fn void QTextEdit::setFontWeight(int weight) | - |
833 | | - |
834 | Sets the font weight of the current format to the given \a weight, | - |
835 | where the value used is in the range defined by the QFont::Weight | - |
836 | enum. | - |
837 | | - |
838 | \sa fontWeight(), setCurrentFont(), setFontFamily() | - |
839 | */ | - |
840 | void QTextEdit::setFontWeight(int w) | - |
841 | { | - |
842 | QTextCharFormat fmt; never executed (the execution status of this line is deduced): QTextCharFormat fmt; | - |
843 | fmt.setFontWeight(w); never executed (the execution status of this line is deduced): fmt.setFontWeight(w); | - |
844 | mergeCurrentCharFormat(fmt); never executed (the execution status of this line is deduced): mergeCurrentCharFormat(fmt); | - |
845 | } | 0 |
846 | | - |
847 | /*! | - |
848 | If \a underline is true, sets the current format to underline; | - |
849 | otherwise sets the current format to non-underline. | - |
850 | | - |
851 | \sa fontUnderline() | - |
852 | */ | - |
853 | void QTextEdit::setFontUnderline(bool underline) | - |
854 | { | - |
855 | QTextCharFormat fmt; never executed (the execution status of this line is deduced): QTextCharFormat fmt; | - |
856 | fmt.setFontUnderline(underline); never executed (the execution status of this line is deduced): fmt.setFontUnderline(underline); | - |
857 | mergeCurrentCharFormat(fmt); never executed (the execution status of this line is deduced): mergeCurrentCharFormat(fmt); | - |
858 | } | 0 |
859 | | - |
860 | /*! | - |
861 | If \a italic is true, sets the current format to italic; | - |
862 | otherwise sets the current format to non-italic. | - |
863 | | - |
864 | \sa fontItalic() | - |
865 | */ | - |
866 | void QTextEdit::setFontItalic(bool italic) | - |
867 | { | - |
868 | QTextCharFormat fmt; never executed (the execution status of this line is deduced): QTextCharFormat fmt; | - |
869 | fmt.setFontItalic(italic); never executed (the execution status of this line is deduced): fmt.setFontItalic(italic); | - |
870 | mergeCurrentCharFormat(fmt); never executed (the execution status of this line is deduced): mergeCurrentCharFormat(fmt); | - |
871 | } | 0 |
872 | | - |
873 | /*! | - |
874 | Sets the text color of the current format to \a c. | - |
875 | | - |
876 | \sa textColor() | - |
877 | */ | - |
878 | void QTextEdit::setTextColor(const QColor &c) | - |
879 | { | - |
880 | QTextCharFormat fmt; never executed (the execution status of this line is deduced): QTextCharFormat fmt; | - |
881 | fmt.setForeground(QBrush(c)); never executed (the execution status of this line is deduced): fmt.setForeground(QBrush(c)); | - |
882 | mergeCurrentCharFormat(fmt); never executed (the execution status of this line is deduced): mergeCurrentCharFormat(fmt); | - |
883 | } | 0 |
884 | | - |
885 | /*! | - |
886 | \since 4.4 | - |
887 | | - |
888 | Sets the text background color of the current format to \a c. | - |
889 | | - |
890 | \sa textBackgroundColor() | - |
891 | */ | - |
892 | void QTextEdit::setTextBackgroundColor(const QColor &c) | - |
893 | { | - |
894 | QTextCharFormat fmt; never executed (the execution status of this line is deduced): QTextCharFormat fmt; | - |
895 | fmt.setBackground(QBrush(c)); never executed (the execution status of this line is deduced): fmt.setBackground(QBrush(c)); | - |
896 | mergeCurrentCharFormat(fmt); never executed (the execution status of this line is deduced): mergeCurrentCharFormat(fmt); | - |
897 | } | 0 |
898 | | - |
899 | /*! | - |
900 | Sets the font of the current format to \a f. | - |
901 | | - |
902 | \sa currentFont(), setFontPointSize(), setFontFamily() | - |
903 | */ | - |
904 | void QTextEdit::setCurrentFont(const QFont &f) | - |
905 | { | - |
906 | QTextCharFormat fmt; executed (the execution status of this line is deduced): QTextCharFormat fmt; | - |
907 | fmt.setFont(f); executed (the execution status of this line is deduced): fmt.setFont(f); | - |
908 | mergeCurrentCharFormat(fmt); executed (the execution status of this line is deduced): mergeCurrentCharFormat(fmt); | - |
909 | } executed: } Execution Count:1 | 1 |
910 | | - |
911 | /*! | - |
912 | \since 4.2 | - |
913 | | - |
914 | Undoes the last operation. | - |
915 | | - |
916 | If there is no operation to undo, i.e. there is no undo step in | - |
917 | the undo/redo history, nothing happens. | - |
918 | | - |
919 | \sa redo() | - |
920 | */ | - |
921 | void QTextEdit::undo() | - |
922 | { | - |
923 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
924 | d->control->undo(); never executed (the execution status of this line is deduced): d->control->undo(); | - |
925 | } | 0 |
926 | | - |
927 | void QTextEdit::redo() | - |
928 | { | - |
929 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
930 | d->control->redo(); never executed (the execution status of this line is deduced): d->control->redo(); | - |
931 | } | 0 |
932 | | - |
933 | /*! | - |
934 | \fn void QTextEdit::redo() | - |
935 | \since 4.2 | - |
936 | | - |
937 | Redoes the last operation. | - |
938 | | - |
939 | If there is no operation to redo, i.e. there is no redo step in | - |
940 | the undo/redo history, nothing happens. | - |
941 | | - |
942 | \sa undo() | - |
943 | */ | - |
944 | | - |
945 | #ifndef QT_NO_CLIPBOARD | - |
946 | /*! | - |
947 | Copies the selected text to the clipboard and deletes it from | - |
948 | the text edit. | - |
949 | | - |
950 | If there is no selected text nothing happens. | - |
951 | | - |
952 | \sa copy(), paste() | - |
953 | */ | - |
954 | | - |
955 | void QTextEdit::cut() | - |
956 | { | - |
957 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
958 | d->control->cut(); never executed (the execution status of this line is deduced): d->control->cut(); | - |
959 | } | 0 |
960 | | - |
961 | /*! | - |
962 | Copies any selected text to the clipboard. | - |
963 | | - |
964 | \sa copyAvailable() | - |
965 | */ | - |
966 | | - |
967 | void QTextEdit::copy() | - |
968 | { | - |
969 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
970 | d->control->copy(); never executed (the execution status of this line is deduced): d->control->copy(); | - |
971 | } | 0 |
972 | | - |
973 | /*! | - |
974 | Pastes the text from the clipboard into the text edit at the | - |
975 | current cursor position. | - |
976 | | - |
977 | If there is no text in the clipboard nothing happens. | - |
978 | | - |
979 | To change the behavior of this function, i.e. to modify what | - |
980 | QTextEdit can paste and how it is being pasted, reimplement the | - |
981 | virtual canInsertFromMimeData() and insertFromMimeData() | - |
982 | functions. | - |
983 | | - |
984 | \sa cut(), copy() | - |
985 | */ | - |
986 | | - |
987 | void QTextEdit::paste() | - |
988 | { | - |
989 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
990 | d->control->paste(); never executed (the execution status of this line is deduced): d->control->paste(); | - |
991 | } | 0 |
992 | #endif | - |
993 | | - |
994 | /*! | - |
995 | Deletes all the text in the text edit. | - |
996 | | - |
997 | Note that the undo/redo history is cleared by this function. | - |
998 | | - |
999 | \sa cut(), setPlainText(), setHtml() | - |
1000 | */ | - |
1001 | void QTextEdit::clear() | - |
1002 | { | - |
1003 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1004 | // clears and sets empty content | - |
1005 | d->control->clear(); executed (the execution status of this line is deduced): d->control->clear(); | - |
1006 | } executed: } Execution Count:17 | 17 |
1007 | | - |
1008 | | - |
1009 | /*! | - |
1010 | Selects all text. | - |
1011 | | - |
1012 | \sa copy(), cut(), textCursor() | - |
1013 | */ | - |
1014 | void QTextEdit::selectAll() | - |
1015 | { | - |
1016 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1017 | d->control->selectAll(); executed (the execution status of this line is deduced): d->control->selectAll(); | - |
1018 | } executed: } Execution Count:2 | 2 |
1019 | | - |
1020 | /*! \internal | - |
1021 | */ | - |
1022 | bool QTextEdit::event(QEvent *e) | - |
1023 | { | - |
1024 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1025 | #ifndef QT_NO_CONTEXTMENU | - |
1026 | if (e->type() == QEvent::ContextMenu partially evaluated: e->type() == QEvent::ContextMenu no Evaluation Count:0 | yes Evaluation Count:2706 |
| 0-2706 |
1027 | && static_cast<QContextMenuEvent *>(e)->reason() == QContextMenuEvent::Keyboard) { never evaluated: static_cast<QContextMenuEvent *>(e)->reason() == QContextMenuEvent::Keyboard | 0 |
1028 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1029 | ensureCursorVisible(); never executed (the execution status of this line is deduced): ensureCursorVisible(); | - |
1030 | const QPoint cursorPos = cursorRect().center(); never executed (the execution status of this line is deduced): const QPoint cursorPos = cursorRect().center(); | - |
1031 | QContextMenuEvent ce(QContextMenuEvent::Keyboard, cursorPos, d->viewport->mapToGlobal(cursorPos)); never executed (the execution status of this line is deduced): QContextMenuEvent ce(QContextMenuEvent::Keyboard, cursorPos, d->viewport->mapToGlobal(cursorPos)); | - |
1032 | ce.setAccepted(e->isAccepted()); never executed (the execution status of this line is deduced): ce.setAccepted(e->isAccepted()); | - |
1033 | const bool result = QAbstractScrollArea::event(&ce); never executed (the execution status of this line is deduced): const bool result = QAbstractScrollArea::event(&ce); | - |
1034 | e->setAccepted(ce.isAccepted()); never executed (the execution status of this line is deduced): e->setAccepted(ce.isAccepted()); | - |
1035 | return result; never executed: return result; | 0 |
1036 | } else if (e->type() == QEvent::ShortcutOverride evaluated: e->type() == QEvent::ShortcutOverride yes Evaluation Count:20 | yes Evaluation Count:2686 |
| 20-2686 |
1037 | || e->type() == QEvent::ToolTip) { partially evaluated: e->type() == QEvent::ToolTip no Evaluation Count:0 | yes Evaluation Count:2686 |
| 0-2686 |
1038 | d->sendControlEvent(e); executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
1039 | } executed: } Execution Count:20 | 20 |
1040 | #endif // QT_NO_CONTEXTMENU | - |
1041 | #ifdef QT_KEYPAD_NAVIGATION | - |
1042 | if (e->type() == QEvent::EnterEditFocus || e->type() == QEvent::LeaveEditFocus) { | - |
1043 | if (QApplication::keypadNavigationEnabled()) | - |
1044 | d->sendControlEvent(e); | - |
1045 | } | - |
1046 | #endif | - |
1047 | return QAbstractScrollArea::event(e); executed: return QAbstractScrollArea::event(e); Execution Count:2706 | 2706 |
1048 | } | - |
1049 | | - |
1050 | /*! \internal | - |
1051 | */ | - |
1052 | | - |
1053 | void QTextEdit::timerEvent(QTimerEvent *e) | - |
1054 | { | - |
1055 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1056 | if (e->timerId() == d->autoScrollTimer.timerId()) { never evaluated: e->timerId() == d->autoScrollTimer.timerId() | 0 |
1057 | QRect visible = d->viewport->rect(); never executed (the execution status of this line is deduced): QRect visible = d->viewport->rect(); | - |
1058 | QPoint pos; never executed (the execution status of this line is deduced): QPoint pos; | - |
1059 | if (d->inDrag) { never evaluated: d->inDrag | 0 |
1060 | pos = d->autoScrollDragPos; never executed (the execution status of this line is deduced): pos = d->autoScrollDragPos; | - |
1061 | visible.adjust(qMin(visible.width()/3,20), qMin(visible.height()/3,20), never executed (the execution status of this line is deduced): visible.adjust(qMin(visible.width()/3,20), qMin(visible.height()/3,20), | - |
1062 | -qMin(visible.width()/3,20), -qMin(visible.height()/3,20)); never executed (the execution status of this line is deduced): -qMin(visible.width()/3,20), -qMin(visible.height()/3,20)); | - |
1063 | } else { | 0 |
1064 | const QPoint globalPos = QCursor::pos(); never executed (the execution status of this line is deduced): const QPoint globalPos = QCursor::pos(); | - |
1065 | pos = d->viewport->mapFromGlobal(globalPos); never executed (the execution status of this line is deduced): pos = d->viewport->mapFromGlobal(globalPos); | - |
1066 | QMouseEvent ev(QEvent::MouseMove, pos, mapTo(topLevelWidget(), pos), globalPos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); never executed (the execution status of this line is deduced): QMouseEvent ev(QEvent::MouseMove, pos, mapTo(topLevelWidget(), pos), globalPos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); | - |
1067 | mouseMoveEvent(&ev); never executed (the execution status of this line is deduced): mouseMoveEvent(&ev); | - |
1068 | } | 0 |
1069 | int deltaY = qMax(pos.y() - visible.top(), visible.bottom() - pos.y()) - visible.height(); never executed (the execution status of this line is deduced): int deltaY = qMax(pos.y() - visible.top(), visible.bottom() - pos.y()) - visible.height(); | - |
1070 | int deltaX = qMax(pos.x() - visible.left(), visible.right() - pos.x()) - visible.width(); never executed (the execution status of this line is deduced): int deltaX = qMax(pos.x() - visible.left(), visible.right() - pos.x()) - visible.width(); | - |
1071 | int delta = qMax(deltaX, deltaY); never executed (the execution status of this line is deduced): int delta = qMax(deltaX, deltaY); | - |
1072 | if (delta >= 0) { never evaluated: delta >= 0 | 0 |
1073 | if (delta < 7) never evaluated: delta < 7 | 0 |
1074 | delta = 7; never executed: delta = 7; | 0 |
1075 | int timeout = 4900 / (delta * delta); never executed (the execution status of this line is deduced): int timeout = 4900 / (delta * delta); | - |
1076 | d->autoScrollTimer.start(timeout, this); never executed (the execution status of this line is deduced): d->autoScrollTimer.start(timeout, this); | - |
1077 | | - |
1078 | if (deltaY > 0) never evaluated: deltaY > 0 | 0 |
1079 | d->vbar->triggerAction(pos.y() < visible.center().y() ? never executed: d->vbar->triggerAction(pos.y() < visible.center().y() ? QAbstractSlider::SliderSingleStepSub : QAbstractSlider::SliderSingleStepAdd); | 0 |
1080 | QAbstractSlider::SliderSingleStepSub never executed: d->vbar->triggerAction(pos.y() < visible.center().y() ? QAbstractSlider::SliderSingleStepSub : QAbstractSlider::SliderSingleStepAdd); | 0 |
1081 | : QAbstractSlider::SliderSingleStepAdd); never executed: d->vbar->triggerAction(pos.y() < visible.center().y() ? QAbstractSlider::SliderSingleStepSub : QAbstractSlider::SliderSingleStepAdd); | 0 |
1082 | if (deltaX > 0) never evaluated: deltaX > 0 | 0 |
1083 | d->hbar->triggerAction(pos.x() < visible.center().x() ? never executed: d->hbar->triggerAction(pos.x() < visible.center().x() ? QAbstractSlider::SliderSingleStepSub : QAbstractSlider::SliderSingleStepAdd); | 0 |
1084 | QAbstractSlider::SliderSingleStepSub never executed: d->hbar->triggerAction(pos.x() < visible.center().x() ? QAbstractSlider::SliderSingleStepSub : QAbstractSlider::SliderSingleStepAdd); | 0 |
1085 | : QAbstractSlider::SliderSingleStepAdd); never executed: d->hbar->triggerAction(pos.x() < visible.center().x() ? QAbstractSlider::SliderSingleStepSub : QAbstractSlider::SliderSingleStepAdd); | 0 |
1086 | } | 0 |
1087 | } | 0 |
1088 | #ifdef QT_KEYPAD_NAVIGATION | - |
1089 | else if (e->timerId() == d->deleteAllTimer.timerId()) { | - |
1090 | d->deleteAllTimer.stop(); | - |
1091 | clear(); | - |
1092 | } | - |
1093 | #endif | - |
1094 | } | 0 |
1095 | | - |
1096 | /*! | - |
1097 | Changes the text of the text edit to the string \a text. | - |
1098 | Any previous text is removed. | - |
1099 | | - |
1100 | \a text is interpreted as plain text. | - |
1101 | | - |
1102 | Note that the undo/redo history is cleared by this function. | - |
1103 | | - |
1104 | \sa toPlainText() | - |
1105 | */ | - |
1106 | | - |
1107 | void QTextEdit::setPlainText(const QString &text) | - |
1108 | { | - |
1109 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1110 | d->control->setPlainText(text); executed (the execution status of this line is deduced): d->control->setPlainText(text); | - |
1111 | d->preferRichText = false; executed (the execution status of this line is deduced): d->preferRichText = false; | - |
1112 | } executed: } Execution Count:4 | 4 |
1113 | | - |
1114 | /*! | - |
1115 | QString QTextEdit::toPlainText() const | - |
1116 | | - |
1117 | Returns the text of the text edit as plain text. | - |
1118 | | - |
1119 | \sa QTextEdit::setPlainText() | - |
1120 | */ | - |
1121 | QString QTextEdit::toPlainText() const | - |
1122 | { | - |
1123 | Q_D(const QTextEdit); executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
1124 | return d->control->toPlainText(); executed: return d->control->toPlainText(); Execution Count:33 | 33 |
1125 | } | - |
1126 | | - |
1127 | /*! | - |
1128 | \property QTextEdit::html | - |
1129 | | - |
1130 | This property provides an HTML interface to the text of the text edit. | - |
1131 | | - |
1132 | toHtml() returns the text of the text edit as html. | - |
1133 | | - |
1134 | setHtml() changes the text of the text edit. Any previous text is | - |
1135 | removed and the undo/redo history is cleared. The input text is | - |
1136 | interpreted as rich text in html format. | - |
1137 | | - |
1138 | \note It is the responsibility of the caller to make sure that the | - |
1139 | text is correctly decoded when a QString containing HTML is created | - |
1140 | and passed to setHtml(). | - |
1141 | | - |
1142 | By default, for a newly-created, empty document, this property contains | - |
1143 | text to describe an HTML 4.0 document with no body text. | - |
1144 | | - |
1145 | \sa {Supported HTML Subset}, plainText | - |
1146 | */ | - |
1147 | | - |
1148 | #ifndef QT_NO_TEXTHTMLPARSER | - |
1149 | void QTextEdit::setHtml(const QString &text) | - |
1150 | { | - |
1151 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1152 | d->control->setHtml(text); executed (the execution status of this line is deduced): d->control->setHtml(text); | - |
1153 | d->preferRichText = true; executed (the execution status of this line is deduced): d->preferRichText = true; | - |
1154 | } executed: } Execution Count:66 | 66 |
1155 | | - |
1156 | QString QTextEdit::toHtml() const | - |
1157 | { | - |
1158 | Q_D(const QTextEdit); executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
1159 | return d->control->toHtml(); executed: return d->control->toHtml(); Execution Count:1 | 1 |
1160 | } | - |
1161 | #endif | - |
1162 | | - |
1163 | | - |
1164 | /*! \reimp | - |
1165 | */ | - |
1166 | void QTextEdit::keyPressEvent(QKeyEvent *e) | - |
1167 | { | - |
1168 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1169 | | - |
1170 | #ifdef QT_KEYPAD_NAVIGATION | - |
1171 | switch (e->key()) { | - |
1172 | case Qt::Key_Select: | - |
1173 | if (QApplication::keypadNavigationEnabled()) { | - |
1174 | // code assumes linksaccessible + editable isn't meaningful | - |
1175 | if (d->control->textInteractionFlags() & Qt::TextEditable) { | - |
1176 | setEditFocus(!hasEditFocus()); | - |
1177 | } else { | - |
1178 | if (!hasEditFocus()) | - |
1179 | setEditFocus(true); | - |
1180 | else { | - |
1181 | QTextCursor cursor = d->control->textCursor(); | - |
1182 | QTextCharFormat charFmt = cursor.charFormat(); | - |
1183 | if (!(d->control->textInteractionFlags() & Qt::LinksAccessibleByKeyboard) | - |
1184 | || !cursor.hasSelection() || charFmt.anchorHref().isEmpty()) { | - |
1185 | e->accept(); | - |
1186 | return; | - |
1187 | } | - |
1188 | } | - |
1189 | } | - |
1190 | } | - |
1191 | break; | - |
1192 | case Qt::Key_Back: | - |
1193 | case Qt::Key_No: | - |
1194 | if (!QApplication::keypadNavigationEnabled() | - |
1195 | || (QApplication::keypadNavigationEnabled() && !hasEditFocus())) { | - |
1196 | e->ignore(); | - |
1197 | return; | - |
1198 | } | - |
1199 | break; | - |
1200 | default: | - |
1201 | if (QApplication::keypadNavigationEnabled()) { | - |
1202 | if (!hasEditFocus() && !(e->modifiers() & Qt::ControlModifier)) { | - |
1203 | if (e->text()[0].isPrint()) | - |
1204 | setEditFocus(true); | - |
1205 | else { | - |
1206 | e->ignore(); | - |
1207 | return; | - |
1208 | } | - |
1209 | } | - |
1210 | } | - |
1211 | break; | - |
1212 | } | - |
1213 | #endif | - |
1214 | #ifndef QT_NO_SHORTCUT | - |
1215 | | - |
1216 | Qt::TextInteractionFlags tif = d->control->textInteractionFlags(); executed (the execution status of this line is deduced): Qt::TextInteractionFlags tif = d->control->textInteractionFlags(); | - |
1217 | | - |
1218 | if (tif & Qt::TextSelectableByKeyboard){ evaluated: tif & Qt::TextSelectableByKeyboard yes Evaluation Count:10 | yes Evaluation Count:6 |
| 6-10 |
1219 | if (e == QKeySequence::SelectPreviousPage) { partially evaluated: e == QKeySequence::SelectPreviousPage no Evaluation Count:0 | yes Evaluation Count:10 |
| 0-10 |
1220 | e->accept(); never executed (the execution status of this line is deduced): e->accept(); | - |
1221 | d->pageUpDown(QTextCursor::Up, QTextCursor::KeepAnchor); never executed (the execution status of this line is deduced): d->pageUpDown(QTextCursor::Up, QTextCursor::KeepAnchor); | - |
1222 | return; | 0 |
1223 | } else if (e ==QKeySequence::SelectNextPage) { partially evaluated: e ==QKeySequence::SelectNextPage no Evaluation Count:0 | yes Evaluation Count:10 |
| 0-10 |
1224 | e->accept(); never executed (the execution status of this line is deduced): e->accept(); | - |
1225 | d->pageUpDown(QTextCursor::Down, QTextCursor::KeepAnchor); never executed (the execution status of this line is deduced): d->pageUpDown(QTextCursor::Down, QTextCursor::KeepAnchor); | - |
1226 | return; | 0 |
1227 | } | - |
1228 | } | - |
1229 | if (tif & (Qt::TextSelectableByKeyboard | Qt::TextEditable)) { evaluated: tif & (Qt::TextSelectableByKeyboard | Qt::TextEditable) yes Evaluation Count:10 | yes Evaluation Count:6 |
| 6-10 |
1230 | if (e == QKeySequence::MoveToPreviousPage) { partially evaluated: e == QKeySequence::MoveToPreviousPage no Evaluation Count:0 | yes Evaluation Count:10 |
| 0-10 |
1231 | e->accept(); never executed (the execution status of this line is deduced): e->accept(); | - |
1232 | d->pageUpDown(QTextCursor::Up, QTextCursor::MoveAnchor); never executed (the execution status of this line is deduced): d->pageUpDown(QTextCursor::Up, QTextCursor::MoveAnchor); | - |
1233 | return; | 0 |
1234 | } else if (e == QKeySequence::MoveToNextPage) { partially evaluated: e == QKeySequence::MoveToNextPage no Evaluation Count:0 | yes Evaluation Count:10 |
| 0-10 |
1235 | e->accept(); never executed (the execution status of this line is deduced): e->accept(); | - |
1236 | d->pageUpDown(QTextCursor::Down, QTextCursor::MoveAnchor); never executed (the execution status of this line is deduced): d->pageUpDown(QTextCursor::Down, QTextCursor::MoveAnchor); | - |
1237 | return; | 0 |
1238 | } | - |
1239 | } | - |
1240 | | - |
1241 | if (!(tif & Qt::TextEditable)) { evaluated: !(tif & Qt::TextEditable) yes Evaluation Count:6 | yes Evaluation Count:10 |
| 6-10 |
1242 | switch (e->key()) { | - |
1243 | case Qt::Key_Space: | - |
1244 | e->accept(); never executed (the execution status of this line is deduced): e->accept(); | - |
1245 | if (e->modifiers() & Qt::ShiftModifier) never evaluated: e->modifiers() & Qt::ShiftModifier | 0 |
1246 | d->vbar->triggerAction(QAbstractSlider::SliderPageStepSub); never executed: d->vbar->triggerAction(QAbstractSlider::SliderPageStepSub); | 0 |
1247 | else | - |
1248 | d->vbar->triggerAction(QAbstractSlider::SliderPageStepAdd); never executed: d->vbar->triggerAction(QAbstractSlider::SliderPageStepAdd); | 0 |
1249 | break; | 0 |
1250 | default: | - |
1251 | d->sendControlEvent(e); executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
1252 | if (!e->isAccepted() && e->modifiers() == Qt::NoModifier) { partially evaluated: !e->isAccepted() no Evaluation Count:0 | yes Evaluation Count:6 |
never evaluated: e->modifiers() == Qt::NoModifier | 0-6 |
1253 | if (e->key() == Qt::Key_Home) { never evaluated: e->key() == Qt::Key_Home | 0 |
1254 | d->vbar->triggerAction(QAbstractSlider::SliderToMinimum); never executed (the execution status of this line is deduced): d->vbar->triggerAction(QAbstractSlider::SliderToMinimum); | - |
1255 | e->accept(); never executed (the execution status of this line is deduced): e->accept(); | - |
1256 | } else if (e->key() == Qt::Key_End) { never executed: } never evaluated: e->key() == Qt::Key_End | 0 |
1257 | d->vbar->triggerAction(QAbstractSlider::SliderToMaximum); never executed (the execution status of this line is deduced): d->vbar->triggerAction(QAbstractSlider::SliderToMaximum); | - |
1258 | e->accept(); never executed (the execution status of this line is deduced): e->accept(); | - |
1259 | } | 0 |
1260 | } | - |
1261 | if (!e->isAccepted()) { partially evaluated: !e->isAccepted() no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
1262 | QAbstractScrollArea::keyPressEvent(e); never executed (the execution status of this line is deduced): QAbstractScrollArea::keyPressEvent(e); | - |
1263 | } | 0 |
1264 | } executed: } Execution Count:6 | 6 |
1265 | return; executed: return; Execution Count:6 | 6 |
1266 | } | - |
1267 | #endif // QT_NO_SHORTCUT | - |
1268 | | - |
1269 | { | - |
1270 | QTextCursor cursor = d->control->textCursor(); executed (the execution status of this line is deduced): QTextCursor cursor = d->control->textCursor(); | - |
1271 | const QString text = e->text(); executed (the execution status of this line is deduced): const QString text = e->text(); | - |
1272 | if (cursor.atBlockStart() evaluated: cursor.atBlockStart() yes Evaluation Count:9 | yes Evaluation Count:1 |
| 1-9 |
1273 | && (d->autoFormatting & AutoBulletList) partially evaluated: (d->autoFormatting & AutoBulletList) no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
1274 | && (text.length() == 1) never evaluated: (text.length() == 1) | 0 |
1275 | && (text.at(0) == QLatin1Char('-') || text.at(0) == QLatin1Char('*')) never evaluated: text.at(0) == QLatin1Char('-') never evaluated: text.at(0) == QLatin1Char('*') | 0 |
1276 | && (!cursor.currentList())) { never evaluated: (!cursor.currentList()) | 0 |
1277 | | - |
1278 | d->createAutoBulletList(); never executed (the execution status of this line is deduced): d->createAutoBulletList(); | - |
1279 | e->accept(); never executed (the execution status of this line is deduced): e->accept(); | - |
1280 | return; | 0 |
1281 | } | - |
1282 | } | - |
1283 | | - |
1284 | d->sendControlEvent(e); executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
1285 | #ifdef QT_KEYPAD_NAVIGATION | - |
1286 | if (!e->isAccepted()) { | - |
1287 | switch (e->key()) { | - |
1288 | case Qt::Key_Up: | - |
1289 | case Qt::Key_Down: | - |
1290 | if (QApplication::keypadNavigationEnabled()) { | - |
1291 | // Cursor position didn't change, so we want to leave | - |
1292 | // these keys to change focus. | - |
1293 | e->ignore(); | - |
1294 | return; | - |
1295 | } | - |
1296 | break; | - |
1297 | case Qt::Key_Back: | - |
1298 | if (!e->isAutoRepeat()) { | - |
1299 | if (QApplication::keypadNavigationEnabled()) { | - |
1300 | if (document()->isEmpty() || !(d->control->textInteractionFlags() & Qt::TextEditable)) { | - |
1301 | setEditFocus(false); | - |
1302 | e->accept(); | - |
1303 | } else if (!d->deleteAllTimer.isActive()) { | - |
1304 | e->accept(); | - |
1305 | d->deleteAllTimer.start(750, this); | - |
1306 | } | - |
1307 | } else { | - |
1308 | e->ignore(); | - |
1309 | return; | - |
1310 | } | - |
1311 | } | - |
1312 | break; | - |
1313 | default: break; | - |
1314 | } | - |
1315 | } | - |
1316 | #endif | - |
1317 | } executed: } Execution Count:10 | 10 |
1318 | | - |
1319 | /*! \reimp | - |
1320 | */ | - |
1321 | void QTextEdit::keyReleaseEvent(QKeyEvent *e) | - |
1322 | { | - |
1323 | #ifdef QT_KEYPAD_NAVIGATION | - |
1324 | Q_D(QTextEdit); | - |
1325 | if (QApplication::keypadNavigationEnabled()) { | - |
1326 | if (!e->isAutoRepeat() && e->key() == Qt::Key_Back | - |
1327 | && d->deleteAllTimer.isActive()) { | - |
1328 | d->deleteAllTimer.stop(); | - |
1329 | QTextCursor cursor = d->control->textCursor(); | - |
1330 | QTextBlockFormat blockFmt = cursor.blockFormat(); | - |
1331 | | - |
1332 | QTextList *list = cursor.currentList(); | - |
1333 | if (list && cursor.atBlockStart()) { | - |
1334 | list->remove(cursor.block()); | - |
1335 | } else if (cursor.atBlockStart() && blockFmt.indent() > 0) { | - |
1336 | blockFmt.setIndent(blockFmt.indent() - 1); | - |
1337 | cursor.setBlockFormat(blockFmt); | - |
1338 | } else { | - |
1339 | cursor.deletePreviousChar(); | - |
1340 | } | - |
1341 | setTextCursor(cursor); | - |
1342 | e->accept(); | - |
1343 | return; | - |
1344 | } | - |
1345 | } | - |
1346 | #endif | - |
1347 | e->ignore(); executed (the execution status of this line is deduced): e->ignore(); | - |
1348 | } executed: } Execution Count:22 | 22 |
1349 | | - |
1350 | /*! | - |
1351 | Loads the resource specified by the given \a type and \a name. | - |
1352 | | - |
1353 | This function is an extension of QTextDocument::loadResource(). | - |
1354 | | - |
1355 | \sa QTextDocument::loadResource() | - |
1356 | */ | - |
1357 | QVariant QTextEdit::loadResource(int type, const QUrl &name) | - |
1358 | { | - |
1359 | Q_UNUSED(type); never executed (the execution status of this line is deduced): (void)type;; | - |
1360 | Q_UNUSED(name); never executed (the execution status of this line is deduced): (void)name;; | - |
1361 | return QVariant(); never executed: return QVariant(); | 0 |
1362 | } | - |
1363 | | - |
1364 | /*! \reimp | - |
1365 | */ | - |
1366 | void QTextEdit::resizeEvent(QResizeEvent *e) | - |
1367 | { | - |
1368 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1369 | | - |
1370 | if (d->lineWrap == NoWrap) { partially evaluated: d->lineWrap == NoWrap no Evaluation Count:0 | yes Evaluation Count:141 |
| 0-141 |
1371 | QTextDocument *doc = d->control->document(); never executed (the execution status of this line is deduced): QTextDocument *doc = d->control->document(); | - |
1372 | QVariant alignmentProperty = doc->documentLayout()->property("contentHasAlignment"); never executed (the execution status of this line is deduced): QVariant alignmentProperty = doc->documentLayout()->property("contentHasAlignment"); | - |
1373 | | - |
1374 | if (!doc->pageSize().isNull() never evaluated: !doc->pageSize().isNull() | 0 |
1375 | && alignmentProperty.type() == QVariant::Bool never evaluated: alignmentProperty.type() == QVariant::Bool | 0 |
1376 | && !alignmentProperty.toBool()) { never evaluated: !alignmentProperty.toBool() | 0 |
1377 | | - |
1378 | d->_q_adjustScrollbars(); never executed (the execution status of this line is deduced): d->_q_adjustScrollbars(); | - |
1379 | return; | 0 |
1380 | } | - |
1381 | } | 0 |
1382 | | - |
1383 | if (d->lineWrap != FixedPixelWidth partially evaluated: d->lineWrap != FixedPixelWidth yes Evaluation Count:141 | no Evaluation Count:0 |
| 0-141 |
1384 | && e->oldSize().width() != e->size().width()) evaluated: e->oldSize().width() != e->size().width() yes Evaluation Count:129 | yes Evaluation Count:12 |
| 12-129 |
1385 | d->relayoutDocument(); executed: d->relayoutDocument(); Execution Count:129 | 129 |
1386 | else | - |
1387 | d->_q_adjustScrollbars(); executed: d->_q_adjustScrollbars(); Execution Count:12 | 12 |
1388 | } | - |
1389 | | - |
1390 | void QTextEditPrivate::relayoutDocument() | - |
1391 | { | - |
1392 | QTextDocument *doc = control->document(); executed (the execution status of this line is deduced): QTextDocument *doc = control->document(); | - |
1393 | QAbstractTextDocumentLayout *layout = doc->documentLayout(); executed (the execution status of this line is deduced): QAbstractTextDocumentLayout *layout = doc->documentLayout(); | - |
1394 | | - |
1395 | if (QTextDocumentLayout *tlayout = qobject_cast<QTextDocumentLayout *>(layout)) { partially evaluated: QTextDocumentLayout *tlayout = qobject_cast<QTextDocumentLayout *>(layout) yes Evaluation Count:148 | no Evaluation Count:0 |
| 0-148 |
1396 | if (lineWrap == QTextEdit::FixedColumnWidth) partially evaluated: lineWrap == QTextEdit::FixedColumnWidth no Evaluation Count:0 | yes Evaluation Count:148 |
| 0-148 |
1397 | tlayout->setFixedColumnWidth(lineWrapColumnOrWidth); never executed: tlayout->setFixedColumnWidth(lineWrapColumnOrWidth); | 0 |
1398 | else | - |
1399 | tlayout->setFixedColumnWidth(-1); executed: tlayout->setFixedColumnWidth(-1); Execution Count:148 | 148 |
1400 | } | - |
1401 | | - |
1402 | QTextDocumentLayout *tlayout = qobject_cast<QTextDocumentLayout *>(layout); executed (the execution status of this line is deduced): QTextDocumentLayout *tlayout = qobject_cast<QTextDocumentLayout *>(layout); | - |
1403 | QSize lastUsedSize; executed (the execution status of this line is deduced): QSize lastUsedSize; | - |
1404 | if (tlayout) partially evaluated: tlayout yes Evaluation Count:148 | no Evaluation Count:0 |
| 0-148 |
1405 | lastUsedSize = tlayout->dynamicDocumentSize().toSize(); executed: lastUsedSize = tlayout->dynamicDocumentSize().toSize(); Execution Count:148 | 148 |
1406 | else | - |
1407 | lastUsedSize = layout->documentSize().toSize(); never executed: lastUsedSize = layout->documentSize().toSize(); | 0 |
1408 | | - |
1409 | // ignore calls to _q_adjustScrollbars caused by an emission of the | - |
1410 | // usedSizeChanged() signal in the layout, as we're calling it | - |
1411 | // later on our own anyway (or deliberately not) . | - |
1412 | const bool oldIgnoreScrollbarAdjustment = ignoreAutomaticScrollbarAdjustment; executed (the execution status of this line is deduced): const bool oldIgnoreScrollbarAdjustment = ignoreAutomaticScrollbarAdjustment; | - |
1413 | ignoreAutomaticScrollbarAdjustment = true; executed (the execution status of this line is deduced): ignoreAutomaticScrollbarAdjustment = true; | - |
1414 | | - |
1415 | int width = viewport->width(); executed (the execution status of this line is deduced): int width = viewport->width(); | - |
1416 | if (lineWrap == QTextEdit::FixedPixelWidth) partially evaluated: lineWrap == QTextEdit::FixedPixelWidth no Evaluation Count:0 | yes Evaluation Count:148 |
| 0-148 |
1417 | width = lineWrapColumnOrWidth; never executed: width = lineWrapColumnOrWidth; | 0 |
1418 | else if (lineWrap == QTextEdit::NoWrap) { partially evaluated: lineWrap == QTextEdit::NoWrap no Evaluation Count:0 | yes Evaluation Count:148 |
| 0-148 |
1419 | QVariant alignmentProperty = doc->documentLayout()->property("contentHasAlignment"); never executed (the execution status of this line is deduced): QVariant alignmentProperty = doc->documentLayout()->property("contentHasAlignment"); | - |
1420 | if (alignmentProperty.type() == QVariant::Bool && !alignmentProperty.toBool()) { never evaluated: alignmentProperty.type() == QVariant::Bool never evaluated: !alignmentProperty.toBool() | 0 |
1421 | | - |
1422 | width = 0; never executed (the execution status of this line is deduced): width = 0; | - |
1423 | } | 0 |
1424 | } | 0 |
1425 | | - |
1426 | doc->setPageSize(QSize(width, -1)); executed (the execution status of this line is deduced): doc->setPageSize(QSize(width, -1)); | - |
1427 | if (tlayout) partially evaluated: tlayout yes Evaluation Count:148 | no Evaluation Count:0 |
| 0-148 |
1428 | tlayout->ensureLayouted(verticalOffset() + viewport->height()); executed: tlayout->ensureLayouted(verticalOffset() + viewport->height()); Execution Count:148 | 148 |
1429 | | - |
1430 | ignoreAutomaticScrollbarAdjustment = oldIgnoreScrollbarAdjustment; executed (the execution status of this line is deduced): ignoreAutomaticScrollbarAdjustment = oldIgnoreScrollbarAdjustment; | - |
1431 | | - |
1432 | QSize usedSize; executed (the execution status of this line is deduced): QSize usedSize; | - |
1433 | if (tlayout) partially evaluated: tlayout yes Evaluation Count:148 | no Evaluation Count:0 |
| 0-148 |
1434 | usedSize = tlayout->dynamicDocumentSize().toSize(); executed: usedSize = tlayout->dynamicDocumentSize().toSize(); Execution Count:148 | 148 |
1435 | else | - |
1436 | usedSize = layout->documentSize().toSize(); never executed: usedSize = layout->documentSize().toSize(); | 0 |
1437 | | - |
1438 | // this is an obscure situation in the layout that can happen: | - |
1439 | // if a character at the end of a line is the tallest one and therefore | - |
1440 | // influencing the total height of the line and the line right below it | - |
1441 | // is always taller though, then it can happen that if due to line breaking | - |
1442 | // that tall character wraps into the lower line the document not only shrinks | - |
1443 | // horizontally (causing the character to wrap in the first place) but also | - |
1444 | // vertically, because the original line is now smaller and the one below kept | - |
1445 | // its size. So a layout with less width _can_ take up less vertical space, too. | - |
1446 | // If the wider case causes a vertical scroll bar to appear and the narrower one | - |
1447 | // (narrower because the vertical scroll bar takes up horizontal space)) to disappear | - |
1448 | // again then we have an endless loop, as _q_adjustScrollBars sets new ranges on the | - |
1449 | // scroll bars, the QAbstractScrollArea will find out about it and try to show/hide | - |
1450 | // the scroll bars again. That's why we try to detect this case here and break out. | - |
1451 | // | - |
1452 | // (if you change this please also check the layoutingLoop() testcase in | - |
1453 | // QTextEdit's autotests) | - |
1454 | if (lastUsedSize.isValid() partially evaluated: lastUsedSize.isValid() yes Evaluation Count:148 | no Evaluation Count:0 |
| 0-148 |
1455 | && !vbar->isHidden() partially evaluated: !vbar->isHidden() yes Evaluation Count:148 | no Evaluation Count:0 |
| 0-148 |
1456 | && viewport->width() < lastUsedSize.width() evaluated: viewport->width() < lastUsedSize.width() yes Evaluation Count:35 | yes Evaluation Count:113 |
| 35-113 |
1457 | && usedSize.height() < lastUsedSize.height() partially evaluated: usedSize.height() < lastUsedSize.height() no Evaluation Count:0 | yes Evaluation Count:35 |
| 0-35 |
1458 | && usedSize.height() <= viewport->height()) never evaluated: usedSize.height() <= viewport->height() | 0 |
1459 | return; | 0 |
1460 | | - |
1461 | _q_adjustScrollbars(); executed (the execution status of this line is deduced): _q_adjustScrollbars(); | - |
1462 | } executed: } Execution Count:148 | 148 |
1463 | | - |
1464 | void QTextEditPrivate::paint(QPainter *p, QPaintEvent *e) | - |
1465 | { | - |
1466 | const int xOffset = horizontalOffset(); executed (the execution status of this line is deduced): const int xOffset = horizontalOffset(); | - |
1467 | const int yOffset = verticalOffset(); executed (the execution status of this line is deduced): const int yOffset = verticalOffset(); | - |
1468 | | - |
1469 | QRect r = e->rect(); executed (the execution status of this line is deduced): QRect r = e->rect(); | - |
1470 | p->translate(-xOffset, -yOffset); executed (the execution status of this line is deduced): p->translate(-xOffset, -yOffset); | - |
1471 | r.translate(xOffset, yOffset); executed (the execution status of this line is deduced): r.translate(xOffset, yOffset); | - |
1472 | | - |
1473 | QTextDocument *doc = control->document(); executed (the execution status of this line is deduced): QTextDocument *doc = control->document(); | - |
1474 | QTextDocumentLayout *layout = qobject_cast<QTextDocumentLayout *>(doc->documentLayout()); executed (the execution status of this line is deduced): QTextDocumentLayout *layout = qobject_cast<QTextDocumentLayout *>(doc->documentLayout()); | - |
1475 | | - |
1476 | // the layout might need to expand the root frame to | - |
1477 | // the viewport if NoWrap is set | - |
1478 | if (layout) partially evaluated: layout yes Evaluation Count:109 | no Evaluation Count:0 |
| 0-109 |
1479 | layout->setViewport(viewport->rect()); executed: layout->setViewport(viewport->rect()); Execution Count:109 | 109 |
1480 | | - |
1481 | control->drawContents(p, r, q_func()); executed (the execution status of this line is deduced): control->drawContents(p, r, q_func()); | - |
1482 | | - |
1483 | if (layout) partially evaluated: layout yes Evaluation Count:109 | no Evaluation Count:0 |
| 0-109 |
1484 | layout->setViewport(QRect()); executed: layout->setViewport(QRect()); Execution Count:109 | 109 |
1485 | } executed: } Execution Count:109 | 109 |
1486 | | - |
1487 | /*! \fn void QTextEdit::paintEvent(QPaintEvent *event) | - |
1488 | | - |
1489 | This event handler can be reimplemented in a subclass to receive paint events passed in \a event. | - |
1490 | It is usually unnecessary to reimplement this function in a subclass of QTextEdit. | - |
1491 | | - |
1492 | \warning The underlying text document must not be modified from within a reimplementation | - |
1493 | of this function. | - |
1494 | */ | - |
1495 | void QTextEdit::paintEvent(QPaintEvent *e) | - |
1496 | { | - |
1497 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1498 | QPainter p(d->viewport); executed (the execution status of this line is deduced): QPainter p(d->viewport); | - |
1499 | d->paint(&p, e); executed (the execution status of this line is deduced): d->paint(&p, e); | - |
1500 | } executed: } Execution Count:83 | 83 |
1501 | | - |
1502 | void QTextEditPrivate::_q_currentCharFormatChanged(const QTextCharFormat &fmt) | - |
1503 | { | - |
1504 | Q_Q(QTextEdit); executed (the execution status of this line is deduced): QTextEdit * const q = q_func(); | - |
1505 | emit q->currentCharFormatChanged(fmt); executed (the execution status of this line is deduced): q->currentCharFormatChanged(fmt); | - |
1506 | } executed: } Execution Count:35 | 35 |
1507 | | - |
1508 | void QTextEditPrivate::updateDefaultTextOption() | - |
1509 | { | - |
1510 | QTextDocument *doc = control->document(); executed (the execution status of this line is deduced): QTextDocument *doc = control->document(); | - |
1511 | | - |
1512 | QTextOption opt = doc->defaultTextOption(); executed (the execution status of this line is deduced): QTextOption opt = doc->defaultTextOption(); | - |
1513 | QTextOption::WrapMode oldWrapMode = opt.wrapMode(); executed (the execution status of this line is deduced): QTextOption::WrapMode oldWrapMode = opt.wrapMode(); | - |
1514 | | - |
1515 | if (lineWrap == QTextEdit::NoWrap) partially evaluated: lineWrap == QTextEdit::NoWrap no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
1516 | opt.setWrapMode(QTextOption::NoWrap); never executed: opt.setWrapMode(QTextOption::NoWrap); | 0 |
1517 | else | - |
1518 | opt.setWrapMode(wordWrap); executed: opt.setWrapMode(wordWrap); Execution Count:4 | 4 |
1519 | | - |
1520 | if (opt.wrapMode() != oldWrapMode) partially evaluated: opt.wrapMode() != oldWrapMode no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
1521 | doc->setDefaultTextOption(opt); never executed: doc->setDefaultTextOption(opt); | 0 |
1522 | } executed: } Execution Count:4 | 4 |
1523 | | - |
1524 | /*! \reimp | - |
1525 | */ | - |
1526 | void QTextEdit::mousePressEvent(QMouseEvent *e) | - |
1527 | { | - |
1528 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1529 | #ifdef QT_KEYPAD_NAVIGATION | - |
1530 | if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) | - |
1531 | setEditFocus(true); | - |
1532 | #endif | - |
1533 | d->sendControlEvent(e); never executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
1534 | } | 0 |
1535 | | - |
1536 | /*! \reimp | - |
1537 | */ | - |
1538 | void QTextEdit::mouseMoveEvent(QMouseEvent *e) | - |
1539 | { | - |
1540 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1541 | d->inDrag = false; // paranoia never executed (the execution status of this line is deduced): d->inDrag = false; | - |
1542 | const QPoint pos = e->pos(); never executed (the execution status of this line is deduced): const QPoint pos = e->pos(); | - |
1543 | d->sendControlEvent(e); never executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
1544 | if (!(e->buttons() & Qt::LeftButton)) never evaluated: !(e->buttons() & Qt::LeftButton) | 0 |
1545 | return; | 0 |
1546 | QRect visible = d->viewport->rect(); never executed (the execution status of this line is deduced): QRect visible = d->viewport->rect(); | - |
1547 | if (visible.contains(pos)) never evaluated: visible.contains(pos) | 0 |
1548 | d->autoScrollTimer.stop(); never executed: d->autoScrollTimer.stop(); | 0 |
1549 | else if (!d->autoScrollTimer.isActive()) never evaluated: !d->autoScrollTimer.isActive() | 0 |
1550 | d->autoScrollTimer.start(100, this); never executed: d->autoScrollTimer.start(100, this); | 0 |
1551 | } | - |
1552 | | - |
1553 | /*! \reimp | - |
1554 | */ | - |
1555 | void QTextEdit::mouseReleaseEvent(QMouseEvent *e) | - |
1556 | { | - |
1557 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1558 | d->sendControlEvent(e); never executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
1559 | if (d->autoScrollTimer.isActive()) { never evaluated: d->autoScrollTimer.isActive() | 0 |
1560 | d->autoScrollTimer.stop(); never executed (the execution status of this line is deduced): d->autoScrollTimer.stop(); | - |
1561 | ensureCursorVisible(); never executed (the execution status of this line is deduced): ensureCursorVisible(); | - |
1562 | } | 0 |
1563 | if (!isReadOnly() && rect().contains(e->pos())) never evaluated: !isReadOnly() never evaluated: rect().contains(e->pos()) | 0 |
1564 | d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus); never executed: d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus); | 0 |
1565 | d->clickCausedFocus = 0; never executed (the execution status of this line is deduced): d->clickCausedFocus = 0; | - |
1566 | } | 0 |
1567 | | - |
1568 | /*! \reimp | - |
1569 | */ | - |
1570 | void QTextEdit::mouseDoubleClickEvent(QMouseEvent *e) | - |
1571 | { | - |
1572 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1573 | d->sendControlEvent(e); never executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
1574 | } | 0 |
1575 | | - |
1576 | /*! \reimp | - |
1577 | */ | - |
1578 | bool QTextEdit::focusNextPrevChild(bool next) | - |
1579 | { | - |
1580 | Q_D(const QTextEdit); executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
1581 | if (!d->tabChangesFocus && d->control->textInteractionFlags() & Qt::TextEditable) partially evaluated: !d->tabChangesFocus yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: d->control->textInteractionFlags() & Qt::TextEditable no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1582 | return false; never executed: return false; | 0 |
1583 | return QAbstractScrollArea::focusNextPrevChild(next); executed: return QAbstractScrollArea::focusNextPrevChild(next); Execution Count:1 | 1 |
1584 | } | - |
1585 | | - |
1586 | #ifndef QT_NO_CONTEXTMENU | - |
1587 | /*! | - |
1588 | \fn void QTextEdit::contextMenuEvent(QContextMenuEvent *event) | - |
1589 | | - |
1590 | Shows the standard context menu created with createStandardContextMenu(). | - |
1591 | | - |
1592 | If you do not want the text edit to have a context menu, you can set | - |
1593 | its \l contextMenuPolicy to Qt::NoContextMenu. If you want to | - |
1594 | customize the context menu, reimplement this function. If you want | - |
1595 | to extend the standard context menu, reimplement this function, call | - |
1596 | createStandardContextMenu() and extend the menu returned. | - |
1597 | | - |
1598 | Information about the event is passed in the \a event object. | - |
1599 | | - |
1600 | \snippet code/src_gui_widgets_qtextedit.cpp 0 | - |
1601 | */ | - |
1602 | void QTextEdit::contextMenuEvent(QContextMenuEvent *e) | - |
1603 | { | - |
1604 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1605 | d->sendControlEvent(e); never executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
1606 | } | 0 |
1607 | #endif // QT_NO_CONTEXTMENU | - |
1608 | | - |
1609 | #ifndef QT_NO_DRAGANDDROP | - |
1610 | /*! \reimp | - |
1611 | */ | - |
1612 | void QTextEdit::dragEnterEvent(QDragEnterEvent *e) | - |
1613 | { | - |
1614 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1615 | d->inDrag = true; never executed (the execution status of this line is deduced): d->inDrag = true; | - |
1616 | d->sendControlEvent(e); never executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
1617 | } | 0 |
1618 | | - |
1619 | /*! \reimp | - |
1620 | */ | - |
1621 | void QTextEdit::dragLeaveEvent(QDragLeaveEvent *e) | - |
1622 | { | - |
1623 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1624 | d->inDrag = false; never executed (the execution status of this line is deduced): d->inDrag = false; | - |
1625 | d->autoScrollTimer.stop(); never executed (the execution status of this line is deduced): d->autoScrollTimer.stop(); | - |
1626 | d->sendControlEvent(e); never executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
1627 | } | 0 |
1628 | | - |
1629 | /*! \reimp | - |
1630 | */ | - |
1631 | void QTextEdit::dragMoveEvent(QDragMoveEvent *e) | - |
1632 | { | - |
1633 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1634 | d->autoScrollDragPos = e->pos(); never executed (the execution status of this line is deduced): d->autoScrollDragPos = e->pos(); | - |
1635 | if (!d->autoScrollTimer.isActive()) never evaluated: !d->autoScrollTimer.isActive() | 0 |
1636 | d->autoScrollTimer.start(100, this); never executed: d->autoScrollTimer.start(100, this); | 0 |
1637 | d->sendControlEvent(e); never executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
1638 | } | 0 |
1639 | | - |
1640 | /*! \reimp | - |
1641 | */ | - |
1642 | void QTextEdit::dropEvent(QDropEvent *e) | - |
1643 | { | - |
1644 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1645 | d->inDrag = false; never executed (the execution status of this line is deduced): d->inDrag = false; | - |
1646 | d->autoScrollTimer.stop(); never executed (the execution status of this line is deduced): d->autoScrollTimer.stop(); | - |
1647 | d->sendControlEvent(e); never executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
1648 | } | 0 |
1649 | | - |
1650 | #endif // QT_NO_DRAGANDDROP | - |
1651 | | - |
1652 | /*! \reimp | - |
1653 | */ | - |
1654 | void QTextEdit::inputMethodEvent(QInputMethodEvent *e) | - |
1655 | { | - |
1656 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1657 | #ifdef QT_KEYPAD_NAVIGATION | - |
1658 | if (d->control->textInteractionFlags() & Qt::TextEditable | - |
1659 | && QApplication::keypadNavigationEnabled() | - |
1660 | && !hasEditFocus()) | - |
1661 | setEditFocus(true); | - |
1662 | #endif | - |
1663 | d->sendControlEvent(e); never executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
1664 | ensureCursorVisible(); never executed (the execution status of this line is deduced): ensureCursorVisible(); | - |
1665 | } | 0 |
1666 | | - |
1667 | /*!\reimp | - |
1668 | */ | - |
1669 | void QTextEdit::scrollContentsBy(int dx, int dy) | - |
1670 | { | - |
1671 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1672 | if (isRightToLeft()) partially evaluated: isRightToLeft() no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
1673 | dx = -dx; never executed: dx = -dx; | 0 |
1674 | d->viewport->scroll(dx, dy); executed (the execution status of this line is deduced): d->viewport->scroll(dx, dy); | - |
1675 | } executed: } Execution Count:12 | 12 |
1676 | | - |
1677 | /*!\reimp | - |
1678 | */ | - |
1679 | QVariant QTextEdit::inputMethodQuery(Qt::InputMethodQuery property) const | - |
1680 | { | - |
1681 | Q_D(const QTextEdit); executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
1682 | QVariant v; executed (the execution status of this line is deduced): QVariant v; | - |
1683 | switch (property) { | - |
1684 | case Qt::ImHints: | - |
1685 | v = QWidget::inputMethodQuery(property); never executed (the execution status of this line is deduced): v = QWidget::inputMethodQuery(property); | - |
1686 | break; | 0 |
1687 | default: | - |
1688 | v = d->control->inputMethodQuery(property); executed (the execution status of this line is deduced): v = d->control->inputMethodQuery(property); | - |
1689 | const QPoint offset(-d->horizontalOffset(), -d->verticalOffset()); executed (the execution status of this line is deduced): const QPoint offset(-d->horizontalOffset(), -d->verticalOffset()); | - |
1690 | if (v.type() == QVariant::RectF) partially evaluated: v.type() == QVariant::RectF no Evaluation Count:0 | yes Evaluation Count:448 |
| 0-448 |
1691 | v = v.toRectF().toRect().translated(offset); never executed: v = v.toRectF().toRect().translated(offset); | 0 |
1692 | else if (v.type() == QVariant::PointF) partially evaluated: v.type() == QVariant::PointF no Evaluation Count:0 | yes Evaluation Count:448 |
| 0-448 |
1693 | v = v.toPointF().toPoint() + offset; never executed: v = v.toPointF().toPoint() + offset; | 0 |
1694 | else if (v.type() == QVariant::Rect) partially evaluated: v.type() == QVariant::Rect no Evaluation Count:0 | yes Evaluation Count:448 |
| 0-448 |
1695 | v = v.toRect().translated(offset); never executed: v = v.toRect().translated(offset); | 0 |
1696 | else if (v.type() == QVariant::Point) partially evaluated: v.type() == QVariant::Point no Evaluation Count:0 | yes Evaluation Count:448 |
| 0-448 |
1697 | v = v.toPoint() + offset; never executed: v = v.toPoint() + offset; | 0 |
1698 | } | - |
1699 | | - |
1700 | return v; executed: return v; Execution Count:448 | 448 |
1701 | } | - |
1702 | | - |
1703 | /*! \reimp | - |
1704 | */ | - |
1705 | void QTextEdit::focusInEvent(QFocusEvent *e) | - |
1706 | { | - |
1707 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1708 | if (e->reason() == Qt::MouseFocusReason) { partially evaluated: e->reason() == Qt::MouseFocusReason no Evaluation Count:0 | yes Evaluation Count:69 |
| 0-69 |
1709 | d->clickCausedFocus = 1; never executed (the execution status of this line is deduced): d->clickCausedFocus = 1; | - |
1710 | } | 0 |
1711 | QAbstractScrollArea::focusInEvent(e); executed (the execution status of this line is deduced): QAbstractScrollArea::focusInEvent(e); | - |
1712 | d->sendControlEvent(e); executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
1713 | } executed: } Execution Count:69 | 69 |
1714 | | - |
1715 | /*! \reimp | - |
1716 | */ | - |
1717 | void QTextEdit::focusOutEvent(QFocusEvent *e) | - |
1718 | { | - |
1719 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1720 | QAbstractScrollArea::focusOutEvent(e); executed (the execution status of this line is deduced): QAbstractScrollArea::focusOutEvent(e); | - |
1721 | d->sendControlEvent(e); executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
1722 | } executed: } Execution Count:45 | 45 |
1723 | | - |
1724 | /*! \reimp | - |
1725 | */ | - |
1726 | void QTextEdit::showEvent(QShowEvent *) | - |
1727 | { | - |
1728 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1729 | if (!d->anchorToScrollToWhenVisible.isEmpty()) { partially evaluated: !d->anchorToScrollToWhenVisible.isEmpty() no Evaluation Count:0 | yes Evaluation Count:131 |
| 0-131 |
1730 | scrollToAnchor(d->anchorToScrollToWhenVisible); never executed (the execution status of this line is deduced): scrollToAnchor(d->anchorToScrollToWhenVisible); | - |
1731 | d->anchorToScrollToWhenVisible.clear(); never executed (the execution status of this line is deduced): d->anchorToScrollToWhenVisible.clear(); | - |
1732 | d->showCursorOnInitialShow = false; never executed (the execution status of this line is deduced): d->showCursorOnInitialShow = false; | - |
1733 | } else if (d->showCursorOnInitialShow) { never executed: } evaluated: d->showCursorOnInitialShow yes Evaluation Count:69 | yes Evaluation Count:62 |
| 0-69 |
1734 | d->showCursorOnInitialShow = false; executed (the execution status of this line is deduced): d->showCursorOnInitialShow = false; | - |
1735 | ensureCursorVisible(); executed (the execution status of this line is deduced): ensureCursorVisible(); | - |
1736 | } executed: } Execution Count:69 | 69 |
1737 | } | - |
1738 | | - |
1739 | /*! \reimp | - |
1740 | */ | - |
1741 | void QTextEdit::changeEvent(QEvent *e) | - |
1742 | { | - |
1743 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1744 | QAbstractScrollArea::changeEvent(e); executed (the execution status of this line is deduced): QAbstractScrollArea::changeEvent(e); | - |
1745 | if (e->type() == QEvent::ApplicationFontChange partially evaluated: e->type() == QEvent::ApplicationFontChange no Evaluation Count:0 | yes Evaluation Count:351 |
| 0-351 |
1746 | || e->type() == QEvent::FontChange) { partially evaluated: e->type() == QEvent::FontChange no Evaluation Count:0 | yes Evaluation Count:351 |
| 0-351 |
1747 | d->control->document()->setDefaultFont(font()); never executed (the execution status of this line is deduced): d->control->document()->setDefaultFont(font()); | - |
1748 | } else if(e->type() == QEvent::ActivationChange) { never executed: } evaluated: e->type() == QEvent::ActivationChange yes Evaluation Count:32 | yes Evaluation Count:319 |
| 0-319 |
1749 | if (!isActiveWindow()) evaluated: !isActiveWindow() yes Evaluation Count:4 | yes Evaluation Count:28 |
| 4-28 |
1750 | d->autoScrollTimer.stop(); executed: d->autoScrollTimer.stop(); Execution Count:4 | 4 |
1751 | } else if (e->type() == QEvent::EnabledChange) { executed: } Execution Count:32 partially evaluated: e->type() == QEvent::EnabledChange no Evaluation Count:0 | yes Evaluation Count:319 |
| 0-319 |
1752 | e->setAccepted(isEnabled()); never executed (the execution status of this line is deduced): e->setAccepted(isEnabled()); | - |
1753 | d->control->setPalette(palette()); never executed (the execution status of this line is deduced): d->control->setPalette(palette()); | - |
1754 | d->sendControlEvent(e); never executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
1755 | } else if (e->type() == QEvent::PaletteChange) { never executed: } partially evaluated: e->type() == QEvent::PaletteChange no Evaluation Count:0 | yes Evaluation Count:319 |
| 0-319 |
1756 | d->control->setPalette(palette()); never executed (the execution status of this line is deduced): d->control->setPalette(palette()); | - |
1757 | } else if (e->type() == QEvent::LayoutDirectionChange) { never executed: } partially evaluated: e->type() == QEvent::LayoutDirectionChange no Evaluation Count:0 | yes Evaluation Count:319 |
| 0-319 |
1758 | d->sendControlEvent(e); never executed (the execution status of this line is deduced): d->sendControlEvent(e); | - |
1759 | } | 0 |
1760 | } | - |
1761 | | - |
1762 | /*! \reimp | - |
1763 | */ | - |
1764 | #ifndef QT_NO_WHEELEVENT | - |
1765 | void QTextEdit::wheelEvent(QWheelEvent *e) | - |
1766 | { | - |
1767 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1768 | if (!(d->control->textInteractionFlags() & Qt::TextEditable)) { never evaluated: !(d->control->textInteractionFlags() & Qt::TextEditable) | 0 |
1769 | if (e->modifiers() & Qt::ControlModifier) { never evaluated: e->modifiers() & Qt::ControlModifier | 0 |
1770 | const int delta = e->delta(); never executed (the execution status of this line is deduced): const int delta = e->delta(); | - |
1771 | if (delta < 0) never evaluated: delta < 0 | 0 |
1772 | zoomOut(); never executed: zoomOut(); | 0 |
1773 | else if (delta > 0) never evaluated: delta > 0 | 0 |
1774 | zoomIn(); never executed: zoomIn(); | 0 |
1775 | return; | 0 |
1776 | } | - |
1777 | } | 0 |
1778 | QAbstractScrollArea::wheelEvent(e); never executed (the execution status of this line is deduced): QAbstractScrollArea::wheelEvent(e); | - |
1779 | updateMicroFocus(); never executed (the execution status of this line is deduced): updateMicroFocus(); | - |
1780 | } | 0 |
1781 | #endif | - |
1782 | | - |
1783 | #ifndef QT_NO_CONTEXTMENU | - |
1784 | /*! This function creates the standard context menu which is shown | - |
1785 | when the user clicks on the text edit with the right mouse | - |
1786 | button. It is called from the default contextMenuEvent() handler. | - |
1787 | The popup menu's ownership is transferred to the caller. | - |
1788 | | - |
1789 | We recommend that you use the createStandardContextMenu(QPoint) version instead | - |
1790 | which will enable the actions that are sensitive to where the user clicked. | - |
1791 | */ | - |
1792 | | - |
1793 | QMenu *QTextEdit::createStandardContextMenu() | - |
1794 | { | - |
1795 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1796 | return d->control->createStandardContextMenu(QPointF(), this); never executed: return d->control->createStandardContextMenu(QPointF(), this); | 0 |
1797 | } | - |
1798 | | - |
1799 | /*! | - |
1800 | \since 4.4 | - |
1801 | This function creates the standard context menu which is shown | - |
1802 | when the user clicks on the text edit with the right mouse | - |
1803 | button. It is called from the default contextMenuEvent() handler | - |
1804 | and it takes the \a position of where the mouse click was. | - |
1805 | This can enable actions that are sensitive to the position where the user clicked. | - |
1806 | The popup menu's ownership is transferred to the caller. | - |
1807 | */ | - |
1808 | | - |
1809 | QMenu *QTextEdit::createStandardContextMenu(const QPoint &position) | - |
1810 | { | - |
1811 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1812 | return d->control->createStandardContextMenu(position, this); never executed: return d->control->createStandardContextMenu(position, this); | 0 |
1813 | } | - |
1814 | #endif // QT_NO_CONTEXTMENU | - |
1815 | | - |
1816 | /*! | - |
1817 | returns a QTextCursor at position \a pos (in viewport coordinates). | - |
1818 | */ | - |
1819 | QTextCursor QTextEdit::cursorForPosition(const QPoint &pos) const | - |
1820 | { | - |
1821 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
1822 | return d->control->cursorForPosition(d->mapToContents(pos)); never executed: return d->control->cursorForPosition(d->mapToContents(pos)); | 0 |
1823 | } | - |
1824 | | - |
1825 | /*! | - |
1826 | returns a rectangle (in viewport coordinates) that includes the | - |
1827 | \a cursor. | - |
1828 | */ | - |
1829 | QRect QTextEdit::cursorRect(const QTextCursor &cursor) const | - |
1830 | { | - |
1831 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
1832 | if (cursor.isNull()) never evaluated: cursor.isNull() | 0 |
1833 | return QRect(); never executed: return QRect(); | 0 |
1834 | | - |
1835 | QRect r = d->control->cursorRect(cursor).toRect(); never executed (the execution status of this line is deduced): QRect r = d->control->cursorRect(cursor).toRect(); | - |
1836 | r.translate(-d->horizontalOffset(),-d->verticalOffset()); never executed (the execution status of this line is deduced): r.translate(-d->horizontalOffset(),-d->verticalOffset()); | - |
1837 | return r; never executed: return r; | 0 |
1838 | } | - |
1839 | | - |
1840 | /*! | - |
1841 | returns a rectangle (in viewport coordinates) that includes the | - |
1842 | cursor of the text edit. | - |
1843 | */ | - |
1844 | QRect QTextEdit::cursorRect() const | - |
1845 | { | - |
1846 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
1847 | QRect r = d->control->cursorRect().toRect(); never executed (the execution status of this line is deduced): QRect r = d->control->cursorRect().toRect(); | - |
1848 | r.translate(-d->horizontalOffset(),-d->verticalOffset()); never executed (the execution status of this line is deduced): r.translate(-d->horizontalOffset(),-d->verticalOffset()); | - |
1849 | return r; never executed: return r; | 0 |
1850 | } | - |
1851 | | - |
1852 | | - |
1853 | /*! | - |
1854 | Returns the reference of the anchor at position \a pos, or an | - |
1855 | empty string if no anchor exists at that point. | - |
1856 | */ | - |
1857 | QString QTextEdit::anchorAt(const QPoint& pos) const | - |
1858 | { | - |
1859 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
1860 | return d->control->anchorAt(d->mapToContents(pos)); never executed: return d->control->anchorAt(d->mapToContents(pos)); | 0 |
1861 | } | - |
1862 | | - |
1863 | /*! | - |
1864 | \property QTextEdit::overwriteMode | - |
1865 | \since 4.1 | - |
1866 | \brief whether text entered by the user will overwrite existing text | - |
1867 | | - |
1868 | As with many text editors, the text editor widget can be configured | - |
1869 | to insert or overwrite existing text with new text entered by the user. | - |
1870 | | - |
1871 | If this property is true, existing text is overwritten, character-for-character | - |
1872 | by new text; otherwise, text is inserted at the cursor position, displacing | - |
1873 | existing text. | - |
1874 | | - |
1875 | By default, this property is false (new text does not overwrite existing text). | - |
1876 | */ | - |
1877 | | - |
1878 | bool QTextEdit::overwriteMode() const | - |
1879 | { | - |
1880 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
1881 | return d->control->overwriteMode(); never executed: return d->control->overwriteMode(); | 0 |
1882 | } | - |
1883 | | - |
1884 | void QTextEdit::setOverwriteMode(bool overwrite) | - |
1885 | { | - |
1886 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1887 | d->control->setOverwriteMode(overwrite); never executed (the execution status of this line is deduced): d->control->setOverwriteMode(overwrite); | - |
1888 | } | 0 |
1889 | | - |
1890 | /*! | - |
1891 | \property QTextEdit::tabStopWidth | - |
1892 | \brief the tab stop width in pixels | - |
1893 | \since 4.1 | - |
1894 | | - |
1895 | By default, this property contains a value of 80 pixels. | - |
1896 | */ | - |
1897 | | - |
1898 | int QTextEdit::tabStopWidth() const | - |
1899 | { | - |
1900 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
1901 | return qRound(d->control->document()->defaultTextOption().tabStop()); never executed: return qRound(d->control->document()->defaultTextOption().tabStop()); | 0 |
1902 | } | - |
1903 | | - |
1904 | void QTextEdit::setTabStopWidth(int width) | - |
1905 | { | - |
1906 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1907 | QTextOption opt = d->control->document()->defaultTextOption(); never executed (the execution status of this line is deduced): QTextOption opt = d->control->document()->defaultTextOption(); | - |
1908 | if (opt.tabStop() == width || width < 0) never evaluated: opt.tabStop() == width never evaluated: width < 0 | 0 |
1909 | return; | 0 |
1910 | opt.setTabStop(width); never executed (the execution status of this line is deduced): opt.setTabStop(width); | - |
1911 | d->control->document()->setDefaultTextOption(opt); never executed (the execution status of this line is deduced): d->control->document()->setDefaultTextOption(opt); | - |
1912 | } | 0 |
1913 | | - |
1914 | /*! | - |
1915 | \since 4.2 | - |
1916 | \property QTextEdit::cursorWidth | - |
1917 | | - |
1918 | This property specifies the width of the cursor in pixels. The default value is 1. | - |
1919 | */ | - |
1920 | int QTextEdit::cursorWidth() const | - |
1921 | { | - |
1922 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
1923 | return d->control->cursorWidth(); never executed: return d->control->cursorWidth(); | 0 |
1924 | } | - |
1925 | | - |
1926 | void QTextEdit::setCursorWidth(int width) | - |
1927 | { | - |
1928 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1929 | d->control->setCursorWidth(width); never executed (the execution status of this line is deduced): d->control->setCursorWidth(width); | - |
1930 | } | 0 |
1931 | | - |
1932 | /*! | - |
1933 | \property QTextEdit::acceptRichText | - |
1934 | \brief whether the text edit accepts rich text insertions by the user | - |
1935 | \since 4.1 | - |
1936 | | - |
1937 | When this propery is set to false text edit will accept only | - |
1938 | plain text input from the user. For example through clipboard or drag and drop. | - |
1939 | | - |
1940 | This property's default is true. | - |
1941 | */ | - |
1942 | | - |
1943 | bool QTextEdit::acceptRichText() const | - |
1944 | { | - |
1945 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
1946 | return d->control->acceptRichText(); never executed: return d->control->acceptRichText(); | 0 |
1947 | } | - |
1948 | | - |
1949 | void QTextEdit::setAcceptRichText(bool accept) | - |
1950 | { | - |
1951 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1952 | d->control->setAcceptRichText(accept); never executed (the execution status of this line is deduced): d->control->setAcceptRichText(accept); | - |
1953 | } | 0 |
1954 | | - |
1955 | /*! | - |
1956 | \class QTextEdit::ExtraSelection | - |
1957 | \since 4.2 | - |
1958 | \inmodule QtWidgets | - |
1959 | | - |
1960 | \brief The QTextEdit::ExtraSelection structure provides a way of specifying a | - |
1961 | character format for a given selection in a document | - |
1962 | */ | - |
1963 | | - |
1964 | /*! | - |
1965 | \variable QTextEdit::ExtraSelection::cursor | - |
1966 | A cursor that contains a selection in a QTextDocument | - |
1967 | */ | - |
1968 | | - |
1969 | /*! | - |
1970 | \variable QTextEdit::ExtraSelection::format | - |
1971 | A format that is used to specify a foreground or background brush/color | - |
1972 | for the selection. | - |
1973 | */ | - |
1974 | | - |
1975 | /*! | - |
1976 | \since 4.2 | - |
1977 | This function allows temporarily marking certain regions in the document | - |
1978 | with a given color, specified as \a selections. This can be useful for | - |
1979 | example in a programming editor to mark a whole line of text with a given | - |
1980 | background color to indicate the existence of a breakpoint. | - |
1981 | | - |
1982 | \sa QTextEdit::ExtraSelection, extraSelections() | - |
1983 | */ | - |
1984 | void QTextEdit::setExtraSelections(const QList<ExtraSelection> &selections) | - |
1985 | { | - |
1986 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
1987 | d->control->setExtraSelections(selections); never executed (the execution status of this line is deduced): d->control->setExtraSelections(selections); | - |
1988 | } | 0 |
1989 | | - |
1990 | /*! | - |
1991 | \since 4.2 | - |
1992 | Returns previously set extra selections. | - |
1993 | | - |
1994 | \sa setExtraSelections() | - |
1995 | */ | - |
1996 | QList<QTextEdit::ExtraSelection> QTextEdit::extraSelections() const | - |
1997 | { | - |
1998 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
1999 | return d->control->extraSelections(); never executed: return d->control->extraSelections(); | 0 |
2000 | } | - |
2001 | | - |
2002 | /*! | - |
2003 | This function returns a new MIME data object to represent the contents | - |
2004 | of the text edit's current selection. It is called when the selection needs | - |
2005 | to be encapsulated into a new QMimeData object; for example, when a drag | - |
2006 | and drop operation is started, or when data is copyied to the clipboard. | - |
2007 | | - |
2008 | If you reimplement this function, note that the ownership of the returned | - |
2009 | QMimeData object is passed to the caller. The selection can be retrieved | - |
2010 | by using the textCursor() function. | - |
2011 | */ | - |
2012 | QMimeData *QTextEdit::createMimeDataFromSelection() const | - |
2013 | { | - |
2014 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
2015 | return d->control->QWidgetTextControl::createMimeDataFromSelection(); never executed: return d->control->QWidgetTextControl::createMimeDataFromSelection(); | 0 |
2016 | } | - |
2017 | | - |
2018 | /*! | - |
2019 | This function returns true if the contents of the MIME data object, specified | - |
2020 | by \a source, can be decoded and inserted into the document. It is called | - |
2021 | for example when during a drag operation the mouse enters this widget and it | - |
2022 | is necessary to determine whether it is possible to accept the drag and drop | - |
2023 | operation. | - |
2024 | | - |
2025 | Reimplement this function to enable drag and drop support for additional MIME types. | - |
2026 | */ | - |
2027 | bool QTextEdit::canInsertFromMimeData(const QMimeData *source) const | - |
2028 | { | - |
2029 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
2030 | return d->control->QWidgetTextControl::canInsertFromMimeData(source); never executed: return d->control->QWidgetTextControl::canInsertFromMimeData(source); | 0 |
2031 | } | - |
2032 | | - |
2033 | /*! | - |
2034 | This function inserts the contents of the MIME data object, specified | - |
2035 | by \a source, into the text edit at the current cursor position. It is | - |
2036 | called whenever text is inserted as the result of a clipboard paste | - |
2037 | operation, or when the text edit accepts data from a drag and drop | - |
2038 | operation. | - |
2039 | | - |
2040 | Reimplement this function to enable drag and drop support for additional MIME types. | - |
2041 | */ | - |
2042 | void QTextEdit::insertFromMimeData(const QMimeData *source) | - |
2043 | { | - |
2044 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
2045 | d->control->QWidgetTextControl::insertFromMimeData(source); never executed (the execution status of this line is deduced): d->control->QWidgetTextControl::insertFromMimeData(source); | - |
2046 | } | 0 |
2047 | | - |
2048 | /*! | - |
2049 | \property QTextEdit::readOnly | - |
2050 | \brief whether the text edit is read-only | - |
2051 | | - |
2052 | In a read-only text edit the user can only navigate through the | - |
2053 | text and select text; modifying the text is not possible. | - |
2054 | | - |
2055 | This property's default is false. | - |
2056 | */ | - |
2057 | | - |
2058 | bool QTextEdit::isReadOnly() const | - |
2059 | { | - |
2060 | Q_D(const QTextEdit); executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
2061 | return !(d->control->textInteractionFlags() & Qt::TextEditable); executed: return !(d->control->textInteractionFlags() & Qt::TextEditable); Execution Count:8 | 8 |
2062 | } | - |
2063 | | - |
2064 | void QTextEdit::setReadOnly(bool ro) | - |
2065 | { | - |
2066 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
2067 | Qt::TextInteractionFlags flags = Qt::NoTextInteraction; executed (the execution status of this line is deduced): Qt::TextInteractionFlags flags = Qt::NoTextInteraction; | - |
2068 | if (ro) { evaluated: ro yes Evaluation Count:6 | yes Evaluation Count:1 |
| 1-6 |
2069 | flags = Qt::TextSelectableByMouse; executed (the execution status of this line is deduced): flags = Qt::TextSelectableByMouse; | - |
2070 | #ifndef QT_NO_TEXTBROWSER | - |
2071 | if (qobject_cast<QTextBrowser *>(this)) evaluated: qobject_cast<QTextBrowser *>(this) yes Evaluation Count:2 | yes Evaluation Count:4 |
| 2-4 |
2072 | flags |= Qt::TextBrowserInteraction; executed: flags |= Qt::TextBrowserInteraction; Execution Count:2 | 2 |
2073 | #endif | - |
2074 | } else { executed: } Execution Count:6 | 6 |
2075 | flags = Qt::TextEditorInteraction; executed (the execution status of this line is deduced): flags = Qt::TextEditorInteraction; | - |
2076 | } executed: } Execution Count:1 | 1 |
2077 | d->control->setTextInteractionFlags(flags); executed (the execution status of this line is deduced): d->control->setTextInteractionFlags(flags); | - |
2078 | setAttribute(Qt::WA_InputMethodEnabled, shouldEnableInputMethod(this)); executed (the execution status of this line is deduced): setAttribute(Qt::WA_InputMethodEnabled, shouldEnableInputMethod(this)); | - |
2079 | } executed: } Execution Count:7 | 7 |
2080 | | - |
2081 | /*! | - |
2082 | \property QTextEdit::textInteractionFlags | - |
2083 | \since 4.2 | - |
2084 | | - |
2085 | Specifies how the widget should interact with user input. | - |
2086 | | - |
2087 | The default value depends on whether the QTextEdit is read-only | - |
2088 | or editable, and whether it is a QTextBrowser or not. | - |
2089 | */ | - |
2090 | | - |
2091 | void QTextEdit::setTextInteractionFlags(Qt::TextInteractionFlags flags) | - |
2092 | { | - |
2093 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
2094 | d->control->setTextInteractionFlags(flags); never executed (the execution status of this line is deduced): d->control->setTextInteractionFlags(flags); | - |
2095 | } | 0 |
2096 | | - |
2097 | Qt::TextInteractionFlags QTextEdit::textInteractionFlags() const | - |
2098 | { | - |
2099 | Q_D(const QTextEdit); executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
2100 | return d->control->textInteractionFlags(); executed: return d->control->textInteractionFlags(); Execution Count:4 | 4 |
2101 | } | - |
2102 | | - |
2103 | /*! | - |
2104 | Merges the properties specified in \a modifier into the current character | - |
2105 | format by calling QTextCursor::mergeCharFormat on the editor's cursor. | - |
2106 | If the editor has a selection then the properties of \a modifier are | - |
2107 | directly applied to the selection. | - |
2108 | | - |
2109 | \sa QTextCursor::mergeCharFormat() | - |
2110 | */ | - |
2111 | void QTextEdit::mergeCurrentCharFormat(const QTextCharFormat &modifier) | - |
2112 | { | - |
2113 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
2114 | d->control->mergeCurrentCharFormat(modifier); executed (the execution status of this line is deduced): d->control->mergeCurrentCharFormat(modifier); | - |
2115 | } executed: } Execution Count:1 | 1 |
2116 | | - |
2117 | /*! | - |
2118 | Sets the char format that is be used when inserting new text to \a | - |
2119 | format by calling QTextCursor::setCharFormat() on the editor's | - |
2120 | cursor. If the editor has a selection then the char format is | - |
2121 | directly applied to the selection. | - |
2122 | */ | - |
2123 | void QTextEdit::setCurrentCharFormat(const QTextCharFormat &format) | - |
2124 | { | - |
2125 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
2126 | d->control->setCurrentCharFormat(format); never executed (the execution status of this line is deduced): d->control->setCurrentCharFormat(format); | - |
2127 | } | 0 |
2128 | | - |
2129 | /*! | - |
2130 | Returns the char format that is used when inserting new text. | - |
2131 | */ | - |
2132 | QTextCharFormat QTextEdit::currentCharFormat() const | - |
2133 | { | - |
2134 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
2135 | return d->control->currentCharFormat(); never executed: return d->control->currentCharFormat(); | 0 |
2136 | } | - |
2137 | | - |
2138 | /*! | - |
2139 | \property QTextEdit::autoFormatting | - |
2140 | \brief the enabled set of auto formatting features | - |
2141 | | - |
2142 | The value can be any combination of the values in the | - |
2143 | AutoFormattingFlag enum. The default is AutoNone. Choose | - |
2144 | AutoAll to enable all automatic formatting. | - |
2145 | | - |
2146 | Currently, the only automatic formatting feature provided is | - |
2147 | AutoBulletList; future versions of Qt may offer more. | - |
2148 | */ | - |
2149 | | - |
2150 | QTextEdit::AutoFormatting QTextEdit::autoFormatting() const | - |
2151 | { | - |
2152 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
2153 | return d->autoFormatting; never executed: return d->autoFormatting; | 0 |
2154 | } | - |
2155 | | - |
2156 | void QTextEdit::setAutoFormatting(AutoFormatting features) | - |
2157 | { | - |
2158 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
2159 | d->autoFormatting = features; never executed (the execution status of this line is deduced): d->autoFormatting = features; | - |
2160 | } | 0 |
2161 | | - |
2162 | /*! | - |
2163 | Convenience slot that inserts \a text at the current | - |
2164 | cursor position. | - |
2165 | | - |
2166 | It is equivalent to | - |
2167 | | - |
2168 | \snippet code/src_gui_widgets_qtextedit.cpp 1 | - |
2169 | */ | - |
2170 | void QTextEdit::insertPlainText(const QString &text) | - |
2171 | { | - |
2172 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
2173 | d->control->insertPlainText(text); executed (the execution status of this line is deduced): d->control->insertPlainText(text); | - |
2174 | } executed: } Execution Count:2 | 2 |
2175 | | - |
2176 | /*! | - |
2177 | Convenience slot that inserts \a text which is assumed to be of | - |
2178 | html formatting at the current cursor position. | - |
2179 | | - |
2180 | It is equivalent to: | - |
2181 | | - |
2182 | \snippet code/src_gui_widgets_qtextedit.cpp 2 | - |
2183 | | - |
2184 | \note When using this function with a style sheet, the style sheet will | - |
2185 | only apply to the current block in the document. In order to apply a style | - |
2186 | sheet throughout a document, use QTextDocument::setDefaultStyleSheet() | - |
2187 | instead. | - |
2188 | */ | - |
2189 | #ifndef QT_NO_TEXTHTMLPARSER | - |
2190 | void QTextEdit::insertHtml(const QString &text) | - |
2191 | { | - |
2192 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
2193 | d->control->insertHtml(text); never executed (the execution status of this line is deduced): d->control->insertHtml(text); | - |
2194 | } | 0 |
2195 | #endif // QT_NO_TEXTHTMLPARSER | - |
2196 | | - |
2197 | /*! | - |
2198 | Scrolls the text edit so that the anchor with the given \a name is | - |
2199 | visible; does nothing if the \a name is empty, or is already | - |
2200 | visible, or isn't found. | - |
2201 | */ | - |
2202 | void QTextEdit::scrollToAnchor(const QString &name) | - |
2203 | { | - |
2204 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
2205 | if (name.isEmpty()) partially evaluated: name.isEmpty() no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
2206 | return; | 0 |
2207 | | - |
2208 | if (!isVisible()) { partially evaluated: !isVisible() no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
2209 | d->anchorToScrollToWhenVisible = name; never executed (the execution status of this line is deduced): d->anchorToScrollToWhenVisible = name; | - |
2210 | return; | 0 |
2211 | } | - |
2212 | | - |
2213 | QPointF p = d->control->anchorPosition(name); executed (the execution status of this line is deduced): QPointF p = d->control->anchorPosition(name); | - |
2214 | const int newPosition = qRound(p.y()); executed (the execution status of this line is deduced): const int newPosition = qRound(p.y()); | - |
2215 | if ( d->vbar->maximum() < newPosition ) partially evaluated: d->vbar->maximum() < newPosition yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
2216 | d->_q_adjustScrollbars(); executed: d->_q_adjustScrollbars(); Execution Count:5 | 5 |
2217 | d->vbar->setValue(newPosition); executed (the execution status of this line is deduced): d->vbar->setValue(newPosition); | - |
2218 | } executed: } Execution Count:5 | 5 |
2219 | | - |
2220 | /*! | - |
2221 | \fn QTextEdit::zoomIn(int range) | - |
2222 | | - |
2223 | Zooms in on the text by making the base font size \a range | - |
2224 | points larger and recalculating all font sizes to be the new size. | - |
2225 | This does not change the size of any images. | - |
2226 | | - |
2227 | \sa zoomOut() | - |
2228 | */ | - |
2229 | void QTextEdit::zoomIn(int range) | - |
2230 | { | - |
2231 | QFont f = font(); never executed (the execution status of this line is deduced): QFont f = font(); | - |
2232 | const int newSize = f.pointSize() + range; never executed (the execution status of this line is deduced): const int newSize = f.pointSize() + range; | - |
2233 | if (newSize <= 0) never evaluated: newSize <= 0 | 0 |
2234 | return; | 0 |
2235 | f.setPointSize(newSize); never executed (the execution status of this line is deduced): f.setPointSize(newSize); | - |
2236 | setFont(f); never executed (the execution status of this line is deduced): setFont(f); | - |
2237 | } | 0 |
2238 | | - |
2239 | /*! | - |
2240 | \fn QTextEdit::zoomOut(int range) | - |
2241 | | - |
2242 | \overload | - |
2243 | | - |
2244 | Zooms out on the text by making the base font size \a range points | - |
2245 | smaller and recalculating all font sizes to be the new size. This | - |
2246 | does not change the size of any images. | - |
2247 | | - |
2248 | \sa zoomIn() | - |
2249 | */ | - |
2250 | void QTextEdit::zoomOut(int range) | - |
2251 | { | - |
2252 | zoomIn(-range); never executed (the execution status of this line is deduced): zoomIn(-range); | - |
2253 | } | 0 |
2254 | | - |
2255 | /*! | - |
2256 | \since 4.2 | - |
2257 | Moves the cursor by performing the given \a operation. | - |
2258 | | - |
2259 | If \a mode is QTextCursor::KeepAnchor, the cursor selects the text it moves over. | - |
2260 | This is the same effect that the user achieves when they hold down the Shift key | - |
2261 | and move the cursor with the cursor keys. | - |
2262 | | - |
2263 | \sa QTextCursor::movePosition() | - |
2264 | */ | - |
2265 | void QTextEdit::moveCursor(QTextCursor::MoveOperation operation, QTextCursor::MoveMode mode) | - |
2266 | { | - |
2267 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
2268 | d->control->moveCursor(operation, mode); executed (the execution status of this line is deduced): d->control->moveCursor(operation, mode); | - |
2269 | } executed: } Execution Count:1 | 1 |
2270 | | - |
2271 | /*! | - |
2272 | \since 4.2 | - |
2273 | Returns whether text can be pasted from the clipboard into the textedit. | - |
2274 | */ | - |
2275 | bool QTextEdit::canPaste() const | - |
2276 | { | - |
2277 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
2278 | return d->control->canPaste(); never executed: return d->control->canPaste(); | 0 |
2279 | } | - |
2280 | | - |
2281 | /*! | - |
2282 | \since 4.3 | - |
2283 | Convenience function to print the text edit's document to the given \a printer. This | - |
2284 | is equivalent to calling the print method on the document directly except that this | - |
2285 | function also supports QPrinter::Selection as print range. | - |
2286 | | - |
2287 | \sa QTextDocument::print() | - |
2288 | */ | - |
2289 | #ifndef QT_NO_PRINTER | - |
2290 | void QTextEdit::print(QPagedPaintDevice *printer) const | - |
2291 | { | - |
2292 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
2293 | d->control->print(printer); never executed (the execution status of this line is deduced): d->control->print(printer); | - |
2294 | } | 0 |
2295 | #endif | - |
2296 | | - |
2297 | /*! \property QTextEdit::tabChangesFocus | - |
2298 | \brief whether \uicontrol Tab changes focus or is accepted as input | - |
2299 | | - |
2300 | In some occasions text edits should not allow the user to input | - |
2301 | tabulators or change indentation using the \uicontrol Tab key, as this breaks | - |
2302 | the focus chain. The default is false. | - |
2303 | | - |
2304 | */ | - |
2305 | | - |
2306 | bool QTextEdit::tabChangesFocus() const | - |
2307 | { | - |
2308 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
2309 | return d->tabChangesFocus; never executed: return d->tabChangesFocus; | 0 |
2310 | } | - |
2311 | | - |
2312 | void QTextEdit::setTabChangesFocus(bool b) | - |
2313 | { | - |
2314 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
2315 | d->tabChangesFocus = b; never executed (the execution status of this line is deduced): d->tabChangesFocus = b; | - |
2316 | } | 0 |
2317 | | - |
2318 | /*! | - |
2319 | \property QTextEdit::documentTitle | - |
2320 | \brief the title of the document parsed from the text. | - |
2321 | | - |
2322 | By default, for a newly-created, empty document, this property contains | - |
2323 | an empty string. | - |
2324 | */ | - |
2325 | | - |
2326 | /*! | - |
2327 | \property QTextEdit::lineWrapMode | - |
2328 | \brief the line wrap mode | - |
2329 | | - |
2330 | The default mode is WidgetWidth which causes words to be | - |
2331 | wrapped at the right edge of the text edit. Wrapping occurs at | - |
2332 | whitespace, keeping whole words intact. If you want wrapping to | - |
2333 | occur within words use setWordWrapMode(). If you set a wrap mode of | - |
2334 | FixedPixelWidth or FixedColumnWidth you should also call | - |
2335 | setLineWrapColumnOrWidth() with the width you want. | - |
2336 | | - |
2337 | \sa lineWrapColumnOrWidth | - |
2338 | */ | - |
2339 | | - |
2340 | QTextEdit::LineWrapMode QTextEdit::lineWrapMode() const | - |
2341 | { | - |
2342 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
2343 | return d->lineWrap; never executed: return d->lineWrap; | 0 |
2344 | } | - |
2345 | | - |
2346 | void QTextEdit::setLineWrapMode(LineWrapMode wrap) | - |
2347 | { | - |
2348 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
2349 | if (d->lineWrap == wrap) never evaluated: d->lineWrap == wrap | 0 |
2350 | return; | 0 |
2351 | d->lineWrap = wrap; never executed (the execution status of this line is deduced): d->lineWrap = wrap; | - |
2352 | d->updateDefaultTextOption(); never executed (the execution status of this line is deduced): d->updateDefaultTextOption(); | - |
2353 | d->relayoutDocument(); never executed (the execution status of this line is deduced): d->relayoutDocument(); | - |
2354 | } | 0 |
2355 | | - |
2356 | /*! | - |
2357 | \property QTextEdit::lineWrapColumnOrWidth | - |
2358 | \brief the position (in pixels or columns depending on the wrap mode) where text will be wrapped | - |
2359 | | - |
2360 | If the wrap mode is FixedPixelWidth, the value is the number of | - |
2361 | pixels from the left edge of the text edit at which text should be | - |
2362 | wrapped. If the wrap mode is FixedColumnWidth, the value is the | - |
2363 | column number (in character columns) from the left edge of the | - |
2364 | text edit at which text should be wrapped. | - |
2365 | | - |
2366 | By default, this property contains a value of 0. | - |
2367 | | - |
2368 | \sa lineWrapMode | - |
2369 | */ | - |
2370 | | - |
2371 | int QTextEdit::lineWrapColumnOrWidth() const | - |
2372 | { | - |
2373 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
2374 | return d->lineWrapColumnOrWidth; never executed: return d->lineWrapColumnOrWidth; | 0 |
2375 | } | - |
2376 | | - |
2377 | void QTextEdit::setLineWrapColumnOrWidth(int w) | - |
2378 | { | - |
2379 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
2380 | d->lineWrapColumnOrWidth = w; never executed (the execution status of this line is deduced): d->lineWrapColumnOrWidth = w; | - |
2381 | d->relayoutDocument(); never executed (the execution status of this line is deduced): d->relayoutDocument(); | - |
2382 | } | 0 |
2383 | | - |
2384 | /*! | - |
2385 | \property QTextEdit::wordWrapMode | - |
2386 | \brief the mode QTextEdit will use when wrapping text by words | - |
2387 | | - |
2388 | By default, this property is set to QTextOption::WrapAtWordBoundaryOrAnywhere. | - |
2389 | | - |
2390 | \sa QTextOption::WrapMode | - |
2391 | */ | - |
2392 | | - |
2393 | QTextOption::WrapMode QTextEdit::wordWrapMode() const | - |
2394 | { | - |
2395 | Q_D(const QTextEdit); never executed (the execution status of this line is deduced): const QTextEditPrivate * const d = d_func(); | - |
2396 | return d->wordWrap; never executed: return d->wordWrap; | 0 |
2397 | } | - |
2398 | | - |
2399 | void QTextEdit::setWordWrapMode(QTextOption::WrapMode mode) | - |
2400 | { | - |
2401 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
2402 | if (mode == d->wordWrap) partially evaluated: mode == d->wordWrap yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
2403 | return; executed: return; Execution Count:1 | 1 |
2404 | d->wordWrap = mode; never executed (the execution status of this line is deduced): d->wordWrap = mode; | - |
2405 | d->updateDefaultTextOption(); never executed (the execution status of this line is deduced): d->updateDefaultTextOption(); | - |
2406 | } | 0 |
2407 | | - |
2408 | /*! | - |
2409 | Finds the next occurrence of the string, \a exp, using the given | - |
2410 | \a options. Returns true if \a exp was found and changes the | - |
2411 | cursor to select the match; otherwise returns false. | - |
2412 | */ | - |
2413 | bool QTextEdit::find(const QString &exp, QTextDocument::FindFlags options) | - |
2414 | { | - |
2415 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
2416 | return d->control->find(exp, options); never executed: return d->control->find(exp, options); | 0 |
2417 | } | - |
2418 | | - |
2419 | /*! | - |
2420 | \fn void QTextEdit::copyAvailable(bool yes) | - |
2421 | | - |
2422 | This signal is emitted when text is selected or de-selected in the | - |
2423 | text edit. | - |
2424 | | - |
2425 | When text is selected this signal will be emitted with \a yes set | - |
2426 | to true. If no text has been selected or if the selected text is | - |
2427 | de-selected this signal is emitted with \a yes set to false. | - |
2428 | | - |
2429 | If \a yes is true then copy() can be used to copy the selection to | - |
2430 | the clipboard. If \a yes is false then copy() does nothing. | - |
2431 | | - |
2432 | \sa selectionChanged() | - |
2433 | */ | - |
2434 | | - |
2435 | /*! | - |
2436 | \fn void QTextEdit::currentCharFormatChanged(const QTextCharFormat &f) | - |
2437 | | - |
2438 | This signal is emitted if the current character format has changed, for | - |
2439 | example caused by a change of the cursor position. | - |
2440 | | - |
2441 | The new format is \a f. | - |
2442 | | - |
2443 | \sa setCurrentCharFormat() | - |
2444 | */ | - |
2445 | | - |
2446 | /*! | - |
2447 | \fn void QTextEdit::selectionChanged() | - |
2448 | | - |
2449 | This signal is emitted whenever the selection changes. | - |
2450 | | - |
2451 | \sa copyAvailable() | - |
2452 | */ | - |
2453 | | - |
2454 | /*! | - |
2455 | \fn void QTextEdit::cursorPositionChanged() | - |
2456 | | - |
2457 | This signal is emitted whenever the position of the | - |
2458 | cursor changed. | - |
2459 | */ | - |
2460 | | - |
2461 | /*! | - |
2462 | \since 4.2 | - |
2463 | | - |
2464 | Sets the text edit's \a text. The text can be plain text or HTML | - |
2465 | and the text edit will try to guess the right format. | - |
2466 | | - |
2467 | Use setHtml() or setPlainText() directly to avoid text edit's guessing. | - |
2468 | | - |
2469 | \sa toPlainText(), toHtml() | - |
2470 | */ | - |
2471 | void QTextEdit::setText(const QString &text) | - |
2472 | { | - |
2473 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
2474 | Qt::TextFormat format = d->textFormat; executed (the execution status of this line is deduced): Qt::TextFormat format = d->textFormat; | - |
2475 | if (d->textFormat == Qt::AutoText) partially evaluated: d->textFormat == Qt::AutoText yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
2476 | format = Qt::mightBeRichText(text) ? Qt::RichText : Qt::PlainText; executed: format = Qt::mightBeRichText(text) ? Qt::RichText : Qt::PlainText; Execution Count:3 evaluated: Qt::mightBeRichText(text) yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-3 |
2477 | #ifndef QT_NO_TEXTHTMLPARSER | - |
2478 | if (format == Qt::RichText) evaluated: format == Qt::RichText yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
2479 | setHtml(text); executed: setHtml(text); Execution Count:2 | 2 |
2480 | else | - |
2481 | #endif | - |
2482 | setPlainText(text); executed: setPlainText(text); Execution Count:1 | 1 |
2483 | } | - |
2484 | | - |
2485 | | - |
2486 | /*! | - |
2487 | Appends a new paragraph with \a text to the end of the text edit. | - |
2488 | | - |
2489 | \note The new paragraph appended will have the same character format and | - |
2490 | block format as the current paragraph, determined by the position of the cursor. | - |
2491 | | - |
2492 | \sa currentCharFormat(), QTextCursor::blockFormat() | - |
2493 | */ | - |
2494 | | - |
2495 | void QTextEdit::append(const QString &text) | - |
2496 | { | - |
2497 | Q_D(QTextEdit); never executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
2498 | const bool atBottom = isReadOnly() ? d->verticalOffset() >= d->vbar->maximum() : never evaluated: isReadOnly() | 0 |
2499 | d->control->textCursor().atEnd(); never executed (the execution status of this line is deduced): d->control->textCursor().atEnd(); | - |
2500 | d->control->append(text); never executed (the execution status of this line is deduced): d->control->append(text); | - |
2501 | if (atBottom) never evaluated: atBottom | 0 |
2502 | d->vbar->setValue(d->vbar->maximum()); never executed: d->vbar->setValue(d->vbar->maximum()); | 0 |
2503 | } | 0 |
2504 | | - |
2505 | /*! | - |
2506 | Ensures that the cursor is visible by scrolling the text edit if | - |
2507 | necessary. | - |
2508 | */ | - |
2509 | void QTextEdit::ensureCursorVisible() | - |
2510 | { | - |
2511 | Q_D(QTextEdit); executed (the execution status of this line is deduced): QTextEditPrivate * const d = d_func(); | - |
2512 | d->control->ensureCursorVisible(); executed (the execution status of this line is deduced): d->control->ensureCursorVisible(); | - |
2513 | } executed: } Execution Count:69 | 69 |
2514 | | - |
2515 | /*! | - |
2516 | \fn void QTextEdit::textChanged() | - |
2517 | | - |
2518 | This signal is emitted whenever the document's content changes; for | - |
2519 | example, when text is inserted or deleted, or when formatting is applied. | - |
2520 | */ | - |
2521 | | - |
2522 | /*! | - |
2523 | \fn void QTextEdit::undoAvailable(bool available) | - |
2524 | | - |
2525 | This signal is emitted whenever undo operations become available | - |
2526 | (\a available is true) or unavailable (\a available is false). | - |
2527 | */ | - |
2528 | | - |
2529 | /*! | - |
2530 | \fn void QTextEdit::redoAvailable(bool available) | - |
2531 | | - |
2532 | This signal is emitted whenever redo operations become available | - |
2533 | (\a available is true) or unavailable (\a available is false). | - |
2534 | */ | - |
2535 | | - |
2536 | #endif // QT_NO_TEXTEDIT | - |
2537 | | - |
2538 | QT_END_NAMESPACE | - |
2539 | | - |
2540 | #include "moc_qtextedit.cpp" | - |
2541 | | - |
| | |