widgets/qtextedit.cpp

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

Generated by Squish Coco Non-Commercial