text/qtextcursor.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5enum { -
6 AdjustPrev = 0x1, -
7 AdjustUp = 0x3, -
8 AdjustNext = 0x4, -
9 AdjustDown = 0x12 -
10}; -
11 -
12QTextCursorPrivate::QTextCursorPrivate(QTextDocumentPrivate *p) -
13 : priv(p), x(0), position(0), anchor(0), adjusted_anchor(0), -
14 currentCharFormat(-1), visualNavigation(false), keepPositionOnInsert(false), -
15 changed(false) -
16{ -
17 priv->addCursor(this); -
18}
executed: }
Execution Count:5257
5257
19 -
20QTextCursorPrivate::QTextCursorPrivate(const QTextCursorPrivate &rhs) -
21 : QSharedData(rhs) -
22{ -
23 position = rhs.position; -
24 anchor = rhs.anchor; -
25 adjusted_anchor = rhs.adjusted_anchor; -
26 priv = rhs.priv; -
27 x = rhs.x; -
28 currentCharFormat = rhs.currentCharFormat; -
29 visualNavigation = rhs.visualNavigation; -
30 keepPositionOnInsert = rhs.keepPositionOnInsert; -
31 changed = rhs.changed; -
32 priv->addCursor(this); -
33}
executed: }
Execution Count:197
197
34 -
35QTextCursorPrivate::~QTextCursorPrivate() -
36{ -
37 if (priv)
evaluated: priv
TRUEFALSE
yes
Evaluation Count:5047
yes
Evaluation Count:403
403-5047
38 priv->removeCursor(this);
executed: priv->removeCursor(this);
Execution Count:5047
5047
39}
executed: }
Execution Count:5450
5450
40 -
41QTextCursorPrivate::AdjustResult QTextCursorPrivate::adjustPosition(int positionOfChange, int charsAddedOrRemoved, QTextUndoCommand::Operation op) -
42{ -
43 QTextCursorPrivate::AdjustResult result = QTextCursorPrivate::CursorMoved; -
44 -
45 if (position < positionOfChange
evaluated: position < positionOfChange
TRUEFALSE
yes
Evaluation Count:408
yes
Evaluation Count:32433
408-32433
46 || (position == positionOfChange
evaluated: position == positionOfChange
TRUEFALSE
yes
Evaluation Count:30308
yes
Evaluation Count:2125
2125-30308
47 && (op == QTextUndoCommand::KeepCursor
evaluated: op == QTextUndoCommand::KeepCursor
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:30269
39-30269
48 || keepPositionOnInsert)
evaluated: keepPositionOnInsert
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:30268
1-30268
49 ) -
50 ) { -
51 result = CursorUnchanged; -
52 } else {
executed: }
Execution Count:448
448
53 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
54 position = positionOfChange;
executed: position = positionOfChange;
Execution Count:42
42
55 else -
56 position += charsAddedOrRemoved;
executed: position += charsAddedOrRemoved;
Execution Count:32351
32351
57 -
58 currentCharFormat = -1; -
59 }
executed: }
Execution Count:32393
32393
60 -
61 if (anchor >= positionOfChange
evaluated: anchor >= positionOfChange
TRUEFALSE
yes
Evaluation Count:32429
yes
Evaluation Count:412
412-32429
62 && (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
63 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
64 anchor = positionOfChange;
executed: anchor = positionOfChange;
Execution Count:987
987
65 else -
66 anchor += charsAddedOrRemoved;
executed: anchor += charsAddedOrRemoved;
Execution Count:31419
31419
67 } -
68 -
69 if (adjusted_anchor >= positionOfChange
evaluated: adjusted_anchor >= positionOfChange
TRUEFALSE
yes
Evaluation Count:32429
yes
Evaluation Count:412
412-32429
70 && (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
71 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
72 adjusted_anchor = positionOfChange;
executed: adjusted_anchor = positionOfChange;
Execution Count:987
987
73 else -
74 adjusted_anchor += charsAddedOrRemoved;
executed: adjusted_anchor += charsAddedOrRemoved;
Execution Count:31420
31420
75 } -
76 -
77 return result;
executed: return result;
Execution Count:32841
32841
78} -
79 -
80void QTextCursorPrivate::setX() -
81{ -
82 if (priv->isInEditBlock()) {
evaluated: priv->isInEditBlock()
TRUEFALSE
yes
Evaluation Count:5181
yes
Evaluation Count:15778
5181-15778
83 x = -1; -
84 return;
executed: return;
Execution Count:5181
5181
85 } -
86 -
87 QTextBlock block = this->block(); -
88 const QTextLayout *layout = blockLayout(block); -
89 int pos = position - block.position(); -
90 -
91 QTextLine line = layout->lineForTextPosition(pos); -
92 if (line.isValid())
evaluated: line.isValid()
TRUEFALSE
yes
Evaluation Count:490
yes
Evaluation Count:15288
490-15288
93 x = line.cursorToX(pos);
executed: x = line.cursorToX(pos);
Execution Count:490
490
94 else -
95 x = -1;
executed: x = -1;
Execution Count:15288
15288
96} -
97 -
98void QTextCursorPrivate::remove() -
99{ -
100 if (anchor == position)
evaluated: anchor == position
TRUEFALSE
yes
Evaluation Count:12780
yes
Evaluation Count:965
965-12780
101 return;
executed: return;
Execution Count:12780
12780
102 currentCharFormat = -1; -
103 int pos1 = position; -
104 int pos2 = adjusted_anchor; -
105 QTextUndoCommand::Operation op = QTextUndoCommand::KeepCursor; -
106 if (pos1 > pos2) {
evaluated: pos1 > pos2
TRUEFALSE
yes
Evaluation Count:945
yes
Evaluation Count:20
20-945
107 pos1 = adjusted_anchor; -
108 pos2 = position; -
109 op = QTextUndoCommand::MoveCursor; -
110 }
executed: }
Execution Count:945
945
111 -
112 -
113 QTextTable *table = complexSelectionTable(); -
114 if (table) {
evaluated: table
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:963
2-963
115 priv->beginEditBlock(); -
116 int startRow, startCol, numRows, numCols; -
117 selectedTableCells(&startRow, &numRows, &startCol, &numCols); -
118 clearCells(table, startRow, startCol, numRows, numCols, op); -
119 adjusted_anchor = anchor = position; -
120 priv->endEditBlock(); -
121 } else {
executed: }
Execution Count:2
2
122 priv->remove(pos1, pos2-pos1, op); -
123 adjusted_anchor = anchor = position; -
124 priv->finishEdit(); -
125 }
executed: }
Execution Count:963
963
126 -
127} -
128 -
129void QTextCursorPrivate::clearCells(QTextTable *table, int startRow, int startCol, int numRows, int numCols, QTextUndoCommand::Operation op) -
130{ -
131 priv->beginEditBlock(); -
132 -
133 for (int row = startRow; row < startRow + numRows; ++row)
evaluated: row < startRow + numRows
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
134 for (int col = startCol; col < startCol + numCols; ++col) {
evaluated: col < startCol + numCols
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2
2-4
135 QTextTableCell cell = table->cellAt(row, col); -
136 const int startPos = cell.firstPosition(); -
137 const int endPos = cell.lastPosition(); -
138 qt_noop(); -
139 priv->remove(startPos, endPos - startPos, op); -
140 }
executed: }
Execution Count:4
4
141 -
142 priv->endEditBlock(); -
143}
executed: }
Execution Count:2
2
144 -
145bool QTextCursorPrivate::canDelete(int pos) const -
146{ -
147 QTextDocumentPrivate::FragmentIterator fit = priv->find(pos); -
148 QTextCharFormat fmt = priv->formatCollection()->charFormat((*fit)->format); -
149 return (fmt.objectIndex() == -1 || fmt.objectType() == QTextFormat::ImageObject);
executed: return (fmt.objectIndex() == -1 || fmt.objectType() == QTextFormat::ImageObject);
Execution Count:23
23
150} -
151 -
152void QTextCursorPrivate::insertBlock(const QTextBlockFormat &format, const QTextCharFormat &charFormat) -
153{ -
154 QTextFormatCollection *formats = priv->formatCollection(); -
155 int idx = formats->indexForFormat(format); -
156 qt_noop(); -
157 -
158 priv->insertBlock(position, idx, formats->indexForFormat(charFormat)); -
159 currentCharFormat = -1; -
160}
executed: }
Execution Count:15099
15099
161 -
162void QTextCursorPrivate::adjustCursor(QTextCursor::MoveOperation m) -
163{ -
164 adjusted_anchor = anchor; -
165 if (position == anchor)
evaluated: position == anchor
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:2199
18-2199
166 return;
executed: return;
Execution Count:18
18
167 -
168 QTextFrame *f_position = priv->frameAt(position); -
169 QTextFrame *f_anchor = priv->frameAt(adjusted_anchor); -
170 -
171 if (f_position != f_anchor) {
evaluated: f_position != f_anchor
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2197
2-2197
172 -
173 QList<QTextFrame *> positionChain; -
174 QList<QTextFrame *> anchorChain; -
175 QTextFrame *f = f_position; -
176 while (f) {
evaluated: f
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2
2-3
177 positionChain.prepend(f); -
178 f = f->parentFrame(); -
179 }
executed: }
Execution Count:3
3
180 f = f_anchor; -
181 while (f) {
evaluated: f
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2
2-3
182 anchorChain.prepend(f); -
183 f = f->parentFrame(); -
184 }
executed: }
Execution Count:3
3
185 qt_noop(); -
186 int i = 1; -
187 int l = qMin(positionChain.size(), anchorChain.size()); -
188 for (; i < l; ++i) {
partially evaluated: i < l
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
189 if (positionChain.at(i) != anchorChain.at(i))
never evaluated: positionChain.at(i) != anchorChain.at(i)
0
190 break;
never executed: break;
0
191 }
never executed: }
0
192 -
193 if (m <= QTextCursor::WordLeft) {
evaluated: m <= QTextCursor::WordLeft
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
194 if (i < positionChain.size())
partially evaluated: i < positionChain.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
195 position = positionChain.at(i)->firstPosition() - 1;
never executed: position = positionChain.at(i)->firstPosition() - 1;
0
196 } else {
executed: }
Execution Count:1
1
197 if (i < positionChain.size())
partially evaluated: i < positionChain.size()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
198 position = positionChain.at(i)->lastPosition() + 1;
executed: position = positionChain.at(i)->lastPosition() + 1;
Execution Count:1
1
199 }
executed: }
Execution Count:1
1
200 if (position < adjusted_anchor) {
evaluated: position < adjusted_anchor
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
201 if (i < anchorChain.size())
partially evaluated: i < anchorChain.size()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
202 adjusted_anchor = anchorChain.at(i)->lastPosition() + 1;
executed: adjusted_anchor = anchorChain.at(i)->lastPosition() + 1;
Execution Count:1
1
203 } else {
executed: }
Execution Count:1
1
204 if (i < anchorChain.size())
partially evaluated: i < anchorChain.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
205 adjusted_anchor = anchorChain.at(i)->firstPosition() - 1;
never executed: adjusted_anchor = anchorChain.at(i)->firstPosition() - 1;
0
206 }
executed: }
Execution Count:1
1
207 -
208 f_position = positionChain.at(i-1); -
209 }
executed: }
Execution Count:2
2
210 -
211 -
212 QTextTable *table = qobject_cast<QTextTable *>(f_position); -
213 if (!table)
evaluated: !table
TRUEFALSE
yes
Evaluation Count:2074
yes
Evaluation Count:125
125-2074
214 return;
executed: return;
Execution Count:2074
2074
215 -
216 QTextTableCell c_position = table->cellAt(position); -
217 QTextTableCell c_anchor = table->cellAt(adjusted_anchor); -
218 if (c_position != c_anchor) {
evaluated: c_position != c_anchor
TRUEFALSE
yes
Evaluation Count:107
yes
Evaluation Count:18
18-107
219 position = c_position.firstPosition(); -
220 if (position < adjusted_anchor)
evaluated: position < adjusted_anchor
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:69
38-69
221 adjusted_anchor = c_anchor.lastPosition();
executed: adjusted_anchor = c_anchor.lastPosition();
Execution Count:38
38
222 else -
223 adjusted_anchor = c_anchor.firstPosition();
executed: adjusted_anchor = c_anchor.firstPosition();
Execution Count:69
69
224 } -
225 currentCharFormat = -1; -
226}
executed: }
Execution Count:125
125
227 -
228void QTextCursorPrivate::aboutToRemoveCell(int from, int to) -
229{ -
230 qt_noop(); -
231 if (position == anchor)
evaluated: position == anchor
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:10
10-22
232 return;
executed: return;
Execution Count:22
22
233 -
234 QTextTable *t = qobject_cast<QTextTable *>(priv->frameAt(position)); -
235 if (!t)
partially evaluated: !t
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
236 return;
never executed: return;
0
237 QTextTableCell removedCellFrom = t->cellAt(from); -
238 QTextTableCell removedCellEnd = t->cellAt(to); -
239 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
240 return;
never executed: return;
0
241 -
242 int curFrom = position; -
243 int curTo = adjusted_anchor; -
244 if (curTo < curFrom)
partially evaluated: curTo < curFrom
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-10
245 qSwap(curFrom, curTo);
executed: qSwap(curFrom, curTo);
Execution Count:10
10
246 -
247 QTextTableCell cellStart = t->cellAt(curFrom); -
248 QTextTableCell cellEnd = t->cellAt(curTo); -
249 -
250 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
251 && cellStart.column() >= removedCellFrom.column()
evaluated: cellStart.column() >= removedCellFrom.column()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:2
2-5
252 && cellEnd.column() <= removedCellEnd.column()) {
evaluated: cellEnd.column() <= removedCellEnd.column()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2
2-3
253 -
254 QTextTableCell cell; -
255 if (removedCellFrom.row() == 0 && removedCellEnd.row() == t->rows()-1)
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
256 cell = t->cellAt(cellStart.row(), removedCellEnd.column()+1);
executed: cell = t->cellAt(cellStart.row(), removedCellEnd.column()+1);
Execution Count:1
1
257 else if (removedCellFrom.column() == 0 && removedCellEnd.column() == t->columns()-1)
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
258 cell = t->cellAt(removedCellEnd.row() + 1, cellStart.column());
executed: cell = t->cellAt(removedCellEnd.row() + 1, cellStart.column());
Execution Count:2
2
259 -
260 int newPosition; -
261 if (cell.isValid())
evaluated: cell.isValid()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
262 newPosition = cell.firstPosition();
executed: newPosition = cell.firstPosition();
Execution Count:2
2
263 else -
264 newPosition = t->lastPosition()+1;
executed: newPosition = t->lastPosition()+1;
Execution Count:1
1
265 -
266 setPosition(newPosition); -
267 anchor = newPosition; -
268 adjusted_anchor = newPosition; -
269 x = 0; -
270 }
executed: }
Execution Count:3
3
271 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
272 && cellEnd.row() > removedCellEnd.row()) {
evaluated: cellEnd.row() > removedCellEnd.row()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:4
1-4
273 int newPosition = t->cellAt(removedCellEnd.row() + 1, cellStart.column()).firstPosition(); -
274 if (position < anchor)
partially evaluated: position < anchor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
275 position = newPosition;
never executed: position = newPosition;
0
276 else -
277 anchor = adjusted_anchor = newPosition;
executed: anchor = adjusted_anchor = newPosition;
Execution Count:1
1
278 } -
279 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
280 && cellEnd.column() > removedCellEnd.column()) {
evaluated: cellEnd.column() > removedCellEnd.column()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
281 int newPosition = t->cellAt(cellStart.row(), removedCellEnd.column()+1).firstPosition(); -
282 if (position < anchor)
partially evaluated: position < anchor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
283 position = newPosition;
never executed: position = newPosition;
0
284 else -
285 anchor = adjusted_anchor = newPosition;
executed: anchor = adjusted_anchor = newPosition;
Execution Count:2
2
286 } -
287} -
288 -
289bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor::MoveMode mode) -
290{ -
291 currentCharFormat = -1; -
292 bool adjustX = true; -
293 QTextBlock blockIt = block(); -
294 bool visualMovement = priv->defaultCursorMoveStyle == Qt::VisualMoveStyle; -
295 -
296 if (!blockIt.isValid())
partially evaluated: !blockIt.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2898
0-2898
297 return false;
never executed: return false;
0
298 -
299 if (blockIt.textDirection() == Qt::RightToLeft) {
evaluated: blockIt.textDirection() == Qt::RightToLeft
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2896
2-2896
300 if (op == QTextCursor::WordLeft)
partially evaluated: op == QTextCursor::WordLeft
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
301 op = QTextCursor::NextWord;
never executed: op = QTextCursor::NextWord;
0
302 else if (op == QTextCursor::WordRight)
partially evaluated: op == QTextCursor::WordRight
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
303 op = QTextCursor::PreviousWord;
never executed: op = QTextCursor::PreviousWord;
0
304 -
305 if (!visualMovement) {
partially evaluated: !visualMovement
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
306 if (op == QTextCursor::Left)
partially evaluated: op == QTextCursor::Left
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
307 op = QTextCursor::NextCharacter;
never executed: op = QTextCursor::NextCharacter;
0
308 else if (op == QTextCursor::Right)
partially evaluated: op == QTextCursor::Right
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
309 op = QTextCursor::PreviousCharacter;
never executed: op = QTextCursor::PreviousCharacter;
0
310 } -
311 }
executed: }
Execution Count:2
2
312 -
313 const QTextLayout *layout = blockLayout(blockIt); -
314 int relativePos = position - blockIt.position(); -
315 QTextLine line; -
316 if (!priv->isInEditBlock())
evaluated: !priv->isInEditBlock()
TRUEFALSE
yes
Evaluation Count:1476
yes
Evaluation Count:1422
1422-1476
317 line = layout->lineForTextPosition(relativePos);
executed: line = layout->lineForTextPosition(relativePos);
Execution Count:1476
1476
318 -
319 qt_noop(); -
320 -
321 int newPosition = position; -
322 -
323 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
324 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
325 || (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
326 QTextTable *t = qobject_cast<QTextTable *>(priv->frameAt(position)); -
327 qt_noop(); -
328 QTextTableCell cell_pos = t->cellAt(position); -
329 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
330 op = QTextCursor::NextCell;
executed: op = QTextCursor::NextCell;
Execution Count:26
26
331 }
executed: }
Execution Count:26
26
332 }
executed: }
Execution Count:87
87
333 -
334 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
335 setX();
executed: setX();
Execution Count:28
28
336 -
337 switch(op) { -
338 case QTextCursor::NoMove: -
339 return true;
never executed: return true;
0
340 -
341 case QTextCursor::Start: -
342 newPosition = 0; -
343 break;
executed: break;
Execution Count:320
320
344 case QTextCursor::StartOfLine: { -
345 newPosition = blockIt.position(); -
346 if (line.isValid())
evaluated: line.isValid()
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:2
2-21
347 newPosition += line.textStart();
executed: newPosition += line.textStart();
Execution Count:21
21
348 -
349 break;
executed: break;
Execution Count:23
23
350 } -
351 case QTextCursor::StartOfBlock: { -
352 newPosition = blockIt.position(); -
353 break;
executed: break;
Execution Count:14
14
354 } -
355 case QTextCursor::PreviousBlock: { -
356 if (blockIt == priv->blocksBegin())
evaluated: blockIt == priv->blocksBegin()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:19
1-19
357 return false;
executed: return false;
Execution Count:1
1
358 blockIt = blockIt.previous(); -
359 -
360 newPosition = blockIt.position(); -
361 break;
executed: break;
Execution Count:19
19
362 } -
363 case QTextCursor::PreviousCharacter: -
364 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
365 newPosition = qMin(position, adjusted_anchor);
never executed: newPosition = qMin(position, adjusted_anchor);
0
366 else -
367 newPosition = priv->previousCursorPosition(position, QTextLayout::SkipCharacters);
executed: newPosition = priv->previousCursorPosition(position, QTextLayout::SkipCharacters);
Execution Count:14
14
368 break;
executed: break;
Execution Count:14
14
369 case QTextCursor::Left: -
370 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
371 newPosition = visualMovement ? qMax(position, adjusted_anchor)
partially evaluated: visualMovement
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
372 : qMin(position, adjusted_anchor);
executed: newPosition = visualMovement ? qMax(position, adjusted_anchor) : qMin(position, adjusted_anchor);
Execution Count:2
2
373 else -
374 newPosition = visualMovement ? priv->leftCursorPosition(position)
partially evaluated: visualMovement
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:49
0-49
375 : priv->previousCursorPosition(position, QTextLayout::SkipCharacters);
executed: newPosition = visualMovement ? priv->leftCursorPosition(position) : priv->previousCursorPosition(position, QTextLayout::SkipCharacters);
Execution Count:49
49
376 break;
executed: break;
Execution Count:51
51
377 case QTextCursor::StartOfWord: { -
378 if (relativePos == 0)
evaluated: relativePos == 0
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:16
16-20
379 break;
executed: break;
Execution Count:20
20
380 -
381 -
382 QTextEngine *engine = layout->engine(); -
383 engine->attributes(); -
384 if ((relativePos == blockIt.length() - 1)
evaluated: (relativePos == blockIt.length() - 1)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:13
3-13
385 && (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
386 return false;
executed: return false;
Execution Count:1
1
387 -
388 if (relativePos < blockIt.length()-1)
evaluated: relativePos < blockIt.length()-1
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:2
2-13
389 ++position;
executed: ++position;
Execution Count:13
13
390 -
391 -
392 } -
393 case QTextCursor::PreviousWord:
code before this statement executed: case QTextCursor::PreviousWord:
Execution Count:15
15
394 case QTextCursor::WordLeft: -
395 newPosition = priv->previousCursorPosition(position, QTextLayout::SkipWords); -
396 break;
executed: break;
Execution Count:48
48
397 case QTextCursor::Up: { -
398 int i = line.lineNumber() - 1; -
399 if (i == -1) {
partially evaluated: i == -1
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-14
400 if (blockIt == priv->blocksBegin())
evaluated: blockIt == priv->blocksBegin()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:13
1-13
401 return false;
executed: return false;
Execution Count:1
1
402 int blockPosition = blockIt.position(); -
403 QTextTable *table = qobject_cast<QTextTable *>(priv->frameAt(blockPosition)); -
404 if (table) {
partially evaluated: table
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-13
405 QTextTableCell cell = table->cellAt(blockPosition); -
406 if (cell.firstPosition() == blockPosition) {
partially evaluated: cell.firstPosition() == blockPosition
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-13
407 int row = cell.row() - 1; -
408 if (row >= 0) {
evaluated: row >= 0
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:1
1-12
409 blockPosition = table->cellAt(row, cell.column()).lastPosition(); -
410 } else {
executed: }
Execution Count:12
12
411 -
412 blockPosition = table->firstPosition() - 1; -
413 }
executed: }
Execution Count:1
1
414 blockIt = priv->blocksFind(blockPosition); -
415 } else {
executed: }
Execution Count:13
13
416 blockIt = blockIt.previous(); -
417 }
never executed: }
0
418 } else { -
419 blockIt = blockIt.previous(); -
420 }
never executed: }
0
421 layout = blockLayout(blockIt); -
422 i = layout->lineCount()-1; -
423 }
executed: }
Execution Count:13
13
424 if (layout->lineCount()) {
partially evaluated: layout->lineCount()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
0-13
425 QTextLine line = layout->lineAt(i); -
426 newPosition = line.xToCursor(x) + blockIt.position(); -
427 } else {
never executed: }
0
428 newPosition = blockIt.position(); -
429 }
executed: }
Execution Count:13
13
430 adjustX = false; -
431 break;
executed: break;
Execution Count:13
13
432 } -
433 -
434 case QTextCursor::End: -
435 newPosition = priv->length() - 1; -
436 break;
executed: break;
Execution Count:894
894
437 case QTextCursor::EndOfLine: { -
438 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
439 if (blockIt.length() >= 1)
partially evaluated: blockIt.length() >= 1
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
440 -
441 newPosition = blockIt.position() + blockIt.length() - 1;
executed: newPosition = blockIt.position() + blockIt.length() - 1;
Execution Count:4
4
442 break;
executed: break;
Execution Count:4
4
443 } -
444 newPosition = blockIt.position() + line.textStart() + line.textLength(); -
445 if (newPosition >= priv->length())
partially evaluated: newPosition >= priv->length()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
446 newPosition = priv->length() - 1;
never executed: newPosition = priv->length() - 1;
0
447 if (line.lineNumber() < layout->lineCount() - 1) {
evaluated: line.lineNumber() < layout->lineCount() - 1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5
1-5
448 const QString text = blockIt.text(); -
449 -
450 -
451 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
452 --newPosition;
executed: --newPosition;
Execution Count:1
1
453 }
executed: }
Execution Count:1
1
454 break;
executed: break;
Execution Count:6
6
455 } -
456 case QTextCursor::EndOfWord: { -
457 QTextEngine *engine = layout->engine(); -
458 engine->attributes(); -
459 const int len = blockIt.length() - 1; -
460 if (relativePos >= len)
evaluated: relativePos >= len
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:37
2-37
461 return false;
executed: return false;
Execution Count:2
2
462 if (engine->atWordSeparator(relativePos)) {
partially evaluated: engine->atWordSeparator(relativePos)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:37
0-37
463 ++relativePos; -
464 while (relativePos < len && engine->atWordSeparator(relativePos))
never evaluated: relativePos < len
never evaluated: engine->atWordSeparator(relativePos)
0
465 ++relativePos;
never executed: ++relativePos;
0
466 } else {
never executed: }
0
467 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
468 ++relativePos;
executed: ++relativePos;
Execution Count:139
139
469 }
executed: }
Execution Count:37
37
470 newPosition = blockIt.position() + relativePos; -
471 break;
executed: break;
Execution Count:37
37
472 } -
473 case QTextCursor::EndOfBlock: -
474 if (blockIt.length() >= 1)
partially evaluated: blockIt.length() >= 1
TRUEFALSE
yes
Evaluation Count:21
no
Evaluation Count:0
0-21
475 -
476 newPosition = blockIt.position() + blockIt.length() - 1;
executed: newPosition = blockIt.position() + blockIt.length() - 1;
Execution Count:21
21
477 break;
executed: break;
Execution Count:21
21
478 case QTextCursor::NextBlock: { -
479 blockIt = blockIt.next(); -
480 if (!blockIt.isValid())
evaluated: !blockIt.isValid()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1136
6-1136
481 return false;
executed: return false;
Execution Count:6
6
482 -
483 newPosition = blockIt.position(); -
484 break;
executed: break;
Execution Count:1136
1136
485 } -
486 case QTextCursor::NextCharacter: -
487 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
488 newPosition = qMax(position, adjusted_anchor);
never executed: newPosition = qMax(position, adjusted_anchor);
0
489 else -
490 newPosition = priv->nextCursorPosition(position, QTextLayout::SkipCharacters);
executed: newPosition = priv->nextCursorPosition(position, QTextLayout::SkipCharacters);
Execution Count:93
93
491 break;
executed: break;
Execution Count:93
93
492 case QTextCursor::Right: -
493 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
494 newPosition = visualMovement ? qMin(position, adjusted_anchor)
partially evaluated: visualMovement
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
0-25
495 : qMax(position, adjusted_anchor);
executed: newPosition = visualMovement ? qMin(position, adjusted_anchor) : qMax(position, adjusted_anchor);
Execution Count:25
25
496 else -
497 newPosition = visualMovement ? priv->rightCursorPosition(position)
partially evaluated: visualMovement
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:29
0-29
498 : priv->nextCursorPosition(position, QTextLayout::SkipCharacters);
executed: newPosition = visualMovement ? priv->rightCursorPosition(position) : priv->nextCursorPosition(position, QTextLayout::SkipCharacters);
Execution Count:29
29
499 break;
executed: break;
Execution Count:54
54
500 case QTextCursor::NextWord: -
501 case QTextCursor::WordRight: -
502 newPosition = priv->nextCursorPosition(position, QTextLayout::SkipWords); -
503 break;
executed: break;
Execution Count:16
16
504 -
505 case QTextCursor::Down: { -
506 int i = line.lineNumber() + 1; -
507 -
508 if (i >= layout->lineCount()) {
evaluated: i >= layout->lineCount()
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:2
2-20
509 int blockPosition = blockIt.position() + blockIt.length() - 1; -
510 QTextTable *table = qobject_cast<QTextTable *>(priv->frameAt(blockPosition)); -
511 if (table) {
evaluated: table
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:7
7-13
512 QTextTableCell cell = table->cellAt(blockPosition); -
513 if (cell.lastPosition() == blockPosition) {
partially evaluated: cell.lastPosition() == blockPosition
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-13
514 int row = cell.row() + cell.rowSpan(); -
515 if (row < table->rows()) {
partially evaluated: row < table->rows()
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-13
516 blockPosition = table->cellAt(row, cell.column()).firstPosition(); -
517 } else {
executed: }
Execution Count:13
13
518 -
519 blockPosition = table->lastPosition() + 1; -
520 }
never executed: }
0
521 blockIt = priv->blocksFind(blockPosition); -
522 } else {
executed: }
Execution Count:13
13
523 blockIt = blockIt.next(); -
524 }
never executed: }
0
525 } else { -
526 blockIt = blockIt.next(); -
527 }
executed: }
Execution Count:7
7
528 -
529 if (blockIt == priv->blocksEnd())
evaluated: blockIt == priv->blocksEnd()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:17
3-17
530 return false;
executed: return false;
Execution Count:3
3
531 layout = blockLayout(blockIt); -
532 i = 0; -
533 }
executed: }
Execution Count:17
17
534 if (layout->lineCount()) {
evaluated: layout->lineCount()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:13
6-13
535 QTextLine line = layout->lineAt(i); -
536 newPosition = line.xToCursor(x) + blockIt.position(); -
537 } else {
executed: }
Execution Count:6
6
538 newPosition = blockIt.position(); -
539 }
executed: }
Execution Count:13
13
540 adjustX = false; -
541 break;
executed: break;
Execution Count:19
19
542 } -
543 case QTextCursor::NextCell: -
544 case QTextCursor::PreviousCell: -
545 case QTextCursor::NextRow: -
546 case QTextCursor::PreviousRow: { -
547 QTextTable *table = qobject_cast<QTextTable *>(priv->frameAt(position)); -
548 if (!table)
partially evaluated: !table
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:82
0-82
549 return false;
never executed: return false;
0
550 -
551 QTextTableCell cell = table->cellAt(position); -
552 qt_noop(); -
553 int column = cell.column(); -
554 int row = cell.row(); -
555 const int currentRow = row; -
556 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
557 do { -
558 column += cell.columnSpan(); -
559 if (column >= table->columns()) {
evaluated: column >= table->columns()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:56
10-56
560 column = 0; -
561 ++row; -
562 }
executed: }
Execution Count:10
10
563 cell = table->cellAt(row, column); -
564 -
565 } while (cell.isValid()
executed: }
Execution Count:66
evaluated: cell.isValid()
TRUEFALSE
yes
Evaluation Count:63
yes
Evaluation Count:3
3-66
566 && ((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
567 || cell.row() < row));
evaluated: cell.row() < row
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:56
1-56
568 }
executed: }
Execution Count:59
59
569 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
570 do { -
571 --column; -
572 if (column < 0) {
evaluated: column < 0
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:20
10-20
573 column = table->columns()-1; -
574 --row; -
575 }
executed: }
Execution Count:10
10
576 cell = table->cellAt(row, column); -
577 -
578 } while (cell.isValid()
executed: }
Execution Count:30
evaluated: cell.isValid()
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:3
3-30
579 && ((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
580 || cell.row() < row));
evaluated: cell.row() < row
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:20
1-20
581 }
executed: }
Execution Count:23
23
582 if (cell.isValid())
evaluated: cell.isValid()
TRUEFALSE
yes
Evaluation Count:76
yes
Evaluation Count:6
6-76
583 newPosition = cell.firstPosition();
executed: newPosition = cell.firstPosition();
Execution Count:76
76
584 break;
executed: break;
Execution Count:82
82
585 } -
586 } -
587 -
588 if (mode == QTextCursor::KeepAnchor) {
evaluated: mode == QTextCursor::KeepAnchor
TRUEFALSE
yes
Evaluation Count:2077
yes
Evaluation Count:807
807-2077
589 QTextTable *table = qobject_cast<QTextTable *>(priv->frameAt(position)); -
590 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
591 || (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
592 int oldColumn = table->cellAt(position).column(); -
593 -
594 const QTextTableCell otherCell = table->cellAt(newPosition); -
595 if (!otherCell.isValid())
evaluated: !otherCell.isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:48
1-48
596 return false;
executed: return false;
Execution Count:1
1
597 -
598 int newColumn = otherCell.column(); -
599 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
600 || (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
601 return false;
executed: return false;
Execution Count:3
3
602 }
executed: }
Execution Count:45
45
603 }
executed: }
Execution Count:2073
2073
604 -
605 const bool moved = setPosition(newPosition); -
606 -
607 if (mode == QTextCursor::MoveAnchor) {
evaluated: mode == QTextCursor::MoveAnchor
TRUEFALSE
yes
Evaluation Count:807
yes
Evaluation Count:2073
807-2073
608 anchor = position; -
609 adjusted_anchor = position; -
610 } else {
executed: }
Execution Count:807
807
611 adjustCursor(op); -
612 }
executed: }
Execution Count:2073
2073
613 -
614 if (adjustX)
evaluated: adjustX
TRUEFALSE
yes
Evaluation Count:2848
yes
Evaluation Count:32
32-2848
615 setX();
executed: setX();
Execution Count:2848
2848
616 -
617 return moved;
executed: return moved;
Execution Count:2880
2880
618} -
619 -
620QTextTable *QTextCursorPrivate::complexSelectionTable() const -
621{ -
622 if (position == anchor)
evaluated: position == anchor
TRUEFALSE
yes
Evaluation Count:4486
yes
Evaluation Count:2259
2259-4486
623 return 0;
executed: return 0;
Execution Count:4486
4486
624 -
625 QTextTable *t = qobject_cast<QTextTable *>(priv->frameAt(position)); -
626 if (t) {
evaluated: t
TRUEFALSE
yes
Evaluation Count:109
yes
Evaluation Count:2150
109-2150
627 QTextTableCell cell_pos = t->cellAt(position); -
628 QTextTableCell cell_anchor = t->cellAt(adjusted_anchor); -
629 -
630 qt_noop(); -
631 -
632 if (cell_pos == cell_anchor)
evaluated: cell_pos == cell_anchor
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:95
14-95
633 t = 0;
executed: t = 0;
Execution Count:14
14
634 }
executed: }
Execution Count:109
109
635 return t;
executed: return t;
Execution Count:2259
2259
636} -
637 -
638void QTextCursorPrivate::selectedTableCells(int *firstRow, int *numRows, int *firstColumn, int *numColumns) const -
639{ -
640 *firstRow = -1; -
641 *firstColumn = -1; -
642 *numRows = -1; -
643 *numColumns = -1; -
644 -
645 if (position == anchor)
partially evaluated: position == anchor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
646 return;
never executed: return;
0
647 -
648 QTextTable *t = qobject_cast<QTextTable *>(priv->frameAt(position)); -
649 if (!t)
partially evaluated: !t
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
650 return;
never executed: return;
0
651 -
652 QTextTableCell cell_pos = t->cellAt(position); -
653 QTextTableCell cell_anchor = t->cellAt(adjusted_anchor); -
654 -
655 qt_noop(); -
656 -
657 if (cell_pos == cell_anchor)
partially evaluated: cell_pos == cell_anchor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
658 return;
never executed: return;
0
659 -
660 *firstRow = qMin(cell_pos.row(), cell_anchor.row()); -
661 *firstColumn = qMin(cell_pos.column(), cell_anchor.column()); -
662 *numRows = qMax(cell_pos.row() + cell_pos.rowSpan(), cell_anchor.row() + cell_anchor.rowSpan()) - *firstRow; -
663 *numColumns = qMax(cell_pos.column() + cell_pos.columnSpan(), cell_anchor.column() + cell_anchor.columnSpan()) - *firstColumn; -
664}
executed: }
Execution Count:9
9
665 -
666static void setBlockCharFormatHelper(QTextDocumentPrivate *priv, int pos1, int pos2, -
667 const QTextCharFormat &format, QTextDocumentPrivate::FormatChangeMode changeMode) -
668{ -
669 QTextBlock it = priv->blocksFind(pos1); -
670 QTextBlock end = priv->blocksFind(pos2); -
671 if (end.isValid())
partially evaluated: end.isValid()
TRUEFALSE
yes
Evaluation Count:1285
no
Evaluation Count:0
0-1285
672 end = end.next();
executed: end = end.next();
Execution Count:1285
1285
673 -
674 for (; it != end; it = it.next()) {
evaluated: it != end
TRUEFALSE
yes
Evaluation Count:1286
yes
Evaluation Count:1285
1285-1286
675 priv->setCharFormat(it.position() - 1, 1, format, changeMode); -
676 }
executed: }
Execution Count:1286
1286
677}
executed: }
Execution Count:1285
1285
678 -
679void QTextCursorPrivate::setBlockCharFormat(const QTextCharFormat &_format, -
680 QTextDocumentPrivate::FormatChangeMode changeMode) -
681{ -
682 priv->beginEditBlock(); -
683 -
684 QTextCharFormat format = _format; -
685 format.clearProperty(QTextFormat::ObjectIndex); -
686 -
687 QTextTable *table = complexSelectionTable(); -
688 if (table) {
partially evaluated: table
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1285
0-1285
689 int row_start, col_start, num_rows, num_cols; -
690 selectedTableCells(&row_start, &num_rows, &col_start, &num_cols); -
691 -
692 qt_noop(); -
693 for (int r = row_start; r < row_start + num_rows; ++r) {
never evaluated: r < row_start + num_rows
0
694 for (int c = col_start; c < col_start + num_cols; ++c) {
never evaluated: c < col_start + num_cols
0
695 QTextTableCell cell = table->cellAt(r, c); -
696 int rspan = cell.rowSpan(); -
697 int cspan = cell.columnSpan(); -
698 if (rspan != 1) {
never evaluated: rspan != 1
0
699 int cr = cell.row(); -
700 if (cr != r)
never evaluated: cr != r
0
701 continue;
never executed: continue;
0
702 }
never executed: }
0
703 if (cspan != 1) {
never evaluated: cspan != 1
0
704 int cc = cell.column(); -
705 if (cc != c)
never evaluated: cc != c
0
706 continue;
never executed: continue;
0
707 }
never executed: }
0
708 -
709 int pos1 = cell.firstPosition(); -
710 int pos2 = cell.lastPosition(); -
711 setBlockCharFormatHelper(priv, pos1, pos2, format, changeMode); -
712 }
never executed: }
0
713 }
never executed: }
0
714 } else {
never executed: }
0
715 int pos1 = position; -
716 int pos2 = adjusted_anchor; -
717 if (pos1 > pos2) {
evaluated: pos1 > pos2
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1283
2-1283
718 pos1 = adjusted_anchor; -
719 pos2 = position; -
720 }
executed: }
Execution Count:2
2
721 -
722 setBlockCharFormatHelper(priv, pos1, pos2, format, changeMode); -
723 }
executed: }
Execution Count:1285
1285
724 priv->endEditBlock(); -
725}
executed: }
Execution Count:1285
1285
726 -
727 -
728void QTextCursorPrivate::setBlockFormat(const QTextBlockFormat &format, QTextDocumentPrivate::FormatChangeMode changeMode) -
729{ -
730 QTextTable *table = complexSelectionTable(); -
731 if (table) {
partially evaluated: table
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:982
0-982
732 priv->beginEditBlock(); -
733 int row_start, col_start, num_rows, num_cols; -
734 selectedTableCells(&row_start, &num_rows, &col_start, &num_cols); -
735 -
736 qt_noop(); -
737 for (int r = row_start; r < row_start + num_rows; ++r) {
never evaluated: r < row_start + num_rows
0
738 for (int c = col_start; c < col_start + num_cols; ++c) {
never evaluated: c < col_start + num_cols
0
739 QTextTableCell cell = table->cellAt(r, c); -
740 int rspan = cell.rowSpan(); -
741 int cspan = cell.columnSpan(); -
742 if (rspan != 1) {
never evaluated: rspan != 1
0
743 int cr = cell.row(); -
744 if (cr != r)
never evaluated: cr != r
0
745 continue;
never executed: continue;
0
746 }
never executed: }
0
747 if (cspan != 1) {
never evaluated: cspan != 1
0
748 int cc = cell.column(); -
749 if (cc != c)
never evaluated: cc != c
0
750 continue;
never executed: continue;
0
751 }
never executed: }
0
752 -
753 int pos1 = cell.firstPosition(); -
754 int pos2 = cell.lastPosition(); -
755 priv->setBlockFormat(priv->blocksFind(pos1), priv->blocksFind(pos2), format, changeMode); -
756 }
never executed: }
0
757 }
never executed: }
0
758 priv->endEditBlock(); -
759 } else {
never executed: }
0
760 int pos1 = position; -
761 int pos2 = adjusted_anchor; -
762 if (pos1 > pos2) {
evaluated: pos1 > pos2
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:981
1-981
763 pos1 = adjusted_anchor; -
764 pos2 = position; -
765 }
executed: }
Execution Count:1
1
766 -
767 priv->setBlockFormat(priv->blocksFind(pos1), priv->blocksFind(pos2), format, changeMode); -
768 }
executed: }
Execution Count:982
982
769} -
770 -
771void QTextCursorPrivate::setCharFormat(const QTextCharFormat &_format, QTextDocumentPrivate::FormatChangeMode changeMode) -
772{ -
773 qt_noop(); -
774 -
775 QTextCharFormat format = _format; -
776 format.clearProperty(QTextFormat::ObjectIndex); -
777 -
778 QTextTable *table = complexSelectionTable(); -
779 if (table) {
partially evaluated: table
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:201
0-201
780 priv->beginEditBlock(); -
781 int row_start, col_start, num_rows, num_cols; -
782 selectedTableCells(&row_start, &num_rows, &col_start, &num_cols); -
783 -
784 qt_noop(); -
785 for (int r = row_start; r < row_start + num_rows; ++r) {
never evaluated: r < row_start + num_rows
0
786 for (int c = col_start; c < col_start + num_cols; ++c) {
never evaluated: c < col_start + num_cols
0
787 QTextTableCell cell = table->cellAt(r, c); -
788 int rspan = cell.rowSpan(); -
789 int cspan = cell.columnSpan(); -
790 if (rspan != 1) {
never evaluated: rspan != 1
0
791 int cr = cell.row(); -
792 if (cr != r)
never evaluated: cr != r
0
793 continue;
never executed: continue;
0
794 }
never executed: }
0
795 if (cspan != 1) {
never evaluated: cspan != 1
0
796 int cc = cell.column(); -
797 if (cc != c)
never evaluated: cc != c
0
798 continue;
never executed: continue;
0
799 }
never executed: }
0
800 -
801 int pos1 = cell.firstPosition(); -
802 int pos2 = cell.lastPosition(); -
803 priv->setCharFormat(pos1, pos2-pos1, format, changeMode); -
804 }
never executed: }
0
805 }
never executed: }
0
806 priv->endEditBlock(); -
807 } else {
never executed: }
0
808 int pos1 = position; -
809 int pos2 = adjusted_anchor; -
810 if (pos1 > pos2) {
evaluated: pos1 > pos2
TRUEFALSE
yes
Evaluation Count:177
yes
Evaluation Count:24
24-177
811 pos1 = adjusted_anchor; -
812 pos2 = position; -
813 }
executed: }
Execution Count:177
177
814 -
815 priv->setCharFormat(pos1, pos2-pos1, format, changeMode); -
816 }
executed: }
Execution Count:201
201
817} -
818 -
819 -
820QTextLayout *QTextCursorPrivate::blockLayout(QTextBlock &block) const{ -
821 QTextLayout *tl = block.layout(); -
822 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
823 priv->layout()->blockBoundingRect(block);
executed: priv->layout()->blockBoundingRect(block);
Execution Count:11248
11248
824 return tl;
executed: return tl;
Execution Count:18713
18713
825} -
826QTextCursor::QTextCursor() -
827 : d(0) -
828{ -
829}
executed: }
Execution Count:5339
5339
830 -
831 -
832 -
833 -
834QTextCursor::QTextCursor(QTextDocument *document) -
835 : d(new QTextCursorPrivate(document->docHandle())) -
836{ -
837}
executed: }
Execution Count:3905
3905
838 -
839 -
840 -
841 -
842QTextCursor::QTextCursor(QTextFrame *frame) -
843 : d(new QTextCursorPrivate(frame->document()->docHandle())) -
844{ -
845 d->adjusted_anchor = d->anchor = d->position = frame->firstPosition(); -
846}
executed: }
Execution Count:1
1
847 -
848 -
849 -
850 -
851 -
852QTextCursor::QTextCursor(const QTextBlock &block) -
853 : d(new QTextCursorPrivate(block.docHandle())) -
854{ -
855 d->adjusted_anchor = d->anchor = d->position = block.position(); -
856}
executed: }
Execution Count:4
4
857 -
858 -
859 -
860 -
861 -
862QTextCursor::QTextCursor(QTextDocumentPrivate *p, int pos) -
863 : d(new QTextCursorPrivate(p)) -
864{ -
865 d->adjusted_anchor = d->anchor = d->position = pos; -
866 -
867 d->setX(); -
868}
executed: }
Execution Count:1347
1347
869 -
870 -
871 -
872 -
873QTextCursor::QTextCursor(QTextCursorPrivate *d) -
874{ -
875 qt_noop(); -
876 this->d = d; -
877}
executed: }
Execution Count:16784
16784
878 -
879 -
880 -
881 -
882QTextCursor::QTextCursor(const QTextCursor &cursor) -
883{ -
884 d = cursor.d; -
885}
executed: }
Execution Count:18080
18080
886 -
887 -
888 -
889 -
890 -
891 -
892 -
893QTextCursor &QTextCursor::operator=(const QTextCursor &cursor) -
894{ -
895 d = cursor.d; -
896 return *this;
executed: return *this;
Execution Count:4164
4164
897} -
898QTextCursor::~QTextCursor() -
899{ -
900} -
901 -
902 -
903 -
904 -
905 -
906bool QTextCursor::isNull() const -
907{ -
908 return !d || !d->priv;
executed: return !d || !d->priv;
Execution Count:2295
2295
909} -
910void QTextCursor::setPosition(int pos, MoveMode m) -
911{ -
912 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
913 return;
never executed: return;
0
914 -
915 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
916 QMessageLogger("text/qtextcursor.cpp", 1158, __PRETTY_FUNCTION__).warning("QTextCursor::setPosition: Position '%d' out of range", pos); -
917 return;
never executed: return;
0
918 } -
919 -
920 d->setPosition(pos); -
921 if (m == MoveAnchor) {
evaluated: m == MoveAnchor
TRUEFALSE
yes
Evaluation Count:464
yes
Evaluation Count:144
144-464
922 d->anchor = pos; -
923 d->adjusted_anchor = pos; -
924 } else {
executed: }
Execution Count:464
464
925 QTextCursor::MoveOperation op; -
926 if (pos < d->anchor)
evaluated: pos < d->anchor
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:122
22-122
927 op = QTextCursor::Left;
executed: op = QTextCursor::Left;
Execution Count:22
22
928 else -
929 op = QTextCursor::Right;
executed: op = QTextCursor::Right;
Execution Count:122
122
930 d->adjustCursor(op); -
931 }
executed: }
Execution Count:144
144
932 d->setX(); -
933}
executed: }
Execution Count:608
608
934 -
935 -
936 -
937 -
938 -
939 -
940 -
941int QTextCursor::position() const -
942{ -
943 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
944 return -1;
executed: return -1;
Execution Count:473
473
945 return d->position;
executed: return d->position;
Execution Count:10757
10757
946} -
947int QTextCursor::positionInBlock() const -
948{ -
949 if (!d || !d->priv)
never evaluated: !d
never evaluated: !d->priv
0
950 return 0;
never executed: return 0;
0
951 return d->position - d->block().position();
never executed: return d->position - d->block().position();
0
952} -
953int QTextCursor::anchor() const -
954{ -
955 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
956 return -1;
executed: return -1;
Execution Count:241
241
957 return d->anchor;
executed: return d->anchor;
Execution Count:1554
1554
958} -
959bool QTextCursor::movePosition(MoveOperation op, MoveMode mode, int n) -
960{ -
961 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
962 return false;
never executed: return false;
0
963 switch (op) { -
964 case Start: -
965 case StartOfLine: -
966 case End: -
967 case EndOfLine: -
968 n = 1; -
969 break;
executed: break;
Execution Count:1247
1247
970 default: break;
executed: break;
Execution Count:1525
1525
971 } -
972 -
973 int previousPosition = d->position; -
974 for (; n > 0; --n) {
evaluated: n > 0
TRUEFALSE
yes
Evaluation Count:2898
yes
Evaluation Count:2630
2630-2898
975 if (!d->movePosition(op, mode))
evaluated: !d->movePosition(op, mode)
TRUEFALSE
yes
Evaluation Count:142
yes
Evaluation Count:2756
142-2756
976 return false;
executed: return false;
Execution Count:142
142
977 }
executed: }
Execution Count:2756
2756
978 -
979 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
980 QTextBlock b = d->block(); -
981 if (previousPosition < d->position) {
never evaluated: previousPosition < d->position
0
982 while (!b.next().isVisible())
never evaluated: !b.next().isVisible()
0
983 b = b.next();
never executed: b = b.next();
0
984 d->setPosition(b.position() + b.length() - 1); -
985 } else {
never executed: }
0
986 while (!b.previous().isVisible())
never evaluated: !b.previous().isVisible()
0
987 b = b.previous();
never executed: b = b.previous();
0
988 d->setPosition(b.position()); -
989 }
never executed: }
0
990 if (mode == QTextCursor::MoveAnchor)
never evaluated: mode == QTextCursor::MoveAnchor
0
991 d->anchor = d->position;
never executed: d->anchor = d->position;
0
992 while (d->movePosition(op, mode)
never evaluated: d->movePosition(op, mode)
0
993 && !d->block().isVisible())
never evaluated: !d->block().isVisible()
0
994 ;
never executed: ;
0
995 -
996 }
never executed: }
0
997 return true;
executed: return true;
Execution Count:2630
2630
998} -
999bool QTextCursor::visualNavigation() const -
1000{ -
1001 return d ? d->visualNavigation : false;
executed: return d ? d->visualNavigation : false;
Execution Count:34
34
1002} -
1003void QTextCursor::setVisualNavigation(bool b) -
1004{ -
1005 if (d)
partially evaluated: d
TRUEFALSE
yes
Evaluation Count:68
no
Evaluation Count:0
0-68
1006 d->visualNavigation = b;
executed: d->visualNavigation = b;
Execution Count:68
68
1007}
executed: }
Execution Count:68
68
1008void QTextCursor::setVerticalMovementX(int x) -
1009{ -
1010 if (d)
never evaluated: d
0
1011 d->x = x;
never executed: d->x = x;
0
1012}
never executed: }
0
1013int QTextCursor::verticalMovementX() const -
1014{ -
1015 return d ? d->x : -1;
never executed: return d ? d->x : -1;
0
1016} -
1017bool QTextCursor::keepPositionOnInsert() const -
1018{ -
1019 return d ? d->keepPositionOnInsert : false;
never executed: return d ? d->keepPositionOnInsert : false;
0
1020} -
1021void QTextCursor::setKeepPositionOnInsert(bool b) -
1022{ -
1023 if (d)
partially evaluated: d
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1024 d->keepPositionOnInsert = b;
executed: d->keepPositionOnInsert = b;
Execution Count:2
2
1025}
executed: }
Execution Count:2
2
1026void QTextCursor::insertText(const QString &text) -
1027{ -
1028 QTextCharFormat fmt = charFormat(); -
1029 fmt.clearProperty(QTextFormat::ObjectType); -
1030 insertText(text, fmt); -
1031}
executed: }
Execution Count:1738
1738
1032 -
1033 -
1034 -
1035 -
1036 -
1037 -
1038 -
1039void QTextCursor::insertText(const QString &text, const QTextCharFormat &_format) -
1040{ -
1041 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
1042 return;
never executed: return;
0
1043 -
1044 qt_noop(); -
1045 -
1046 QTextCharFormat format = _format; -
1047 format.clearProperty(QTextFormat::ObjectIndex); -
1048 -
1049 bool hasEditBlock = false; -
1050 -
1051 if (d->anchor != d->position) {
evaluated: d->anchor != d->position
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:2958
6-2958
1052 hasEditBlock = true; -
1053 d->priv->beginEditBlock(); -
1054 d->remove(); -
1055 }
executed: }
Execution Count:6
6
1056 -
1057 if (!text.isEmpty()) {
evaluated: !text.isEmpty()
TRUEFALSE
yes
Evaluation Count:2958
yes
Evaluation Count:6
6-2958
1058 QTextFormatCollection *formats = d->priv->formatCollection(); -
1059 int formatIdx = formats->indexForFormat(format); -
1060 qt_noop(); -
1061 -
1062 QTextBlockFormat blockFmt = blockFormat(); -
1063 -
1064 -
1065 int textStart = d->priv->text.length(); -
1066 int blockStart = 0; -
1067 d->priv->text += text; -
1068 int textEnd = d->priv->text.length(); -
1069 -
1070 for (int i = 0; i < text.length(); ++i) {
evaluated: i < text.length()
TRUEFALSE
yes
Evaluation Count:678486
yes
Evaluation Count:2958
2958-678486
1071 QChar ch = text.at(i); -
1072 -
1073 const int blockEnd = i; -
1074 -
1075 if (ch == QLatin1Char('\r')
evaluated: ch == QLatin1Char('\r')
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:678483
3-678483
1076 && (i + 1) < text.length()
partially evaluated: (i + 1) < text.length()
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
1077 && text.at(i + 1) == QLatin1Char('\n')) {
evaluated: text.at(i + 1) == QLatin1Char('\n')
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
1078 ++i; -
1079 ch = text.at(i); -
1080 }
executed: }
Execution Count:2
2
1081 -
1082 if (ch == QLatin1Char('\n')
evaluated: ch == QLatin1Char('\n')
TRUEFALSE
yes
Evaluation Count:2879
yes
Evaluation Count:675607
2879-675607
1083 || ch == QChar::ParagraphSeparator
evaluated: ch == QChar::ParagraphSeparator
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:675596
11-675596
1084 || ch == QChar(0xfdd0)
partially evaluated: ch == QChar(0xfdd0)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:675596
0-675596
1085 || ch == QChar(0xfdd1)
partially evaluated: ch == QChar(0xfdd1)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:675596
0-675596
1086 || ch == QLatin1Char('\r')) {
evaluated: ch == QLatin1Char('\r')
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:675595
1-675595
1087 -
1088 if (!hasEditBlock) {
evaluated: !hasEditBlock
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:2845
46-2845
1089 hasEditBlock = true; -
1090 d->priv->beginEditBlock(); -
1091 }
executed: }
Execution Count:46
46
1092 -
1093 if (blockEnd > blockStart)
evaluated: blockEnd > blockStart
TRUEFALSE
yes
Evaluation Count:2881
yes
Evaluation Count:10
10-2881
1094 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
1095 -
1096 d->insertBlock(blockFmt, format); -
1097 blockStart = i + 1; -
1098 }
executed: }
Execution Count:2891
2891
1099 }
executed: }
Execution Count:678486
678486
1100 if (textStart + blockStart < textEnd)
evaluated: textStart + blockStart < textEnd
TRUEFALSE
yes
Evaluation Count:2941
yes
Evaluation Count:17
17-2941
1101 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
1102 }
executed: }
Execution Count:2958
2958
1103 if (hasEditBlock)
evaluated: hasEditBlock
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:2912
52-2912
1104 d->priv->endEditBlock();
executed: d->priv->endEditBlock();
Execution Count:52
52
1105 d->setX(); -
1106}
executed: }
Execution Count:2964
2964
1107 -
1108 -
1109 -
1110 -
1111 -
1112 -
1113 -
1114void QTextCursor::deleteChar() -
1115{ -
1116 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
1117 return;
never executed: return;
0
1118 -
1119 if (d->position != d->anchor) {
evaluated: d->position != d->anchor
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:8
8-12
1120 removeSelectedText(); -
1121 return;
executed: return;
Execution Count:12
12
1122 } -
1123 -
1124 if (!d->canDelete(d->position))
evaluated: !d->canDelete(d->position)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:6
2-6
1125 return;
executed: return;
Execution Count:2
2
1126 d->adjusted_anchor = d->anchor = -
1127 d->priv->nextCursorPosition(d->anchor, QTextLayout::SkipCharacters); -
1128 d->remove(); -
1129 d->setX(); -
1130}
executed: }
Execution Count:6
6
1131 -
1132 -
1133 -
1134 -
1135 -
1136 -
1137 -
1138void QTextCursor::deletePreviousChar() -
1139{ -
1140 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
1141 return;
never executed: return;
0
1142 -
1143 if (d->position != d->anchor) {
partially evaluated: d->position != d->anchor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
1144 removeSelectedText(); -
1145 return;
never executed: return;
0
1146 } -
1147 -
1148 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
1149 return;
executed: return;
Execution Count:1
1
1150 d->anchor--; -
1151 -
1152 QTextDocumentPrivate::FragmentIterator fragIt = d->priv->find(d->anchor); -
1153 const QTextFragmentData * const frag = fragIt.value(); -
1154 int fpos = fragIt.position(); -
1155 QChar uc = d->priv->buffer().at(d->anchor - fpos + frag->stringPosition); -
1156 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
1157 -
1158 -
1159 uc = d->priv->buffer().at(d->anchor - 1 - fpos + frag->stringPosition); -
1160 if (uc.isHighSurrogate())
never evaluated: uc.isHighSurrogate()
0
1161 --d->anchor;
never executed: --d->anchor;
0
1162 }
never executed: }
0
1163 -
1164 d->adjusted_anchor = d->anchor; -
1165 d->remove(); -
1166 d->setX(); -
1167}
executed: }
Execution Count:14
14
1168 -
1169 -
1170 -
1171 -
1172void QTextCursor::select(SelectionType selection) -
1173{ -
1174 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
1175 return;
never executed: return;
0
1176 -
1177 clearSelection(); -
1178 -
1179 const QTextBlock block = d->block(); -
1180 -
1181 switch (selection) { -
1182 case LineUnderCursor: -
1183 movePosition(StartOfLine); -
1184 movePosition(EndOfLine, KeepAnchor); -
1185 break;
executed: break;
Execution Count:1
1
1186 case WordUnderCursor: -
1187 movePosition(StartOfWord); -
1188 movePosition(EndOfWord, KeepAnchor); -
1189 break;
executed: break;
Execution Count:29
29
1190 case BlockUnderCursor: -
1191 if (block.length() == 1)
partially evaluated: block.length() == 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1192 break;
never executed: break;
0
1193 movePosition(StartOfBlock); -
1194 -
1195 if (movePosition(PreviousBlock)) {
partially evaluated: movePosition(PreviousBlock)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1196 movePosition(EndOfBlock); -
1197 movePosition(NextBlock, KeepAnchor); -
1198 }
executed: }
Execution Count:1
1
1199 movePosition(EndOfBlock, KeepAnchor); -
1200 break;
executed: break;
Execution Count:1
1
1201 case Document: -
1202 movePosition(Start); -
1203 movePosition(End, KeepAnchor); -
1204 break;
executed: break;
Execution Count:173
173
1205 } -
1206}
executed: }
Execution Count:204
204
1207 -
1208 -
1209 -
1210 -
1211bool QTextCursor::hasSelection() const -
1212{ -
1213 return !!d && d->position != d->anchor;
executed: return !!d && d->position != d->anchor;
Execution Count:3178
3178
1214} -
1215bool QTextCursor::hasComplexSelection() const -
1216{ -
1217 if (!d)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1159
0-1159
1218 return false;
never executed: return false;
0
1219 -
1220 return d->complexSelectionTable() != 0;
executed: return d->complexSelectionTable() != 0;
Execution Count:1159
1159
1221} -
1222void QTextCursor::selectedTableCells(int *firstRow, int *numRows, int *firstColumn, int *numColumns) const -
1223{ -
1224 *firstRow = -1; -
1225 *firstColumn = -1; -
1226 *numRows = -1; -
1227 *numColumns = -1; -
1228 -
1229 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
1230 return;
never executed: return;
0
1231 -
1232 d->selectedTableCells(firstRow, numRows, firstColumn, numColumns); -
1233}
executed: }
Execution Count:7
7
1234void QTextCursor::clearSelection() -
1235{ -
1236 if (!d)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:229
0-229
1237 return;
never executed: return;
0
1238 d->adjusted_anchor = d->anchor = d->position; -
1239 d->currentCharFormat = -1; -
1240}
executed: }
Execution Count:229
229
1241 -
1242 -
1243 -
1244 -
1245 -
1246 -
1247 -
1248void QTextCursor::removeSelectedText() -
1249{ -
1250 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
1251 return;
never executed: return;
0
1252 -
1253 d->priv->beginEditBlock(); -
1254 d->remove(); -
1255 d->priv->endEditBlock(); -
1256 d->setX(); -
1257}
executed: }
Execution Count:936
936
1258 -
1259 -
1260 -
1261 -
1262 -
1263 -
1264 -
1265int QTextCursor::selectionStart() const -
1266{ -
1267 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
1268 return -1;
never executed: return -1;
0
1269 return qMin(d->position, d->adjusted_anchor);
executed: return qMin(d->position, d->adjusted_anchor);
Execution Count:2244
2244
1270} -
1271 -
1272 -
1273 -
1274 -
1275 -
1276 -
1277 -
1278int QTextCursor::selectionEnd() const -
1279{ -
1280 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
1281 return -1;
never executed: return -1;
0
1282 return qMax(d->position, d->adjusted_anchor);
executed: return qMax(d->position, d->adjusted_anchor);
Execution Count:1783
1783
1283} -
1284 -
1285static void getText(QString &text, QTextDocumentPrivate *priv, const QString &docText, int pos, int end) -
1286{ -
1287 while (pos < end) {
evaluated: pos < end
TRUEFALSE
yes
Evaluation Count:79
yes
Evaluation Count:74
74-79
1288 QTextDocumentPrivate::FragmentIterator fragIt = priv->find(pos); -
1289 const QTextFragmentData * const frag = fragIt.value(); -
1290 -
1291 const int offsetInFragment = qMax(0, pos - fragIt.position()); -
1292 const int len = qMin(int(frag->size_array[0] - offsetInFragment), end - pos); -
1293 -
1294 text += QString(docText.constData() + frag->stringPosition + offsetInFragment, len); -
1295 pos += len; -
1296 }
executed: }
Execution Count:79
79
1297}
executed: }
Execution Count:74
74
1298QString QTextCursor::selectedText() const -
1299{ -
1300 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
1301 return QString();
executed: return QString();
Execution Count:4
4
1302 -
1303 const QString docText = d->priv->buffer(); -
1304 QString text; -
1305 -
1306 QTextTable *table = d->complexSelectionTable(); -
1307 if (table) {
partially evaluated: table
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:74
0-74
1308 int row_start, col_start, num_rows, num_cols; -
1309 selectedTableCells(&row_start, &num_rows, &col_start, &num_cols); -
1310 -
1311 qt_noop(); -
1312 for (int r = row_start; r < row_start + num_rows; ++r) {
never evaluated: r < row_start + num_rows
0
1313 for (int c = col_start; c < col_start + num_cols; ++c) {
never evaluated: c < col_start + num_cols
0
1314 QTextTableCell cell = table->cellAt(r, c); -
1315 int rspan = cell.rowSpan(); -
1316 int cspan = cell.columnSpan(); -
1317 if (rspan != 1) {
never evaluated: rspan != 1
0
1318 int cr = cell.row(); -
1319 if (cr != r)
never evaluated: cr != r
0
1320 continue;
never executed: continue;
0
1321 }
never executed: }
0
1322 if (cspan != 1) {
never evaluated: cspan != 1
0
1323 int cc = cell.column(); -
1324 if (cc != c)
never evaluated: cc != c
0
1325 continue;
never executed: continue;
0
1326 }
never executed: }
0
1327 -
1328 getText(text, d->priv, docText, cell.firstPosition(), cell.lastPosition()); -
1329 }
never executed: }
0
1330 }
never executed: }
0
1331 } else {
never executed: }
0
1332 getText(text, d->priv, docText, selectionStart(), selectionEnd()); -
1333 }
executed: }
Execution Count:74
74
1334 -
1335 return text;
executed: return text;
Execution Count:74
74
1336} -
1337QTextDocumentFragment QTextCursor::selection() const -
1338{ -
1339 return QTextDocumentFragment(*this);
executed: return QTextDocumentFragment(*this);
Execution Count:19
19
1340} -
1341 -
1342 -
1343 -
1344 -
1345QTextBlock QTextCursor::block() const -
1346{ -
1347 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
1348 return QTextBlock();
executed: return QTextBlock();
Execution Count:62
62
1349 return d->block();
executed: return d->block();
Execution Count:666
666
1350} -
1351 -
1352 -
1353 -
1354 -
1355 -
1356 -
1357QTextBlockFormat QTextCursor::blockFormat() const -
1358{ -
1359 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
1360 return QTextBlockFormat();
never executed: return QTextBlockFormat();
0
1361 -
1362 return d->block().blockFormat();
executed: return d->block().blockFormat();
Execution Count:16100
16100
1363} -
1364 -
1365 -
1366 -
1367 -
1368 -
1369 -
1370 -
1371void QTextCursor::setBlockFormat(const QTextBlockFormat &format) -
1372{ -
1373 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
1374 return;
never executed: return;
0
1375 -
1376 d->setBlockFormat(format, QTextDocumentPrivate::SetFormat); -
1377}
executed: }
Execution Count:851
851
1378void QTextCursor::mergeBlockFormat(const QTextBlockFormat &modifier) -
1379{ -
1380 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
1381 return;
never executed: return;
0
1382 -
1383 d->setBlockFormat(modifier, QTextDocumentPrivate::MergeFormat); -
1384}
executed: }
Execution Count:131
131
1385QTextCharFormat QTextCursor::blockCharFormat() const -
1386{ -
1387 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
1388 return QTextCharFormat();
never executed: return QTextCharFormat();
0
1389 -
1390 return d->block().charFormat();
executed: return d->block().charFormat();
Execution Count:1672
1672
1391} -
1392 -
1393 -
1394 -
1395 -
1396 -
1397 -
1398 -
1399void QTextCursor::setBlockCharFormat(const QTextCharFormat &format) -
1400{ -
1401 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
1402 return;
never executed: return;
0
1403 -
1404 d->setBlockCharFormat(format, QTextDocumentPrivate::SetFormatAndPreserveObjectIndices); -
1405}
executed: }
Execution Count:1273
1273
1406void QTextCursor::mergeBlockCharFormat(const QTextCharFormat &modifier) -
1407{ -
1408 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
1409 return;
never executed: return;
0
1410 -
1411 d->setBlockCharFormat(modifier, QTextDocumentPrivate::MergeFormat); -
1412}
executed: }
Execution Count:12
12
1413QTextCharFormat QTextCursor::charFormat() const -
1414{ -
1415 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
1416 return QTextCharFormat();
executed: return QTextCharFormat();
Execution Count:618
618
1417 -
1418 int idx = d->currentCharFormat; -
1419 if (idx == -1) {
evaluated: idx == -1
TRUEFALSE
yes
Evaluation Count:15205
yes
Evaluation Count:1011
1011-15205
1420 QTextBlock block = d->block(); -
1421 -
1422 int pos; -
1423 if (d->position == block.position()
evaluated: d->position == block.position()
TRUEFALSE
yes
Evaluation Count:13521
yes
Evaluation Count:1684
1684-13521
1424 && block.length() > 1)
evaluated: block.length() > 1
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:13481
40-13481
1425 pos = d->position;
executed: pos = d->position;
Execution Count:40
40
1426 else -
1427 pos = d->position - 1;
executed: pos = d->position - 1;
Execution Count:15165
15165
1428 -
1429 if (pos == -1) {
evaluated: pos == -1
TRUEFALSE
yes
Evaluation Count:1279
yes
Evaluation Count:13926
1279-13926
1430 idx = d->priv->blockCharFormatIndex(d->priv->blockMap().firstNode()); -
1431 } else {
executed: }
Execution Count:1279
1279
1432 qt_noop(); -
1433 -
1434 QTextDocumentPrivate::FragmentIterator it = d->priv->find(pos); -
1435 qt_noop(); -
1436 idx = it.value()->format; -
1437 }
executed: }
Execution Count:13926
13926
1438 } -
1439 -
1440 QTextCharFormat cfmt = d->priv->formatCollection()->charFormat(idx); -
1441 cfmt.clearProperty(QTextFormat::ObjectIndex); -
1442 -
1443 qt_noop(); -
1444 return cfmt;
executed: return cfmt;
Execution Count:16216
16216
1445} -
1446void QTextCursor::setCharFormat(const QTextCharFormat &format) -
1447{ -
1448 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
1449 return;
never executed: return;
0
1450 if (d->position == d->anchor) {
evaluated: d->position == d->anchor
TRUEFALSE
yes
Evaluation Count:674
yes
Evaluation Count:163
163-674
1451 d->currentCharFormat = d->priv->formatCollection()->indexForFormat(format); -
1452 return;
executed: return;
Execution Count:674
674
1453 } -
1454 d->setCharFormat(format, QTextDocumentPrivate::SetFormatAndPreserveObjectIndices); -
1455}
executed: }
Execution Count:163
163
1456void QTextCursor::mergeCharFormat(const QTextCharFormat &modifier) -
1457{ -
1458 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
1459 return;
never executed: return;
0
1460 if (d->position == d->anchor) {
evaluated: d->position == d->anchor
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:38
5-38
1461 QTextCharFormat format = charFormat(); -
1462 format.merge(modifier); -
1463 d->currentCharFormat = d->priv->formatCollection()->indexForFormat(format); -
1464 return;
executed: return;
Execution Count:5
5
1465 } -
1466 -
1467 d->setCharFormat(modifier, QTextDocumentPrivate::MergeFormat); -
1468}
executed: }
Execution Count:38
38
1469 -
1470 -
1471 -
1472 -
1473 -
1474 -
1475 -
1476bool QTextCursor::atBlockStart() const -
1477{ -
1478 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
1479 return false;
never executed: return false;
0
1480 -
1481 return d->position == d->block().position();
executed: return d->position == d->block().position();
Execution Count:21
21
1482} -
1483 -
1484 -
1485 -
1486 -
1487 -
1488 -
1489 -
1490bool QTextCursor::atBlockEnd() const -
1491{ -
1492 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
1493 return false;
never executed: return false;
0
1494 -
1495 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
1496} -
1497 -
1498 -
1499 -
1500 -
1501 -
1502 -
1503 -
1504bool QTextCursor::atStart() const -
1505{ -
1506 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
1507 return false;
never executed: return false;
0
1508 -
1509 return d->position == 0;
executed: return d->position == 0;
Execution Count:2
2
1510} -
1511bool QTextCursor::atEnd() const -
1512{ -
1513 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
1514 return false;
never executed: return false;
0
1515 -
1516 return d->position == d->priv->length() - 1;
executed: return d->position == d->priv->length() - 1;
Execution Count:4
4
1517} -
1518 -
1519 -
1520 -
1521 -
1522 -
1523 -
1524 -
1525void QTextCursor::insertBlock() -
1526{ -
1527 insertBlock(blockFormat()); -
1528}
executed: }
Execution Count:12027
12027
1529void QTextCursor::insertBlock(const QTextBlockFormat &format) -
1530{ -
1531 QTextCharFormat charFmt = charFormat(); -
1532 charFmt.clearProperty(QTextFormat::ObjectType); -
1533 insertBlock(format, charFmt); -
1534}
executed: }
Execution Count:12051
12051
1535void QTextCursor::insertBlock(const QTextBlockFormat &format, const QTextCharFormat &_charFormat) -
1536{ -
1537 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
1538 return;
never executed: return;
0
1539 -
1540 QTextCharFormat charFormat = _charFormat; -
1541 charFormat.clearProperty(QTextFormat::ObjectIndex); -
1542 -
1543 d->priv->beginEditBlock(); -
1544 d->remove(); -
1545 d->insertBlock(format, charFormat); -
1546 d->priv->endEditBlock(); -
1547 d->setX(); -
1548}
executed: }
Execution Count:12208
12208
1549QTextList *QTextCursor::insertList(const QTextListFormat &format) -
1550{ -
1551 insertBlock(); -
1552 return createList(format);
executed: return createList(format);
Execution Count:4
4
1553} -
1554QTextList *QTextCursor::insertList(QTextListFormat::Style style) -
1555{ -
1556 insertBlock(); -
1557 return createList(style);
executed: return createList(style);
Execution Count:16
16
1558} -
1559 -
1560 -
1561 -
1562 -
1563 -
1564 -
1565 -
1566QTextList *QTextCursor::createList(const QTextListFormat &format) -
1567{ -
1568 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
1569 return 0;
never executed: return 0;
0
1570 -
1571 QTextList *list = static_cast<QTextList *>(d->priv->createObject(format)); -
1572 QTextBlockFormat modifier; -
1573 modifier.setObjectIndex(list->objectIndex()); -
1574 mergeBlockFormat(modifier); -
1575 return list;
executed: return list;
Execution Count:68
68
1576} -
1577QTextList *QTextCursor::createList(QTextListFormat::Style style) -
1578{ -
1579 QTextListFormat fmt; -
1580 fmt.setStyle(style); -
1581 return createList(fmt);
executed: return createList(fmt);
Execution Count:16
16
1582} -
1583 -
1584 -
1585 -
1586 -
1587 -
1588 -
1589 -
1590QTextList *QTextCursor::currentList() const -
1591{ -
1592 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
1593 return 0;
never executed: return 0;
0
1594 -
1595 QTextBlockFormat b = blockFormat(); -
1596 QTextObject *o = d->priv->objectForFormat(b); -
1597 return qobject_cast<QTextList *>(o);
executed: return qobject_cast<QTextList *>(o);
Execution Count:104
104
1598} -
1599QTextTable *QTextCursor::insertTable(int rows, int cols) -
1600{ -
1601 return insertTable(rows, cols, QTextTableFormat());
executed: return insertTable(rows, cols, QTextTableFormat());
Execution Count:64
64
1602} -
1603QTextTable *QTextCursor::insertTable(int rows, int cols, const QTextTableFormat &format) -
1604{ -
1605 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
1606 return 0;
never executed: return 0;
0
1607 -
1608 int pos = d->position; -
1609 QTextTable *t = QTextTablePrivate::createTable(d->priv, d->position, rows, cols, format); -
1610 d->setPosition(pos+1); -
1611 -
1612 d->anchor = d->position; -
1613 d->adjusted_anchor = d->anchor; -
1614 return t;
executed: return t;
Execution Count:151
151
1615} -
1616 -
1617 -
1618 -
1619 -
1620 -
1621 -
1622 -
1623QTextTable *QTextCursor::currentTable() const -
1624{ -
1625 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
1626 return 0;
never executed: return 0;
0
1627 -
1628 QTextFrame *frame = d->priv->frameAt(d->position); -
1629 while (frame) {
partially evaluated: frame
TRUEFALSE
yes
Evaluation Count:76
no
Evaluation Count:0
0-76
1630 QTextTable *table = qobject_cast<QTextTable *>(frame); -
1631 if (table)
partially evaluated: table
TRUEFALSE
yes
Evaluation Count:76
no
Evaluation Count:0
0-76
1632 return table;
executed: return table;
Execution Count:76
76
1633 frame = frame->parentFrame(); -
1634 }
never executed: }
0
1635 return 0;
never executed: return 0;
0
1636} -
1637QTextFrame *QTextCursor::insertFrame(const QTextFrameFormat &format) -
1638{ -
1639 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
1640 return 0;
never executed: return 0;
0
1641 -
1642 return d->priv->insertFrame(selectionStart(), selectionEnd(), format);
executed: return d->priv->insertFrame(selectionStart(), selectionEnd(), format);
Execution Count:9
9
1643} -
1644 -
1645 -
1646 -
1647 -
1648 -
1649 -
1650QTextFrame *QTextCursor::currentFrame() const -
1651{ -
1652 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
1653 return 0;
never executed: return 0;
0
1654 -
1655 return d->priv->frameAt(d->position);
executed: return d->priv->frameAt(d->position);
Execution Count:53
53
1656} -
1657 -
1658 -
1659 -
1660 -
1661 -
1662void QTextCursor::insertFragment(const QTextDocumentFragment &fragment) -
1663{ -
1664 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
1665 return;
executed: return;
Execution Count:7
7
1666 -
1667 d->priv->beginEditBlock(); -
1668 d->remove(); -
1669 fragment.d->insert(*this); -
1670 d->priv->endEditBlock(); -
1671 -
1672 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
1673 d->priv->mergeCachedResources(fragment.d->doc->docHandle());
executed: d->priv->mergeCachedResources(fragment.d->doc->docHandle());
Execution Count:551
551
1674}
executed: }
Execution Count:551
551
1675void QTextCursor::insertHtml(const QString &html) -
1676{ -
1677 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
1678 return;
never executed: return;
0
1679 QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(html, d->priv->document()); -
1680 insertFragment(fragment); -
1681}
executed: }
Execution Count:15
15
1682void QTextCursor::insertImage(const QTextImageFormat &format, QTextFrameFormat::Position alignment) -
1683{ -
1684 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
1685 return;
never executed: return;
0
1686 -
1687 QTextFrameFormat ffmt; -
1688 ffmt.setPosition(alignment); -
1689 QTextObject *obj = d->priv->createObject(ffmt); -
1690 -
1691 QTextImageFormat fmt = format; -
1692 fmt.setObjectIndex(obj->objectIndex()); -
1693 -
1694 d->priv->beginEditBlock(); -
1695 d->remove(); -
1696 const int idx = d->priv->formatCollection()->indexForFormat(fmt); -
1697 d->priv->insert(d->position, QString(QChar(QChar::ObjectReplacementCharacter)), idx); -
1698 d->priv->endEditBlock(); -
1699}
executed: }
Execution Count:24
24
1700 -
1701 -
1702 -
1703 -
1704void QTextCursor::insertImage(const QTextImageFormat &format) -
1705{ -
1706 insertText(QString(QChar::ObjectReplacementCharacter), format); -
1707}
executed: }
Execution Count:9
9
1708void QTextCursor::insertImage(const QString &name) -
1709{ -
1710 QTextImageFormat format; -
1711 format.setName(name); -
1712 insertImage(format); -
1713}
executed: }
Execution Count:3
3
1714void QTextCursor::insertImage(const QImage &image, const QString &name) -
1715{ -
1716 if (image.isNull()) {
partially evaluated: image.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1717 QMessageLogger("text/qtextcursor.cpp", 2332, __PRETTY_FUNCTION__).warning("QTextCursor::insertImage: attempt to add an invalid image"); -
1718 return;
never executed: return;
0
1719 } -
1720 QString imageName = name; -
1721 if (name.isEmpty())
partially evaluated: name.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1722 imageName = QString::number(image.cacheKey());
executed: imageName = QString::number(image.cacheKey());
Execution Count:1
1
1723 d->priv->document()->addResource(QTextDocument::ImageResource, QUrl(imageName), image); -
1724 QTextImageFormat format; -
1725 format.setName(imageName); -
1726 insertImage(format); -
1727}
executed: }
Execution Count:1
1
1728 -
1729 -
1730 -
1731 -
1732 -
1733 -
1734 -
1735bool QTextCursor::operator!=(const QTextCursor &rhs) const -
1736{ -
1737 return !operator==(rhs);
executed: return !operator==(rhs);
Execution Count:3
3
1738} -
1739 -
1740 -
1741 -
1742 -
1743 -
1744 -
1745 -
1746bool QTextCursor::operator<(const QTextCursor &rhs) const -
1747{ -
1748 if (!d)
evaluated: !d
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
1749 return !!rhs.d;
executed: return !!rhs.d;
Execution Count:2
2
1750 -
1751 if (!rhs.d)
evaluated: !rhs.d
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
1752 return false;
executed: return false;
Execution Count:1
1
1753 -
1754 qt_noop(); -
1755 -
1756 return d->position < rhs.d->position;
executed: return d->position < rhs.d->position;
Execution Count:1
1
1757} -
1758bool QTextCursor::operator<=(const QTextCursor &rhs) const -
1759{ -
1760 if (!d)
evaluated: !d
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
1761 return true;
executed: return true;
Execution Count:1
1
1762 -
1763 if (!rhs.d)
evaluated: !rhs.d
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
1764 return false;
executed: return false;
Execution Count:1
1
1765 -
1766 qt_noop(); -
1767 -
1768 return d->position <= rhs.d->position;
executed: return d->position <= rhs.d->position;
Execution Count:1
1
1769} -
1770 -
1771 -
1772 -
1773 -
1774 -
1775 -
1776 -
1777bool QTextCursor::operator==(const QTextCursor &rhs) const -
1778{ -
1779 if (!d)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:26
0-26
1780 return !rhs.d;
never executed: return !rhs.d;
0
1781 -
1782 if (!rhs.d)
partially evaluated: !rhs.d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:26
0-26
1783 return false;
never executed: return false;
0
1784 -
1785 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
1786} -
1787bool QTextCursor::operator>=(const QTextCursor &rhs) const -
1788{ -
1789 if (!d)
evaluated: !d
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
1790 return false;
executed: return false;
Execution Count:1
1
1791 -
1792 if (!rhs.d)
evaluated: !rhs.d
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
1793 return true;
executed: return true;
Execution Count:1
1
1794 -
1795 qt_noop(); -
1796 -
1797 return d->position >= rhs.d->position;
executed: return d->position >= rhs.d->position;
Execution Count:1
1
1798} -
1799 -
1800 -
1801 -
1802 -
1803 -
1804 -
1805 -
1806bool QTextCursor::operator>(const QTextCursor &rhs) const -
1807{ -
1808 if (!d)
evaluated: !d
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
1809 return false;
executed: return false;
Execution Count:2
2
1810 -
1811 if (!rhs.d)
evaluated: !rhs.d
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
1812 return true;
executed: return true;
Execution Count:1
1
1813 -
1814 qt_noop(); -
1815 -
1816 return d->position > rhs.d->position;
executed: return d->position > rhs.d->position;
Execution Count:1
1
1817} -
1818void QTextCursor::beginEditBlock() -
1819{ -
1820 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
1821 return;
never executed: return;
0
1822 -
1823 if (d->priv->editBlock == 0)
evaluated: d->priv->editBlock == 0
TRUEFALSE
yes
Evaluation Count:667
yes
Evaluation Count:234
234-667
1824 d->priv->editBlockCursorPosition = d->position;
executed: d->priv->editBlockCursorPosition = d->position;
Execution Count:667
667
1825 -
1826 d->priv->beginEditBlock(); -
1827}
executed: }
Execution Count:901
901
1828void QTextCursor::joinPreviousEditBlock() -
1829{ -
1830 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
1831 return;
never executed: return;
0
1832 -
1833 d->priv->joinPreviousEditBlock(); -
1834}
executed: }
Execution Count:1
1
1835void QTextCursor::endEditBlock() -
1836{ -
1837 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
1838 return;
never executed: return;
0
1839 -
1840 d->priv->endEditBlock(); -
1841}
executed: }
Execution Count:902
902
1842bool QTextCursor::isCopyOf(const QTextCursor &other) const -
1843{ -
1844 return d == other.d;
executed: return d == other.d;
Execution Count:387
387
1845} -
1846int QTextCursor::blockNumber() const -
1847{ -
1848 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
1849 return 0;
executed: return 0;
Execution Count:1
1
1850 -
1851 return d->block().blockNumber();
executed: return d->block().blockNumber();
Execution Count:9
9
1852} -
1853int QTextCursor::columnNumber() const -
1854{ -
1855 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
1856 return 0;
executed: return 0;
Execution Count:1
1
1857 -
1858 QTextBlock block = d->block(); -
1859 if (!block.isValid())
partially evaluated: !block.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
1860 return 0;
never executed: return 0;
0
1861 -
1862 const QTextLayout *layout = d->blockLayout(block); -
1863 -
1864 const int relativePos = d->position - block.position(); -
1865 -
1866 if (layout->lineCount() == 0)
evaluated: layout->lineCount() == 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:4
3-4
1867 return relativePos;
executed: return relativePos;
Execution Count:3
3
1868 -
1869 QTextLine line = layout->lineForTextPosition(relativePos); -
1870 if (!line.isValid())
partially evaluated: !line.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
1871 return 0;
never executed: return 0;
0
1872 return relativePos - line.textStart();
executed: return relativePos - line.textStart();
Execution Count:4
4
1873} -
1874 -
1875 -
1876 -
1877 -
1878 -
1879QTextDocument *QTextCursor::document() const -
1880{ -
1881 if (d->priv)
never evaluated: d->priv
0
1882 return d->priv->document();
never executed: return d->priv->document();
0
1883 return 0;
never executed: return 0;
0
1884} -
1885 -
1886 -
1887 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial