qgraphicsscenebsptreeindex.cpp

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

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9