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:356
356
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:798
798
28void QGraphicsSceneBspTreeIndexPrivate::_q_updateIndex() -
29{ -
30 QGraphicsSceneBspTreeIndex * const q = q_func(); -
31 if (!indexTimerId)
evaluated: !indexTimerId
TRUEFALSE
yes
Evaluation Count:2165
yes
Evaluation Count:372
372-2165
32 return;
executed: return;
Execution Count:2165
2165
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:808
yes
Evaluation Count:372
372-808
41 if (QGraphicsItem *item = unindexedItems.at(i)) {
partially evaluated: QGraphicsItem *item = unindexedItems.at(i)
TRUEFALSE
yes
Evaluation Count:808
no
Evaluation Count:0
0-808
42 qt_noop(); -
43 if (!freeItemIndexes.isEmpty()) {
evaluated: !freeItemIndexes.isEmpty()
TRUEFALSE
yes
Evaluation Count:227
yes
Evaluation Count:581
227-581
44 int freeIndex = freeItemIndexes.takeFirst(); -
45 item->d_func()->index = freeIndex; -
46 indexedItems[freeIndex] = item; -
47 } else {
executed: }
Execution Count:227
227
48 item->d_func()->index = indexedItems.size(); -
49 indexedItems << item; -
50 }
executed: }
Execution Count:581
581
51 } -
52 }
executed: }
Execution Count:808
808
53 -
54 -
55 if (bspTreeDepth == 0) {
evaluated: bspTreeDepth == 0
TRUEFALSE
yes
Evaluation Count:178
yes
Evaluation Count:194
178-194
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)) {
evaluated: bsp.leafCount() == 0
TRUEFALSE
yes
Evaluation Count:177
yes
Evaluation Count:1
partially evaluated: oldDepth != bspTreeDepth
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: qAbs(lastItemCount - indexedItems.size()) > slack
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-177
60 -
61 regenerateIndex = true; -
62 }
executed: }
Execution Count:177
177
63 }
executed: }
Execution Count:178
178
64 -
65 -
66 if (regenerateIndex) {
evaluated: regenerateIndex
TRUEFALSE
yes
Evaluation Count:197
yes
Evaluation Count:175
175-197
67 regenerateIndex = false; -
68 bsp.initialize(sceneRect, bspTreeDepth); -
69 unindexedItems = indexedItems; -
70 lastItemCount = indexedItems.size(); -
71 }
executed: }
Execution Count:197
197
72 -
73 -
74 for (int i = 0; i < unindexedItems.size(); ++i) {
evaluated: i < unindexedItems.size()
TRUEFALSE
yes
Evaluation Count:808
yes
Evaluation Count:372
372-808
75 if (QGraphicsItem *item = unindexedItems.at(i)) {
partially evaluated: QGraphicsItem *item = unindexedItems.at(i)
TRUEFALSE
yes
Evaluation Count:808
no
Evaluation Count:0
0-808
76 if (item->d_ptr->itemIsUntransformable()) {
evaluated: item->d_ptr->itemIsUntransformable()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:803
5-803
77 untransformableItems << item; -
78 continue;
executed: continue;
Execution Count:5
5
79 } -
80 if (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)
evaluated: item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:796
7-796
81 continue;
executed: continue;
Execution Count:7
7
82 -
83 bsp.insertItem(item, item->d_ptr->sceneEffectiveBoundingRect()); -
84 }
executed: }
Execution Count:796
796
85 }
executed: }
Execution Count:796
796
86 unindexedItems.clear(); -
87}
executed: }
Execution Count:372
372
88 -
89 -
90 -
91 -
92 -
93 -
94 -
95void QGraphicsSceneBspTreeIndexPrivate::purgeRemovedItems() -
96{ -
97 if (!purgePending && removedItems.isEmpty())
evaluated: !purgePending
TRUEFALSE
yes
Evaluation Count:7322
yes
Evaluation Count:2
partially evaluated: removedItems.isEmpty()
TRUEFALSE
yes
Evaluation Count:7322
no
Evaluation Count:0
0-7322
98 return;
executed: return;
Execution Count:7322
7322
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:1872
yes
Evaluation Count:959
959-1872
121 restartIndexTimer = true; -
122 } else {
executed: }
Execution Count:1872
1872
123 indexTimerId = q->startTimer(interval); -
124 }
executed: }
Execution Count:959
959
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:176
yes
Evaluation Count:833
176-833
134 if (QGraphicsItem *item = indexedItems.at(i)) {
evaluated: QGraphicsItem *item = indexedItems.at(i)
TRUEFALSE
yes
Evaluation Count:148
yes
Evaluation Count:28
28-148
135 item->d_ptr->index = -1; -
136 qt_noop(); -
137 unindexedItems << item; -
138 }
executed: }
Execution Count:148
148
139 }
executed: }
Execution Count:176
176
140 indexedItems.clear(); -
141 freeItemIndexes.clear(); -
142 untransformableItems.clear(); -
143 regenerateIndex = true; -
144 startIndexTimer(); -
145}
executed: }
Execution Count:833
833
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:2442
no
Evaluation Count:0
never evaluated: !updatingSortCache
0-2442
180 return;
executed: return;
Execution Count:2442
2442
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:4040
no
Evaluation Count:0
never evaluated: updatingSortCache
0-4040
205 return;
executed: return;
Execution Count:4040
4040
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:1998
0-1998
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:1998
no
Evaluation Count:0
0-1998
228 qt_noop(); -
229 unindexedItems << item; -
230 startIndexTimer(0); -
231 } else {
executed: }
Execution Count:1998
1998
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:1998
0-1998
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:1998
1998
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:1972
0-1972
246 return;
never executed: return;
0
247 -
248 if (item->d_ptr->index != -1) {
evaluated: item->d_ptr->index != -1
TRUEFALSE
yes
Evaluation Count:317
yes
Evaluation Count:1655
317-1655
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()) {
evaluated: item->d_ptr->itemIsUntransformable()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:315
2-315
257 untransformableItems.removeOne(item); -
258 } else if (item->d_ptr->inDestructor) {
evaluated: item->d_ptr->inDestructor
TRUEFALSE
yes
Evaluation Count:55
yes
Evaluation Count:260
executed: }
Execution Count:2
2-260
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:260
no
Evaluation Count:0
executed: }
Execution Count:55
0-260
263 bsp.removeItem(item, item->d_ptr->sceneEffectiveBoundingRect()); -
264 }
executed: }
Execution Count:260
260
265 } else { -
266 unindexedItems.removeOne(item); -
267 }
executed: }
Execution Count:1655
1655
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:272
yes
Evaluation Count:1700
272-1700
276 addItem(item);
executed: addItem(item);
Execution Count:272
272
277 -
278 if (recursive) {
evaluated: recursive
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:1953
19-1953
279 for (int i = 0; i < item->d_ptr->children.size(); ++i)
evaluated: i < item->d_ptr->children.size()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:19
6-19
280 removeItem(item->d_ptr->children.at(i), recursive, moveToUnindexedItems);
executed: removeItem(item->d_ptr->children.at(i), recursive, moveToUnindexedItems);
Execution Count:6
6
281 }
executed: }
Execution Count:19
19
282}
executed: }
Execution Count:1972
1972
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:2442
no
Evaluation Count:0
partially evaluated: rect.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2442
0-2442
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:2442
no
Evaluation Count:0
0-2442
297 for (int i = 0; i < untransformableItems.size(); ++i) {
evaluated: i < untransformableItems.size()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:2442
8-2442
298 QGraphicsItem *item = untransformableItems.at(i); -
299 if (!item->d_ptr->parent) {
evaluated: !item->d_ptr->parent
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:2
2-6
300 rectItems << item; -
301 } else {
executed: }
Execution Count:6
6
302 item = item->topLevelItem(); -
303 if (!rectItems.contains(item))
partially evaluated: !rectItems.contains(item)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
304 rectItems << item;
never executed: rectItems << item;
0
305 }
executed: }
Execution Count:2
2
306 } -
307 } else {
executed: }
Execution Count:2442
2442
308 rectItems += untransformableItems; -
309 }
never executed: }
0
310 -
311 sortItems(&rectItems, order, sortCacheEnabled, onlyTopLevelItems); -
312 return rectItems;
executed: return rectItems;
Execution Count:2442
2442
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:4121
0-4121
324 return;
never executed: return;
0
325 -
326 if (onlyTopLevelItems) {
evaluated: onlyTopLevelItems
TRUEFALSE
yes
Evaluation Count:2442
yes
Evaluation Count:1679
1679-2442
327 if (order == Qt::DescendingOrder)
partially evaluated: order == Qt::DescendingOrder
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2442
0-2442
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:2442
no
Evaluation Count:0
0-2442
330 std::sort(itemList->begin(), itemList->end(), qt_notclosestLeaf);
executed: std::sort(itemList->begin(), itemList->end(), qt_notclosestLeaf);
Execution Count:2442
2442
331 return;
executed: return;
Execution Count:2442
2442
332 } -
333 -
334 if (sortCacheEnabled) {
partially evaluated: sortCacheEnabled
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1679
0-1679
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) {
evaluated: order == Qt::DescendingOrder
TRUEFALSE
yes
Evaluation Count:1673
yes
Evaluation Count:6
6-1673
342 std::sort(itemList->begin(), itemList->end(), qt_closestItemFirst); -
343 } else if (order == Qt::AscendingOrder) {
partially evaluated: order == Qt::AscendingOrder
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
executed: }
Execution Count:1673
0-1673
344 std::sort(itemList->begin(), itemList->end(), qt_closestItemLast); -
345 }
executed: }
Execution Count:6
6
346 } -
347} -
348 -
349 -
350 -
351 -
352QGraphicsSceneBspTreeIndex::QGraphicsSceneBspTreeIndex(QGraphicsScene *scene) -
353 : QGraphicsSceneIndex(*new QGraphicsSceneBspTreeIndexPrivate(scene), scene) -
354{ -
355 -
356}
executed: }
Execution Count:798
798
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:779
0-779
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:779
779
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:387
yes
Evaluation Count:779
387-779
381 -
382 if (QGraphicsItem *item = d->indexedItems.at(i)) {
evaluated: QGraphicsItem *item = d->indexedItems.at(i)
TRUEFALSE
yes
Evaluation Count:325
yes
Evaluation Count:62
62-325
383 qt_noop(); -
384 item->d_ptr->index = -1; -
385 }
executed: }
Execution Count:325
325
386 }
executed: }
Execution Count:387
387
387 d->indexedItems.clear(); -
388 d->unindexedItems.clear(); -
389 d->untransformableItems.clear(); -
390 d->regenerateIndex = true; -
391}
executed: }
Execution Count:779
779
392 -
393 -
394 -
395 -
396void QGraphicsSceneBspTreeIndex::addItem(QGraphicsItem *item) -
397{ -
398 QGraphicsSceneBspTreeIndexPrivate * const d = d_func(); -
399 d->addItem(item); -
400}
executed: }
Execution Count:1726
1726
401 -
402 -
403 -
404 -
405void QGraphicsSceneBspTreeIndex::removeItem(QGraphicsItem *item) -
406{ -
407 QGraphicsSceneBspTreeIndexPrivate * const d = d_func(); -
408 d->removeItem(item); -
409}
executed: }
Execution Count:1700
1700
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:1774
0-1774
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:1520
yes
Evaluation Count:254
partially evaluated: item->d_ptr->itemIsUntransformable()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:254
0-1520
421 || (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)) {
evaluated: (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:253
1-253
422 return;
executed: return;
Execution Count:1521
1521
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:16
yes
Evaluation Count:253
16-253
429 prepareBoundingRectChange(item->d_ptr->children.at(i));
executed: prepareBoundingRectChange(item->d_ptr->children.at(i));
Execution Count:16
16
430}
executed: }
Execution Count:253
253
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:2442
2442
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:1676
yes
Evaluation Count:3
3-1676
457 if (d->unindexedItems.isEmpty()) {
evaluated: d->unindexedItems.isEmpty()
TRUEFALSE
yes
Evaluation Count:1181
yes
Evaluation Count:495
495-1181
458 itemList = d->indexedItems; -
459 } else {
executed: }
Execution Count:1181
1181
460 itemList = d->indexedItems + d->unindexedItems; -
461 }
executed: }
Execution Count:495
495
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:1679
no
Evaluation Count:0
0-1679
471 -
472 d->sortItems(&itemList, order, d->sortCacheEnabled); -
473 }
executed: }
Execution Count:1679
1679
474 return itemList;
executed: return itemList;
Execution Count:1679
1679
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:833
833
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)) {
evaluated: (ignoredTransform != willIgnoreTransform)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:25
evaluated: (clipsChildren != willClipChildren)
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:16
1-25
522 QGraphicsItem *thatItem = const_cast<QGraphicsItem *>(item); -
523 -
524 -
525 -
526 -
527 d->removeItem(thatItem, true, true); -
528 }
executed: }
Execution Count:10
10
529 break;
executed: break;
Execution Count:26
26
530 } -
531 case QGraphicsItem::ItemZValueChange: -
532 d->invalidateSortCache(); -
533 break;
executed: break;
Execution Count:55
55
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:15
0-15
540 || (newParent && newParent->d_ptr->itemIsUntransformable());
partially evaluated: newParent
TRUEFALSE
yes
Evaluation Count:15
no
Evaluation Count:0
partially evaluated: newParent->d_ptr->itemIsUntransformable()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
541 bool ancestorClippedChildren = item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren; -
542 bool ancestorWillClipChildren = newParent
partially evaluated: newParent
TRUEFALSE
yes
Evaluation Count:15
no
Evaluation Count:0
0-15
543 && ((newParent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape)
evaluated: (newParent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:12
3-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:15
evaluated: (ancestorClippedChildren != ancestorWillClipChildren)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:12
0-15
546 QGraphicsItem *thatItem = const_cast<QGraphicsItem *>(item); -
547 -
548 -
549 -
550 -
551 d->removeItem(thatItem, true, true); -
552 }
executed: }
Execution Count:3
3
553 break;
executed: break;
Execution Count:15
15
554 } -
555 default: -
556 break;
never executed: break;
0
557 } -
558}
executed: }
Execution Count:96
96
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:316
no
Evaluation Count:0
partially evaluated: static_cast<QTimerEvent *>(event)->timerId() == d->indexTimerId
TRUEFALSE
yes
Evaluation Count:316
no
Evaluation Count:0
0-316
572 if (d->restartIndexTimer) {
evaluated: d->restartIndexTimer
TRUEFALSE
yes
Evaluation Count:221
yes
Evaluation Count:95
95-221
573 d->restartIndexTimer = false; -
574 } else {
executed: }
Execution Count:221
221
575 -
576 d->_q_updateIndex(); -
577 }
executed: }
Execution Count:95
95
578 } -
579 -
580 default: -
581 return QObject::event(event);
executed: return QObject::event(event);
Execution Count:316
316
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