graphicsview/qgraphicsscenebsptreeindex.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8static inline int intmaxlog(int n) -
9{ -
10 return (n > 0 ? qMax(qCeil(qLn(qreal(n)) / qLn(qreal(2))), 5) : 0);
executed: return (n > 0 ? qMax(qCeil(qLn(qreal(n)) / qLn(qreal(2))), 5) : 0);
Execution Count:134
134
11} -
12 -
13 -
14 -
15 -
16QGraphicsSceneBspTreeIndexPrivate::QGraphicsSceneBspTreeIndexPrivate(QGraphicsScene *scene) -
17 : QGraphicsSceneIndexPrivate(scene), -
18 bspTreeDepth(0), -
19 indexTimerId(0), -
20 restartIndexTimer(false), -
21 regenerateIndex(true), -
22 lastItemCount(0), -
23 purgePending(false), -
24 sortCacheEnabled(false), -
25 updatingSortCache(false) -
26{ -
27}
executed: }
Execution Count:233
233
28void QGraphicsSceneBspTreeIndexPrivate::_q_updateIndex() -
29{ -
30 QGraphicsSceneBspTreeIndex * const q = q_func(); -
31 if (!indexTimerId)
evaluated: !indexTimerId
TRUEFALSE
yes
Evaluation Count:129
yes
Evaluation Count:120
120-129
32 return;
executed: return;
Execution Count:129
129
33 -
34 q->killTimer(indexTimerId); -
35 indexTimerId = 0; -
36 -
37 purgeRemovedItems(); -
38 -
39 -
40 for (int i = 0; i < unindexedItems.size(); ++i) {
evaluated: i < unindexedItems.size()
TRUEFALSE
yes
Evaluation Count:374
yes
Evaluation Count:120
120-374
41 if (QGraphicsItem *item = unindexedItems.at(i)) {
partially evaluated: QGraphicsItem *item = unindexedItems.at(i)
TRUEFALSE
yes
Evaluation Count:374
no
Evaluation Count:0
0-374
42 qt_noop(); -
43 if (!freeItemIndexes.isEmpty()) {
evaluated: !freeItemIndexes.isEmpty()
TRUEFALSE
yes
Evaluation Count:84
yes
Evaluation Count:290
84-290
44 int freeIndex = freeItemIndexes.takeFirst(); -
45 item->d_func()->index = freeIndex; -
46 indexedItems[freeIndex] = item; -
47 } else {
executed: }
Execution Count:84
84
48 item->d_func()->index = indexedItems.size(); -
49 indexedItems << item; -
50 }
executed: }
Execution Count:290
290
51 } -
52 }
executed: }
Execution Count:374
374
53 -
54 -
55 if (bspTreeDepth == 0) {
evaluated: bspTreeDepth == 0
TRUEFALSE
yes
Evaluation Count:67
yes
Evaluation Count:53
53-67
56 int oldDepth = intmaxlog(lastItemCount); -
57 bspTreeDepth = intmaxlog(indexedItems.size()); -
58 static const int slack = 100; -
59 if (bsp.leafCount() == 0 || (oldDepth != bspTreeDepth && qAbs(lastItemCount - indexedItems.size()) > slack)) {
partially evaluated: bsp.leafCount() == 0
TRUEFALSE
yes
Evaluation Count:67
no
Evaluation Count:0
never evaluated: oldDepth != bspTreeDepth
never evaluated: qAbs(lastItemCount - indexedItems.size()) > slack
0-67
60 -
61 regenerateIndex = true; -
62 }
executed: }
Execution Count:67
67
63 }
executed: }
Execution Count:67
67
64 -
65 -
66 if (regenerateIndex) {
evaluated: regenerateIndex
TRUEFALSE
yes
Evaluation Count:86
yes
Evaluation Count:34
34-86
67 regenerateIndex = false; -
68 bsp.initialize(sceneRect, bspTreeDepth); -
69 unindexedItems = indexedItems; -
70 lastItemCount = indexedItems.size(); -
71 }
executed: }
Execution Count:86
86
72 -
73 -
74 for (int i = 0; i < unindexedItems.size(); ++i) {
evaluated: i < unindexedItems.size()
TRUEFALSE
yes
Evaluation Count:374
yes
Evaluation Count:120
120-374
75 if (QGraphicsItem *item = unindexedItems.at(i)) {
partially evaluated: QGraphicsItem *item = unindexedItems.at(i)
TRUEFALSE
yes
Evaluation Count:374
no
Evaluation Count:0
0-374
76 if (item->d_ptr->itemIsUntransformable()) {
partially evaluated: item->d_ptr->itemIsUntransformable()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:374
0-374
77 untransformableItems << item; -
78 continue;
never executed: continue;
0
79 } -
80 if (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)
evaluated: item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:373
1-373
81 continue;
executed: continue;
Execution Count:1
1
82 -
83 bsp.insertItem(item, item->d_ptr->sceneEffectiveBoundingRect()); -
84 }
executed: }
Execution Count:373
373
85 }
executed: }
Execution Count:373
373
86 unindexedItems.clear(); -
87}
executed: }
Execution Count:120
120
88 -
89 -
90 -
91 -
92 -
93 -
94 -
95void QGraphicsSceneBspTreeIndexPrivate::purgeRemovedItems() -
96{ -
97 if (!purgePending && removedItems.isEmpty())
evaluated: !purgePending
TRUEFALSE
yes
Evaluation Count:2403
yes
Evaluation Count:2
partially evaluated: removedItems.isEmpty()
TRUEFALSE
yes
Evaluation Count:2403
no
Evaluation Count:0
0-2403
98 return;
executed: return;
Execution Count:2403
2403
99 -
100 -
101 bsp.removeItems(removedItems); -
102 -
103 removedItems.clear(); -
104 freeItemIndexes.clear(); -
105 for (int i = 0; i < indexedItems.size(); ++i) {
evaluated: i < indexedItems.size()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2
2-4
106 if (!indexedItems.at(i))
partially evaluated: !indexedItems.at(i)
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
107 freeItemIndexes << i;
executed: freeItemIndexes << i;
Execution Count:4
4
108 }
executed: }
Execution Count:4
4
109 purgePending = false; -
110}
executed: }
Execution Count:2
2
111 -
112 -
113 -
114 -
115 -
116 -
117void QGraphicsSceneBspTreeIndexPrivate::startIndexTimer(int interval) -
118{ -
119 QGraphicsSceneBspTreeIndex * const q = q_func(); -
120 if (indexTimerId) {
evaluated: indexTimerId
TRUEFALSE
yes
Evaluation Count:1151
yes
Evaluation Count:290
290-1151
121 restartIndexTimer = true; -
122 } else {
executed: }
Execution Count:1151
1151
123 indexTimerId = q->startTimer(interval); -
124 }
executed: }
Execution Count:290
290
125} -
126 -
127 -
128 -
129 -
130void QGraphicsSceneBspTreeIndexPrivate::resetIndex() -
131{ -
132 purgeRemovedItems(); -
133 for (int i = 0; i < indexedItems.size(); ++i) {
evaluated: i < indexedItems.size()
TRUEFALSE
yes
Evaluation Count:72
yes
Evaluation Count:300
72-300
134 if (QGraphicsItem *item = indexedItems.at(i)) {
evaluated: QGraphicsItem *item = indexedItems.at(i)
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:26
26-46
135 item->d_ptr->index = -1; -
136 qt_noop(); -
137 unindexedItems << item; -
138 }
executed: }
Execution Count:46
46
139 }
executed: }
Execution Count:72
72
140 indexedItems.clear(); -
141 freeItemIndexes.clear(); -
142 untransformableItems.clear(); -
143 regenerateIndex = true; -
144 startIndexTimer(); -
145}
executed: }
Execution Count:300
300
146 -
147 -
148 -
149 -
150void QGraphicsSceneBspTreeIndexPrivate::climbTree(QGraphicsItem *item, int *stackingOrder) -
151{ -
152 if (!item->d_ptr->children.isEmpty()) {
never evaluated: !item->d_ptr->children.isEmpty()
0
153 QList<QGraphicsItem *> childList = item->d_ptr->children; -
154 std::sort(childList.begin(), childList.end(), qt_closestLeaf); -
155 for (int i = 0; i < childList.size(); ++i) {
never evaluated: i < childList.size()
0
156 QGraphicsItem *item = childList.at(i); -
157 if (!(item->flags() & QGraphicsItem::ItemStacksBehindParent))
never evaluated: !(item->flags() & QGraphicsItem::ItemStacksBehindParent)
0
158 climbTree(childList.at(i), stackingOrder);
never executed: climbTree(childList.at(i), stackingOrder);
0
159 }
never executed: }
0
160 item->d_ptr->globalStackingOrder = (*stackingOrder)++; -
161 for (int i = 0; i < childList.size(); ++i) {
never evaluated: i < childList.size()
0
162 QGraphicsItem *item = childList.at(i); -
163 if (item->flags() & QGraphicsItem::ItemStacksBehindParent)
never evaluated: item->flags() & QGraphicsItem::ItemStacksBehindParent
0
164 climbTree(childList.at(i), stackingOrder);
never executed: climbTree(childList.at(i), stackingOrder);
0
165 }
never executed: }
0
166 } else {
never executed: }
0
167 item->d_ptr->globalStackingOrder = (*stackingOrder)++; -
168 }
never executed: }
0
169} -
170 -
171 -
172 -
173 -
174void QGraphicsSceneBspTreeIndexPrivate::_q_updateSortCache() -
175{ -
176 QGraphicsSceneBspTreeIndex * const q = q_func(); -
177 _q_updateIndex(); -
178 -
179 if (!sortCacheEnabled || !updatingSortCache)
partially evaluated: !sortCacheEnabled
TRUEFALSE
yes
Evaluation Count:201
no
Evaluation Count:0
never evaluated: !updatingSortCache
0-201
180 return;
executed: return;
Execution Count:201
201
181 -
182 updatingSortCache = false; -
183 int stackingOrder = 0; -
184 -
185 QList<QGraphicsItem *> topLevels; -
186 const QList<QGraphicsItem *> items = q->items(); -
187 for (int i = 0; i < items.size(); ++i) {
never evaluated: i < items.size()
0
188 QGraphicsItem *item = items.at(i); -
189 if (item && !item->d_ptr->parent)
never evaluated: item
never evaluated: !item->d_ptr->parent
0
190 topLevels << item;
never executed: topLevels << item;
0
191 }
never executed: }
0
192 -
193 std::sort(topLevels.begin(), topLevels.end(), qt_closestLeaf); -
194 for (int i = 0; i < topLevels.size(); ++i)
never evaluated: i < topLevels.size()
0
195 climbTree(topLevels.at(i), &stackingOrder);
never executed: climbTree(topLevels.at(i), &stackingOrder);
0
196}
never executed: }
0
197 -
198 -
199 -
200 -
201void QGraphicsSceneBspTreeIndexPrivate::invalidateSortCache() -
202{ -
203 QGraphicsSceneBspTreeIndex * const q = q_func(); -
204 if (!sortCacheEnabled || updatingSortCache)
partially evaluated: !sortCacheEnabled
TRUEFALSE
yes
Evaluation Count:2296
no
Evaluation Count:0
never evaluated: updatingSortCache
0-2296
205 return;
executed: return;
Execution Count:2296
2296
206 -
207 updatingSortCache = true; -
208 QMetaObject::invokeMethod(q, "_q_updateSortCache", Qt::QueuedConnection); -
209}
never executed: }
0
210 -
211void QGraphicsSceneBspTreeIndexPrivate::addItem(QGraphicsItem *item, bool recursive) -
212{ -
213 if (!item)
partially evaluated: !item
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1141
0-1141
214 return;
never executed: return;
0
215 -
216 -
217 purgeRemovedItems(); -
218 -
219 -
220 -
221 item->d_ptr->globalStackingOrder = -1; -
222 invalidateSortCache(); -
223 -
224 -
225 -
226 -
227 if (item->d_ptr->index == -1) {
partially evaluated: item->d_ptr->index == -1
TRUEFALSE
yes
Evaluation Count:1141
no
Evaluation Count:0
0-1141
228 qt_noop(); -
229 unindexedItems << item; -
230 startIndexTimer(0); -
231 } else {
executed: }
Execution Count:1141
1141
232 qt_noop(); -
233 QMessageLogger("graphicsview/qgraphicsscenebsptreeindex.cpp", 325, __PRETTY_FUNCTION__).warning("QGraphicsSceneBspTreeIndex::addItem: item has already been added to this BSP"); -
234 }
never executed: }
0
235 -
236 if (recursive) {
partially evaluated: recursive
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1141
0-1141
237 for (int i = 0; i < item->d_ptr->children.size(); ++i)
never evaluated: i < item->d_ptr->children.size()
0
238 addItem(item->d_ptr->children.at(i), recursive);
never executed: addItem(item->d_ptr->children.at(i), recursive);
0
239 }
never executed: }
0
240}
executed: }
Execution Count:1141
1141
241 -
242void QGraphicsSceneBspTreeIndexPrivate::removeItem(QGraphicsItem *item, bool recursive, -
243 bool moveToUnindexedItems) -
244{ -
245 if (!item)
partially evaluated: !item
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1124
0-1124
246 return;
never executed: return;
0
247 -
248 if (item->d_ptr->index != -1) {
evaluated: item->d_ptr->index != -1
TRUEFALSE
yes
Evaluation Count:169
yes
Evaluation Count:955
169-955
249 qt_noop(); -
250 qt_noop(); -
251 qt_noop(); -
252 freeItemIndexes << item->d_ptr->index; -
253 indexedItems[item->d_ptr->index] = 0; -
254 item->d_ptr->index = -1; -
255 -
256 if (item->d_ptr->itemIsUntransformable()) {
partially evaluated: item->d_ptr->itemIsUntransformable()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:169
0-169
257 untransformableItems.removeOne(item); -
258 } else if (item->d_ptr->inDestructor) {
evaluated: item->d_ptr->inDestructor
TRUEFALSE
yes
Evaluation Count:54
yes
Evaluation Count:115
never executed: }
0-115
259 -
260 purgePending = true; -
261 removedItems << item; -
262 } else if (!(item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)) {
partially evaluated: !(item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)
TRUEFALSE
yes
Evaluation Count:115
no
Evaluation Count:0
executed: }
Execution Count:54
0-115
263 bsp.removeItem(item, item->d_ptr->sceneEffectiveBoundingRect()); -
264 }
executed: }
Execution Count:115
115
265 } else { -
266 unindexedItems.removeOne(item); -
267 }
executed: }
Execution Count:955
955
268 invalidateSortCache(); -
269 -
270 qt_noop(); -
271 qt_noop(); -
272 qt_noop(); -
273 qt_noop(); -
274 -
275 if (moveToUnindexedItems)
evaluated: moveToUnindexedItems
TRUEFALSE
yes
Evaluation Count:123
yes
Evaluation Count:1001
123-1001
276 addItem(item);
executed: addItem(item);
Execution Count:123
123
277 -
278 if (recursive) {
evaluated: recursive
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:1115
9-1115
279 for (int i = 0; i < item->d_ptr->children.size(); ++i)
evaluated: i < item->d_ptr->children.size()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:9
4-9
280 removeItem(item->d_ptr->children.at(i), recursive, moveToUnindexedItems);
executed: removeItem(item->d_ptr->children.at(i), recursive, moveToUnindexedItems);
Execution Count:4
4
281 }
executed: }
Execution Count:9
9
282}
executed: }
Execution Count:1124
1124
283 -
284QList<QGraphicsItem *> QGraphicsSceneBspTreeIndexPrivate::estimateItems(const QRectF &rect, Qt::SortOrder order, -
285 bool onlyTopLevelItems) -
286{ -
287 QGraphicsSceneBspTreeIndex * const q = q_func(); -
288 if (onlyTopLevelItems && rect.isNull())
partially evaluated: onlyTopLevelItems
TRUEFALSE
yes
Evaluation Count:201
no
Evaluation Count:0
partially evaluated: rect.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:201
0-201
289 return q->QGraphicsSceneIndex::estimateTopLevelItems(rect, order);
never executed: return q->QGraphicsSceneIndex::estimateTopLevelItems(rect, order);
0
290 -
291 purgeRemovedItems(); -
292 _q_updateSortCache(); -
293 qt_noop(); -
294 -
295 QList<QGraphicsItem *> rectItems = bsp.items(rect, onlyTopLevelItems); -
296 if (onlyTopLevelItems) {
partially evaluated: onlyTopLevelItems
TRUEFALSE
yes
Evaluation Count:201
no
Evaluation Count:0
0-201
297 for (int i = 0; i < untransformableItems.size(); ++i) {
partially evaluated: i < untransformableItems.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:201
0-201
298 QGraphicsItem *item = untransformableItems.at(i); -
299 if (!item->d_ptr->parent) {
never evaluated: !item->d_ptr->parent
0
300 rectItems << item; -
301 } else {
never executed: }
0
302 item = item->topLevelItem(); -
303 if (!rectItems.contains(item))
never evaluated: !rectItems.contains(item)
0
304 rectItems << item;
never executed: rectItems << item;
0
305 }
never executed: }
0
306 } -
307 } else {
executed: }
Execution Count:201
201
308 rectItems += untransformableItems; -
309 }
never executed: }
0
310 -
311 sortItems(&rectItems, order, sortCacheEnabled, onlyTopLevelItems); -
312 return rectItems;
executed: return rectItems;
Execution Count:201
201
313} -
314 -
315 -
316 -
317 -
318 -
319 -
320void QGraphicsSceneBspTreeIndexPrivate::sortItems(QList<QGraphicsItem *> *itemList, Qt::SortOrder order, -
321 bool sortCacheEnabled, bool onlyTopLevelItems) -
322{ -
323 if (order == Qt::SortOrder(-1))
partially evaluated: order == Qt::SortOrder(-1)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:844
0-844
324 return;
never executed: return;
0
325 -
326 if (onlyTopLevelItems) {
evaluated: onlyTopLevelItems
TRUEFALSE
yes
Evaluation Count:201
yes
Evaluation Count:643
201-643
327 if (order == Qt::DescendingOrder)
partially evaluated: order == Qt::DescendingOrder
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:201
0-201
328 std::sort(itemList->begin(), itemList->end(), qt_closestLeaf);
never executed: std::sort(itemList->begin(), itemList->end(), qt_closestLeaf);
0
329 else if (order == Qt::AscendingOrder)
partially evaluated: order == Qt::AscendingOrder
TRUEFALSE
yes
Evaluation Count:201
no
Evaluation Count:0
0-201
330 std::sort(itemList->begin(), itemList->end(), qt_notclosestLeaf);
executed: std::sort(itemList->begin(), itemList->end(), qt_notclosestLeaf);
Execution Count:201
201
331 return;
executed: return;
Execution Count:201
201
332 } -
333 -
334 if (sortCacheEnabled) {
partially evaluated: sortCacheEnabled
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:643
0-643
335 if (order == Qt::DescendingOrder) {
never evaluated: order == Qt::DescendingOrder
0
336 std::sort(itemList->begin(), itemList->end(), closestItemFirst_withCache); -
337 } else if (order == Qt::AscendingOrder) {
never evaluated: order == Qt::AscendingOrder
never executed: }
0
338 std::sort(itemList->begin(), itemList->end(), closestItemLast_withCache); -
339 }
never executed: }
0
340 } else { -
341 if (order == Qt::DescendingOrder) {
partially evaluated: order == Qt::DescendingOrder
TRUEFALSE
yes
Evaluation Count:643
no
Evaluation Count:0
0-643
342 std::sort(itemList->begin(), itemList->end(), qt_closestItemFirst); -
343 } else if (order == Qt::AscendingOrder) {
never evaluated: order == Qt::AscendingOrder
executed: }
Execution Count:643
0-643
344 std::sort(itemList->begin(), itemList->end(), qt_closestItemLast); -
345 }
never executed: }
0
346 } -
347} -
348 -
349 -
350 -
351 -
352QGraphicsSceneBspTreeIndex::QGraphicsSceneBspTreeIndex(QGraphicsScene *scene) -
353 : QGraphicsSceneIndex(*new QGraphicsSceneBspTreeIndexPrivate(scene), scene) -
354{ -
355 -
356}
executed: }
Execution Count:233
233
357 -
358QGraphicsSceneBspTreeIndex::~QGraphicsSceneBspTreeIndex() -
359{ -
360 QGraphicsSceneBspTreeIndexPrivate * const d = d_func(); -
361 for (int i = 0; i < d->indexedItems.size(); ++i) {
partially evaluated: i < d->indexedItems.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:221
0-221
362 -
363 if (QGraphicsItem *item = d->indexedItems.at(i)) {
never evaluated: QGraphicsItem *item = d->indexedItems.at(i)
0
364 qt_noop(); -
365 item->d_ptr->index = -1; -
366 }
never executed: }
0
367 }
never executed: }
0
368}
executed: }
Execution Count:221
221
369 -
370 -
371 -
372 -
373 -
374void QGraphicsSceneBspTreeIndex::clear() -
375{ -
376 QGraphicsSceneBspTreeIndexPrivate * const d = d_func(); -
377 d->bsp.clear(); -
378 d->lastItemCount = 0; -
379 d->freeItemIndexes.clear(); -
380 for (int i = 0; i < d->indexedItems.size(); ++i) {
evaluated: i < d->indexedItems.size()
TRUEFALSE
yes
Evaluation Count:207
yes
Evaluation Count:221
207-221
381 -
382 if (QGraphicsItem *item = d->indexedItems.at(i)) {
evaluated: QGraphicsItem *item = d->indexedItems.at(i)
TRUEFALSE
yes
Evaluation Count:148
yes
Evaluation Count:59
59-148
383 qt_noop(); -
384 item->d_ptr->index = -1; -
385 }
executed: }
Execution Count:148
148
386 }
executed: }
Execution Count:207
207
387 d->indexedItems.clear(); -
388 d->unindexedItems.clear(); -
389 d->untransformableItems.clear(); -
390 d->regenerateIndex = true; -
391}
executed: }
Execution Count:221
221
392 -
393 -
394 -
395 -
396void QGraphicsSceneBspTreeIndex::addItem(QGraphicsItem *item) -
397{ -
398 QGraphicsSceneBspTreeIndexPrivate * const d = d_func(); -
399 d->addItem(item); -
400}
executed: }
Execution Count:1018
1018
401 -
402 -
403 -
404 -
405void QGraphicsSceneBspTreeIndex::removeItem(QGraphicsItem *item) -
406{ -
407 QGraphicsSceneBspTreeIndexPrivate * const d = d_func(); -
408 d->removeItem(item); -
409}
executed: }
Execution Count:1001
1001
410 -
411 -
412 -
413 -
414 -
415void QGraphicsSceneBspTreeIndex::prepareBoundingRectChange(const QGraphicsItem *item) -
416{ -
417 if (!item)
partially evaluated: !item
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1485
0-1485
418 return;
never executed: return;
0
419 -
420 if (item->d_ptr->index == -1 || item->d_ptr->itemIsUntransformable()
evaluated: item->d_ptr->index == -1
TRUEFALSE
yes
Evaluation Count:1371
yes
Evaluation Count:114
partially evaluated: item->d_ptr->itemIsUntransformable()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:114
0-1371
421 || (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)) {
partially evaluated: (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:114
0-114
422 return;
executed: return;
Execution Count:1371
1371
423 } -
424 -
425 QGraphicsSceneBspTreeIndexPrivate * const d = d_func(); -
426 QGraphicsItem *thatItem = const_cast<QGraphicsItem *>(item); -
427 d->removeItem(thatItem, false, true); -
428 for (int i = 0; i < item->d_ptr->children.size(); ++i)
evaluated: i < item->d_ptr->children.size()
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:114
15-114
429 prepareBoundingRectChange(item->d_ptr->children.at(i));
executed: prepareBoundingRectChange(item->d_ptr->children.at(i));
Execution Count:15
15
430}
executed: }
Execution Count:114
114
431QList<QGraphicsItem *> QGraphicsSceneBspTreeIndex::estimateItems(const QRectF &rect, Qt::SortOrder order) const -
432{ -
433 const QGraphicsSceneBspTreeIndexPrivate * const d = d_func(); -
434 return const_cast<QGraphicsSceneBspTreeIndexPrivate*>(d)->estimateItems(rect, order);
never executed: return const_cast<QGraphicsSceneBspTreeIndexPrivate*>(d)->estimateItems(rect, order);
0
435} -
436 -
437QList<QGraphicsItem *> QGraphicsSceneBspTreeIndex::estimateTopLevelItems(const QRectF &rect, Qt::SortOrder order) const -
438{ -
439 const QGraphicsSceneBspTreeIndexPrivate * const d = d_func(); -
440 return const_cast<QGraphicsSceneBspTreeIndexPrivate*>(d)->estimateItems(rect, order, true);
executed: return const_cast<QGraphicsSceneBspTreeIndexPrivate*>(d)->estimateItems(rect, order, true);
Execution Count:201
201
441} -
442 -
443 -
444 -
445 -
446 -
447 -
448QList<QGraphicsItem *> QGraphicsSceneBspTreeIndex::items(Qt::SortOrder order) const -
449{ -
450 const QGraphicsSceneBspTreeIndexPrivate * const d = d_func(); -
451 const_cast<QGraphicsSceneBspTreeIndexPrivate*>(d)->purgeRemovedItems(); -
452 QList<QGraphicsItem *> itemList; -
453 -
454 -
455 -
456 if (d->freeItemIndexes.isEmpty()) {
evaluated: d->freeItemIndexes.isEmpty()
TRUEFALSE
yes
Evaluation Count:640
yes
Evaluation Count:3
3-640
457 if (d->unindexedItems.isEmpty()) {
evaluated: d->unindexedItems.isEmpty()
TRUEFALSE
yes
Evaluation Count:239
yes
Evaluation Count:401
239-401
458 itemList = d->indexedItems; -
459 } else {
executed: }
Execution Count:239
239
460 itemList = d->indexedItems + d->unindexedItems; -
461 }
executed: }
Execution Count:401
401
462 } else { -
463 -
464 -
465 for (QForeachContainer<__typeof__(d->indexedItems + d->unindexedItems)> _container_(d->indexedItems + d->unindexedItems); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) { -
466 if (item)
evaluated: item
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:5
4-5
467 itemList << item;
executed: itemList << item;
Execution Count:4
4
468 }
executed: }
Execution Count:9
9
469 }
executed: }
Execution Count:3
3
470 if (order != -1) {
partially evaluated: order != -1
TRUEFALSE
yes
Evaluation Count:643
no
Evaluation Count:0
0-643
471 -
472 d->sortItems(&itemList, order, d->sortCacheEnabled); -
473 }
executed: }
Execution Count:643
643
474 return itemList;
executed: return itemList;
Execution Count:643
643
475} -
476int QGraphicsSceneBspTreeIndex::bspTreeDepth() const -
477{ -
478 const QGraphicsSceneBspTreeIndexPrivate * const d = d_func(); -
479 return d->bspTreeDepth;
never executed: return d->bspTreeDepth;
0
480} -
481 -
482void QGraphicsSceneBspTreeIndex::setBspTreeDepth(int depth) -
483{ -
484 QGraphicsSceneBspTreeIndexPrivate * const d = d_func(); -
485 if (d->bspTreeDepth == depth)
never evaluated: d->bspTreeDepth == depth
0
486 return;
never executed: return;
0
487 d->bspTreeDepth = depth; -
488 d->resetIndex(); -
489}
never executed: }
0
490 -
491 -
492 -
493 -
494 -
495 -
496 -
497void QGraphicsSceneBspTreeIndex::updateSceneRect(const QRectF &rect) -
498{ -
499 QGraphicsSceneBspTreeIndexPrivate * const d = d_func(); -
500 d->sceneRect = rect; -
501 d->resetIndex(); -
502}
executed: }
Execution Count:300
300
503 -
504 -
505 -
506 -
507 -
508 -
509 -
510void QGraphicsSceneBspTreeIndex::itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const void *const value) -
511{ -
512 QGraphicsSceneBspTreeIndexPrivate * const d = d_func(); -
513 switch (change) { -
514 case QGraphicsItem::ItemFlagsChange: { -
515 -
516 QGraphicsItem::GraphicsItemFlags newFlags = *static_cast<const QGraphicsItem::GraphicsItemFlags *>(value); -
517 bool ignoredTransform = item->d_ptr->flags & QGraphicsItem::ItemIgnoresTransformations; -
518 bool willIgnoreTransform = newFlags & QGraphicsItem::ItemIgnoresTransformations; -
519 bool clipsChildren = item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape; -
520 bool willClipChildren = newFlags & QGraphicsItem::ItemClipsChildrenToShape; -
521 if ((ignoredTransform != willIgnoreTransform) || (clipsChildren != willClipChildren)) {
partially evaluated: (ignoredTransform != willIgnoreTransform)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
partially evaluated: (clipsChildren != willClipChildren)
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
522 QGraphicsItem *thatItem = const_cast<QGraphicsItem *>(item); -
523 -
524 -
525 -
526 -
527 d->removeItem(thatItem, true, true); -
528 }
executed: }
Execution Count:5
5
529 break;
executed: break;
Execution Count:5
5
530 } -
531 case QGraphicsItem::ItemZValueChange: -
532 d->invalidateSortCache(); -
533 break;
executed: break;
Execution Count:19
19
534 case QGraphicsItem::ItemParentChange: { -
535 d->invalidateSortCache(); -
536 -
537 const QGraphicsItem *newParent = static_cast<const QGraphicsItem *>(value); -
538 bool ignoredTransform = item->d_ptr->itemIsUntransformable(); -
539 bool willIgnoreTransform = (item->d_ptr->flags & QGraphicsItem::ItemIgnoresTransformations)
partially evaluated: (item->d_ptr->flags & QGraphicsItem::ItemIgnoresTransformations)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
540 || (newParent && newParent->d_ptr->itemIsUntransformable());
partially evaluated: newParent
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
partially evaluated: newParent->d_ptr->itemIsUntransformable()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
541 bool ancestorClippedChildren = item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren; -
542 bool ancestorWillClipChildren = newParent
partially evaluated: newParent
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-12
543 && ((newParent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape)
partially evaluated: (newParent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
544 || (newParent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren));
partially evaluated: (newParent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
545 if ((ignoredTransform != willIgnoreTransform) || (ancestorClippedChildren != ancestorWillClipChildren)) {
partially evaluated: (ignoredTransform != willIgnoreTransform)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
partially evaluated: (ancestorClippedChildren != ancestorWillClipChildren)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
546 QGraphicsItem *thatItem = const_cast<QGraphicsItem *>(item); -
547 -
548 -
549 -
550 -
551 d->removeItem(thatItem, true, true); -
552 }
never executed: }
0
553 break;
executed: break;
Execution Count:12
12
554 } -
555 default: -
556 break;
never executed: break;
0
557 } -
558}
executed: }
Execution Count:36
36
559 -
560 -
561 -
562 -
563 -
564 -
565 -
566bool QGraphicsSceneBspTreeIndex::event(QEvent *event) -
567{ -
568 QGraphicsSceneBspTreeIndexPrivate * const d = d_func(); -
569 switch (event->type()) { -
570 case QEvent::Timer: -
571 if (d->indexTimerId && static_cast<QTimerEvent *>(event)->timerId() == d->indexTimerId) {
partially evaluated: d->indexTimerId
TRUEFALSE
yes
Evaluation Count:218
no
Evaluation Count:0
partially evaluated: static_cast<QTimerEvent *>(event)->timerId() == d->indexTimerId
TRUEFALSE
yes
Evaluation Count:218
no
Evaluation Count:0
0-218
572 if (d->restartIndexTimer) {
evaluated: d->restartIndexTimer
TRUEFALSE
yes
Evaluation Count:170
yes
Evaluation Count:48
48-170
573 d->restartIndexTimer = false; -
574 } else {
executed: }
Execution Count:170
170
575 -
576 d->_q_updateIndex(); -
577 }
executed: }
Execution Count:48
48
578 } -
579 -
580 default: -
581 return QObject::event(event);
executed: return QObject::event(event);
Execution Count:218
218
582 } -
583 return true;
never executed: return true;
0
584} -
585 -
586 -
587 -
588 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial