text/qtextcursor.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtGui module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qtextcursor.h" -
43#include "qtextcursor_p.h" -
44#include "qglobal.h" -
45#include "qtextdocumentfragment.h" -
46#include "qtextdocumentfragment_p.h" -
47#include "qtextlist.h" -
48#include "qtexttable.h" -
49#include "qtexttable_p.h" -
50#include "qtextengine_p.h" -
51#include "qabstracttextdocumentlayout.h" -
52 -
53#include <qtextlayout.h> -
54#include <qdebug.h> -
55 -
56QT_BEGIN_NAMESPACE -
57 -
58enum { -
59 AdjustPrev = 0x1, -
60 AdjustUp = 0x3, -
61 AdjustNext = 0x4, -
62 AdjustDown = 0x12 -
63}; -
64 -
65QTextCursorPrivate::QTextCursorPrivate(QTextDocumentPrivate *p) -
66 : priv(p), x(0), position(0), anchor(0), adjusted_anchor(0), -
67 currentCharFormat(-1), visualNavigation(false), keepPositionOnInsert(false), -
68 changed(false) -
69{ -
70 priv->addCursor(this);
executed (the execution status of this line is deduced): priv->addCursor(this);
-
71}
executed: }
Execution Count:5257
5257
72 -
73QTextCursorPrivate::QTextCursorPrivate(const QTextCursorPrivate &rhs) -
74 : QSharedData(rhs) -
75{ -
76 position = rhs.position;
executed (the execution status of this line is deduced): position = rhs.position;
-
77 anchor = rhs.anchor;
executed (the execution status of this line is deduced): anchor = rhs.anchor;
-
78 adjusted_anchor = rhs.adjusted_anchor;
executed (the execution status of this line is deduced): adjusted_anchor = rhs.adjusted_anchor;
-
79 priv = rhs.priv;
executed (the execution status of this line is deduced): priv = rhs.priv;
-
80 x = rhs.x;
executed (the execution status of this line is deduced): x = rhs.x;
-
81 currentCharFormat = rhs.currentCharFormat;
executed (the execution status of this line is deduced): currentCharFormat = rhs.currentCharFormat;
-
82 visualNavigation = rhs.visualNavigation;
executed (the execution status of this line is deduced): visualNavigation = rhs.visualNavigation;
-
83 keepPositionOnInsert = rhs.keepPositionOnInsert;
executed (the execution status of this line is deduced): keepPositionOnInsert = rhs.keepPositionOnInsert;
-
84 changed = rhs.changed;
executed (the execution status of this line is deduced): changed = rhs.changed;
-
85 priv->addCursor(this);
executed (the execution status of this line is deduced): priv->addCursor(this);
-
86}
executed: }
Execution Count:197
197
87 -
88QTextCursorPrivate::~QTextCursorPrivate() -
89{ -
90 if (priv)
evaluated: priv
TRUEFALSE
yes
Evaluation Count:5047
yes
Evaluation Count:403
403-5047
91 priv->removeCursor(this);
executed: priv->removeCursor(this);
Execution Count:5047
5047
92}
executed: }
Execution Count:5450
5450
93 -
94QTextCursorPrivate::AdjustResult QTextCursorPrivate::adjustPosition(int positionOfChange, int charsAddedOrRemoved, QTextUndoCommand::Operation op) -
95{ -
96 QTextCursorPrivate::AdjustResult result = QTextCursorPrivate::CursorMoved;
executed (the execution status of this line is deduced): QTextCursorPrivate::AdjustResult result = QTextCursorPrivate::CursorMoved;
-
97 // not(!) <= , so that inserting text adjusts the cursor correctly -
98 if (position < positionOfChange
evaluated: position < positionOfChange
TRUEFALSE
yes
Evaluation Count:408
yes
Evaluation Count:32433
408-32433
99 || (position == positionOfChange
evaluated: position == positionOfChange
TRUEFALSE
yes
Evaluation Count:30308
yes
Evaluation Count:2125
2125-30308
100 && (op == QTextUndoCommand::KeepCursor
evaluated: op == QTextUndoCommand::KeepCursor
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:30269
39-30269
101 || keepPositionOnInsert)
evaluated: keepPositionOnInsert
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:30268
1-30268
102 )
executed (the execution status of this line is deduced): )
-
103 ) { -
104 result = CursorUnchanged;
executed (the execution status of this line is deduced): result = CursorUnchanged;
-
105 } else {
executed: }
Execution Count:448
448
106 if (charsAddedOrRemoved < 0 && position < positionOfChange - charsAddedOrRemoved)
evaluated: charsAddedOrRemoved < 0
TRUEFALSE
yes
Evaluation Count:2063
yes
Evaluation Count:30330
evaluated: position < positionOfChange - charsAddedOrRemoved
TRUEFALSE
yes
Evaluation Count:42
yes
Evaluation Count:2021
42-30330
107 position = positionOfChange;
executed: position = positionOfChange;
Execution Count:42
42
108 else -
109 position += charsAddedOrRemoved;
executed: position += charsAddedOrRemoved;
Execution Count:32351
32351
110 -
111 currentCharFormat = -1;
executed (the execution status of this line is deduced): currentCharFormat = -1;
-
112 }
executed: }
Execution Count:32393
32393
113 -
114 if (anchor >= positionOfChange
evaluated: anchor >= positionOfChange
TRUEFALSE
yes
Evaluation Count:32429
yes
Evaluation Count:412
412-32429
115 && (anchor != positionOfChange || op != QTextUndoCommand::KeepCursor)) {
evaluated: anchor != positionOfChange
TRUEFALSE
yes
Evaluation Count:1194
yes
Evaluation Count:31235
evaluated: op != QTextUndoCommand::KeepCursor
TRUEFALSE
yes
Evaluation Count:31212
yes
Evaluation Count:23
23-31235
116 if (charsAddedOrRemoved < 0 && anchor < positionOfChange - charsAddedOrRemoved)
evaluated: charsAddedOrRemoved < 0
TRUEFALSE
yes
Evaluation Count:2075
yes
Evaluation Count:30331
evaluated: anchor < positionOfChange - charsAddedOrRemoved
TRUEFALSE
yes
Evaluation Count:987
yes
Evaluation Count:1088
987-30331
117 anchor = positionOfChange;
executed: anchor = positionOfChange;
Execution Count:987
987
118 else -
119 anchor += charsAddedOrRemoved;
executed: anchor += charsAddedOrRemoved;
Execution Count:31419
31419
120 } -
121 -
122 if (adjusted_anchor >= positionOfChange
evaluated: adjusted_anchor >= positionOfChange
TRUEFALSE
yes
Evaluation Count:32429
yes
Evaluation Count:412
412-32429
123 && (adjusted_anchor != positionOfChange || op != QTextUndoCommand::KeepCursor)) {
evaluated: adjusted_anchor != positionOfChange
TRUEFALSE
yes
Evaluation Count:1195
yes
Evaluation Count:31234
evaluated: op != QTextUndoCommand::KeepCursor
TRUEFALSE
yes
Evaluation Count:31212
yes
Evaluation Count:22
22-31234
124 if (charsAddedOrRemoved < 0 && adjusted_anchor < positionOfChange - charsAddedOrRemoved)
evaluated: charsAddedOrRemoved < 0
TRUEFALSE
yes
Evaluation Count:2076
yes
Evaluation Count:30331
evaluated: adjusted_anchor < positionOfChange - charsAddedOrRemoved
TRUEFALSE
yes
Evaluation Count:987
yes
Evaluation Count:1089
987-30331
125 adjusted_anchor = positionOfChange;
executed: adjusted_anchor = positionOfChange;
Execution Count:987
987
126 else -
127 adjusted_anchor += charsAddedOrRemoved;
executed: adjusted_anchor += charsAddedOrRemoved;
Execution Count:31420
31420
128 } -
129 -
130 return result;
executed: return result;
Execution Count:32841
32841
131} -
132 -
133void QTextCursorPrivate::setX() -
134{ -
135 if (priv->isInEditBlock()) {
evaluated: priv->isInEditBlock()
TRUEFALSE
yes
Evaluation Count:5181
yes
Evaluation Count:15778
5181-15778
136 x = -1; // mark dirty
executed (the execution status of this line is deduced): x = -1;
-
137 return;
executed: return;
Execution Count:5181
5181
138 } -
139 -
140 QTextBlock block = this->block();
executed (the execution status of this line is deduced): QTextBlock block = this->block();
-
141 const QTextLayout *layout = blockLayout(block);
executed (the execution status of this line is deduced): const QTextLayout *layout = blockLayout(block);
-
142 int pos = position - block.position();
executed (the execution status of this line is deduced): int pos = position - block.position();
-
143 -
144 QTextLine line = layout->lineForTextPosition(pos);
executed (the execution status of this line is deduced): QTextLine line = layout->lineForTextPosition(pos);
-
145 if (line.isValid())
evaluated: line.isValid()
TRUEFALSE
yes
Evaluation Count:490
yes
Evaluation Count:15288
490-15288
146 x = line.cursorToX(pos);
executed: x = line.cursorToX(pos);
Execution Count:490
490
147 else -
148 x = -1; // delayed init. Makes movePosition() call setX later on again.
executed: x = -1;
Execution Count:15288
15288
149} -
150 -
151void QTextCursorPrivate::remove() -
152{ -
153 if (anchor == position)
evaluated: anchor == position
TRUEFALSE
yes
Evaluation Count:12780
yes
Evaluation Count:965
965-12780
154 return;
executed: return;
Execution Count:12780
12780
155 currentCharFormat = -1;
executed (the execution status of this line is deduced): currentCharFormat = -1;
-
156 int pos1 = position;
executed (the execution status of this line is deduced): int pos1 = position;
-
157 int pos2 = adjusted_anchor;
executed (the execution status of this line is deduced): int pos2 = adjusted_anchor;
-
158 QTextUndoCommand::Operation op = QTextUndoCommand::KeepCursor;
executed (the execution status of this line is deduced): QTextUndoCommand::Operation op = QTextUndoCommand::KeepCursor;
-
159 if (pos1 > pos2) {
evaluated: pos1 > pos2
TRUEFALSE
yes
Evaluation Count:945
yes
Evaluation Count:20
20-945
160 pos1 = adjusted_anchor;
executed (the execution status of this line is deduced): pos1 = adjusted_anchor;
-
161 pos2 = position;
executed (the execution status of this line is deduced): pos2 = position;
-
162 op = QTextUndoCommand::MoveCursor;
executed (the execution status of this line is deduced): op = QTextUndoCommand::MoveCursor;
-
163 }
executed: }
Execution Count:945
945
164 -
165 // deleting inside table? -> delete only content -
166 QTextTable *table = complexSelectionTable();
executed (the execution status of this line is deduced): QTextTable *table = complexSelectionTable();
-
167 if (table) {
evaluated: table
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:963
2-963
168 priv->beginEditBlock();
executed (the execution status of this line is deduced): priv->beginEditBlock();
-
169 int startRow, startCol, numRows, numCols;
executed (the execution status of this line is deduced): int startRow, startCol, numRows, numCols;
-
170 selectedTableCells(&startRow, &numRows, &startCol, &numCols);
executed (the execution status of this line is deduced): selectedTableCells(&startRow, &numRows, &startCol, &numCols);
-
171 clearCells(table, startRow, startCol, numRows, numCols, op);
executed (the execution status of this line is deduced): clearCells(table, startRow, startCol, numRows, numCols, op);
-
172 adjusted_anchor = anchor = position;
executed (the execution status of this line is deduced): adjusted_anchor = anchor = position;
-
173 priv->endEditBlock();
executed (the execution status of this line is deduced): priv->endEditBlock();
-
174 } else {
executed: }
Execution Count:2
2
175 priv->remove(pos1, pos2-pos1, op);
executed (the execution status of this line is deduced): priv->remove(pos1, pos2-pos1, op);
-
176 adjusted_anchor = anchor = position;
executed (the execution status of this line is deduced): adjusted_anchor = anchor = position;
-
177 priv->finishEdit();
executed (the execution status of this line is deduced): priv->finishEdit();
-
178 }
executed: }
Execution Count:963
963
179 -
180} -
181 -
182void QTextCursorPrivate::clearCells(QTextTable *table, int startRow, int startCol, int numRows, int numCols, QTextUndoCommand::Operation op) -
183{ -
184 priv->beginEditBlock();
executed (the execution status of this line is deduced): priv->beginEditBlock();
-
185 -
186 for (int row = startRow; row < startRow + numRows; ++row)
evaluated: row < startRow + numRows
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
187 for (int col = startCol; col < startCol + numCols; ++col) {
evaluated: col < startCol + numCols
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2
2-4
188 QTextTableCell cell = table->cellAt(row, col);
executed (the execution status of this line is deduced): QTextTableCell cell = table->cellAt(row, col);
-
189 const int startPos = cell.firstPosition();
executed (the execution status of this line is deduced): const int startPos = cell.firstPosition();
-
190 const int endPos = cell.lastPosition();
executed (the execution status of this line is deduced): const int endPos = cell.lastPosition();
-
191 Q_ASSERT(startPos <= endPos);
executed (the execution status of this line is deduced): qt_noop();
-
192 priv->remove(startPos, endPos - startPos, op);
executed (the execution status of this line is deduced): priv->remove(startPos, endPos - startPos, op);
-
193 }
executed: }
Execution Count:4
4
194 -
195 priv->endEditBlock();
executed (the execution status of this line is deduced): priv->endEditBlock();
-
196}
executed: }
Execution Count:2
2
197 -
198bool QTextCursorPrivate::canDelete(int pos) const -
199{ -
200 QTextDocumentPrivate::FragmentIterator fit = priv->find(pos);
executed (the execution status of this line is deduced): QTextDocumentPrivate::FragmentIterator fit = priv->find(pos);
-
201 QTextCharFormat fmt = priv->formatCollection()->charFormat((*fit)->format);
executed (the execution status of this line is deduced): QTextCharFormat fmt = priv->formatCollection()->charFormat((*fit)->format);
-
202 return (fmt.objectIndex() == -1 || fmt.objectType() == QTextFormat::ImageObject);
executed: return (fmt.objectIndex() == -1 || fmt.objectType() == QTextFormat::ImageObject);
Execution Count:23
23
203} -
204 -
205void QTextCursorPrivate::insertBlock(const QTextBlockFormat &format, const QTextCharFormat &charFormat) -
206{ -
207 QTextFormatCollection *formats = priv->formatCollection();
executed (the execution status of this line is deduced): QTextFormatCollection *formats = priv->formatCollection();
-
208 int idx = formats->indexForFormat(format);
executed (the execution status of this line is deduced): int idx = formats->indexForFormat(format);
-
209 Q_ASSERT(formats->format(idx).isBlockFormat());
executed (the execution status of this line is deduced): qt_noop();
-
210 -
211 priv->insertBlock(position, idx, formats->indexForFormat(charFormat));
executed (the execution status of this line is deduced): priv->insertBlock(position, idx, formats->indexForFormat(charFormat));
-
212 currentCharFormat = -1;
executed (the execution status of this line is deduced): currentCharFormat = -1;
-
213}
executed: }
Execution Count:15099
15099
214 -
215void QTextCursorPrivate::adjustCursor(QTextCursor::MoveOperation m) -
216{ -
217 adjusted_anchor = anchor;
executed (the execution status of this line is deduced): adjusted_anchor = anchor;
-
218 if (position == anchor)
evaluated: position == anchor
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:2199
18-2199
219 return;
executed: return;
Execution Count:18
18
220 -
221 QTextFrame *f_position = priv->frameAt(position);
executed (the execution status of this line is deduced): QTextFrame *f_position = priv->frameAt(position);
-
222 QTextFrame *f_anchor = priv->frameAt(adjusted_anchor);
executed (the execution status of this line is deduced): QTextFrame *f_anchor = priv->frameAt(adjusted_anchor);
-
223 -
224 if (f_position != f_anchor) {
evaluated: f_position != f_anchor
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2197
2-2197
225 // find common parent frame -
226 QList<QTextFrame *> positionChain;
executed (the execution status of this line is deduced): QList<QTextFrame *> positionChain;
-
227 QList<QTextFrame *> anchorChain;
executed (the execution status of this line is deduced): QList<QTextFrame *> anchorChain;
-
228 QTextFrame *f = f_position;
executed (the execution status of this line is deduced): QTextFrame *f = f_position;
-
229 while (f) {
evaluated: f
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2
2-3
230 positionChain.prepend(f);
executed (the execution status of this line is deduced): positionChain.prepend(f);
-
231 f = f->parentFrame();
executed (the execution status of this line is deduced): f = f->parentFrame();
-
232 }
executed: }
Execution Count:3
3
233 f = f_anchor;
executed (the execution status of this line is deduced): f = f_anchor;
-
234 while (f) {
evaluated: f
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2
2-3
235 anchorChain.prepend(f);
executed (the execution status of this line is deduced): anchorChain.prepend(f);
-
236 f = f->parentFrame();
executed (the execution status of this line is deduced): f = f->parentFrame();
-
237 }
executed: }
Execution Count:3
3
238 Q_ASSERT(positionChain.at(0) == anchorChain.at(0));
executed (the execution status of this line is deduced): qt_noop();
-
239 int i = 1;
executed (the execution status of this line is deduced): int i = 1;
-
240 int l = qMin(positionChain.size(), anchorChain.size());
executed (the execution status of this line is deduced): int l = qMin(positionChain.size(), anchorChain.size());
-
241 for (; i < l; ++i) {
partially evaluated: i < l
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
242 if (positionChain.at(i) != anchorChain.at(i))
never evaluated: positionChain.at(i) != anchorChain.at(i)
0
243 break;
never executed: break;
0
244 }
never executed: }
0
245 -
246 if (m <= QTextCursor::WordLeft) {
evaluated: m <= QTextCursor::WordLeft
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
247 if (i < positionChain.size())
partially evaluated: i < positionChain.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
248 position = positionChain.at(i)->firstPosition() - 1;
never executed: position = positionChain.at(i)->firstPosition() - 1;
0
249 } else {
executed: }
Execution Count:1
1
250 if (i < positionChain.size())
partially evaluated: i < positionChain.size()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
251 position = positionChain.at(i)->lastPosition() + 1;
executed: position = positionChain.at(i)->lastPosition() + 1;
Execution Count:1
1
252 }
executed: }
Execution Count:1
1
253 if (position < adjusted_anchor) {
evaluated: position < adjusted_anchor
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
254 if (i < anchorChain.size())
partially evaluated: i < anchorChain.size()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
255 adjusted_anchor = anchorChain.at(i)->lastPosition() + 1;
executed: adjusted_anchor = anchorChain.at(i)->lastPosition() + 1;
Execution Count:1
1
256 } else {
executed: }
Execution Count:1
1
257 if (i < anchorChain.size())
partially evaluated: i < anchorChain.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
258 adjusted_anchor = anchorChain.at(i)->firstPosition() - 1;
never executed: adjusted_anchor = anchorChain.at(i)->firstPosition() - 1;
0
259 }
executed: }
Execution Count:1
1
260 -
261 f_position = positionChain.at(i-1);
executed (the execution status of this line is deduced): f_position = positionChain.at(i-1);
-
262 }
executed: }
Execution Count:2
2
263 -
264 // same frame, either need to adjust to cell boundaries or return -
265 QTextTable *table = qobject_cast<QTextTable *>(f_position);
executed (the execution status of this line is deduced): QTextTable *table = qobject_cast<QTextTable *>(f_position);
-
266 if (!table)
evaluated: !table
TRUEFALSE
yes
Evaluation Count:2074
yes
Evaluation Count:125
125-2074
267 return;
executed: return;
Execution Count:2074
2074
268 -
269 QTextTableCell c_position = table->cellAt(position);
executed (the execution status of this line is deduced): QTextTableCell c_position = table->cellAt(position);
-
270 QTextTableCell c_anchor = table->cellAt(adjusted_anchor);
executed (the execution status of this line is deduced): QTextTableCell c_anchor = table->cellAt(adjusted_anchor);
-
271 if (c_position != c_anchor) {
evaluated: c_position != c_anchor
TRUEFALSE
yes
Evaluation Count:107
yes
Evaluation Count:18
18-107
272 position = c_position.firstPosition();
executed (the execution status of this line is deduced): position = c_position.firstPosition();
-
273 if (position < adjusted_anchor)
evaluated: position < adjusted_anchor
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:69
38-69
274 adjusted_anchor = c_anchor.lastPosition();
executed: adjusted_anchor = c_anchor.lastPosition();
Execution Count:38
38
275 else -
276 adjusted_anchor = c_anchor.firstPosition();
executed: adjusted_anchor = c_anchor.firstPosition();
Execution Count:69
69
277 } -
278 currentCharFormat = -1;
executed (the execution status of this line is deduced): currentCharFormat = -1;
-
279}
executed: }
Execution Count:125
125
280 -
281void QTextCursorPrivate::aboutToRemoveCell(int from, int to) -
282{ -
283 Q_ASSERT(from <= to);
executed (the execution status of this line is deduced): qt_noop();
-
284 if (position == anchor)
evaluated: position == anchor
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:10
10-22
285 return;
executed: return;
Execution Count:22
22
286 -
287 QTextTable *t = qobject_cast<QTextTable *>(priv->frameAt(position));
executed (the execution status of this line is deduced): QTextTable *t = qobject_cast<QTextTable *>(priv->frameAt(position));
-
288 if (!t)
partially evaluated: !t
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
289 return;
never executed: return;
0
290 QTextTableCell removedCellFrom = t->cellAt(from);
executed (the execution status of this line is deduced): QTextTableCell removedCellFrom = t->cellAt(from);
-
291 QTextTableCell removedCellEnd = t->cellAt(to);
executed (the execution status of this line is deduced): QTextTableCell removedCellEnd = t->cellAt(to);
-
292 if (! removedCellFrom.isValid() || !removedCellEnd.isValid())
partially evaluated: ! removedCellFrom.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
partially evaluated: !removedCellEnd.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
293 return;
never executed: return;
0
294 -
295 int curFrom = position;
executed (the execution status of this line is deduced): int curFrom = position;
-
296 int curTo = adjusted_anchor;
executed (the execution status of this line is deduced): int curTo = adjusted_anchor;
-
297 if (curTo < curFrom)
partially evaluated: curTo < curFrom
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-10
298 qSwap(curFrom, curTo);
executed: qSwap(curFrom, curTo);
Execution Count:10
10
299 -
300 QTextTableCell cellStart = t->cellAt(curFrom);
executed (the execution status of this line is deduced): QTextTableCell cellStart = t->cellAt(curFrom);
-
301 QTextTableCell cellEnd = t->cellAt(curTo);
executed (the execution status of this line is deduced): QTextTableCell cellEnd = t->cellAt(curTo);
-
302 -
303 if (cellStart.row() >= removedCellFrom.row() && cellEnd.row() <= removedCellEnd.row()
evaluated: cellStart.row() >= removedCellFrom.row()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:2
evaluated: cellEnd.row() <= removedCellEnd.row()
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:1
1-8
304 && cellStart.column() >= removedCellFrom.column()
evaluated: cellStart.column() >= removedCellFrom.column()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:2
2-5
305 && cellEnd.column() <= removedCellEnd.column()) { // selection is completely removed
evaluated: cellEnd.column() <= removedCellEnd.column()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2
2-3
306 // find a new position, as close as possible to where we were. -
307 QTextTableCell cell;
executed (the execution status of this line is deduced): QTextTableCell cell;
-
308 if (removedCellFrom.row() == 0 && removedCellEnd.row() == t->rows()-1) // removed n columns
evaluated: removedCellFrom.row() == 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
partially evaluated: removedCellEnd.row() == t->rows()-1
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-2
309 cell = t->cellAt(cellStart.row(), removedCellEnd.column()+1);
executed: cell = t->cellAt(cellStart.row(), removedCellEnd.column()+1);
Execution Count:1
1
310 else if (removedCellFrom.column() == 0 && removedCellEnd.column() == t->columns()-1) // removed n rows
partially evaluated: removedCellFrom.column() == 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: removedCellEnd.column() == t->columns()-1
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
311 cell = t->cellAt(removedCellEnd.row() + 1, cellStart.column());
executed: cell = t->cellAt(removedCellEnd.row() + 1, cellStart.column());
Execution Count:2
2
312 -
313 int newPosition;
executed (the execution status of this line is deduced): int newPosition;
-
314 if (cell.isValid())
evaluated: cell.isValid()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
315 newPosition = cell.firstPosition();
executed: newPosition = cell.firstPosition();
Execution Count:2
2
316 else -
317 newPosition = t->lastPosition()+1;
executed: newPosition = t->lastPosition()+1;
Execution Count:1
1
318 -
319 setPosition(newPosition);
executed (the execution status of this line is deduced): setPosition(newPosition);
-
320 anchor = newPosition;
executed (the execution status of this line is deduced): anchor = newPosition;
-
321 adjusted_anchor = newPosition;
executed (the execution status of this line is deduced): adjusted_anchor = newPosition;
-
322 x = 0;
executed (the execution status of this line is deduced): x = 0;
-
323 }
executed: }
Execution Count:3
3
324 else if (cellStart.row() >= removedCellFrom.row() && cellStart.row() <= removedCellEnd.row()
evaluated: cellStart.row() >= removedCellFrom.row()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:2
partially evaluated: cellStart.row() <= removedCellEnd.row()
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
325 && cellEnd.row() > removedCellEnd.row()) {
evaluated: cellEnd.row() > removedCellEnd.row()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:4
1-4
326 int newPosition = t->cellAt(removedCellEnd.row() + 1, cellStart.column()).firstPosition();
executed (the execution status of this line is deduced): int newPosition = t->cellAt(removedCellEnd.row() + 1, cellStart.column()).firstPosition();
-
327 if (position < anchor)
partially evaluated: position < anchor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
328 position = newPosition;
never executed: position = newPosition;
0
329 else -
330 anchor = adjusted_anchor = newPosition;
executed: anchor = adjusted_anchor = newPosition;
Execution Count:1
1
331 } -
332 else if (cellStart.column() >= removedCellFrom.column() && cellStart.column() <= removedCellEnd.column()
evaluated: cellStart.column() >= removedCellFrom.column()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2
partially evaluated: cellStart.column() <= removedCellEnd.column()
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
333 && cellEnd.column() > removedCellEnd.column()) {
evaluated: cellEnd.column() > removedCellEnd.column()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
334 int newPosition = t->cellAt(cellStart.row(), removedCellEnd.column()+1).firstPosition();
executed (the execution status of this line is deduced): int newPosition = t->cellAt(cellStart.row(), removedCellEnd.column()+1).firstPosition();
-
335 if (position < anchor)
partially evaluated: position < anchor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
336 position = newPosition;
never executed: position = newPosition;
0
337 else -
338 anchor = adjusted_anchor = newPosition;
executed: anchor = adjusted_anchor = newPosition;
Execution Count:2
2
339 } -
340} -
341 -
342bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor::MoveMode mode) -
343{ -
344 currentCharFormat = -1;
executed (the execution status of this line is deduced): currentCharFormat = -1;
-
345 bool adjustX = true;
executed (the execution status of this line is deduced): bool adjustX = true;
-
346 QTextBlock blockIt = block();
executed (the execution status of this line is deduced): QTextBlock blockIt = block();
-
347 bool visualMovement = priv->defaultCursorMoveStyle == Qt::VisualMoveStyle;
executed (the execution status of this line is deduced): bool visualMovement = priv->defaultCursorMoveStyle == Qt::VisualMoveStyle;
-
348 -
349 if (!blockIt.isValid())
partially evaluated: !blockIt.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2898
0-2898
350 return false;
never executed: return false;
0
351 -
352 if (blockIt.textDirection() == Qt::RightToLeft) {
evaluated: blockIt.textDirection() == Qt::RightToLeft
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2896
2-2896
353 if (op == QTextCursor::WordLeft)
partially evaluated: op == QTextCursor::WordLeft
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
354 op = QTextCursor::NextWord;
never executed: op = QTextCursor::NextWord;
0
355 else if (op == QTextCursor::WordRight)
partially evaluated: op == QTextCursor::WordRight
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
356 op = QTextCursor::PreviousWord;
never executed: op = QTextCursor::PreviousWord;
0
357 -
358 if (!visualMovement) {
partially evaluated: !visualMovement
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
359 if (op == QTextCursor::Left)
partially evaluated: op == QTextCursor::Left
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
360 op = QTextCursor::NextCharacter;
never executed: op = QTextCursor::NextCharacter;
0
361 else if (op == QTextCursor::Right)
partially evaluated: op == QTextCursor::Right
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
362 op = QTextCursor::PreviousCharacter;
never executed: op = QTextCursor::PreviousCharacter;
0
363 } -
364 }
executed: }
Execution Count:2
2
365 -
366 const QTextLayout *layout = blockLayout(blockIt);
executed (the execution status of this line is deduced): const QTextLayout *layout = blockLayout(blockIt);
-
367 int relativePos = position - blockIt.position();
executed (the execution status of this line is deduced): int relativePos = position - blockIt.position();
-
368 QTextLine line;
executed (the execution status of this line is deduced): QTextLine line;
-
369 if (!priv->isInEditBlock())
evaluated: !priv->isInEditBlock()
TRUEFALSE
yes
Evaluation Count:1476
yes
Evaluation Count:1422
1422-1476
370 line = layout->lineForTextPosition(relativePos);
executed: line = layout->lineForTextPosition(relativePos);
Execution Count:1476
1476
371 -
372 Q_ASSERT(priv->frameAt(position) == priv->frameAt(adjusted_anchor));
executed (the execution status of this line is deduced): qt_noop();
-
373 -
374 int newPosition = position;
executed (the execution status of this line is deduced): int newPosition = position;
-
375 -
376 if (mode == QTextCursor::KeepAnchor && complexSelectionTable() != 0) {
evaluated: mode == QTextCursor::KeepAnchor
TRUEFALSE
yes
Evaluation Count:2079
yes
Evaluation Count:819
evaluated: complexSelectionTable() != 0
TRUEFALSE
yes
Evaluation Count:87
yes
Evaluation Count:1992
87-2079
377 if ((op >= QTextCursor::EndOfLine && op <= QTextCursor::NextWord)
evaluated: op >= QTextCursor::EndOfLine
TRUEFALSE
yes
Evaluation Count:42
yes
Evaluation Count:45
evaluated: op <= QTextCursor::NextWord
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:27
15-45
378 || (op >= QTextCursor::Right && op <= QTextCursor::WordRight)) {
evaluated: op >= QTextCursor::Right
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:45
evaluated: op <= QTextCursor::WordRight
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:16
11-45
379 QTextTable *t = qobject_cast<QTextTable *>(priv->frameAt(position));
executed (the execution status of this line is deduced): QTextTable *t = qobject_cast<QTextTable *>(priv->frameAt(position));
-
380 Q_ASSERT(t); // as we have already made sure we have a complex selection
executed (the execution status of this line is deduced): qt_noop();
-
381 QTextTableCell cell_pos = t->cellAt(position);
executed (the execution status of this line is deduced): QTextTableCell cell_pos = t->cellAt(position);
-
382 if (cell_pos.column() + cell_pos.columnSpan() != t->columns())
partially evaluated: cell_pos.column() + cell_pos.columnSpan() != t->columns()
TRUEFALSE
yes
Evaluation Count:26
no
Evaluation Count:0
0-26
383 op = QTextCursor::NextCell;
executed: op = QTextCursor::NextCell;
Execution Count:26
26
384 }
executed: }
Execution Count:26
26
385 }
executed: }
Execution Count:87
87
386 -
387 if (x == -1 && !priv->isInEditBlock() && (op == QTextCursor::Up || op == QTextCursor::Down))
evaluated: x == -1
TRUEFALSE
yes
Evaluation Count:1778
yes
Evaluation Count:1120
evaluated: !priv->isInEditBlock()
TRUEFALSE
yes
Evaluation Count:553
yes
Evaluation Count:1225
evaluated: op == QTextCursor::Up
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:539
evaluated: op == QTextCursor::Down
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:525
14-1778
388 setX();
executed: setX();
Execution Count:28
28
389 -
390 switch(op) { -
391 case QTextCursor::NoMove: -
392 return true;
never executed: return true;
0
393 -
394 case QTextCursor::Start: -
395 newPosition = 0;
executed (the execution status of this line is deduced): newPosition = 0;
-
396 break;
executed: break;
Execution Count:320
320
397 case QTextCursor::StartOfLine: { -
398 newPosition = blockIt.position();
executed (the execution status of this line is deduced): newPosition = blockIt.position();
-
399 if (line.isValid())
evaluated: line.isValid()
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:2
2-21
400 newPosition += line.textStart();
executed: newPosition += line.textStart();
Execution Count:21
21
401 -
402 break;
executed: break;
Execution Count:23
23
403 } -
404 case QTextCursor::StartOfBlock: { -
405 newPosition = blockIt.position();
executed (the execution status of this line is deduced): newPosition = blockIt.position();
-
406 break;
executed: break;
Execution Count:14
14
407 } -
408 case QTextCursor::PreviousBlock: { -
409 if (blockIt == priv->blocksBegin())
evaluated: blockIt == priv->blocksBegin()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:19
1-19
410 return false;
executed: return false;
Execution Count:1
1
411 blockIt = blockIt.previous();
executed (the execution status of this line is deduced): blockIt = blockIt.previous();
-
412 -
413 newPosition = blockIt.position();
executed (the execution status of this line is deduced): newPosition = blockIt.position();
-
414 break;
executed: break;
Execution Count:19
19
415 } -
416 case QTextCursor::PreviousCharacter: -
417 if (mode == QTextCursor::MoveAnchor && position != adjusted_anchor)
evaluated: mode == QTextCursor::MoveAnchor
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:6
partially evaluated: position != adjusted_anchor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
418 newPosition = qMin(position, adjusted_anchor);
never executed: newPosition = qMin(position, adjusted_anchor);
0
419 else -
420 newPosition = priv->previousCursorPosition(position, QTextLayout::SkipCharacters);
executed: newPosition = priv->previousCursorPosition(position, QTextLayout::SkipCharacters);
Execution Count:14
14
421 break;
executed: break;
Execution Count:14
14
422 case QTextCursor::Left: -
423 if (mode == QTextCursor::MoveAnchor && position != adjusted_anchor)
evaluated: mode == QTextCursor::MoveAnchor
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:44
evaluated: position != adjusted_anchor
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:5
2-44
424 newPosition = visualMovement ? qMax(position, adjusted_anchor)
executed: newPosition = visualMovement ? qMax(position, adjusted_anchor) : qMin(position, adjusted_anchor);
Execution Count:2
partially evaluated: visualMovement
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
425 : qMin(position, adjusted_anchor);
executed: newPosition = visualMovement ? qMax(position, adjusted_anchor) : qMin(position, adjusted_anchor);
Execution Count:2
2
426 else -
427 newPosition = visualMovement ? priv->leftCursorPosition(position)
executed: newPosition = visualMovement ? priv->leftCursorPosition(position) : priv->previousCursorPosition(position, QTextLayout::SkipCharacters);
Execution Count:49
partially evaluated: visualMovement
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:49
0-49
428 : priv->previousCursorPosition(position, QTextLayout::SkipCharacters);
executed: newPosition = visualMovement ? priv->leftCursorPosition(position) : priv->previousCursorPosition(position, QTextLayout::SkipCharacters);
Execution Count:49
49
429 break;
executed: break;
Execution Count:51
51
430 case QTextCursor::StartOfWord: { -
431 if (relativePos == 0)
evaluated: relativePos == 0
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:16
16-20
432 break;
executed: break;
Execution Count:20
20
433 -
434 // skip if already at word start -
435 QTextEngine *engine = layout->engine();
executed (the execution status of this line is deduced): QTextEngine *engine = layout->engine();
-
436 engine->attributes();
executed (the execution status of this line is deduced): engine->attributes();
-
437 if ((relativePos == blockIt.length() - 1)
evaluated: (relativePos == blockIt.length() - 1)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:13
3-13
438 && (engine->atSpace(relativePos - 1) || engine->atWordSeparator(relativePos - 1)))
evaluated: engine->atSpace(relativePos - 1)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
partially evaluated: engine->atWordSeparator(relativePos - 1)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
439 return false;
executed: return false;
Execution Count:1
1
440 -
441 if (relativePos < blockIt.length()-1)
evaluated: relativePos < blockIt.length()-1
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:2
2-13
442 ++position;
executed: ++position;
Execution Count:13
13
443 -
444 // FALL THROUGH! -
445 } -
446 case QTextCursor::PreviousWord:
code before this statement executed: case QTextCursor::PreviousWord:
Execution Count:15
15
447 case QTextCursor::WordLeft: -
448 newPosition = priv->previousCursorPosition(position, QTextLayout::SkipWords);
executed (the execution status of this line is deduced): newPosition = priv->previousCursorPosition(position, QTextLayout::SkipWords);
-
449 break;
executed: break;
Execution Count:48
48
450 case QTextCursor::Up: { -
451 int i = line.lineNumber() - 1;
executed (the execution status of this line is deduced): int i = line.lineNumber() - 1;
-
452 if (i == -1) {
partially evaluated: i == -1
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-14
453 if (blockIt == priv->blocksBegin())
evaluated: blockIt == priv->blocksBegin()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:13
1-13
454 return false;
executed: return false;
Execution Count:1
1
455 int blockPosition = blockIt.position();
executed (the execution status of this line is deduced): int blockPosition = blockIt.position();
-
456 QTextTable *table = qobject_cast<QTextTable *>(priv->frameAt(blockPosition));
executed (the execution status of this line is deduced): QTextTable *table = qobject_cast<QTextTable *>(priv->frameAt(blockPosition));
-
457 if (table) {
partially evaluated: table
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-13
458 QTextTableCell cell = table->cellAt(blockPosition);
executed (the execution status of this line is deduced): QTextTableCell cell = table->cellAt(blockPosition);
-
459 if (cell.firstPosition() == blockPosition) {
partially evaluated: cell.firstPosition() == blockPosition
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-13
460 int row = cell.row() - 1;
executed (the execution status of this line is deduced): int row = cell.row() - 1;
-
461 if (row >= 0) {
evaluated: row >= 0
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:1
1-12
462 blockPosition = table->cellAt(row, cell.column()).lastPosition();
executed (the execution status of this line is deduced): blockPosition = table->cellAt(row, cell.column()).lastPosition();
-
463 } else {
executed: }
Execution Count:12
12
464 // move to line above the table -
465 blockPosition = table->firstPosition() - 1;
executed (the execution status of this line is deduced): blockPosition = table->firstPosition() - 1;
-
466 }
executed: }
Execution Count:1
1
467 blockIt = priv->blocksFind(blockPosition);
executed (the execution status of this line is deduced): blockIt = priv->blocksFind(blockPosition);
-
468 } else {
executed: }
Execution Count:13
13
469 blockIt = blockIt.previous();
never executed (the execution status of this line is deduced): blockIt = blockIt.previous();
-
470 }
never executed: }
0
471 } else { -
472 blockIt = blockIt.previous();
never executed (the execution status of this line is deduced): blockIt = blockIt.previous();
-
473 }
never executed: }
0
474 layout = blockLayout(blockIt);
executed (the execution status of this line is deduced): layout = blockLayout(blockIt);
-
475 i = layout->lineCount()-1;
executed (the execution status of this line is deduced): i = layout->lineCount()-1;
-
476 }
executed: }
Execution Count:13
13
477 if (layout->lineCount()) {
partially evaluated: layout->lineCount()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
0-13
478 QTextLine line = layout->lineAt(i);
never executed (the execution status of this line is deduced): QTextLine line = layout->lineAt(i);
-
479 newPosition = line.xToCursor(x) + blockIt.position();
never executed (the execution status of this line is deduced): newPosition = line.xToCursor(x) + blockIt.position();
-
480 } else {
never executed: }
0
481 newPosition = blockIt.position();
executed (the execution status of this line is deduced): newPosition = blockIt.position();
-
482 }
executed: }
Execution Count:13
13
483 adjustX = false;
executed (the execution status of this line is deduced): adjustX = false;
-
484 break;
executed: break;
Execution Count:13
13
485 } -
486 -
487 case QTextCursor::End: -
488 newPosition = priv->length() - 1;
executed (the execution status of this line is deduced): newPosition = priv->length() - 1;
-
489 break;
executed: break;
Execution Count:894
894
490 case QTextCursor::EndOfLine: { -
491 if (!line.isValid() || line.textLength() == 0) {
evaluated: !line.isValid()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:6
partially evaluated: line.textLength() == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
492 if (blockIt.length() >= 1)
partially evaluated: blockIt.length() >= 1
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
493 // position right before the block separator -
494 newPosition = blockIt.position() + blockIt.length() - 1;
executed: newPosition = blockIt.position() + blockIt.length() - 1;
Execution Count:4
4
495 break;
executed: break;
Execution Count:4
4
496 } -
497 newPosition = blockIt.position() + line.textStart() + line.textLength();
executed (the execution status of this line is deduced): newPosition = blockIt.position() + line.textStart() + line.textLength();
-
498 if (newPosition >= priv->length())
partially evaluated: newPosition >= priv->length()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
499 newPosition = priv->length() - 1;
never executed: newPosition = priv->length() - 1;
0
500 if (line.lineNumber() < layout->lineCount() - 1) {
evaluated: line.lineNumber() < layout->lineCount() - 1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5
1-5
501 const QString text = blockIt.text();
executed (the execution status of this line is deduced): const QString text = blockIt.text();
-
502 // ###### this relies on spaces being the cause for linebreaks. -
503 // this doesn't work with japanese -
504 if (text.at(line.textStart() + line.textLength() - 1).isSpace())
partially evaluated: text.at(line.textStart() + line.textLength() - 1).isSpace()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
505 --newPosition;
executed: --newPosition;
Execution Count:1
1
506 }
executed: }
Execution Count:1
1
507 break;
executed: break;
Execution Count:6
6
508 } -
509 case QTextCursor::EndOfWord: { -
510 QTextEngine *engine = layout->engine();
executed (the execution status of this line is deduced): QTextEngine *engine = layout->engine();
-
511 engine->attributes();
executed (the execution status of this line is deduced): engine->attributes();
-
512 const int len = blockIt.length() - 1;
executed (the execution status of this line is deduced): const int len = blockIt.length() - 1;
-
513 if (relativePos >= len)
evaluated: relativePos >= len
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:37
2-37
514 return false;
executed: return false;
Execution Count:2
2
515 if (engine->atWordSeparator(relativePos)) {
partially evaluated: engine->atWordSeparator(relativePos)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:37
0-37
516 ++relativePos;
never executed (the execution status of this line is deduced): ++relativePos;
-
517 while (relativePos < len && engine->atWordSeparator(relativePos))
never evaluated: relativePos < len
never evaluated: engine->atWordSeparator(relativePos)
0
518 ++relativePos;
never executed: ++relativePos;
0
519 } else {
never executed: }
0
520 while (relativePos < len && !engine->atSpace(relativePos) && !engine->atWordSeparator(relativePos))
evaluated: relativePos < len
TRUEFALSE
yes
Evaluation Count:173
yes
Evaluation Count:3
evaluated: !engine->atSpace(relativePos)
TRUEFALSE
yes
Evaluation Count:159
yes
Evaluation Count:14
evaluated: !engine->atWordSeparator(relativePos)
TRUEFALSE
yes
Evaluation Count:139
yes
Evaluation Count:20
3-173
521 ++relativePos;
executed: ++relativePos;
Execution Count:139
139
522 }
executed: }
Execution Count:37
37
523 newPosition = blockIt.position() + relativePos;
executed (the execution status of this line is deduced): newPosition = blockIt.position() + relativePos;
-
524 break;
executed: break;
Execution Count:37
37
525 } -
526 case QTextCursor::EndOfBlock: -
527 if (blockIt.length() >= 1)
partially evaluated: blockIt.length() >= 1
TRUEFALSE
yes
Evaluation Count:21
no
Evaluation Count:0
0-21
528 // position right before the block separator -
529 newPosition = blockIt.position() + blockIt.length() - 1;
executed: newPosition = blockIt.position() + blockIt.length() - 1;
Execution Count:21
21
530 break;
executed: break;
Execution Count:21
21
531 case QTextCursor::NextBlock: { -
532 blockIt = blockIt.next();
executed (the execution status of this line is deduced): blockIt = blockIt.next();
-
533 if (!blockIt.isValid())
evaluated: !blockIt.isValid()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1136
6-1136
534 return false;
executed: return false;
Execution Count:6
6
535 -
536 newPosition = blockIt.position();
executed (the execution status of this line is deduced): newPosition = blockIt.position();
-
537 break;
executed: break;
Execution Count:1136
1136
538 } -
539 case QTextCursor::NextCharacter: -
540 if (mode == QTextCursor::MoveAnchor && position != adjusted_anchor)
evaluated: mode == QTextCursor::MoveAnchor
TRUEFALSE
yes
Evaluation Count:54
yes
Evaluation Count:39
partially evaluated: position != adjusted_anchor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:54
0-54
541 newPosition = qMax(position, adjusted_anchor);
never executed: newPosition = qMax(position, adjusted_anchor);
0
542 else -
543 newPosition = priv->nextCursorPosition(position, QTextLayout::SkipCharacters);
executed: newPosition = priv->nextCursorPosition(position, QTextLayout::SkipCharacters);
Execution Count:93
93
544 break;
executed: break;
Execution Count:93
93
545 case QTextCursor::Right: -
546 if (mode == QTextCursor::MoveAnchor && position != adjusted_anchor)
evaluated: mode == QTextCursor::MoveAnchor
TRUEFALSE
yes
Evaluation Count:45
yes
Evaluation Count:9
evaluated: position != adjusted_anchor
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:20
9-45
547 newPosition = visualMovement ? qMin(position, adjusted_anchor)
executed: newPosition = visualMovement ? qMin(position, adjusted_anchor) : qMax(position, adjusted_anchor);
Execution Count:25
partially evaluated: visualMovement
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
0-25
548 : qMax(position, adjusted_anchor);
executed: newPosition = visualMovement ? qMin(position, adjusted_anchor) : qMax(position, adjusted_anchor);
Execution Count:25
25
549 else -
550 newPosition = visualMovement ? priv->rightCursorPosition(position)
executed: newPosition = visualMovement ? priv->rightCursorPosition(position) : priv->nextCursorPosition(position, QTextLayout::SkipCharacters);
Execution Count:29
partially evaluated: visualMovement
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:29
0-29
551 : priv->nextCursorPosition(position, QTextLayout::SkipCharacters);
executed: newPosition = visualMovement ? priv->rightCursorPosition(position) : priv->nextCursorPosition(position, QTextLayout::SkipCharacters);
Execution Count:29
29
552 break;
executed: break;
Execution Count:54
54
553 case QTextCursor::NextWord: -
554 case QTextCursor::WordRight: -
555 newPosition = priv->nextCursorPosition(position, QTextLayout::SkipWords);
executed (the execution status of this line is deduced): newPosition = priv->nextCursorPosition(position, QTextLayout::SkipWords);
-
556 break;
executed: break;
Execution Count:16
16
557 -
558 case QTextCursor::Down: { -
559 int i = line.lineNumber() + 1;
executed (the execution status of this line is deduced): int i = line.lineNumber() + 1;
-
560 -
561 if (i >= layout->lineCount()) {
evaluated: i >= layout->lineCount()
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:2
2-20
562 int blockPosition = blockIt.position() + blockIt.length() - 1;
executed (the execution status of this line is deduced): int blockPosition = blockIt.position() + blockIt.length() - 1;
-
563 QTextTable *table = qobject_cast<QTextTable *>(priv->frameAt(blockPosition));
executed (the execution status of this line is deduced): QTextTable *table = qobject_cast<QTextTable *>(priv->frameAt(blockPosition));
-
564 if (table) {
evaluated: table
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:7
7-13
565 QTextTableCell cell = table->cellAt(blockPosition);
executed (the execution status of this line is deduced): QTextTableCell cell = table->cellAt(blockPosition);
-
566 if (cell.lastPosition() == blockPosition) {
partially evaluated: cell.lastPosition() == blockPosition
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-13
567 int row = cell.row() + cell.rowSpan();
executed (the execution status of this line is deduced): int row = cell.row() + cell.rowSpan();
-
568 if (row < table->rows()) {
partially evaluated: row < table->rows()
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-13
569 blockPosition = table->cellAt(row, cell.column()).firstPosition();
executed (the execution status of this line is deduced): blockPosition = table->cellAt(row, cell.column()).firstPosition();
-
570 } else {
executed: }
Execution Count:13
13
571 // move to line below the table -
572 blockPosition = table->lastPosition() + 1;
never executed (the execution status of this line is deduced): blockPosition = table->lastPosition() + 1;
-
573 }
never executed: }
0
574 blockIt = priv->blocksFind(blockPosition);
executed (the execution status of this line is deduced): blockIt = priv->blocksFind(blockPosition);
-
575 } else {
executed: }
Execution Count:13
13
576 blockIt = blockIt.next();
never executed (the execution status of this line is deduced): blockIt = blockIt.next();
-
577 }
never executed: }
0
578 } else { -
579 blockIt = blockIt.next();
executed (the execution status of this line is deduced): blockIt = blockIt.next();
-
580 }
executed: }
Execution Count:7
7
581 -
582 if (blockIt == priv->blocksEnd())
evaluated: blockIt == priv->blocksEnd()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:17
3-17
583 return false;
executed: return false;
Execution Count:3
3
584 layout = blockLayout(blockIt);
executed (the execution status of this line is deduced): layout = blockLayout(blockIt);
-
585 i = 0;
executed (the execution status of this line is deduced): i = 0;
-
586 }
executed: }
Execution Count:17
17
587 if (layout->lineCount()) {
evaluated: layout->lineCount()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:13
6-13
588 QTextLine line = layout->lineAt(i);
executed (the execution status of this line is deduced): QTextLine line = layout->lineAt(i);
-
589 newPosition = line.xToCursor(x) + blockIt.position();
executed (the execution status of this line is deduced): newPosition = line.xToCursor(x) + blockIt.position();
-
590 } else {
executed: }
Execution Count:6
6
591 newPosition = blockIt.position();
executed (the execution status of this line is deduced): newPosition = blockIt.position();
-
592 }
executed: }
Execution Count:13
13
593 adjustX = false;
executed (the execution status of this line is deduced): adjustX = false;
-
594 break;
executed: break;
Execution Count:19
19
595 } -
596 case QTextCursor::NextCell: // fall through -
597 case QTextCursor::PreviousCell: // fall through -
598 case QTextCursor::NextRow: // fall through -
599 case QTextCursor::PreviousRow: { -
600 QTextTable *table = qobject_cast<QTextTable *>(priv->frameAt(position));
executed (the execution status of this line is deduced): QTextTable *table = qobject_cast<QTextTable *>(priv->frameAt(position));
-
601 if (!table)
partially evaluated: !table
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:82
0-82
602 return false;
never executed: return false;
0
603 -
604 QTextTableCell cell = table->cellAt(position);
executed (the execution status of this line is deduced): QTextTableCell cell = table->cellAt(position);
-
605 Q_ASSERT(cell.isValid());
executed (the execution status of this line is deduced): qt_noop();
-
606 int column = cell.column();
executed (the execution status of this line is deduced): int column = cell.column();
-
607 int row = cell.row();
executed (the execution status of this line is deduced): int row = cell.row();
-
608 const int currentRow = row;
executed (the execution status of this line is deduced): const int currentRow = row;
-
609 if (op == QTextCursor::NextCell || op == QTextCursor::NextRow) {
evaluated: op == QTextCursor::NextCell
TRUEFALSE
yes
Evaluation Count:56
yes
Evaluation Count:26
evaluated: op == QTextCursor::NextRow
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:23
3-56
610 do { -
611 column += cell.columnSpan();
executed (the execution status of this line is deduced): column += cell.columnSpan();
-
612 if (column >= table->columns()) {
evaluated: column >= table->columns()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:56
10-56
613 column = 0;
executed (the execution status of this line is deduced): column = 0;
-
614 ++row;
executed (the execution status of this line is deduced): ++row;
-
615 }
executed: }
Execution Count:10
10
616 cell = table->cellAt(row, column);
executed (the execution status of this line is deduced): cell = table->cellAt(row, column);
-
617 // note we also continue while we have not reached a cell thats not merged with one above us -
618 } while (cell.isValid()
executed: }
Execution Count:66
evaluated: cell.isValid()
TRUEFALSE
yes
Evaluation Count:63
yes
Evaluation Count:3
3-66
619 && ((op == QTextCursor::NextRow && currentRow == cell.row())
evaluated: op == QTextCursor::NextRow
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:55
evaluated: currentRow == cell.row()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:2
2-55
620 || cell.row() < row));
evaluated: cell.row() < row
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:56
1-56
621 }
executed: }
Execution Count:59
59
622 else if (op == QTextCursor::PreviousCell || op == QTextCursor::PreviousRow) {
evaluated: op == QTextCursor::PreviousCell
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:3
partially evaluated: op == QTextCursor::PreviousRow
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-20
623 do { -
624 --column;
executed (the execution status of this line is deduced): --column;
-
625 if (column < 0) {
evaluated: column < 0
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:20
10-20
626 column = table->columns()-1;
executed (the execution status of this line is deduced): column = table->columns()-1;
-
627 --row;
executed (the execution status of this line is deduced): --row;
-
628 }
executed: }
Execution Count:10
10
629 cell = table->cellAt(row, column);
executed (the execution status of this line is deduced): cell = table->cellAt(row, column);
-
630 // note we also continue while we have not reached a cell thats not merged with one above us -
631 } while (cell.isValid()
executed: }
Execution Count:30
evaluated: cell.isValid()
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:3
3-30
632 && ((op == QTextCursor::PreviousRow && currentRow == cell.row())
evaluated: op == QTextCursor::PreviousRow
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:19
evaluated: currentRow == cell.row()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:2
2-19
633 || cell.row() < row));
evaluated: cell.row() < row
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:20
1-20
634 }
executed: }
Execution Count:23
23
635 if (cell.isValid())
evaluated: cell.isValid()
TRUEFALSE
yes
Evaluation Count:76
yes
Evaluation Count:6
6-76
636 newPosition = cell.firstPosition();
executed: newPosition = cell.firstPosition();
Execution Count:76
76
637 break;
executed: break;
Execution Count:82
82
638 } -
639 } -
640 -
641 if (mode == QTextCursor::KeepAnchor) {
evaluated: mode == QTextCursor::KeepAnchor
TRUEFALSE
yes
Evaluation Count:2077
yes
Evaluation Count:807
807-2077
642 QTextTable *table = qobject_cast<QTextTable *>(priv->frameAt(position));
executed (the execution status of this line is deduced): QTextTable *table = qobject_cast<QTextTable *>(priv->frameAt(position));
-
643 if (table && ((op >= QTextCursor::PreviousBlock && op <= QTextCursor::WordLeft)
evaluated: table
TRUEFALSE
yes
Evaluation Count:125
yes
Evaluation Count:1952
evaluated: op >= QTextCursor::PreviousBlock
TRUEFALSE
yes
Evaluation Count:115
yes
Evaluation Count:10
evaluated: op <= QTextCursor::WordLeft
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:77
10-1952
644 || (op >= QTextCursor::NextBlock && op <= QTextCursor::WordRight))) {
evaluated: op >= QTextCursor::NextBlock
TRUEFALSE
yes
Evaluation Count:65
yes
Evaluation Count:22
evaluated: op <= QTextCursor::WordRight
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:54
11-65
645 int oldColumn = table->cellAt(position).column();
executed (the execution status of this line is deduced): int oldColumn = table->cellAt(position).column();
-
646 -
647 const QTextTableCell otherCell = table->cellAt(newPosition);
executed (the execution status of this line is deduced): const QTextTableCell otherCell = table->cellAt(newPosition);
-
648 if (!otherCell.isValid())
evaluated: !otherCell.isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:48
1-48
649 return false;
executed: return false;
Execution Count:1
1
650 -
651 int newColumn = otherCell.column();
executed (the execution status of this line is deduced): int newColumn = otherCell.column();
-
652 if ((oldColumn > newColumn && op >= QTextCursor::End)
evaluated: oldColumn > newColumn
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:14
evaluated: op >= QTextCursor::End
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:32
2-34
653 || (oldColumn < newColumn && op <= QTextCursor::WordLeft))
evaluated: oldColumn < newColumn
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:45
partially evaluated: op <= QTextCursor::WordLeft
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-45
654 return false;
executed: return false;
Execution Count:3
3
655 }
executed: }
Execution Count:45
45
656 }
executed: }
Execution Count:2073
2073
657 -
658 const bool moved = setPosition(newPosition);
executed (the execution status of this line is deduced): const bool moved = setPosition(newPosition);
-
659 -
660 if (mode == QTextCursor::MoveAnchor) {
evaluated: mode == QTextCursor::MoveAnchor
TRUEFALSE
yes
Evaluation Count:807
yes
Evaluation Count:2073
807-2073
661 anchor = position;
executed (the execution status of this line is deduced): anchor = position;
-
662 adjusted_anchor = position;
executed (the execution status of this line is deduced): adjusted_anchor = position;
-
663 } else {
executed: }
Execution Count:807
807
664 adjustCursor(op);
executed (the execution status of this line is deduced): adjustCursor(op);
-
665 }
executed: }
Execution Count:2073
2073
666 -
667 if (adjustX)
evaluated: adjustX
TRUEFALSE
yes
Evaluation Count:2848
yes
Evaluation Count:32
32-2848
668 setX();
executed: setX();
Execution Count:2848
2848
669 -
670 return moved;
executed: return moved;
Execution Count:2880
2880
671} -
672 -
673QTextTable *QTextCursorPrivate::complexSelectionTable() const -
674{ -
675 if (position == anchor)
evaluated: position == anchor
TRUEFALSE
yes
Evaluation Count:4486
yes
Evaluation Count:2259
2259-4486
676 return 0;
executed: return 0;
Execution Count:4486
4486
677 -
678 QTextTable *t = qobject_cast<QTextTable *>(priv->frameAt(position));
executed (the execution status of this line is deduced): QTextTable *t = qobject_cast<QTextTable *>(priv->frameAt(position));
-
679 if (t) {
evaluated: t
TRUEFALSE
yes
Evaluation Count:109
yes
Evaluation Count:2150
109-2150
680 QTextTableCell cell_pos = t->cellAt(position);
executed (the execution status of this line is deduced): QTextTableCell cell_pos = t->cellAt(position);
-
681 QTextTableCell cell_anchor = t->cellAt(adjusted_anchor);
executed (the execution status of this line is deduced): QTextTableCell cell_anchor = t->cellAt(adjusted_anchor);
-
682 -
683 Q_ASSERT(cell_anchor.isValid());
executed (the execution status of this line is deduced): qt_noop();
-
684 -
685 if (cell_pos == cell_anchor)
evaluated: cell_pos == cell_anchor
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:95
14-95
686 t = 0;
executed: t = 0;
Execution Count:14
14
687 }
executed: }
Execution Count:109
109
688 return t;
executed: return t;
Execution Count:2259
2259
689} -
690 -
691void QTextCursorPrivate::selectedTableCells(int *firstRow, int *numRows, int *firstColumn, int *numColumns) const -
692{ -
693 *firstRow = -1;
executed (the execution status of this line is deduced): *firstRow = -1;
-
694 *firstColumn = -1;
executed (the execution status of this line is deduced): *firstColumn = -1;
-
695 *numRows = -1;
executed (the execution status of this line is deduced): *numRows = -1;
-
696 *numColumns = -1;
executed (the execution status of this line is deduced): *numColumns = -1;
-
697 -
698 if (position == anchor)
partially evaluated: position == anchor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
699 return;
never executed: return;
0
700 -
701 QTextTable *t = qobject_cast<QTextTable *>(priv->frameAt(position));
executed (the execution status of this line is deduced): QTextTable *t = qobject_cast<QTextTable *>(priv->frameAt(position));
-
702 if (!t)
partially evaluated: !t
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
703 return;
never executed: return;
0
704 -
705 QTextTableCell cell_pos = t->cellAt(position);
executed (the execution status of this line is deduced): QTextTableCell cell_pos = t->cellAt(position);
-
706 QTextTableCell cell_anchor = t->cellAt(adjusted_anchor);
executed (the execution status of this line is deduced): QTextTableCell cell_anchor = t->cellAt(adjusted_anchor);
-
707 -
708 Q_ASSERT(cell_anchor.isValid());
executed (the execution status of this line is deduced): qt_noop();
-
709 -
710 if (cell_pos == cell_anchor)
partially evaluated: cell_pos == cell_anchor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
711 return;
never executed: return;
0
712 -
713 *firstRow = qMin(cell_pos.row(), cell_anchor.row());
executed (the execution status of this line is deduced): *firstRow = qMin(cell_pos.row(), cell_anchor.row());
-
714 *firstColumn = qMin(cell_pos.column(), cell_anchor.column());
executed (the execution status of this line is deduced): *firstColumn = qMin(cell_pos.column(), cell_anchor.column());
-
715 *numRows = qMax(cell_pos.row() + cell_pos.rowSpan(), cell_anchor.row() + cell_anchor.rowSpan()) - *firstRow;
executed (the execution status of this line is deduced): *numRows = qMax(cell_pos.row() + cell_pos.rowSpan(), cell_anchor.row() + cell_anchor.rowSpan()) - *firstRow;
-
716 *numColumns = qMax(cell_pos.column() + cell_pos.columnSpan(), cell_anchor.column() + cell_anchor.columnSpan()) - *firstColumn;
executed (the execution status of this line is deduced): *numColumns = qMax(cell_pos.column() + cell_pos.columnSpan(), cell_anchor.column() + cell_anchor.columnSpan()) - *firstColumn;
-
717}
executed: }
Execution Count:9
9
718 -
719static void setBlockCharFormatHelper(QTextDocumentPrivate *priv, int pos1, int pos2, -
720 const QTextCharFormat &format, QTextDocumentPrivate::FormatChangeMode changeMode) -
721{ -
722 QTextBlock it = priv->blocksFind(pos1);
executed (the execution status of this line is deduced): QTextBlock it = priv->blocksFind(pos1);
-
723 QTextBlock end = priv->blocksFind(pos2);
executed (the execution status of this line is deduced): QTextBlock end = priv->blocksFind(pos2);
-
724 if (end.isValid())
partially evaluated: end.isValid()
TRUEFALSE
yes
Evaluation Count:1285
no
Evaluation Count:0
0-1285
725 end = end.next();
executed: end = end.next();
Execution Count:1285
1285
726 -
727 for (; it != end; it = it.next()) {
evaluated: it != end
TRUEFALSE
yes
Evaluation Count:1286
yes
Evaluation Count:1285
1285-1286
728 priv->setCharFormat(it.position() - 1, 1, format, changeMode);
executed (the execution status of this line is deduced): priv->setCharFormat(it.position() - 1, 1, format, changeMode);
-
729 }
executed: }
Execution Count:1286
1286
730}
executed: }
Execution Count:1285
1285
731 -
732void QTextCursorPrivate::setBlockCharFormat(const QTextCharFormat &_format, -
733 QTextDocumentPrivate::FormatChangeMode changeMode) -
734{ -
735 priv->beginEditBlock();
executed (the execution status of this line is deduced): priv->beginEditBlock();
-
736 -
737 QTextCharFormat format = _format;
executed (the execution status of this line is deduced): QTextCharFormat format = _format;
-
738 format.clearProperty(QTextFormat::ObjectIndex);
executed (the execution status of this line is deduced): format.clearProperty(QTextFormat::ObjectIndex);
-
739 -
740 QTextTable *table = complexSelectionTable();
executed (the execution status of this line is deduced): QTextTable *table = complexSelectionTable();
-
741 if (table) {
partially evaluated: table
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1285
0-1285
742 int row_start, col_start, num_rows, num_cols;
never executed (the execution status of this line is deduced): int row_start, col_start, num_rows, num_cols;
-
743 selectedTableCells(&row_start, &num_rows, &col_start, &num_cols);
never executed (the execution status of this line is deduced): selectedTableCells(&row_start, &num_rows, &col_start, &num_cols);
-
744 -
745 Q_ASSERT(row_start != -1);
never executed (the execution status of this line is deduced): qt_noop();
-
746 for (int r = row_start; r < row_start + num_rows; ++r) {
never evaluated: r < row_start + num_rows
0
747 for (int c = col_start; c < col_start + num_cols; ++c) {
never evaluated: c < col_start + num_cols
0
748 QTextTableCell cell = table->cellAt(r, c);
never executed (the execution status of this line is deduced): QTextTableCell cell = table->cellAt(r, c);
-
749 int rspan = cell.rowSpan();
never executed (the execution status of this line is deduced): int rspan = cell.rowSpan();
-
750 int cspan = cell.columnSpan();
never executed (the execution status of this line is deduced): int cspan = cell.columnSpan();
-
751 if (rspan != 1) {
never evaluated: rspan != 1
0
752 int cr = cell.row();
never executed (the execution status of this line is deduced): int cr = cell.row();
-
753 if (cr != r)
never evaluated: cr != r
0
754 continue;
never executed: continue;
0
755 }
never executed: }
0
756 if (cspan != 1) {
never evaluated: cspan != 1
0
757 int cc = cell.column();
never executed (the execution status of this line is deduced): int cc = cell.column();
-
758 if (cc != c)
never evaluated: cc != c
0
759 continue;
never executed: continue;
0
760 }
never executed: }
0
761 -
762 int pos1 = cell.firstPosition();
never executed (the execution status of this line is deduced): int pos1 = cell.firstPosition();
-
763 int pos2 = cell.lastPosition();
never executed (the execution status of this line is deduced): int pos2 = cell.lastPosition();
-
764 setBlockCharFormatHelper(priv, pos1, pos2, format, changeMode);
never executed (the execution status of this line is deduced): setBlockCharFormatHelper(priv, pos1, pos2, format, changeMode);
-
765 }
never executed: }
0
766 }
never executed: }
0
767 } else {
never executed: }
0
768 int pos1 = position;
executed (the execution status of this line is deduced): int pos1 = position;
-
769 int pos2 = adjusted_anchor;
executed (the execution status of this line is deduced): int pos2 = adjusted_anchor;
-
770 if (pos1 > pos2) {
evaluated: pos1 > pos2
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1283
2-1283
771 pos1 = adjusted_anchor;
executed (the execution status of this line is deduced): pos1 = adjusted_anchor;
-
772 pos2 = position;
executed (the execution status of this line is deduced): pos2 = position;
-
773 }
executed: }
Execution Count:2
2
774 -
775 setBlockCharFormatHelper(priv, pos1, pos2, format, changeMode);
executed (the execution status of this line is deduced): setBlockCharFormatHelper(priv, pos1, pos2, format, changeMode);
-
776 }
executed: }
Execution Count:1285
1285
777 priv->endEditBlock();
executed (the execution status of this line is deduced): priv->endEditBlock();
-
778}
executed: }
Execution Count:1285
1285
779 -
780 -
781void QTextCursorPrivate::setBlockFormat(const QTextBlockFormat &format, QTextDocumentPrivate::FormatChangeMode changeMode) -
782{ -
783 QTextTable *table = complexSelectionTable();
executed (the execution status of this line is deduced): QTextTable *table = complexSelectionTable();
-
784 if (table) {
partially evaluated: table
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:982
0-982
785 priv->beginEditBlock();
never executed (the execution status of this line is deduced): priv->beginEditBlock();
-
786 int row_start, col_start, num_rows, num_cols;
never executed (the execution status of this line is deduced): int row_start, col_start, num_rows, num_cols;
-
787 selectedTableCells(&row_start, &num_rows, &col_start, &num_cols);
never executed (the execution status of this line is deduced): selectedTableCells(&row_start, &num_rows, &col_start, &num_cols);
-
788 -
789 Q_ASSERT(row_start != -1);
never executed (the execution status of this line is deduced): qt_noop();
-
790 for (int r = row_start; r < row_start + num_rows; ++r) {
never evaluated: r < row_start + num_rows
0
791 for (int c = col_start; c < col_start + num_cols; ++c) {
never evaluated: c < col_start + num_cols
0
792 QTextTableCell cell = table->cellAt(r, c);
never executed (the execution status of this line is deduced): QTextTableCell cell = table->cellAt(r, c);
-
793 int rspan = cell.rowSpan();
never executed (the execution status of this line is deduced): int rspan = cell.rowSpan();
-
794 int cspan = cell.columnSpan();
never executed (the execution status of this line is deduced): int cspan = cell.columnSpan();
-
795 if (rspan != 1) {
never evaluated: rspan != 1
0
796 int cr = cell.row();
never executed (the execution status of this line is deduced): int cr = cell.row();
-
797 if (cr != r)
never evaluated: cr != r
0
798 continue;
never executed: continue;
0
799 }
never executed: }
0
800 if (cspan != 1) {
never evaluated: cspan != 1
0
801 int cc = cell.column();
never executed (the execution status of this line is deduced): int cc = cell.column();
-
802 if (cc != c)
never evaluated: cc != c
0
803 continue;
never executed: continue;
0
804 }
never executed: }
0
805 -
806 int pos1 = cell.firstPosition();
never executed (the execution status of this line is deduced): int pos1 = cell.firstPosition();
-
807 int pos2 = cell.lastPosition();
never executed (the execution status of this line is deduced): int pos2 = cell.lastPosition();
-
808 priv->setBlockFormat(priv->blocksFind(pos1), priv->blocksFind(pos2), format, changeMode);
never executed (the execution status of this line is deduced): priv->setBlockFormat(priv->blocksFind(pos1), priv->blocksFind(pos2), format, changeMode);
-
809 }
never executed: }
0
810 }
never executed: }
0
811 priv->endEditBlock();
never executed (the execution status of this line is deduced): priv->endEditBlock();
-
812 } else {
never executed: }
0
813 int pos1 = position;
executed (the execution status of this line is deduced): int pos1 = position;
-
814 int pos2 = adjusted_anchor;
executed (the execution status of this line is deduced): int pos2 = adjusted_anchor;
-
815 if (pos1 > pos2) {
evaluated: pos1 > pos2
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:981
1-981
816 pos1 = adjusted_anchor;
executed (the execution status of this line is deduced): pos1 = adjusted_anchor;
-
817 pos2 = position;
executed (the execution status of this line is deduced): pos2 = position;
-
818 }
executed: }
Execution Count:1
1
819 -
820 priv->setBlockFormat(priv->blocksFind(pos1), priv->blocksFind(pos2), format, changeMode);
executed (the execution status of this line is deduced): priv->setBlockFormat(priv->blocksFind(pos1), priv->blocksFind(pos2), format, changeMode);
-
821 }
executed: }
Execution Count:982
982
822} -
823 -
824void QTextCursorPrivate::setCharFormat(const QTextCharFormat &_format, QTextDocumentPrivate::FormatChangeMode changeMode) -
825{ -
826 Q_ASSERT(position != anchor);
executed (the execution status of this line is deduced): qt_noop();
-
827 -
828 QTextCharFormat format = _format;
executed (the execution status of this line is deduced): QTextCharFormat format = _format;
-
829 format.clearProperty(QTextFormat::ObjectIndex);
executed (the execution status of this line is deduced): format.clearProperty(QTextFormat::ObjectIndex);
-
830 -
831 QTextTable *table = complexSelectionTable();
executed (the execution status of this line is deduced): QTextTable *table = complexSelectionTable();
-
832 if (table) {
partially evaluated: table
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:201
0-201
833 priv->beginEditBlock();
never executed (the execution status of this line is deduced): priv->beginEditBlock();
-
834 int row_start, col_start, num_rows, num_cols;
never executed (the execution status of this line is deduced): int row_start, col_start, num_rows, num_cols;
-
835 selectedTableCells(&row_start, &num_rows, &col_start, &num_cols);
never executed (the execution status of this line is deduced): selectedTableCells(&row_start, &num_rows, &col_start, &num_cols);
-
836 -
837 Q_ASSERT(row_start != -1);
never executed (the execution status of this line is deduced): qt_noop();
-
838 for (int r = row_start; r < row_start + num_rows; ++r) {
never evaluated: r < row_start + num_rows
0
839 for (int c = col_start; c < col_start + num_cols; ++c) {
never evaluated: c < col_start + num_cols
0
840 QTextTableCell cell = table->cellAt(r, c);
never executed (the execution status of this line is deduced): QTextTableCell cell = table->cellAt(r, c);
-
841 int rspan = cell.rowSpan();
never executed (the execution status of this line is deduced): int rspan = cell.rowSpan();
-
842 int cspan = cell.columnSpan();
never executed (the execution status of this line is deduced): int cspan = cell.columnSpan();
-
843 if (rspan != 1) {
never evaluated: rspan != 1
0
844 int cr = cell.row();
never executed (the execution status of this line is deduced): int cr = cell.row();
-
845 if (cr != r)
never evaluated: cr != r
0
846 continue;
never executed: continue;
0
847 }
never executed: }
0
848 if (cspan != 1) {
never evaluated: cspan != 1
0
849 int cc = cell.column();
never executed (the execution status of this line is deduced): int cc = cell.column();
-
850 if (cc != c)
never evaluated: cc != c
0
851 continue;
never executed: continue;
0
852 }
never executed: }
0
853 -
854 int pos1 = cell.firstPosition();
never executed (the execution status of this line is deduced): int pos1 = cell.firstPosition();
-
855 int pos2 = cell.lastPosition();
never executed (the execution status of this line is deduced): int pos2 = cell.lastPosition();
-
856 priv->setCharFormat(pos1, pos2-pos1, format, changeMode);
never executed (the execution status of this line is deduced): priv->setCharFormat(pos1, pos2-pos1, format, changeMode);
-
857 }
never executed: }
0
858 }
never executed: }
0
859 priv->endEditBlock();
never executed (the execution status of this line is deduced): priv->endEditBlock();
-
860 } else {
never executed: }
0
861 int pos1 = position;
executed (the execution status of this line is deduced): int pos1 = position;
-
862 int pos2 = adjusted_anchor;
executed (the execution status of this line is deduced): int pos2 = adjusted_anchor;
-
863 if (pos1 > pos2) {
evaluated: pos1 > pos2
TRUEFALSE
yes
Evaluation Count:177
yes
Evaluation Count:24
24-177
864 pos1 = adjusted_anchor;
executed (the execution status of this line is deduced): pos1 = adjusted_anchor;
-
865 pos2 = position;
executed (the execution status of this line is deduced): pos2 = position;
-
866 }
executed: }
Execution Count:177
177
867 -
868 priv->setCharFormat(pos1, pos2-pos1, format, changeMode);
executed (the execution status of this line is deduced): priv->setCharFormat(pos1, pos2-pos1, format, changeMode);
-
869 }
executed: }
Execution Count:201
201
870} -
871 -
872 -
873QTextLayout *QTextCursorPrivate::blockLayout(QTextBlock &block) const{ -
874 QTextLayout *tl = block.layout();
executed (the execution status of this line is deduced): QTextLayout *tl = block.layout();
-
875 if (!tl->lineCount() && priv->layout())
evaluated: !tl->lineCount()
TRUEFALSE
yes
Evaluation Count:17770
yes
Evaluation Count:943
evaluated: priv->layout()
TRUEFALSE
yes
Evaluation Count:11248
yes
Evaluation Count:6522
943-17770
876 priv->layout()->blockBoundingRect(block);
executed: priv->layout()->blockBoundingRect(block);
Execution Count:11248
11248
877 return tl;
executed: return tl;
Execution Count:18713
18713
878} -
879 -
880/*! -
881 \class QTextCursor -
882 \reentrant -
883 \inmodule QtGui -
884 -
885 \brief The QTextCursor class offers an API to access and modify QTextDocuments. -
886 -
887 \ingroup richtext-processing -
888 \ingroup shared -
889 -
890 Text cursors are objects that are used to access and modify the -
891 contents and underlying structure of text documents via a -
892 programming interface that mimics the behavior of a cursor in a -
893 text editor. QTextCursor contains information about both the -
894 cursor's position within a QTextDocument and any selection that it -
895 has made. -
896 -
897 QTextCursor is modeled on the way a text cursor behaves in a text -
898 editor, providing a programmatic means of performing standard -
899 actions through the user interface. A document can be thought of -
900 as a single string of characters. The cursor's current position() -
901 then is always either \e between two consecutive characters in the -
902 string, or else \e before the very first character or \e after the -
903 very last character in the string. Documents can also contain -
904 tables, lists, images, and other objects in addition to text but, -
905 from the developer's point of view, the document can be treated as -
906 one long string. Some portions of that string can be considered -
907 to lie within particular blocks (e.g. paragraphs), or within a -
908 table's cell, or a list's item, or other structural elements. When -
909 we refer to "current character" we mean the character immediately -
910 \e before the cursor position() in the document. Similarly, the -
911 "current block" is the block that contains the cursor position(). -
912 -
913 A QTextCursor also has an anchor() position. The text that is -
914 between the anchor() and the position() is the selection. If -
915 anchor() == position() there is no selection. -
916 -
917 The cursor position can be changed programmatically using -
918 setPosition() and movePosition(); the latter can also be used to -
919 select text. For selections see selectionStart(), selectionEnd(), -
920 hasSelection(), clearSelection(), and removeSelectedText(). -
921 -
922 If the position() is at the start of a block atBlockStart() -
923 returns true; and if it is at the end of a block atBlockEnd() returns -
924 true. The format of the current character is returned by -
925 charFormat(), and the format of the current block is returned by -
926 blockFormat(). -
927 -
928 Formatting can be applied to the current text document using the -
929 setCharFormat(), mergeCharFormat(), setBlockFormat() and -
930 mergeBlockFormat() functions. The 'set' functions will replace the -
931 cursor's current character or block format, while the 'merge' -
932 functions add the given format properties to the cursor's current -
933 format. If the cursor has a selection the given format is applied -
934 to the current selection. Note that when only parts of a block is -
935 selected the block format is applied to the entire block. The text -
936 at the current character position can be turned into a list using -
937 createList(). -
938 -
939 Deletions can be achieved using deleteChar(), -
940 deletePreviousChar(), and removeSelectedText(). -
941 -
942 Text strings can be inserted into the document with the insertText() -
943 function, blocks (representing new paragraphs) can be inserted with -
944 insertBlock(). -
945 -
946 Existing fragments of text can be inserted with insertFragment() but, -
947 if you want to insert pieces of text in various formats, it is usually -
948 still easier to use insertText() and supply a character format. -
949 -
950 Various types of higher-level structure can also be inserted into the -
951 document with the cursor: -
952 -
953 \list -
954 \li Lists are ordered sequences of block elements that are decorated with -
955 bullet points or symbols. These are inserted in a specified format -
956 with insertList(). -
957 \li Tables are inserted with the insertTable() function, and can be -
958 given an optional format. These contain an array of cells that can -
959 be traversed using the cursor. -
960 \li Inline images are inserted with insertImage(). The image to be -
961 used can be specified in an image format, or by name. -
962 \li Frames are inserted by calling insertFrame() with a specified format. -
963 \endlist -
964 -
965 Actions can be grouped (i.e. treated as a single action for -
966 undo/redo) using beginEditBlock() and endEditBlock(). -
967 -
968 Cursor movements are limited to valid cursor positions. In Latin -
969 writing this is between any two consecutive characters in the -
970 text, before the first character, or after the last character. In -
971 some other writing systems cursor movements are limited to -
972 "clusters" (e.g. a syllable in Devanagari, or a base letter plus -
973 diacritics). Functions such as movePosition() and deleteChar() -
974 limit cursor movement to these valid positions. -
975 -
976 \sa {Rich Text Processing} -
977 -
978*/ -
979 -
980/*! -
981 \enum QTextCursor::MoveOperation -
982 -
983 \value NoMove Keep the cursor where it is -
984 -
985 \value Start Move to the start of the document. -
986 \value StartOfLine Move to the start of the current line. -
987 \value StartOfBlock Move to the start of the current block. -
988 \value StartOfWord Move to the start of the current word. -
989 \value PreviousBlock Move to the start of the previous block. -
990 \value PreviousCharacter Move to the previous character. -
991 \value PreviousWord Move to the beginning of the previous word. -
992 \value Up Move up one line. -
993 \value Left Move left one character. -
994 \value WordLeft Move left one word. -
995 -
996 \value End Move to the end of the document. -
997 \value EndOfLine Move to the end of the current line. -
998 \value EndOfWord Move to the end of the current word. -
999 \value EndOfBlock Move to the end of the current block. -
1000 \value NextBlock Move to the beginning of the next block. -
1001 \value NextCharacter Move to the next character. -
1002 \value NextWord Move to the next word. -
1003 \value Down Move down one line. -
1004 \value Right Move right one character. -
1005 \value WordRight Move right one word. -
1006 -
1007 \value NextCell Move to the beginning of the next table cell inside the -
1008 current table. If the current cell is the last cell in the row, the -
1009 cursor will move to the first cell in the next row. -
1010 \value PreviousCell Move to the beginning of the previous table cell -
1011 inside the current table. If the current cell is the first cell in -
1012 the row, the cursor will move to the last cell in the previous row. -
1013 \value NextRow Move to the first new cell of the next row in the current -
1014 table. -
1015 \value PreviousRow Move to the last cell of the previous row in the -
1016 current table. -
1017 -
1018 \sa movePosition() -
1019*/ -
1020 -
1021/*! -
1022 \enum QTextCursor::MoveMode -
1023 -
1024 \value MoveAnchor Moves the anchor to the same position as the cursor itself. -
1025 \value KeepAnchor Keeps the anchor where it is. -
1026 -
1027 If the anchor() is kept where it is and the position() is moved, -
1028 the text in between will be selected. -
1029*/ -
1030 -
1031/*! -
1032 \enum QTextCursor::SelectionType -
1033 -
1034 This enum describes the types of selection that can be applied with the -
1035 select() function. -
1036 -
1037 \value Document Selects the entire document. -
1038 \value BlockUnderCursor Selects the block of text under the cursor. -
1039 \value LineUnderCursor Selects the line of text under the cursor. -
1040 \value WordUnderCursor Selects the word under the cursor. If the cursor -
1041 is not positioned within a string of selectable characters, no -
1042 text is selected. -
1043*/ -
1044 -
1045/*! -
1046 Constructs a null cursor. -
1047 */ -
1048QTextCursor::QTextCursor() -
1049 : d(0) -
1050{ -
1051}
executed: }
Execution Count:5339
5339
1052 -
1053/*! -
1054 Constructs a cursor pointing to the beginning of the \a document. -
1055 */ -
1056QTextCursor::QTextCursor(QTextDocument *document) -
1057 : d(new QTextCursorPrivate(document->docHandle())) -
1058{ -
1059}
executed: }
Execution Count:3905
3905
1060 -
1061/*! -
1062 Constructs a cursor pointing to the beginning of the \a frame. -
1063*/ -
1064QTextCursor::QTextCursor(QTextFrame *frame) -
1065 : d(new QTextCursorPrivate(frame->document()->docHandle())) -
1066{ -
1067 d->adjusted_anchor = d->anchor = d->position = frame->firstPosition();
executed (the execution status of this line is deduced): d->adjusted_anchor = d->anchor = d->position = frame->firstPosition();
-
1068}
executed: }
Execution Count:1
1
1069 -
1070 -
1071/*! -
1072 Constructs a cursor pointing to the beginning of the \a block. -
1073*/ -
1074QTextCursor::QTextCursor(const QTextBlock &block) -
1075 : d(new QTextCursorPrivate(block.docHandle())) -
1076{ -
1077 d->adjusted_anchor = d->anchor = d->position = block.position();
executed (the execution status of this line is deduced): d->adjusted_anchor = d->anchor = d->position = block.position();
-
1078}
executed: }
Execution Count:4
4
1079 -
1080 -
1081/*! -
1082 \internal -
1083 */ -
1084QTextCursor::QTextCursor(QTextDocumentPrivate *p, int pos) -
1085 : d(new QTextCursorPrivate(p)) -
1086{ -
1087 d->adjusted_anchor = d->anchor = d->position = pos;
executed (the execution status of this line is deduced): d->adjusted_anchor = d->anchor = d->position = pos;
-
1088 -
1089 d->setX();
executed (the execution status of this line is deduced): d->setX();
-
1090}
executed: }
Execution Count:1347
1347
1091 -
1092/*! -
1093 \internal -
1094*/ -
1095QTextCursor::QTextCursor(QTextCursorPrivate *d) -
1096{ -
1097 Q_ASSERT(d);
executed (the execution status of this line is deduced): qt_noop();
-
1098 this->d = d;
executed (the execution status of this line is deduced): this->d = d;
-
1099}
executed: }
Execution Count:16784
16784
1100 -
1101/*! -
1102 Constructs a new cursor that is a copy of \a cursor. -
1103 */ -
1104QTextCursor::QTextCursor(const QTextCursor &cursor) -
1105{ -
1106 d = cursor.d;
executed (the execution status of this line is deduced): d = cursor.d;
-
1107}
executed: }
Execution Count:18080
18080
1108 -
1109/*! -
1110 Makes a copy of \a cursor and assigns it to this QTextCursor. Note -
1111 that QTextCursor is an \l{Implicitly Shared Classes}{implicitly -
1112 shared} class. -
1113 -
1114 */ -
1115QTextCursor &QTextCursor::operator=(const QTextCursor &cursor) -
1116{ -
1117 d = cursor.d;
executed (the execution status of this line is deduced): d = cursor.d;
-
1118 return *this;
executed: return *this;
Execution Count:4164
4164
1119} -
1120 -
1121/*! -
1122 \fn void QTextCursor::swap(QTextCursor &other) -
1123 \since 5.0 -
1124 -
1125 Swaps this text cursor instance with \a other. This function is -
1126 very fast and never fails. -
1127*/ -
1128 -
1129/*! -
1130 Destroys the QTextCursor. -
1131 */ -
1132QTextCursor::~QTextCursor() -
1133{ -
1134} -
1135 -
1136/*! -
1137 Returns true if the cursor is null; otherwise returns false. A null -
1138 cursor is created by the default constructor. -
1139 */ -
1140bool QTextCursor::isNull() const -
1141{ -
1142 return !d || !d->priv;
executed: return !d || !d->priv;
Execution Count:2295
2295
1143} -
1144 -
1145/*! -
1146 Moves the cursor to the absolute position in the document specified by -
1147 \a pos using a \c MoveMode specified by \a m. The cursor is positioned -
1148 between characters. -
1149 -
1150 \sa position(), movePosition(), anchor() -
1151*/ -
1152void QTextCursor::setPosition(int pos, MoveMode m) -
1153{ -
1154 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:608
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:608
0-608
1155 return;
never executed: return;
0
1156 -
1157 if (pos < 0 || pos >= d->priv->length()) {
partially evaluated: pos < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:608
partially evaluated: pos >= d->priv->length()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:608
0-608
1158 qWarning("QTextCursor::setPosition: Position '%d' out of range", pos);
never executed (the execution status of this line is deduced): QMessageLogger("text/qtextcursor.cpp", 1158, __PRETTY_FUNCTION__).warning("QTextCursor::setPosition: Position '%d' out of range", pos);
-
1159 return;
never executed: return;
0
1160 } -
1161 -
1162 d->setPosition(pos);
executed (the execution status of this line is deduced): d->setPosition(pos);
-
1163 if (m == MoveAnchor) {
evaluated: m == MoveAnchor
TRUEFALSE
yes
Evaluation Count:464
yes
Evaluation Count:144
144-464
1164 d->anchor = pos;
executed (the execution status of this line is deduced): d->anchor = pos;
-
1165 d->adjusted_anchor = pos;
executed (the execution status of this line is deduced): d->adjusted_anchor = pos;
-
1166 } else { // keep anchor
executed: }
Execution Count:464
464
1167 QTextCursor::MoveOperation op;
executed (the execution status of this line is deduced): QTextCursor::MoveOperation op;
-
1168 if (pos < d->anchor)
evaluated: pos < d->anchor
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:122
22-122
1169 op = QTextCursor::Left;
executed: op = QTextCursor::Left;
Execution Count:22
22
1170 else -
1171 op = QTextCursor::Right;
executed: op = QTextCursor::Right;
Execution Count:122
122
1172 d->adjustCursor(op);
executed (the execution status of this line is deduced): d->adjustCursor(op);
-
1173 }
executed: }
Execution Count:144
144
1174 d->setX();
executed (the execution status of this line is deduced): d->setX();
-
1175}
executed: }
Execution Count:608
608
1176 -
1177/*! -
1178 Returns the absolute position of the cursor within the document. -
1179 The cursor is positioned between characters. -
1180 -
1181 \sa setPosition(), movePosition(), anchor(), positionInBlock() -
1182*/ -
1183int QTextCursor::position() const -
1184{ -
1185 if (!d || !d->priv)
evaluated: !d
TRUEFALSE
yes
Evaluation Count:473
yes
Evaluation Count:10757
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10757
0-10757
1186 return -1;
executed: return -1;
Execution Count:473
473
1187 return d->position;
executed: return d->position;
Execution Count:10757
10757
1188} -
1189 -
1190/*! -
1191 \since 4.7 -
1192 Returns the relative position of the cursor within the block. -
1193 The cursor is positioned between characters. -
1194 -
1195 This is equivalent to \c{ position() - block().position()}. -
1196 -
1197 \sa position() -
1198*/ -
1199int QTextCursor::positionInBlock() const -
1200{ -
1201 if (!d || !d->priv)
never evaluated: !d
never evaluated: !d->priv
0
1202 return 0;
never executed: return 0;
0
1203 return d->position - d->block().position();
never executed: return d->position - d->block().position();
0
1204} -
1205 -
1206/*! -
1207 Returns the anchor position; this is the same as position() unless -
1208 there is a selection in which case position() marks one end of the -
1209 selection and anchor() marks the other end. Just like the cursor -
1210 position, the anchor position is between characters. -
1211 -
1212 \sa position(), setPosition(), movePosition(), selectionStart(), selectionEnd() -
1213*/ -
1214int QTextCursor::anchor() const -
1215{ -
1216 if (!d || !d->priv)
evaluated: !d
TRUEFALSE
yes
Evaluation Count:241
yes
Evaluation Count:1554
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1554
0-1554
1217 return -1;
executed: return -1;
Execution Count:241
241
1218 return d->anchor;
executed: return d->anchor;
Execution Count:1554
1554
1219} -
1220 -
1221/*! -
1222 \fn bool QTextCursor::movePosition(MoveOperation operation, MoveMode mode, int n) -
1223 -
1224 Moves the cursor by performing the given \a operation \a n times, using the specified -
1225 \a mode, and returns true if all operations were completed successfully; otherwise -
1226 returns false. -
1227 -
1228 For example, if this function is repeatedly used to seek to the end of the next -
1229 word, it will eventually fail when the end of the document is reached. -
1230 -
1231 By default, the move operation is performed once (\a n = 1). -
1232 -
1233 If \a mode is \c KeepAnchor, the cursor selects the text it moves -
1234 over. This is the same effect that the user achieves when they -
1235 hold down the Shift key and move the cursor with the cursor keys. -
1236 -
1237 \sa setVisualNavigation() -
1238*/ -
1239bool QTextCursor::movePosition(MoveOperation op, MoveMode mode, int n) -
1240{ -
1241 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2772
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2772
0-2772
1242 return false;
never executed: return false;
0
1243 switch (op) { -
1244 case Start: -
1245 case StartOfLine: -
1246 case End: -
1247 case EndOfLine: -
1248 n = 1;
executed (the execution status of this line is deduced): n = 1;
-
1249 break;
executed: break;
Execution Count:1247
1247
1250 default: break;
executed: break;
Execution Count:1525
1525
1251 } -
1252 -
1253 int previousPosition = d->position;
executed (the execution status of this line is deduced): int previousPosition = d->position;
-
1254 for (; n > 0; --n) {
evaluated: n > 0
TRUEFALSE
yes
Evaluation Count:2898
yes
Evaluation Count:2630
2630-2898
1255 if (!d->movePosition(op, mode))
evaluated: !d->movePosition(op, mode)
TRUEFALSE
yes
Evaluation Count:142
yes
Evaluation Count:2756
142-2756
1256 return false;
executed: return false;
Execution Count:142
142
1257 }
executed: }
Execution Count:2756
2756
1258 -
1259 if (d->visualNavigation && !d->block().isVisible()) {
evaluated: d->visualNavigation
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:2601
partially evaluated: !d->block().isVisible()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:29
0-2601
1260 QTextBlock b = d->block();
never executed (the execution status of this line is deduced): QTextBlock b = d->block();
-
1261 if (previousPosition < d->position) {
never evaluated: previousPosition < d->position
0
1262 while (!b.next().isVisible())
never evaluated: !b.next().isVisible()
0
1263 b = b.next();
never executed: b = b.next();
0
1264 d->setPosition(b.position() + b.length() - 1);
never executed (the execution status of this line is deduced): d->setPosition(b.position() + b.length() - 1);
-
1265 } else {
never executed: }
0
1266 while (!b.previous().isVisible())
never evaluated: !b.previous().isVisible()
0
1267 b = b.previous();
never executed: b = b.previous();
0
1268 d->setPosition(b.position());
never executed (the execution status of this line is deduced): d->setPosition(b.position());
-
1269 }
never executed: }
0
1270 if (mode == QTextCursor::MoveAnchor)
never evaluated: mode == QTextCursor::MoveAnchor
0
1271 d->anchor = d->position;
never executed: d->anchor = d->position;
0
1272 while (d->movePosition(op, mode)
never evaluated: d->movePosition(op, mode)
0
1273 && !d->block().isVisible())
never evaluated: !d->block().isVisible()
0
1274 ;
never executed: ;
0
1275 -
1276 }
never executed: }
0
1277 return true;
executed: return true;
Execution Count:2630
2630
1278} -
1279 -
1280/*! -
1281 \since 4.4 -
1282 -
1283 Returns true if the cursor does visual navigation; otherwise -
1284 returns false. -
1285 -
1286 Visual navigation means skipping over hidden text paragraphs. The -
1287 default is false. -
1288 -
1289 \sa setVisualNavigation(), movePosition() -
1290 */ -
1291bool QTextCursor::visualNavigation() const -
1292{ -
1293 return d ? d->visualNavigation : false;
executed: return d ? d->visualNavigation : false;
Execution Count:34
34
1294} -
1295 -
1296/*! -
1297 \since 4.4 -
1298 -
1299 Sets visual navigation to \a b. -
1300 -
1301 Visual navigation means skipping over hidden text paragraphs. The -
1302 default is false. -
1303 -
1304 \sa visualNavigation(), movePosition() -
1305 */ -
1306void QTextCursor::setVisualNavigation(bool b) -
1307{ -
1308 if (d)
partially evaluated: d
TRUEFALSE
yes
Evaluation Count:68
no
Evaluation Count:0
0-68
1309 d->visualNavigation = b;
executed: d->visualNavigation = b;
Execution Count:68
68
1310}
executed: }
Execution Count:68
68
1311 -
1312 -
1313/*! -
1314 \since 4.7 -
1315 -
1316 Sets the visual x position for vertical cursor movements to \a x. -
1317 -
1318 The vertical movement x position is cleared automatically when the cursor moves horizontally, and kept -
1319 unchanged when the cursor moves vertically. The mechanism allows the cursor to move up and down on a -
1320 visually straight line with proportional fonts, and to gently "jump" over short lines. -
1321 -
1322 A value of -1 indicates no predefined x position. It will then be set automatically the next time the -
1323 cursor moves up or down. -
1324 -
1325 \sa verticalMovementX() -
1326 */ -
1327void QTextCursor::setVerticalMovementX(int x) -
1328{ -
1329 if (d)
never evaluated: d
0
1330 d->x = x;
never executed: d->x = x;
0
1331}
never executed: }
0
1332 -
1333/*! \since 4.7 -
1334 -
1335 Returns the visual x position for vertical cursor movements. -
1336 -
1337 A value of -1 indicates no predefined x position. It will then be set automatically the next time the -
1338 cursor moves up or down. -
1339 -
1340 \sa setVerticalMovementX() -
1341 */ -
1342int QTextCursor::verticalMovementX() const -
1343{ -
1344 return d ? d->x : -1;
never executed: return d ? d->x : -1;
0
1345} -
1346 -
1347/*! -
1348 \since 4.7 -
1349 -
1350 Returns whether the cursor should keep its current position when text gets inserted at the position of the -
1351 cursor. -
1352 -
1353 The default is false; -
1354 -
1355 \sa setKeepPositionOnInsert() -
1356 */ -
1357bool QTextCursor::keepPositionOnInsert() const -
1358{ -
1359 return d ? d->keepPositionOnInsert : false;
never executed: return d ? d->keepPositionOnInsert : false;
0
1360} -
1361 -
1362/*! -
1363 \since 4.7 -
1364 -
1365 Defines whether the cursor should keep its current position when text gets inserted at the current position of the -
1366 cursor. -
1367 -
1368 If \a b is true, the cursor keeps its current position when text gets inserted at the positing of the cursor. -
1369 If \a b is false, the cursor moves along with the inserted text. -
1370 -
1371 The default is false. -
1372 -
1373 Note that a cursor always moves when text is inserted before the current position of the cursor, and it -
1374 always keeps its position when text is inserted after the current position of the cursor. -
1375 -
1376 \sa keepPositionOnInsert() -
1377 */ -
1378void QTextCursor::setKeepPositionOnInsert(bool b) -
1379{ -
1380 if (d)
partially evaluated: d
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1381 d->keepPositionOnInsert = b;
executed: d->keepPositionOnInsert = b;
Execution Count:2
2
1382}
executed: }
Execution Count:2
2
1383 -
1384 -
1385 -
1386/*! -
1387 Inserts \a text at the current position, using the current -
1388 character format. -
1389 -
1390 If there is a selection, the selection is deleted and replaced by -
1391 \a text, for example: -
1392 \snippet code/src_gui_text_qtextcursor.cpp 0 -
1393 This clears any existing selection, selects the word at the cursor -
1394 (i.e. from position() forward), and replaces the selection with -
1395 the phrase "Hello World". -
1396 -
1397 Any ASCII linefeed characters (\\n) in the inserted text are transformed -
1398 into unicode block separators, corresponding to insertBlock() calls. -
1399 -
1400 \sa charFormat(), hasSelection() -
1401*/ -
1402void QTextCursor::insertText(const QString &text) -
1403{ -
1404 QTextCharFormat fmt = charFormat();
executed (the execution status of this line is deduced): QTextCharFormat fmt = charFormat();
-
1405 fmt.clearProperty(QTextFormat::ObjectType);
executed (the execution status of this line is deduced): fmt.clearProperty(QTextFormat::ObjectType);
-
1406 insertText(text, fmt);
executed (the execution status of this line is deduced): insertText(text, fmt);
-
1407}
executed: }
Execution Count:1738
1738
1408 -
1409/*! -
1410 \fn void QTextCursor::insertText(const QString &text, const QTextCharFormat &format) -
1411 \overload -
1412 -
1413 Inserts \a text at the current position with the given \a format. -
1414*/ -
1415void QTextCursor::insertText(const QString &text, const QTextCharFormat &_format) -
1416{ -
1417 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2964
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2964
0-2964
1418 return;
never executed: return;
0
1419 -
1420 Q_ASSERT(_format.isValid());
executed (the execution status of this line is deduced): qt_noop();
-
1421 -
1422 QTextCharFormat format = _format;
executed (the execution status of this line is deduced): QTextCharFormat format = _format;
-
1423 format.clearProperty(QTextFormat::ObjectIndex);
executed (the execution status of this line is deduced): format.clearProperty(QTextFormat::ObjectIndex);
-
1424 -
1425 bool hasEditBlock = false;
executed (the execution status of this line is deduced): bool hasEditBlock = false;
-
1426 -
1427 if (d->anchor != d->position) {
evaluated: d->anchor != d->position
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:2958
6-2958
1428 hasEditBlock = true;
executed (the execution status of this line is deduced): hasEditBlock = true;
-
1429 d->priv->beginEditBlock();
executed (the execution status of this line is deduced): d->priv->beginEditBlock();
-
1430 d->remove();
executed (the execution status of this line is deduced): d->remove();
-
1431 }
executed: }
Execution Count:6
6
1432 -
1433 if (!text.isEmpty()) {
evaluated: !text.isEmpty()
TRUEFALSE
yes
Evaluation Count:2958
yes
Evaluation Count:6
6-2958
1434 QTextFormatCollection *formats = d->priv->formatCollection();
executed (the execution status of this line is deduced): QTextFormatCollection *formats = d->priv->formatCollection();
-
1435 int formatIdx = formats->indexForFormat(format);
executed (the execution status of this line is deduced): int formatIdx = formats->indexForFormat(format);
-
1436 Q_ASSERT(formats->format(formatIdx).isCharFormat());
executed (the execution status of this line is deduced): qt_noop();
-
1437 -
1438 QTextBlockFormat blockFmt = blockFormat();
executed (the execution status of this line is deduced): QTextBlockFormat blockFmt = blockFormat();
-
1439 -
1440 -
1441 int textStart = d->priv->text.length();
executed (the execution status of this line is deduced): int textStart = d->priv->text.length();
-
1442 int blockStart = 0;
executed (the execution status of this line is deduced): int blockStart = 0;
-
1443 d->priv->text += text;
executed (the execution status of this line is deduced): d->priv->text += text;
-
1444 int textEnd = d->priv->text.length();
executed (the execution status of this line is deduced): int textEnd = d->priv->text.length();
-
1445 -
1446 for (int i = 0; i < text.length(); ++i) {
evaluated: i < text.length()
TRUEFALSE
yes
Evaluation Count:678486
yes
Evaluation Count:2958
2958-678486
1447 QChar ch = text.at(i);
executed (the execution status of this line is deduced): QChar ch = text.at(i);
-
1448 -
1449 const int blockEnd = i;
executed (the execution status of this line is deduced): const int blockEnd = i;
-
1450 -
1451 if (ch == QLatin1Char('\r')
evaluated: ch == QLatin1Char('\r')
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:678483
3-678483
1452 && (i + 1) < text.length()
partially evaluated: (i + 1) < text.length()
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
1453 && text.at(i + 1) == QLatin1Char('\n')) {
evaluated: text.at(i + 1) == QLatin1Char('\n')
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
1454 ++i;
executed (the execution status of this line is deduced): ++i;
-
1455 ch = text.at(i);
executed (the execution status of this line is deduced): ch = text.at(i);
-
1456 }
executed: }
Execution Count:2
2
1457 -
1458 if (ch == QLatin1Char('\n')
evaluated: ch == QLatin1Char('\n')
TRUEFALSE
yes
Evaluation Count:2879
yes
Evaluation Count:675607
2879-675607
1459 || ch == QChar::ParagraphSeparator
evaluated: ch == QChar::ParagraphSeparator
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:675596
11-675596
1460 || ch == QTextBeginningOfFrame
partially evaluated: ch == QChar(0xfdd0)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:675596
0-675596
1461 || ch == QTextEndOfFrame
partially evaluated: ch == QChar(0xfdd1)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:675596
0-675596
1462 || ch == QLatin1Char('\r')) {
evaluated: ch == QLatin1Char('\r')
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:675595
1-675595
1463 -
1464 if (!hasEditBlock) {
evaluated: !hasEditBlock
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:2845
46-2845
1465 hasEditBlock = true;
executed (the execution status of this line is deduced): hasEditBlock = true;
-
1466 d->priv->beginEditBlock();
executed (the execution status of this line is deduced): d->priv->beginEditBlock();
-
1467 }
executed: }
Execution Count:46
46
1468 -
1469 if (blockEnd > blockStart)
evaluated: blockEnd > blockStart
TRUEFALSE
yes
Evaluation Count:2881
yes
Evaluation Count:10
10-2881
1470 d->priv->insert(d->position, textStart + blockStart, blockEnd - blockStart, formatIdx);
executed: d->priv->insert(d->position, textStart + blockStart, blockEnd - blockStart, formatIdx);
Execution Count:2881
2881
1471 -
1472 d->insertBlock(blockFmt, format);
executed (the execution status of this line is deduced): d->insertBlock(blockFmt, format);
-
1473 blockStart = i + 1;
executed (the execution status of this line is deduced): blockStart = i + 1;
-
1474 }
executed: }
Execution Count:2891
2891
1475 }
executed: }
Execution Count:678486
678486
1476 if (textStart + blockStart < textEnd)
evaluated: textStart + blockStart < textEnd
TRUEFALSE
yes
Evaluation Count:2941
yes
Evaluation Count:17
17-2941
1477 d->priv->insert(d->position, textStart + blockStart, textEnd - textStart - blockStart, formatIdx);
executed: d->priv->insert(d->position, textStart + blockStart, textEnd - textStart - blockStart, formatIdx);
Execution Count:2941
2941
1478 }
executed: }
Execution Count:2958
2958
1479 if (hasEditBlock)
evaluated: hasEditBlock
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:2912
52-2912
1480 d->priv->endEditBlock();
executed: d->priv->endEditBlock();
Execution Count:52
52
1481 d->setX();
executed (the execution status of this line is deduced): d->setX();
-
1482}
executed: }
Execution Count:2964
2964
1483 -
1484/*! -
1485 If there is no selected text, deletes the character \e at the -
1486 current cursor position; otherwise deletes the selected text. -
1487 -
1488 \sa deletePreviousChar(), hasSelection(), clearSelection() -
1489*/ -
1490void QTextCursor::deleteChar() -
1491{ -
1492 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
0-20
1493 return;
never executed: return;
0
1494 -
1495 if (d->position != d->anchor) {
evaluated: d->position != d->anchor
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:8
8-12
1496 removeSelectedText();
executed (the execution status of this line is deduced): removeSelectedText();
-
1497 return;
executed: return;
Execution Count:12
12
1498 } -
1499 -
1500 if (!d->canDelete(d->position))
evaluated: !d->canDelete(d->position)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:6
2-6
1501 return;
executed: return;
Execution Count:2
2
1502 d->adjusted_anchor = d->anchor =
executed (the execution status of this line is deduced): d->adjusted_anchor = d->anchor =
-
1503 d->priv->nextCursorPosition(d->anchor, QTextLayout::SkipCharacters);
executed (the execution status of this line is deduced): d->priv->nextCursorPosition(d->anchor, QTextLayout::SkipCharacters);
-
1504 d->remove();
executed (the execution status of this line is deduced): d->remove();
-
1505 d->setX();
executed (the execution status of this line is deduced): d->setX();
-
1506}
executed: }
Execution Count:6
6
1507 -
1508/*! -
1509 If there is no selected text, deletes the character \e before the -
1510 current cursor position; otherwise deletes the selected text. -
1511 -
1512 \sa deleteChar(), hasSelection(), clearSelection() -
1513*/ -
1514void QTextCursor::deletePreviousChar() -
1515{ -
1516 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
1517 return;
never executed: return;
0
1518 -
1519 if (d->position != d->anchor) {
partially evaluated: d->position != d->anchor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
1520 removeSelectedText();
never executed (the execution status of this line is deduced): removeSelectedText();
-
1521 return;
never executed: return;
0
1522 } -
1523 -
1524 if (d->anchor < 1 || !d->canDelete(d->anchor-1))
partially evaluated: d->anchor < 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
evaluated: !d->canDelete(d->anchor-1)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:14
0-15
1525 return;
executed: return;
Execution Count:1
1
1526 d->anchor--;
executed (the execution status of this line is deduced): d->anchor--;
-
1527 -
1528 QTextDocumentPrivate::FragmentIterator fragIt = d->priv->find(d->anchor);
executed (the execution status of this line is deduced): QTextDocumentPrivate::FragmentIterator fragIt = d->priv->find(d->anchor);
-
1529 const QTextFragmentData * const frag = fragIt.value();
executed (the execution status of this line is deduced): const QTextFragmentData * const frag = fragIt.value();
-
1530 int fpos = fragIt.position();
executed (the execution status of this line is deduced): int fpos = fragIt.position();
-
1531 QChar uc = d->priv->buffer().at(d->anchor - fpos + frag->stringPosition);
executed (the execution status of this line is deduced): QChar uc = d->priv->buffer().at(d->anchor - fpos + frag->stringPosition);
-
1532 if (d->anchor > fpos && uc.isLowSurrogate()) {
evaluated: d->anchor > fpos
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:4
partially evaluated: uc.isLowSurrogate()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
1533 // second half of a surrogate, check if we have the first half as well, -
1534 // if yes delete both at once -
1535 uc = d->priv->buffer().at(d->anchor - 1 - fpos + frag->stringPosition);
never executed (the execution status of this line is deduced): uc = d->priv->buffer().at(d->anchor - 1 - fpos + frag->stringPosition);
-
1536 if (uc.isHighSurrogate())
never evaluated: uc.isHighSurrogate()
0
1537 --d->anchor;
never executed: --d->anchor;
0
1538 }
never executed: }
0
1539 -
1540 d->adjusted_anchor = d->anchor;
executed (the execution status of this line is deduced): d->adjusted_anchor = d->anchor;
-
1541 d->remove();
executed (the execution status of this line is deduced): d->remove();
-
1542 d->setX();
executed (the execution status of this line is deduced): d->setX();
-
1543}
executed: }
Execution Count:14
14
1544 -
1545/*! -
1546 Selects text in the document according to the given \a selection. -
1547*/ -
1548void QTextCursor::select(SelectionType selection) -
1549{ -
1550 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:204
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:204
0-204
1551 return;
never executed: return;
0
1552 -
1553 clearSelection();
executed (the execution status of this line is deduced): clearSelection();
-
1554 -
1555 const QTextBlock block = d->block();
executed (the execution status of this line is deduced): const QTextBlock block = d->block();
-
1556 -
1557 switch (selection) { -
1558 case LineUnderCursor: -
1559 movePosition(StartOfLine);
executed (the execution status of this line is deduced): movePosition(StartOfLine);
-
1560 movePosition(EndOfLine, KeepAnchor);
executed (the execution status of this line is deduced): movePosition(EndOfLine, KeepAnchor);
-
1561 break;
executed: break;
Execution Count:1
1
1562 case WordUnderCursor: -
1563 movePosition(StartOfWord);
executed (the execution status of this line is deduced): movePosition(StartOfWord);
-
1564 movePosition(EndOfWord, KeepAnchor);
executed (the execution status of this line is deduced): movePosition(EndOfWord, KeepAnchor);
-
1565 break;
executed: break;
Execution Count:29
29
1566 case BlockUnderCursor: -
1567 if (block.length() == 1) // no content
partially evaluated: block.length() == 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1568 break;
never executed: break;
0
1569 movePosition(StartOfBlock);
executed (the execution status of this line is deduced): movePosition(StartOfBlock);
-
1570 // also select the paragraph separator -
1571 if (movePosition(PreviousBlock)) {
partially evaluated: movePosition(PreviousBlock)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1572 movePosition(EndOfBlock);
executed (the execution status of this line is deduced): movePosition(EndOfBlock);
-
1573 movePosition(NextBlock, KeepAnchor);
executed (the execution status of this line is deduced): movePosition(NextBlock, KeepAnchor);
-
1574 }
executed: }
Execution Count:1
1
1575 movePosition(EndOfBlock, KeepAnchor);
executed (the execution status of this line is deduced): movePosition(EndOfBlock, KeepAnchor);
-
1576 break;
executed: break;
Execution Count:1
1
1577 case Document: -
1578 movePosition(Start);
executed (the execution status of this line is deduced): movePosition(Start);
-
1579 movePosition(End, KeepAnchor);
executed (the execution status of this line is deduced): movePosition(End, KeepAnchor);
-
1580 break;
executed: break;
Execution Count:173
173
1581 } -
1582}
executed: }
Execution Count:204
204
1583 -
1584/*! -
1585 Returns true if the cursor contains a selection; otherwise returns false. -
1586*/ -
1587bool QTextCursor::hasSelection() const -
1588{ -
1589 return !!d && d->position != d->anchor;
executed: return !!d && d->position != d->anchor;
Execution Count:3178
3178
1590} -
1591 -
1592 -
1593/*! -
1594 Returns true if the cursor contains a selection that is not simply a -
1595 range from selectionStart() to selectionEnd(); otherwise returns false. -
1596 -
1597 Complex selections are ones that span at least two cells in a table; -
1598 their extent is specified by selectedTableCells(). -
1599*/ -
1600bool QTextCursor::hasComplexSelection() const -
1601{ -
1602 if (!d)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1159
0-1159
1603 return false;
never executed: return false;
0
1604 -
1605 return d->complexSelectionTable() != 0;
executed: return d->complexSelectionTable() != 0;
Execution Count:1159
1159
1606} -
1607 -
1608/*! -
1609 If the selection spans over table cells, \a firstRow is populated -
1610 with the number of the first row in the selection, \a firstColumn -
1611 with the number of the first column in the selection, and \a -
1612 numRows and \a numColumns with the number of rows and columns in -
1613 the selection. If the selection does not span any table cells the -
1614 results are harmless but undefined. -
1615*/ -
1616void QTextCursor::selectedTableCells(int *firstRow, int *numRows, int *firstColumn, int *numColumns) const -
1617{ -
1618 *firstRow = -1;
executed (the execution status of this line is deduced): *firstRow = -1;
-
1619 *firstColumn = -1;
executed (the execution status of this line is deduced): *firstColumn = -1;
-
1620 *numRows = -1;
executed (the execution status of this line is deduced): *numRows = -1;
-
1621 *numColumns = -1;
executed (the execution status of this line is deduced): *numColumns = -1;
-
1622 -
1623 if (!d || d->position == d->anchor)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
partially evaluated: d->position == d->anchor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
1624 return;
never executed: return;
0
1625 -
1626 d->selectedTableCells(firstRow, numRows, firstColumn, numColumns);
executed (the execution status of this line is deduced): d->selectedTableCells(firstRow, numRows, firstColumn, numColumns);
-
1627}
executed: }
Execution Count:7
7
1628 -
1629 -
1630/*! -
1631 Clears the current selection by setting the anchor to the cursor position. -
1632 -
1633 Note that it does \b{not} delete the text of the selection. -
1634 -
1635 \sa removeSelectedText(), hasSelection() -
1636*/ -
1637void QTextCursor::clearSelection() -
1638{ -
1639 if (!d)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:229
0-229
1640 return;
never executed: return;
0
1641 d->adjusted_anchor = d->anchor = d->position;
executed (the execution status of this line is deduced): d->adjusted_anchor = d->anchor = d->position;
-
1642 d->currentCharFormat = -1;
executed (the execution status of this line is deduced): d->currentCharFormat = -1;
-
1643}
executed: }
Execution Count:229
229
1644 -
1645/*! -
1646 If there is a selection, its content is deleted; otherwise does -
1647 nothing. -
1648 -
1649 \sa hasSelection() -
1650*/ -
1651void QTextCursor::removeSelectedText() -
1652{ -
1653 if (!d || !d->priv || d->position == d->anchor)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:936
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:936
partially evaluated: d->position == d->anchor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:936
0-936
1654 return;
never executed: return;
0
1655 -
1656 d->priv->beginEditBlock();
executed (the execution status of this line is deduced): d->priv->beginEditBlock();
-
1657 d->remove();
executed (the execution status of this line is deduced): d->remove();
-
1658 d->priv->endEditBlock();
executed (the execution status of this line is deduced): d->priv->endEditBlock();
-
1659 d->setX();
executed (the execution status of this line is deduced): d->setX();
-
1660}
executed: }
Execution Count:936
936
1661 -
1662/*! -
1663 Returns the start of the selection or position() if the -
1664 cursor doesn't have a selection. -
1665 -
1666 \sa selectionEnd(), position(), anchor() -
1667*/ -
1668int QTextCursor::selectionStart() const -
1669{ -
1670 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2244
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2244
0-2244
1671 return -1;
never executed: return -1;
0
1672 return qMin(d->position, d->adjusted_anchor);
executed: return qMin(d->position, d->adjusted_anchor);
Execution Count:2244
2244
1673} -
1674 -
1675/*! -
1676 Returns the end of the selection or position() if the cursor -
1677 doesn't have a selection. -
1678 -
1679 \sa selectionStart(), position(), anchor() -
1680*/ -
1681int QTextCursor::selectionEnd() const -
1682{ -
1683 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1783
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1783
0-1783
1684 return -1;
never executed: return -1;
0
1685 return qMax(d->position, d->adjusted_anchor);
executed: return qMax(d->position, d->adjusted_anchor);
Execution Count:1783
1783
1686} -
1687 -
1688static void getText(QString &text, QTextDocumentPrivate *priv, const QString &docText, int pos, int end) -
1689{ -
1690 while (pos < end) {
evaluated: pos < end
TRUEFALSE
yes
Evaluation Count:79
yes
Evaluation Count:74
74-79
1691 QTextDocumentPrivate::FragmentIterator fragIt = priv->find(pos);
executed (the execution status of this line is deduced): QTextDocumentPrivate::FragmentIterator fragIt = priv->find(pos);
-
1692 const QTextFragmentData * const frag = fragIt.value();
executed (the execution status of this line is deduced): const QTextFragmentData * const frag = fragIt.value();
-
1693 -
1694 const int offsetInFragment = qMax(0, pos - fragIt.position());
executed (the execution status of this line is deduced): const int offsetInFragment = qMax(0, pos - fragIt.position());
-
1695 const int len = qMin(int(frag->size_array[0] - offsetInFragment), end - pos);
executed (the execution status of this line is deduced): const int len = qMin(int(frag->size_array[0] - offsetInFragment), end - pos);
-
1696 -
1697 text += QString(docText.constData() + frag->stringPosition + offsetInFragment, len);
executed (the execution status of this line is deduced): text += QString(docText.constData() + frag->stringPosition + offsetInFragment, len);
-
1698 pos += len;
executed (the execution status of this line is deduced): pos += len;
-
1699 }
executed: }
Execution Count:79
79
1700}
executed: }
Execution Count:74
74
1701 -
1702/*! -
1703 Returns the current selection's text (which may be empty). This -
1704 only returns the text, with no rich text formatting information. -
1705 If you want a document fragment (i.e. formatted rich text) use -
1706 selection() instead. -
1707 -
1708 \note If the selection obtained from an editor spans a line break, -
1709 the text will contain a Unicode U+2029 paragraph separator character -
1710 instead of a newline \c{\n} character. Use QString::replace() to -
1711 replace these characters with newlines. -
1712*/ -
1713QString QTextCursor::selectedText() const -
1714{ -
1715 if (!d || !d->priv || d->position == d->anchor)
evaluated: !d
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:76
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:76
evaluated: d->position == d->anchor
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:74
0-76
1716 return QString();
executed: return QString();
Execution Count:4
4
1717 -
1718 const QString docText = d->priv->buffer();
executed (the execution status of this line is deduced): const QString docText = d->priv->buffer();
-
1719 QString text;
executed (the execution status of this line is deduced): QString text;
-
1720 -
1721 QTextTable *table = d->complexSelectionTable();
executed (the execution status of this line is deduced): QTextTable *table = d->complexSelectionTable();
-
1722 if (table) {
partially evaluated: table
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:74
0-74
1723 int row_start, col_start, num_rows, num_cols;
never executed (the execution status of this line is deduced): int row_start, col_start, num_rows, num_cols;
-
1724 selectedTableCells(&row_start, &num_rows, &col_start, &num_cols);
never executed (the execution status of this line is deduced): selectedTableCells(&row_start, &num_rows, &col_start, &num_cols);
-
1725 -
1726 Q_ASSERT(row_start != -1);
never executed (the execution status of this line is deduced): qt_noop();
-
1727 for (int r = row_start; r < row_start + num_rows; ++r) {
never evaluated: r < row_start + num_rows
0
1728 for (int c = col_start; c < col_start + num_cols; ++c) {
never evaluated: c < col_start + num_cols
0
1729 QTextTableCell cell = table->cellAt(r, c);
never executed (the execution status of this line is deduced): QTextTableCell cell = table->cellAt(r, c);
-
1730 int rspan = cell.rowSpan();
never executed (the execution status of this line is deduced): int rspan = cell.rowSpan();
-
1731 int cspan = cell.columnSpan();
never executed (the execution status of this line is deduced): int cspan = cell.columnSpan();
-
1732 if (rspan != 1) {
never evaluated: rspan != 1
0
1733 int cr = cell.row();
never executed (the execution status of this line is deduced): int cr = cell.row();
-
1734 if (cr != r)
never evaluated: cr != r
0
1735 continue;
never executed: continue;
0
1736 }
never executed: }
0
1737 if (cspan != 1) {
never evaluated: cspan != 1
0
1738 int cc = cell.column();
never executed (the execution status of this line is deduced): int cc = cell.column();
-
1739 if (cc != c)
never evaluated: cc != c
0
1740 continue;
never executed: continue;
0
1741 }
never executed: }
0
1742 -
1743 getText(text, d->priv, docText, cell.firstPosition(), cell.lastPosition());
never executed (the execution status of this line is deduced): getText(text, d->priv, docText, cell.firstPosition(), cell.lastPosition());
-
1744 }
never executed: }
0
1745 }
never executed: }
0
1746 } else {
never executed: }
0
1747 getText(text, d->priv, docText, selectionStart(), selectionEnd());
executed (the execution status of this line is deduced): getText(text, d->priv, docText, selectionStart(), selectionEnd());
-
1748 }
executed: }
Execution Count:74
74
1749 -
1750 return text;
executed: return text;
Execution Count:74
74
1751} -
1752 -
1753/*! -
1754 Returns the current selection (which may be empty) with all its -
1755 formatting information. If you just want the selected text (i.e. -
1756 plain text) use selectedText() instead. -
1757 -
1758 \note Unlike QTextDocumentFragment::toPlainText(), -
1759 selectedText() may include special unicode characters such as -
1760 QChar::ParagraphSeparator. -
1761 -
1762 \sa QTextDocumentFragment::toPlainText() -
1763*/ -
1764QTextDocumentFragment QTextCursor::selection() const -
1765{ -
1766 return QTextDocumentFragment(*this);
executed: return QTextDocumentFragment(*this);
Execution Count:19
19
1767} -
1768 -
1769/*! -
1770 Returns the block that contains the cursor. -
1771*/ -
1772QTextBlock QTextCursor::block() const -
1773{ -
1774 if (!d || !d->priv)
evaluated: !d
TRUEFALSE
yes
Evaluation Count:62
yes
Evaluation Count:666
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:666
0-666
1775 return QTextBlock();
executed: return QTextBlock();
Execution Count:62
62
1776 return d->block();
executed: return d->block();
Execution Count:666
666
1777} -
1778 -
1779/*! -
1780 Returns the block format of the block the cursor is in. -
1781 -
1782 \sa setBlockFormat(), charFormat() -
1783 */ -
1784QTextBlockFormat QTextCursor::blockFormat() const -
1785{ -
1786 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16100
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16100
0-16100
1787 return QTextBlockFormat();
never executed: return QTextBlockFormat();
0
1788 -
1789 return d->block().blockFormat();
executed: return d->block().blockFormat();
Execution Count:16100
16100
1790} -
1791 -
1792/*! -
1793 Sets the block format of the current block (or all blocks that -
1794 are contained in the selection) to \a format. -
1795 -
1796 \sa blockFormat(), mergeBlockFormat() -
1797*/ -
1798void QTextCursor::setBlockFormat(const QTextBlockFormat &format) -
1799{ -
1800 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:851
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:851
0-851
1801 return;
never executed: return;
0
1802 -
1803 d->setBlockFormat(format, QTextDocumentPrivate::SetFormat);
executed (the execution status of this line is deduced): d->setBlockFormat(format, QTextDocumentPrivate::SetFormat);
-
1804}
executed: }
Execution Count:851
851
1805 -
1806/*! -
1807 Modifies the block format of the current block (or all blocks that -
1808 are contained in the selection) with the block format specified by -
1809 \a modifier. -
1810 -
1811 \sa setBlockFormat(), blockFormat() -
1812*/ -
1813void QTextCursor::mergeBlockFormat(const QTextBlockFormat &modifier) -
1814{ -
1815 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:131
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:131
0-131
1816 return;
never executed: return;
0
1817 -
1818 d->setBlockFormat(modifier, QTextDocumentPrivate::MergeFormat);
executed (the execution status of this line is deduced): d->setBlockFormat(modifier, QTextDocumentPrivate::MergeFormat);
-
1819}
executed: }
Execution Count:131
131
1820 -
1821/*! -
1822 Returns the block character format of the block the cursor is in. -
1823 -
1824 The block char format is the format used when inserting text at the -
1825 beginning of an empty block. -
1826 -
1827 \sa setBlockCharFormat() -
1828 */ -
1829QTextCharFormat QTextCursor::blockCharFormat() const -
1830{ -
1831 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1672
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1672
0-1672
1832 return QTextCharFormat();
never executed: return QTextCharFormat();
0
1833 -
1834 return d->block().charFormat();
executed: return d->block().charFormat();
Execution Count:1672
1672
1835} -
1836 -
1837/*! -
1838 Sets the block char format of the current block (or all blocks that -
1839 are contained in the selection) to \a format. -
1840 -
1841 \sa blockCharFormat() -
1842*/ -
1843void QTextCursor::setBlockCharFormat(const QTextCharFormat &format) -
1844{ -
1845 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1273
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1273
0-1273
1846 return;
never executed: return;
0
1847 -
1848 d->setBlockCharFormat(format, QTextDocumentPrivate::SetFormatAndPreserveObjectIndices);
executed (the execution status of this line is deduced): d->setBlockCharFormat(format, QTextDocumentPrivate::SetFormatAndPreserveObjectIndices);
-
1849}
executed: }
Execution Count:1273
1273
1850 -
1851/*! -
1852 Modifies the block char format of the current block (or all blocks that -
1853 are contained in the selection) with the block format specified by -
1854 \a modifier. -
1855 -
1856 \sa setBlockCharFormat() -
1857*/ -
1858void QTextCursor::mergeBlockCharFormat(const QTextCharFormat &modifier) -
1859{ -
1860 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
1861 return;
never executed: return;
0
1862 -
1863 d->setBlockCharFormat(modifier, QTextDocumentPrivate::MergeFormat);
executed (the execution status of this line is deduced): d->setBlockCharFormat(modifier, QTextDocumentPrivate::MergeFormat);
-
1864}
executed: }
Execution Count:12
12
1865 -
1866/*! -
1867 Returns the format of the character immediately before the cursor -
1868 position(). If the cursor is positioned at the beginning of a text -
1869 block that is not empty then the format of the character -
1870 immediately after the cursor is returned. -
1871 -
1872 \sa insertText(), blockFormat() -
1873 */ -
1874QTextCharFormat QTextCursor::charFormat() const -
1875{ -
1876 if (!d || !d->priv)
evaluated: !d
TRUEFALSE
yes
Evaluation Count:523
yes
Evaluation Count:16311
evaluated: !d->priv
TRUEFALSE
yes
Evaluation Count:95
yes
Evaluation Count:16216
95-16311
1877 return QTextCharFormat();
executed: return QTextCharFormat();
Execution Count:618
618
1878 -
1879 int idx = d->currentCharFormat;
executed (the execution status of this line is deduced): int idx = d->currentCharFormat;
-
1880 if (idx == -1) {
evaluated: idx == -1
TRUEFALSE
yes
Evaluation Count:15205
yes
Evaluation Count:1011
1011-15205
1881 QTextBlock block = d->block();
executed (the execution status of this line is deduced): QTextBlock block = d->block();
-
1882 -
1883 int pos;
executed (the execution status of this line is deduced): int pos;
-
1884 if (d->position == block.position()
evaluated: d->position == block.position()
TRUEFALSE
yes
Evaluation Count:13521
yes
Evaluation Count:1684
1684-13521
1885 && block.length() > 1)
evaluated: block.length() > 1
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:13481
40-13481
1886 pos = d->position;
executed: pos = d->position;
Execution Count:40
40
1887 else -
1888 pos = d->position - 1;
executed: pos = d->position - 1;
Execution Count:15165
15165
1889 -
1890 if (pos == -1) {
evaluated: pos == -1
TRUEFALSE
yes
Evaluation Count:1279
yes
Evaluation Count:13926
1279-13926
1891 idx = d->priv->blockCharFormatIndex(d->priv->blockMap().firstNode());
executed (the execution status of this line is deduced): idx = d->priv->blockCharFormatIndex(d->priv->blockMap().firstNode());
-
1892 } else {
executed: }
Execution Count:1279
1279
1893 Q_ASSERT(pos >= 0 && pos < d->priv->length());
executed (the execution status of this line is deduced): qt_noop();
-
1894 -
1895 QTextDocumentPrivate::FragmentIterator it = d->priv->find(pos);
executed (the execution status of this line is deduced): QTextDocumentPrivate::FragmentIterator it = d->priv->find(pos);
-
1896 Q_ASSERT(!it.atEnd());
executed (the execution status of this line is deduced): qt_noop();
-
1897 idx = it.value()->format;
executed (the execution status of this line is deduced): idx = it.value()->format;
-
1898 }
executed: }
Execution Count:13926
13926
1899 } -
1900 -
1901 QTextCharFormat cfmt = d->priv->formatCollection()->charFormat(idx);
executed (the execution status of this line is deduced): QTextCharFormat cfmt = d->priv->formatCollection()->charFormat(idx);
-
1902 cfmt.clearProperty(QTextFormat::ObjectIndex);
executed (the execution status of this line is deduced): cfmt.clearProperty(QTextFormat::ObjectIndex);
-
1903 -
1904 Q_ASSERT(cfmt.isValid());
executed (the execution status of this line is deduced): qt_noop();
-
1905 return cfmt;
executed: return cfmt;
Execution Count:16216
16216
1906} -
1907 -
1908/*! -
1909 Sets the cursor's current character format to the given \a -
1910 format. If the cursor has a selection, the given \a format is -
1911 applied to the current selection. -
1912 -
1913 \sa hasSelection(), mergeCharFormat() -
1914*/ -
1915void QTextCursor::setCharFormat(const QTextCharFormat &format) -
1916{ -
1917 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:837
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:837
0-837
1918 return;
never executed: return;
0
1919 if (d->position == d->anchor) {
evaluated: d->position == d->anchor
TRUEFALSE
yes
Evaluation Count:674
yes
Evaluation Count:163
163-674
1920 d->currentCharFormat = d->priv->formatCollection()->indexForFormat(format);
executed (the execution status of this line is deduced): d->currentCharFormat = d->priv->formatCollection()->indexForFormat(format);
-
1921 return;
executed: return;
Execution Count:674
674
1922 } -
1923 d->setCharFormat(format, QTextDocumentPrivate::SetFormatAndPreserveObjectIndices);
executed (the execution status of this line is deduced): d->setCharFormat(format, QTextDocumentPrivate::SetFormatAndPreserveObjectIndices);
-
1924}
executed: }
Execution Count:163
163
1925 -
1926/*! -
1927 Merges the cursor's current character format with the properties -
1928 described by format \a modifier. If the cursor has a selection, -
1929 this function applies all the properties set in \a modifier to all -
1930 the character formats that are part of the selection. -
1931 -
1932 \sa hasSelection(), setCharFormat() -
1933*/ -
1934void QTextCursor::mergeCharFormat(const QTextCharFormat &modifier) -
1935{ -
1936 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:43
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:43
0-43
1937 return;
never executed: return;
0
1938 if (d->position == d->anchor) {
evaluated: d->position == d->anchor
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:38
5-38
1939 QTextCharFormat format = charFormat();
executed (the execution status of this line is deduced): QTextCharFormat format = charFormat();
-
1940 format.merge(modifier);
executed (the execution status of this line is deduced): format.merge(modifier);
-
1941 d->currentCharFormat = d->priv->formatCollection()->indexForFormat(format);
executed (the execution status of this line is deduced): d->currentCharFormat = d->priv->formatCollection()->indexForFormat(format);
-
1942 return;
executed: return;
Execution Count:5
5
1943 } -
1944 -
1945 d->setCharFormat(modifier, QTextDocumentPrivate::MergeFormat);
executed (the execution status of this line is deduced): d->setCharFormat(modifier, QTextDocumentPrivate::MergeFormat);
-
1946}
executed: }
Execution Count:38
38
1947 -
1948/*! -
1949 Returns true if the cursor is at the start of a block; otherwise -
1950 returns false. -
1951 -
1952 \sa atBlockEnd(), atStart() -
1953*/ -
1954bool QTextCursor::atBlockStart() const -
1955{ -
1956 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21
0-21
1957 return false;
never executed: return false;
0
1958 -
1959 return d->position == d->block().position();
executed: return d->position == d->block().position();
Execution Count:21
21
1960} -
1961 -
1962/*! -
1963 Returns true if the cursor is at the end of a block; otherwise -
1964 returns false. -
1965 -
1966 \sa atBlockStart(), atEnd() -
1967*/ -
1968bool QTextCursor::atBlockEnd() const -
1969{ -
1970 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
1971 return false;
never executed: return false;
0
1972 -
1973 return d->position == d->block().position() + d->block().length() - 1;
executed: return d->position == d->block().position() + d->block().length() - 1;
Execution Count:12
12
1974} -
1975 -
1976/*! -
1977 Returns true if the cursor is at the start of the document; -
1978 otherwise returns false. -
1979 -
1980 \sa atBlockStart(), atEnd() -
1981*/ -
1982bool QTextCursor::atStart() const -
1983{ -
1984 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1985 return false;
never executed: return false;
0
1986 -
1987 return d->position == 0;
executed: return d->position == 0;
Execution Count:2
2
1988} -
1989 -
1990/*! -
1991 \since 4.6 -
1992 -
1993 Returns true if the cursor is at the end of the document; -
1994 otherwise returns false. -
1995 -
1996 \sa atStart(), atBlockEnd() -
1997*/ -
1998bool QTextCursor::atEnd() const -
1999{ -
2000 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
2001 return false;
never executed: return false;
0
2002 -
2003 return d->position == d->priv->length() - 1;
executed: return d->position == d->priv->length() - 1;
Execution Count:4
4
2004} -
2005 -
2006/*! -
2007 Inserts a new empty block at the cursor position() with the -
2008 current blockFormat() and charFormat(). -
2009 -
2010 \sa setBlockFormat() -
2011*/ -
2012void QTextCursor::insertBlock() -
2013{ -
2014 insertBlock(blockFormat());
executed (the execution status of this line is deduced): insertBlock(blockFormat());
-
2015}
executed: }
Execution Count:12027
12027
2016 -
2017/*! -
2018 \overload -
2019 -
2020 Inserts a new empty block at the cursor position() with block -
2021 format \a format and the current charFormat() as block char format. -
2022 -
2023 \sa setBlockFormat() -
2024*/ -
2025void QTextCursor::insertBlock(const QTextBlockFormat &format) -
2026{ -
2027 QTextCharFormat charFmt = charFormat();
executed (the execution status of this line is deduced): QTextCharFormat charFmt = charFormat();
-
2028 charFmt.clearProperty(QTextFormat::ObjectType);
executed (the execution status of this line is deduced): charFmt.clearProperty(QTextFormat::ObjectType);
-
2029 insertBlock(format, charFmt);
executed (the execution status of this line is deduced): insertBlock(format, charFmt);
-
2030}
executed: }
Execution Count:12051
12051
2031 -
2032/*! -
2033 \fn void QTextCursor::insertBlock(const QTextBlockFormat &format, const QTextCharFormat &charFormat) -
2034 \overload -
2035 -
2036 Inserts a new empty block at the cursor position() with block -
2037 format \a format and \a charFormat as block char format. -
2038 -
2039 \sa setBlockFormat() -
2040*/ -
2041void QTextCursor::insertBlock(const QTextBlockFormat &format, const QTextCharFormat &_charFormat) -
2042{ -
2043 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12208
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12208
0-12208
2044 return;
never executed: return;
0
2045 -
2046 QTextCharFormat charFormat = _charFormat;
executed (the execution status of this line is deduced): QTextCharFormat charFormat = _charFormat;
-
2047 charFormat.clearProperty(QTextFormat::ObjectIndex);
executed (the execution status of this line is deduced): charFormat.clearProperty(QTextFormat::ObjectIndex);
-
2048 -
2049 d->priv->beginEditBlock();
executed (the execution status of this line is deduced): d->priv->beginEditBlock();
-
2050 d->remove();
executed (the execution status of this line is deduced): d->remove();
-
2051 d->insertBlock(format, charFormat);
executed (the execution status of this line is deduced): d->insertBlock(format, charFormat);
-
2052 d->priv->endEditBlock();
executed (the execution status of this line is deduced): d->priv->endEditBlock();
-
2053 d->setX();
executed (the execution status of this line is deduced): d->setX();
-
2054}
executed: }
Execution Count:12208
12208
2055 -
2056/*! -
2057 Inserts a new block at the current position and makes it the first -
2058 list item of a newly created list with the given \a format. Returns -
2059 the created list. -
2060 -
2061 \sa currentList(), createList(), insertBlock() -
2062 */ -
2063QTextList *QTextCursor::insertList(const QTextListFormat &format) -
2064{ -
2065 insertBlock();
executed (the execution status of this line is deduced): insertBlock();
-
2066 return createList(format);
executed: return createList(format);
Execution Count:4
4
2067} -
2068 -
2069/*! -
2070 \overload -
2071 -
2072 Inserts a new block at the current position and makes it the first -
2073 list item of a newly created list with the given \a style. Returns -
2074 the created list. -
2075 -
2076 \sa currentList(), createList(), insertBlock() -
2077 */ -
2078QTextList *QTextCursor::insertList(QTextListFormat::Style style) -
2079{ -
2080 insertBlock();
executed (the execution status of this line is deduced): insertBlock();
-
2081 return createList(style);
executed: return createList(style);
Execution Count:16
16
2082} -
2083 -
2084/*! -
2085 Creates and returns a new list with the given \a format, and makes the -
2086 current paragraph the cursor is in the first list item. -
2087 -
2088 \sa insertList(), currentList() -
2089 */ -
2090QTextList *QTextCursor::createList(const QTextListFormat &format) -
2091{ -
2092 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:68
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:68
0-68
2093 return 0;
never executed: return 0;
0
2094 -
2095 QTextList *list = static_cast<QTextList *>(d->priv->createObject(format));
executed (the execution status of this line is deduced): QTextList *list = static_cast<QTextList *>(d->priv->createObject(format));
-
2096 QTextBlockFormat modifier;
executed (the execution status of this line is deduced): QTextBlockFormat modifier;
-
2097 modifier.setObjectIndex(list->objectIndex());
executed (the execution status of this line is deduced): modifier.setObjectIndex(list->objectIndex());
-
2098 mergeBlockFormat(modifier);
executed (the execution status of this line is deduced): mergeBlockFormat(modifier);
-
2099 return list;
executed: return list;
Execution Count:68
68
2100} -
2101 -
2102/*! -
2103 \overload -
2104 -
2105 Creates and returns a new list with the given \a style, making the -
2106 cursor's current paragraph the first list item. -
2107 -
2108 The style to be used is defined by the QTextListFormat::Style enum. -
2109 -
2110 \sa insertList(), currentList() -
2111 */ -
2112QTextList *QTextCursor::createList(QTextListFormat::Style style) -
2113{ -
2114 QTextListFormat fmt;
executed (the execution status of this line is deduced): QTextListFormat fmt;
-
2115 fmt.setStyle(style);
executed (the execution status of this line is deduced): fmt.setStyle(style);
-
2116 return createList(fmt);
executed: return createList(fmt);
Execution Count:16
16
2117} -
2118 -
2119/*! -
2120 Returns the current list if the cursor position() is inside a -
2121 block that is part of a list; otherwise returns 0. -
2122 -
2123 \sa insertList(), createList() -
2124 */ -
2125QTextList *QTextCursor::currentList() const -
2126{ -
2127 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:104
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:104
0-104
2128 return 0;
never executed: return 0;
0
2129 -
2130 QTextBlockFormat b = blockFormat();
executed (the execution status of this line is deduced): QTextBlockFormat b = blockFormat();
-
2131 QTextObject *o = d->priv->objectForFormat(b);
executed (the execution status of this line is deduced): QTextObject *o = d->priv->objectForFormat(b);
-
2132 return qobject_cast<QTextList *>(o);
executed: return qobject_cast<QTextList *>(o);
Execution Count:104
104
2133} -
2134 -
2135/*! -
2136 \fn QTextTable *QTextCursor::insertTable(int rows, int columns) -
2137 -
2138 \overload -
2139 -
2140 Creates a new table with the given number of \a rows and \a columns, -
2141 inserts it at the current cursor position() in the document, and returns -
2142 the table object. The cursor is moved to the beginning of the first cell. -
2143 -
2144 There must be at least one row and one column in the table. -
2145 -
2146 \sa currentTable() -
2147 */ -
2148QTextTable *QTextCursor::insertTable(int rows, int cols) -
2149{ -
2150 return insertTable(rows, cols, QTextTableFormat());
executed: return insertTable(rows, cols, QTextTableFormat());
Execution Count:64
64
2151} -
2152 -
2153/*! -
2154 \fn QTextTable *QTextCursor::insertTable(int rows, int columns, const QTextTableFormat &format) -
2155 -
2156 Creates a new table with the given number of \a rows and \a columns -
2157 in the specified \a format, inserts it at the current cursor position() -
2158 in the document, and returns the table object. The cursor is moved to -
2159 the beginning of the first cell. -
2160 -
2161 There must be at least one row and one column in the table. -
2162 -
2163 \sa currentTable() -
2164*/ -
2165QTextTable *QTextCursor::insertTable(int rows, int cols, const QTextTableFormat &format) -
2166{ -
2167 if(!d || !d->priv || rows == 0 || cols == 0)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:151
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:151
partially evaluated: rows == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:151
partially evaluated: cols == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:151
0-151
2168 return 0;
never executed: return 0;
0
2169 -
2170 int pos = d->position;
executed (the execution status of this line is deduced): int pos = d->position;
-
2171 QTextTable *t = QTextTablePrivate::createTable(d->priv, d->position, rows, cols, format);
executed (the execution status of this line is deduced): QTextTable *t = QTextTablePrivate::createTable(d->priv, d->position, rows, cols, format);
-
2172 d->setPosition(pos+1);
executed (the execution status of this line is deduced): d->setPosition(pos+1);
-
2173 // ##### what should we do if we have a selection? -
2174 d->anchor = d->position;
executed (the execution status of this line is deduced): d->anchor = d->position;
-
2175 d->adjusted_anchor = d->anchor;
executed (the execution status of this line is deduced): d->adjusted_anchor = d->anchor;
-
2176 return t;
executed: return t;
Execution Count:151
151
2177} -
2178 -
2179/*! -
2180 Returns a pointer to the current table if the cursor position() -
2181 is inside a block that is part of a table; otherwise returns 0. -
2182 -
2183 \sa insertTable() -
2184*/ -
2185QTextTable *QTextCursor::currentTable() const -
2186{ -
2187 if(!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:76
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:76
0-76
2188 return 0;
never executed: return 0;
0
2189 -
2190 QTextFrame *frame = d->priv->frameAt(d->position);
executed (the execution status of this line is deduced): QTextFrame *frame = d->priv->frameAt(d->position);
-
2191 while (frame) {
partially evaluated: frame
TRUEFALSE
yes
Evaluation Count:76
no
Evaluation Count:0
0-76
2192 QTextTable *table = qobject_cast<QTextTable *>(frame);
executed (the execution status of this line is deduced): QTextTable *table = qobject_cast<QTextTable *>(frame);
-
2193 if (table)
partially evaluated: table
TRUEFALSE
yes
Evaluation Count:76
no
Evaluation Count:0
0-76
2194 return table;
executed: return table;
Execution Count:76
76
2195 frame = frame->parentFrame();
never executed (the execution status of this line is deduced): frame = frame->parentFrame();
-
2196 }
never executed: }
0
2197 return 0;
never executed: return 0;
0
2198} -
2199 -
2200/*! -
2201 Inserts a frame with the given \a format at the current cursor position(), -
2202 moves the cursor position() inside the frame, and returns the frame. -
2203 -
2204 If the cursor holds a selection, the whole selection is moved inside the -
2205 frame. -
2206 -
2207 \sa hasSelection() -
2208*/ -
2209QTextFrame *QTextCursor::insertFrame(const QTextFrameFormat &format) -
2210{ -
2211 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
2212 return 0;
never executed: return 0;
0
2213 -
2214 return d->priv->insertFrame(selectionStart(), selectionEnd(), format);
executed: return d->priv->insertFrame(selectionStart(), selectionEnd(), format);
Execution Count:9
9
2215} -
2216 -
2217/*! -
2218 Returns a pointer to the current frame. Returns 0 if the cursor is invalid. -
2219 -
2220 \sa insertFrame() -
2221*/ -
2222QTextFrame *QTextCursor::currentFrame() const -
2223{ -
2224 if(!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:53
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:53
0-53
2225 return 0;
never executed: return 0;
0
2226 -
2227 return d->priv->frameAt(d->position);
executed: return d->priv->frameAt(d->position);
Execution Count:53
53
2228} -
2229 -
2230 -
2231/*! -
2232 Inserts the text \a fragment at the current position(). -
2233*/ -
2234void QTextCursor::insertFragment(const QTextDocumentFragment &fragment) -
2235{ -
2236 if (!d || !d->priv || fragment.isEmpty())
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:558
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:558
evaluated: fragment.isEmpty()
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:551
0-558
2237 return;
executed: return;
Execution Count:7
7
2238 -
2239 d->priv->beginEditBlock();
executed (the execution status of this line is deduced): d->priv->beginEditBlock();
-
2240 d->remove();
executed (the execution status of this line is deduced): d->remove();
-
2241 fragment.d->insert(*this);
executed (the execution status of this line is deduced): fragment.d->insert(*this);
-
2242 d->priv->endEditBlock();
executed (the execution status of this line is deduced): d->priv->endEditBlock();
-
2243 -
2244 if (fragment.d && fragment.d->doc)
partially evaluated: fragment.d
TRUEFALSE
yes
Evaluation Count:551
no
Evaluation Count:0
partially evaluated: fragment.d->doc
TRUEFALSE
yes
Evaluation Count:551
no
Evaluation Count:0
0-551
2245 d->priv->mergeCachedResources(fragment.d->doc->docHandle());
executed: d->priv->mergeCachedResources(fragment.d->doc->docHandle());
Execution Count:551
551
2246}
executed: }
Execution Count:551
551
2247 -
2248/*! -
2249 \since 4.2 -
2250 Inserts the text \a html at the current position(). The text is interpreted as -
2251 HTML. -
2252 -
2253 \note When using this function with a style sheet, the style sheet will -
2254 only apply to the current block in the document. In order to apply a style -
2255 sheet throughout a document, use QTextDocument::setDefaultStyleSheet() -
2256 instead. -
2257*/ -
2258 -
2259#ifndef QT_NO_TEXTHTMLPARSER -
2260 -
2261void QTextCursor::insertHtml(const QString &html) -
2262{ -
2263 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
2264 return;
never executed: return;
0
2265 QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(html, d->priv->document());
executed (the execution status of this line is deduced): QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(html, d->priv->document());
-
2266 insertFragment(fragment);
executed (the execution status of this line is deduced): insertFragment(fragment);
-
2267}
executed: }
Execution Count:15
15
2268 -
2269#endif // QT_NO_TEXTHTMLPARSER -
2270 -
2271/*! -
2272 \overload -
2273 \since 4.2 -
2274 -
2275 Inserts the image defined by the given \a format at the cursor's current position -
2276 with the specified \a alignment. -
2277 -
2278 \sa position() -
2279*/ -
2280void QTextCursor::insertImage(const QTextImageFormat &format, QTextFrameFormat::Position alignment) -
2281{ -
2282 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:24
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:24
0-24
2283 return;
never executed: return;
0
2284 -
2285 QTextFrameFormat ffmt;
executed (the execution status of this line is deduced): QTextFrameFormat ffmt;
-
2286 ffmt.setPosition(alignment);
executed (the execution status of this line is deduced): ffmt.setPosition(alignment);
-
2287 QTextObject *obj = d->priv->createObject(ffmt);
executed (the execution status of this line is deduced): QTextObject *obj = d->priv->createObject(ffmt);
-
2288 -
2289 QTextImageFormat fmt = format;
executed (the execution status of this line is deduced): QTextImageFormat fmt = format;
-
2290 fmt.setObjectIndex(obj->objectIndex());
executed (the execution status of this line is deduced): fmt.setObjectIndex(obj->objectIndex());
-
2291 -
2292 d->priv->beginEditBlock();
executed (the execution status of this line is deduced): d->priv->beginEditBlock();
-
2293 d->remove();
executed (the execution status of this line is deduced): d->remove();
-
2294 const int idx = d->priv->formatCollection()->indexForFormat(fmt);
executed (the execution status of this line is deduced): const int idx = d->priv->formatCollection()->indexForFormat(fmt);
-
2295 d->priv->insert(d->position, QString(QChar(QChar::ObjectReplacementCharacter)), idx);
executed (the execution status of this line is deduced): d->priv->insert(d->position, QString(QChar(QChar::ObjectReplacementCharacter)), idx);
-
2296 d->priv->endEditBlock();
executed (the execution status of this line is deduced): d->priv->endEditBlock();
-
2297}
executed: }
Execution Count:24
24
2298 -
2299/*! -
2300 Inserts the image defined by \a format at the current position(). -
2301*/ -
2302void QTextCursor::insertImage(const QTextImageFormat &format) -
2303{ -
2304 insertText(QString(QChar::ObjectReplacementCharacter), format);
executed (the execution status of this line is deduced): insertText(QString(QChar::ObjectReplacementCharacter), format);
-
2305}
executed: }
Execution Count:9
9
2306 -
2307/*! -
2308 \overload -
2309 -
2310 Convenience method for inserting the image with the given \a name at the -
2311 current position(). -
2312 -
2313 \snippet code/src_gui_text_qtextcursor.cpp 1 -
2314*/ -
2315void QTextCursor::insertImage(const QString &name) -
2316{ -
2317 QTextImageFormat format;
executed (the execution status of this line is deduced): QTextImageFormat format;
-
2318 format.setName(name);
executed (the execution status of this line is deduced): format.setName(name);
-
2319 insertImage(format);
executed (the execution status of this line is deduced): insertImage(format);
-
2320}
executed: }
Execution Count:3
3
2321 -
2322/*! -
2323 \since 4.5 -
2324 \overload -
2325 -
2326 Convenience function for inserting the given \a image with an optional -
2327 \a name at the current position(). -
2328*/ -
2329void QTextCursor::insertImage(const QImage &image, const QString &name) -
2330{ -
2331 if (image.isNull()) {
partially evaluated: image.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
2332 qWarning("QTextCursor::insertImage: attempt to add an invalid image");
never executed (the execution status of this line is deduced): QMessageLogger("text/qtextcursor.cpp", 2332, __PRETTY_FUNCTION__).warning("QTextCursor::insertImage: attempt to add an invalid image");
-
2333 return;
never executed: return;
0
2334 } -
2335 QString imageName = name;
executed (the execution status of this line is deduced): QString imageName = name;
-
2336 if (name.isEmpty())
partially evaluated: name.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
2337 imageName = QString::number(image.cacheKey());
executed: imageName = QString::number(image.cacheKey());
Execution Count:1
1
2338 d->priv->document()->addResource(QTextDocument::ImageResource, QUrl(imageName), image);
executed (the execution status of this line is deduced): d->priv->document()->addResource(QTextDocument::ImageResource, QUrl(imageName), image);
-
2339 QTextImageFormat format;
executed (the execution status of this line is deduced): QTextImageFormat format;
-
2340 format.setName(imageName);
executed (the execution status of this line is deduced): format.setName(imageName);
-
2341 insertImage(format);
executed (the execution status of this line is deduced): insertImage(format);
-
2342}
executed: }
Execution Count:1
1
2343 -
2344/*! -
2345 \fn bool QTextCursor::operator!=(const QTextCursor &other) const -
2346 -
2347 Returns true if the \a other cursor is at a different position in -
2348 the document as this cursor; otherwise returns false. -
2349*/ -
2350bool QTextCursor::operator!=(const QTextCursor &rhs) const -
2351{ -
2352 return !operator==(rhs);
executed: return !operator==(rhs);
Execution Count:3
3
2353} -
2354 -
2355/*! -
2356 \fn bool QTextCursor::operator<(const QTextCursor &other) const -
2357 -
2358 Returns true if the \a other cursor is positioned later in the -
2359 document than this cursor; otherwise returns false. -
2360*/ -
2361bool QTextCursor::operator<(const QTextCursor &rhs) const -
2362{ -
2363 if (!d)
evaluated: !d
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
2364 return !!rhs.d;
executed: return !!rhs.d;
Execution Count:2
2
2365 -
2366 if (!rhs.d)
evaluated: !rhs.d
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
2367 return false;
executed: return false;
Execution Count:1
1
2368 -
2369 Q_ASSERT_X(d->priv == rhs.d->priv, "QTextCursor::operator<", "cannot compare cursors attached to different documents");
executed (the execution status of this line is deduced): qt_noop();
-
2370 -
2371 return d->position < rhs.d->position;
executed: return d->position < rhs.d->position;
Execution Count:1
1
2372} -
2373 -
2374/*! -
2375 \fn bool QTextCursor::operator<=(const QTextCursor &other) const -
2376 -
2377 Returns true if the \a other cursor is positioned later or at the -
2378 same position in the document as this cursor; otherwise returns -
2379 false. -
2380*/ -
2381bool QTextCursor::operator<=(const QTextCursor &rhs) const -
2382{ -
2383 if (!d)
evaluated: !d
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
2384 return true;
executed: return true;
Execution Count:1
1
2385 -
2386 if (!rhs.d)
evaluated: !rhs.d
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
2387 return false;
executed: return false;
Execution Count:1
1
2388 -
2389 Q_ASSERT_X(d->priv == rhs.d->priv, "QTextCursor::operator<=", "cannot compare cursors attached to different documents");
executed (the execution status of this line is deduced): qt_noop();
-
2390 -
2391 return d->position <= rhs.d->position;
executed: return d->position <= rhs.d->position;
Execution Count:1
1
2392} -
2393 -
2394/*! -
2395 \fn bool QTextCursor::operator==(const QTextCursor &other) const -
2396 -
2397 Returns true if the \a other cursor is at the same position in the -
2398 document as this cursor; otherwise returns false. -
2399*/ -
2400bool QTextCursor::operator==(const QTextCursor &rhs) const -
2401{ -
2402 if (!d)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:26
0-26
2403 return !rhs.d;
never executed: return !rhs.d;
0
2404 -
2405 if (!rhs.d)
partially evaluated: !rhs.d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:26
0-26
2406 return false;
never executed: return false;
0
2407 -
2408 return d->position == rhs.d->position && d->priv == rhs.d->priv;
executed: return d->position == rhs.d->position && d->priv == rhs.d->priv;
Execution Count:26
26
2409} -
2410 -
2411/*! -
2412 \fn bool QTextCursor::operator>=(const QTextCursor &other) const -
2413 -
2414 Returns true if the \a other cursor is positioned earlier or at the -
2415 same position in the document as this cursor; otherwise returns -
2416 false. -
2417*/ -
2418bool QTextCursor::operator>=(const QTextCursor &rhs) const -
2419{ -
2420 if (!d)
evaluated: !d
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
2421 return false;
executed: return false;
Execution Count:1
1
2422 -
2423 if (!rhs.d)
evaluated: !rhs.d
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
2424 return true;
executed: return true;
Execution Count:1
1
2425 -
2426 Q_ASSERT_X(d->priv == rhs.d->priv, "QTextCursor::operator>=", "cannot compare cursors attached to different documents");
executed (the execution status of this line is deduced): qt_noop();
-
2427 -
2428 return d->position >= rhs.d->position;
executed: return d->position >= rhs.d->position;
Execution Count:1
1
2429} -
2430 -
2431/*! -
2432 \fn bool QTextCursor::operator>(const QTextCursor &other) const -
2433 -
2434 Returns true if the \a other cursor is positioned earlier in the -
2435 document than this cursor; otherwise returns false. -
2436*/ -
2437bool QTextCursor::operator>(const QTextCursor &rhs) const -
2438{ -
2439 if (!d)
evaluated: !d
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
2440 return false;
executed: return false;
Execution Count:2
2
2441 -
2442 if (!rhs.d)
evaluated: !rhs.d
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
2443 return true;
executed: return true;
Execution Count:1
1
2444 -
2445 Q_ASSERT_X(d->priv == rhs.d->priv, "QTextCursor::operator>", "cannot compare cursors attached to different documents");
executed (the execution status of this line is deduced): qt_noop();
-
2446 -
2447 return d->position > rhs.d->position;
executed: return d->position > rhs.d->position;
Execution Count:1
1
2448} -
2449 -
2450/*! -
2451 Indicates the start of a block of editing operations on the -
2452 document that should appear as a single operation from an -
2453 undo/redo point of view. -
2454 -
2455 For example: -
2456 -
2457 \snippet code/src_gui_text_qtextcursor.cpp 2 -
2458 -
2459 The call to undo() will cause both insertions to be undone, -
2460 causing both "World" and "Hello" to be removed. -
2461 -
2462 It is possible to nest calls to beginEditBlock and endEditBlock. The -
2463 top-most pair will determine the scope of the undo/redo operation. -
2464 -
2465 \sa endEditBlock() -
2466 */ -
2467void QTextCursor::beginEditBlock() -
2468{ -
2469 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:901
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:901
0-901
2470 return;
never executed: return;
0
2471 -
2472 if (d->priv->editBlock == 0) // we are the initial edit block, store current cursor position for undo
evaluated: d->priv->editBlock == 0
TRUEFALSE
yes
Evaluation Count:667
yes
Evaluation Count:234
234-667
2473 d->priv->editBlockCursorPosition = d->position;
executed: d->priv->editBlockCursorPosition = d->position;
Execution Count:667
667
2474 -
2475 d->priv->beginEditBlock();
executed (the execution status of this line is deduced): d->priv->beginEditBlock();
-
2476}
executed: }
Execution Count:901
901
2477 -
2478/*! -
2479 Like beginEditBlock() indicates the start of a block of editing operations -
2480 that should appear as a single operation for undo/redo. However unlike -
2481 beginEditBlock() it does not start a new block but reverses the previous call to -
2482 endEditBlock() and therefore makes following operations part of the previous edit block created. -
2483 -
2484 For example: -
2485 -
2486 \snippet code/src_gui_text_qtextcursor.cpp 3 -
2487 -
2488 The call to undo() will cause all three insertions to be undone. -
2489 -
2490 \sa beginEditBlock(), endEditBlock() -
2491 */ -
2492void QTextCursor::joinPreviousEditBlock() -
2493{ -
2494 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
2495 return;
never executed: return;
0
2496 -
2497 d->priv->joinPreviousEditBlock();
executed (the execution status of this line is deduced): d->priv->joinPreviousEditBlock();
-
2498}
executed: }
Execution Count:1
1
2499 -
2500/*! -
2501 Indicates the end of a block of editing operations on the document -
2502 that should appear as a single operation from an undo/redo point -
2503 of view. -
2504 -
2505 \sa beginEditBlock() -
2506 */ -
2507 -
2508void QTextCursor::endEditBlock() -
2509{ -
2510 if (!d || !d->priv)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:902
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:902
0-902
2511 return;
never executed: return;
0
2512 -
2513 d->priv->endEditBlock();
executed (the execution status of this line is deduced): d->priv->endEditBlock();
-
2514}
executed: }
Execution Count:902
902
2515 -
2516/*! -
2517 Returns true if this cursor and \a other are copies of each other, i.e. -
2518 one of them was created as a copy of the other and neither has moved since. -
2519 This is much stricter than equality. -
2520 -
2521 \sa operator=(), operator==() -
2522*/ -
2523bool QTextCursor::isCopyOf(const QTextCursor &other) const -
2524{ -
2525 return d == other.d;
executed: return d == other.d;
Execution Count:387
387
2526} -
2527 -
2528/*! -
2529 \since 4.2 -
2530 Returns the number of the block the cursor is in, or 0 if the cursor is invalid. -
2531 -
2532 Note that this function only makes sense in documents without complex objects such -
2533 as tables or frames. -
2534*/ -
2535int QTextCursor::blockNumber() const -
2536{ -
2537 if (!d || !d->priv)
evaluated: !d
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:9
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
2538 return 0;
executed: return 0;
Execution Count:1
1
2539 -
2540 return d->block().blockNumber();
executed: return d->block().blockNumber();
Execution Count:9
9
2541} -
2542 -
2543 -
2544/*! -
2545 \since 4.2 -
2546 Returns the position of the cursor within its containing line. -
2547 -
2548 Note that this is the column number relative to a wrapped line, -
2549 not relative to the block (i.e. the paragraph). -
2550 -
2551 You probably want to call positionInBlock() instead. -
2552 -
2553 \sa positionInBlock() -
2554*/ -
2555int QTextCursor::columnNumber() const -
2556{ -
2557 if (!d || !d->priv)
evaluated: !d
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:7
partially evaluated: !d->priv
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
2558 return 0;
executed: return 0;
Execution Count:1
1
2559 -
2560 QTextBlock block = d->block();
executed (the execution status of this line is deduced): QTextBlock block = d->block();
-
2561 if (!block.isValid())
partially evaluated: !block.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
2562 return 0;
never executed: return 0;
0
2563 -
2564 const QTextLayout *layout = d->blockLayout(block);
executed (the execution status of this line is deduced): const QTextLayout *layout = d->blockLayout(block);
-
2565 -
2566 const int relativePos = d->position - block.position();
executed (the execution status of this line is deduced): const int relativePos = d->position - block.position();
-
2567 -
2568 if (layout->lineCount() == 0)
evaluated: layout->lineCount() == 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:4
3-4
2569 return relativePos;
executed: return relativePos;
Execution Count:3
3
2570 -
2571 QTextLine line = layout->lineForTextPosition(relativePos);
executed (the execution status of this line is deduced): QTextLine line = layout->lineForTextPosition(relativePos);
-
2572 if (!line.isValid())
partially evaluated: !line.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
2573 return 0;
never executed: return 0;
0
2574 return relativePos - line.textStart();
executed: return relativePos - line.textStart();
Execution Count:4
4
2575} -
2576 -
2577/*! -
2578 \since 4.5 -
2579 Returns the document this cursor is associated with. -
2580*/ -
2581QTextDocument *QTextCursor::document() const -
2582{ -
2583 if (d->priv)
never evaluated: d->priv
0
2584 return d->priv->document();
never executed: return d->priv->document();
0
2585 return 0; // document went away
never executed: return 0;
0
2586} -
2587 -
2588QT_END_NAMESPACE -
2589 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial