OpenCoverage

qgraphicssceneindex.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/graphicsview/qgraphicssceneindex.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39/*!-
40 \class QGraphicsSceneIndex-
41 \brief The QGraphicsSceneIndex class provides a base class to implement-
42 a custom indexing algorithm for discovering items in QGraphicsScene.-
43 \since 4.6-
44 \ingroup graphicsview-api-
45-
46 \internal-
47-
48 The QGraphicsSceneIndex class provides a base class to implement-
49 a custom indexing algorithm for discovering items in QGraphicsScene. You-
50 need to subclass it and reimplement addItem, removeItem, estimateItems-
51 and items in order to have an functional indexing.-
52-
53 \sa QGraphicsScene, QGraphicsView-
54*/-
55-
56#include "qdebug.h"-
57#include "qgraphicsscene.h"-
58#include "qgraphicsitem_p.h"-
59#include "qgraphicsscene_p.h"-
60#include "qgraphicswidget.h"-
61#include "qgraphicssceneindex_p.h"-
62#include "qgraphicsscenebsptreeindex_p.h"-
63-
64#ifndef QT_NO_GRAPHICSVIEW-
65-
66QT_BEGIN_NAMESPACE-
67-
68namespace QtPrivate { // just to keep indentation of the following functions at the same level-
69-
70 static bool intersect_rect(const QGraphicsItem *item, const QRectF &exposeRect, Qt::ItemSelectionMode mode,-
71 const QTransform &deviceTransform, const void *intersectData)-
72 {-
73 const QRectF sceneRect = *static_cast<const QRectF *>(intersectData);-
74-
75 QRectF brect = item->boundingRect();-
76 _q_adjustRect(&brect);-
77-
78 // ### Add test for this (without making things slower?)-
79 Q_UNUSED(exposeRect);-
80-
81 bool keep = true;-
82 const QGraphicsItemPrivate *itemd = QGraphicsItemPrivate::get(item);-
83 if (itemd->itemIsUntransformable()) {
itemd->itemIsUntransformable()Description
TRUEnever evaluated
FALSEnever evaluated
0
84 // Untransformable items; map the scene rect to item coordinates.-
85 const QTransform transform = item->deviceTransform(deviceTransform);-
86 QRectF itemRect = (deviceTransform * transform.inverted()).mapRect(sceneRect);-
87 if (mode == Qt::ContainsItemShape || mode == Qt::ContainsItemBoundingRect)
mode == Qt::ContainsItemShapeDescription
TRUEnever evaluated
FALSEnever evaluated
mode == Qt::Co...emBoundingRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
88 keep = itemRect.contains(brect) && itemRect != brect;
never executed: keep = itemRect.contains(brect) && itemRect != brect;
itemRect.contains(brect)Description
TRUEnever evaluated
FALSEnever evaluated
itemRect != brectDescription
TRUEnever evaluated
FALSEnever evaluated
0
89 else-
90 keep = itemRect.intersects(brect);
never executed: keep = itemRect.intersects(brect);
0
91 if (keep && (mode == Qt::ContainsItemShape || mode == Qt::IntersectsItemShape)) {
keepDescription
TRUEnever evaluated
FALSEnever evaluated
mode == Qt::ContainsItemShapeDescription
TRUEnever evaluated
FALSEnever evaluated
mode == Qt::In...sectsItemShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
92 QPainterPath itemPath;-
93 itemPath.addRect(itemRect);-
94 keep = QGraphicsSceneIndexPrivate::itemCollidesWithPath(item, itemPath, mode);-
95 }
never executed: end of block
0
96 } else {
never executed: end of block
0
97 Q_ASSERT(!itemd->dirtySceneTransform);-
98 const QRectF itemSceneBoundingRect = itemd->sceneTransformTranslateOnly
itemd->sceneTr...mTranslateOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
0
99 ? brect.translated(itemd->sceneTransform.dx(),-
100 itemd->sceneTransform.dy())-
101 : itemd->sceneTransform.mapRect(brect);-
102 if (mode == Qt::ContainsItemShape || mode == Qt::ContainsItemBoundingRect)
mode == Qt::ContainsItemShapeDescription
TRUEnever evaluated
FALSEnever evaluated
mode == Qt::Co...emBoundingRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
103 keep = sceneRect != brect && sceneRect.contains(itemSceneBoundingRect);
never executed: keep = sceneRect != brect && sceneRect.contains(itemSceneBoundingRect);
sceneRect != brectDescription
TRUEnever evaluated
FALSEnever evaluated
sceneRect.cont...eBoundingRect)Description
TRUEnever evaluated
FALSEnever evaluated
0
104 else-
105 keep = sceneRect.intersects(itemSceneBoundingRect);
never executed: keep = sceneRect.intersects(itemSceneBoundingRect);
0
106 if (keep && (mode == Qt::ContainsItemShape || mode == Qt::IntersectsItemShape)) {
keepDescription
TRUEnever evaluated
FALSEnever evaluated
mode == Qt::ContainsItemShapeDescription
TRUEnever evaluated
FALSEnever evaluated
mode == Qt::In...sectsItemShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
107 QPainterPath rectPath;-
108 rectPath.addRect(sceneRect);-
109 if (itemd->sceneTransformTranslateOnly)
itemd->sceneTr...mTranslateOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
0
110 rectPath.translate(-itemd->sceneTransform.dx(), -itemd->sceneTransform.dy());
never executed: rectPath.translate(-itemd->sceneTransform.dx(), -itemd->sceneTransform.dy());
0
111 else-
112 rectPath = itemd->sceneTransform.inverted().map(rectPath);
never executed: rectPath = itemd->sceneTransform.inverted().map(rectPath);
0
113 keep = QGraphicsSceneIndexPrivate::itemCollidesWithPath(item, rectPath, mode);-
114 }
never executed: end of block
0
115 }
never executed: end of block
0
116 return keep;
never executed: return keep;
0
117 }-
118-
119 static bool intersect_point(const QGraphicsItem *item, const QRectF &exposeRect, Qt::ItemSelectionMode mode,-
120 const QTransform &deviceTransform, const void *intersectData)-
121 {-
122 const QPointF scenePoint = *static_cast<const QPointF *>(intersectData);-
123-
124 QRectF brect = item->boundingRect();-
125 _q_adjustRect(&brect);-
126-
127 // ### Add test for this (without making things slower?)-
128 Q_UNUSED(exposeRect);-
129-
130 bool keep = false;-
131 const QGraphicsItemPrivate *itemd = QGraphicsItemPrivate::get(item);-
132 if (itemd->itemIsUntransformable()) {
itemd->itemIsUntransformable()Description
TRUEnever evaluated
FALSEnever evaluated
0
133 // Untransformable items; map the scene point to item coordinates.-
134 const QTransform transform = item->deviceTransform(deviceTransform);-
135 QPointF itemPoint = (deviceTransform * transform.inverted()).map(scenePoint);-
136 keep = brect.contains(itemPoint);-
137 if (keep && (mode == Qt::ContainsItemShape || mode == Qt::IntersectsItemShape)) {
keepDescription
TRUEnever evaluated
FALSEnever evaluated
mode == Qt::ContainsItemShapeDescription
TRUEnever evaluated
FALSEnever evaluated
mode == Qt::In...sectsItemShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
138 QPainterPath pointPath;-
139 pointPath.addRect(QRectF(itemPoint, QSizeF(1, 1)));-
140 keep = QGraphicsSceneIndexPrivate::itemCollidesWithPath(item, pointPath, mode);-
141 }
never executed: end of block
0
142 } else {
never executed: end of block
0
143 Q_ASSERT(!itemd->dirtySceneTransform);-
144 QRectF sceneBoundingRect = itemd->sceneTransformTranslateOnly
itemd->sceneTr...mTranslateOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
0
145 ? brect.translated(itemd->sceneTransform.dx(),-
146 itemd->sceneTransform.dy())-
147 : itemd->sceneTransform.mapRect(brect);-
148 keep = sceneBoundingRect.intersects(QRectF(scenePoint, QSizeF(1, 1)));-
149 if (keep && (mode == Qt::ContainsItemShape || mode == Qt::IntersectsItemShape)) {
keepDescription
TRUEnever evaluated
FALSEnever evaluated
mode == Qt::ContainsItemShapeDescription
TRUEnever evaluated
FALSEnever evaluated
mode == Qt::In...sectsItemShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
150 QPointF p = itemd->sceneTransformTranslateOnly
itemd->sceneTr...mTranslateOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
0
151 ? QPointF(scenePoint.x() - itemd->sceneTransform.dx(),-
152 scenePoint.y() - itemd->sceneTransform.dy())-
153 : itemd->sceneTransform.inverted().map(scenePoint);-
154 keep = item->contains(p);-
155 }
never executed: end of block
0
156 }
never executed: end of block
0
157-
158 return keep;
never executed: return keep;
0
159 }-
160-
161 static bool intersect_path(const QGraphicsItem *item, const QRectF &exposeRect, Qt::ItemSelectionMode mode,-
162 const QTransform &deviceTransform, const void *intersectData)-
163 {-
164 const QPainterPath scenePath = *static_cast<const QPainterPath *>(intersectData);-
165-
166 QRectF brect = item->boundingRect();-
167 _q_adjustRect(&brect);-
168-
169 // ### Add test for this (without making things slower?)-
170 Q_UNUSED(exposeRect);-
171-
172 bool keep = true;-
173 const QGraphicsItemPrivate *itemd = QGraphicsItemPrivate::get(item);-
174 if (itemd->itemIsUntransformable()) {
itemd->itemIsUntransformable()Description
TRUEnever evaluated
FALSEnever evaluated
0
175 // Untransformable items; map the scene rect to item coordinates.-
176 const QTransform transform = item->deviceTransform(deviceTransform);-
177 QPainterPath itemPath = (deviceTransform * transform.inverted()).map(scenePath);-
178 if (mode == Qt::ContainsItemShape || mode == Qt::ContainsItemBoundingRect)
mode == Qt::ContainsItemShapeDescription
TRUEnever evaluated
FALSEnever evaluated
mode == Qt::Co...emBoundingRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
179 keep = itemPath.contains(brect);
never executed: keep = itemPath.contains(brect);
0
180 else-
181 keep = itemPath.intersects(brect);
never executed: keep = itemPath.intersects(brect);
0
182 if (keep && (mode == Qt::ContainsItemShape || mode == Qt::IntersectsItemShape))
keepDescription
TRUEnever evaluated
FALSEnever evaluated
mode == Qt::ContainsItemShapeDescription
TRUEnever evaluated
FALSEnever evaluated
mode == Qt::In...sectsItemShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
183 keep = QGraphicsSceneIndexPrivate::itemCollidesWithPath(item, itemPath, mode);
never executed: keep = QGraphicsSceneIndexPrivate::itemCollidesWithPath(item, itemPath, mode);
0
184 } else {
never executed: end of block
0
185 Q_ASSERT(!itemd->dirtySceneTransform);-
186 const QRectF itemSceneBoundingRect = itemd->sceneTransformTranslateOnly
itemd->sceneTr...mTranslateOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
0
187 ? brect.translated(itemd->sceneTransform.dx(),-
188 itemd->sceneTransform.dy())-
189 : itemd->sceneTransform.mapRect(brect);-
190 if (mode == Qt::ContainsItemShape || mode == Qt::ContainsItemBoundingRect)
mode == Qt::ContainsItemShapeDescription
TRUEnever evaluated
FALSEnever evaluated
mode == Qt::Co...emBoundingRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
191 keep = scenePath.contains(itemSceneBoundingRect);
never executed: keep = scenePath.contains(itemSceneBoundingRect);
0
192 else-
193 keep = scenePath.intersects(itemSceneBoundingRect);
never executed: keep = scenePath.intersects(itemSceneBoundingRect);
0
194 if (keep && (mode == Qt::ContainsItemShape || mode == Qt::IntersectsItemShape)) {
keepDescription
TRUEnever evaluated
FALSEnever evaluated
mode == Qt::ContainsItemShapeDescription
TRUEnever evaluated
FALSEnever evaluated
mode == Qt::In...sectsItemShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
195 QPainterPath itemPath = itemd->sceneTransformTranslateOnly
itemd->sceneTr...mTranslateOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
0
196 ? scenePath.translated(-itemd->sceneTransform.dx(),-
197 -itemd->sceneTransform.dy())-
198 : itemd->sceneTransform.inverted().map(scenePath);-
199 keep = QGraphicsSceneIndexPrivate::itemCollidesWithPath(item, itemPath, mode);-
200 }
never executed: end of block
0
201 }
never executed: end of block
0
202 return keep;
never executed: return keep;
0
203 }-
204-
205} // namespace QtPrivate-
206-
207/*!-
208 Constructs a private scene index.-
209*/-
210QGraphicsSceneIndexPrivate::QGraphicsSceneIndexPrivate(QGraphicsScene *scene) : scene(scene)-
211{-
212}
never executed: end of block
0
213-
214/*!-
215 Destructor of private scene index.-
216*/-
217QGraphicsSceneIndexPrivate::~QGraphicsSceneIndexPrivate()-
218{-
219}-
220-
221/*!-
222 \internal-
223-
224 Checks if item collides with the path and mode, but also checks that if it-
225 doesn't collide, maybe its frame rect will.-
226*/-
227bool QGraphicsSceneIndexPrivate::itemCollidesWithPath(const QGraphicsItem *item,-
228 const QPainterPath &path,-
229 Qt::ItemSelectionMode mode)-
230{-
231 if (item->collidesWithPath(path, mode))
item->collides...th(path, mode)Description
TRUEnever evaluated
FALSEnever evaluated
0
232 return true;
never executed: return true;
0
233 if (item->isWidget()) {
item->isWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
234 // Check if this is a window, and if its frame rect collides.-
235 const QGraphicsWidget *widget = static_cast<const QGraphicsWidget *>(item);-
236 if (widget->isWindow()) {
widget->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
237 QRectF frameRect = widget->windowFrameRect();-
238 QPainterPath framePath;-
239 framePath.addRect(frameRect);-
240 bool intersects = path.intersects(frameRect);-
241 if (mode == Qt::IntersectsItemShape || mode == Qt::IntersectsItemBoundingRect)
mode == Qt::In...sectsItemShapeDescription
TRUEnever evaluated
FALSEnever evaluated
mode == Qt::In...emBoundingRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
242 return intersects || path.contains(frameRect.topLeft())
never executed: return intersects || path.contains(frameRect.topLeft()) || framePath.contains(path.elementAt(0));
0
243 || framePath.contains(path.elementAt(0));
never executed: return intersects || path.contains(frameRect.topLeft()) || framePath.contains(path.elementAt(0));
0
244 return !intersects && path.contains(frameRect.topLeft());
never executed: return !intersects && path.contains(frameRect.topLeft());
0
245 }-
246 }
never executed: end of block
0
247 return false;
never executed: return false;
0
248}-
249-
250/*!-
251 \internal-
252 This function returns the items in ascending order.-
253*/-
254void QGraphicsSceneIndexPrivate::recursive_items_helper(QGraphicsItem *item, QRectF exposeRect,-
255 QGraphicsSceneIndexIntersector intersect,-
256 QList<QGraphicsItem *> *items,-
257 const QTransform &viewTransform,-
258 Qt::ItemSelectionMode mode,-
259 qreal parentOpacity, const void *intersectData) const-
260{-
261 Q_ASSERT(item);-
262 if (!item->d_ptr->visible)
!item->d_ptr->visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
263 return;
never executed: return;
0
264-
265 const qreal opacity = item->d_ptr->combineOpacityFromParent(parentOpacity);-
266 const bool itemIsFullyTransparent = QGraphicsItemPrivate::isOpacityNull(opacity);-
267 const bool itemHasChildren = !item->d_ptr->children.isEmpty();-
268 if (itemIsFullyTransparent && (!itemHasChildren || item->d_ptr->childrenCombineOpacity()))
itemIsFullyTransparentDescription
TRUEnever evaluated
FALSEnever evaluated
!itemHasChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
item->d_ptr->c...mbineOpacity()Description
TRUEnever evaluated
FALSEnever evaluated
0
269 return;
never executed: return;
0
270-
271 // Update the item's scene transform if dirty.-
272 const bool itemIsUntransformable = item->d_ptr->itemIsUntransformable();-
273 const bool wasDirtyParentSceneTransform = item->d_ptr->dirtySceneTransform && !itemIsUntransformable;
item->d_ptr->d...SceneTransformDescription
TRUEnever evaluated
FALSEnever evaluated
!itemIsUntransformableDescription
TRUEnever evaluated
FALSEnever evaluated
0
274 if (wasDirtyParentSceneTransform) {
wasDirtyParentSceneTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
275 item->d_ptr->updateSceneTransformFromParent();-
276 Q_ASSERT(!item->d_ptr->dirtySceneTransform);-
277 }
never executed: end of block
0
278-
279 const bool itemClipsChildrenToShape = (item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape
item->d_ptr->f...hildrenToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
280 || item->d_ptr->flags & QGraphicsItem::ItemContainsChildrenInShape);
item->d_ptr->f...hildrenInShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
281 bool processItem = !itemIsFullyTransparent;-
282 if (processItem) {
processItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
283 processItem = intersect(item, exposeRect, mode, viewTransform, intersectData);-
284 if (!processItem && (!itemHasChildren || itemClipsChildrenToShape)) {
!processItemDescription
TRUEnever evaluated
FALSEnever evaluated
!itemHasChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
itemClipsChildrenToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
285 if (wasDirtyParentSceneTransform)
wasDirtyParentSceneTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
286 item->d_ptr->invalidateChildrenSceneTransform();
never executed: item->d_ptr->invalidateChildrenSceneTransform();
0
287 return;
never executed: return;
0
288 }-
289 } // else we know for sure this item has children we must process.
never executed: end of block
0
290-
291 int i = 0;-
292 if (itemHasChildren) {
itemHasChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
293 // Sort children.-
294 item->d_ptr->ensureSortedChildren();-
295-
296 // Clip to shape.-
297 if (itemClipsChildrenToShape && !itemIsUntransformable) {
itemClipsChildrenToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
!itemIsUntransformableDescription
TRUEnever evaluated
FALSEnever evaluated
0
298 QPainterPath mappedShape = item->d_ptr->sceneTransformTranslateOnly
item->d_ptr->s...mTranslateOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
0
299 ? item->shape().translated(item->d_ptr->sceneTransform.dx(),-
300 item->d_ptr->sceneTransform.dy())-
301 : item->d_ptr->sceneTransform.map(item->shape());-
302 exposeRect &= mappedShape.controlPointRect();-
303 }
never executed: end of block
0
304-
305 // Process children behind-
306 for (i = 0; i < item->d_ptr->children.size(); ++i) {
i < item->d_pt...hildren.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
307 QGraphicsItem *child = item->d_ptr->children.at(i);-
308 if (wasDirtyParentSceneTransform)
wasDirtyParentSceneTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
309 child->d_ptr->dirtySceneTransform = 1;
never executed: child->d_ptr->dirtySceneTransform = 1;
0
310 if (!(child->d_ptr->flags & QGraphicsItem::ItemStacksBehindParent))
!(child->d_ptr...sBehindParent)Description
TRUEnever evaluated
FALSEnever evaluated
0
311 break;
never executed: break;
0
312 if (itemIsFullyTransparent && !(child->d_ptr->flags & QGraphicsItem::ItemIgnoresParentOpacity))
itemIsFullyTransparentDescription
TRUEnever evaluated
FALSEnever evaluated
!(child->d_ptr...ParentOpacity)Description
TRUEnever evaluated
FALSEnever evaluated
0
313 continue;
never executed: continue;
0
314 recursive_items_helper(child, exposeRect, intersect, items, viewTransform,-
315 mode, opacity, intersectData);-
316 }
never executed: end of block
0
317 }
never executed: end of block
0
318-
319 // Process item-
320 if (processItem)
processItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
321 items->append(item);
never executed: items->append(item);
0
322-
323 // Process children in front-
324 if (itemHasChildren) {
itemHasChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
325 for (; i < item->d_ptr->children.size(); ++i) {
i < item->d_pt...hildren.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
326 QGraphicsItem *child = item->d_ptr->children.at(i);-
327 if (wasDirtyParentSceneTransform)
wasDirtyParentSceneTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
328 child->d_ptr->dirtySceneTransform = 1;
never executed: child->d_ptr->dirtySceneTransform = 1;
0
329 if (itemIsFullyTransparent && !(child->d_ptr->flags & QGraphicsItem::ItemIgnoresParentOpacity))
itemIsFullyTransparentDescription
TRUEnever evaluated
FALSEnever evaluated
!(child->d_ptr...ParentOpacity)Description
TRUEnever evaluated
FALSEnever evaluated
0
330 continue;
never executed: continue;
0
331 recursive_items_helper(child, exposeRect, intersect, items, viewTransform,-
332 mode, opacity, intersectData);-
333 }
never executed: end of block
0
334 }
never executed: end of block
0
335}
never executed: end of block
0
336-
337void QGraphicsSceneIndexPrivate::init()-
338{-
339 if (!scene)
!sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
340 return;
never executed: return;
0
341-
342 QObject::connect(scene, SIGNAL(sceneRectChanged(QRectF)),-
343 q_func(), SLOT(updateSceneRect(QRectF)));-
344}
never executed: end of block
0
345-
346/*!-
347 Constructs an abstract scene index for a given \a scene.-
348*/-
349QGraphicsSceneIndex::QGraphicsSceneIndex(QGraphicsScene *scene)-
350: QObject(*new QGraphicsSceneIndexPrivate(scene), scene)-
351{-
352 d_func()->init();-
353}
never executed: end of block
0
354-
355/*!-
356 \internal-
357*/-
358QGraphicsSceneIndex::QGraphicsSceneIndex(QGraphicsSceneIndexPrivate &dd, QGraphicsScene *scene)-
359 : QObject(dd, scene)-
360{-
361 d_func()->init();-
362}
never executed: end of block
0
363-
364/*!-
365 Destroys the scene index.-
366*/-
367QGraphicsSceneIndex::~QGraphicsSceneIndex()-
368{-
369-
370}-
371-
372/*!-
373 Returns the scene of this index.-
374*/-
375QGraphicsScene* QGraphicsSceneIndex::scene() const-
376{-
377 Q_D(const QGraphicsSceneIndex);-
378 return d->scene;
never executed: return d->scene;
0
379}-
380-
381/*!-
382 \fn QList<QGraphicsItem *> QGraphicsSceneIndex::items(const QPointF &pos,-
383 Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform-
384 &deviceTransform) const-
385-
386 Returns all visible items that, depending on \a mode, are at the specified-
387 \a pos and return a list sorted using \a order.-
388-
389 The default value for \a mode is Qt::IntersectsItemShape; all items whose-
390 exact shape intersects with \a pos are returned.-
391-
392 \a deviceTransform is the transformation apply to the view.-
393-
394 This method use the estimation of the index (estimateItems) and refine the-
395 list to get an exact result. If you want to implement your own refinement-
396 algorithm you can reimplement this method.-
397-
398 \sa estimateItems()-
399-
400*/-
401QList<QGraphicsItem *> QGraphicsSceneIndex::items(const QPointF &pos, Qt::ItemSelectionMode mode,-
402 Qt::SortOrder order, const QTransform &deviceTransform) const-
403{-
404-
405 Q_D(const QGraphicsSceneIndex);-
406 QList<QGraphicsItem *> itemList;-
407 d->items_helper(QRectF(pos, QSizeF(1, 1)), &QtPrivate::intersect_point, &itemList, deviceTransform, mode, order, &pos);-
408 return itemList;
never executed: return itemList;
0
409}-
410-
411/*!-
412 \fn QList<QGraphicsItem *> QGraphicsSceneIndex::items(const QRectF &rect,-
413 Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform-
414 &deviceTransform) const-
415-
416 \overload-
417-
418 Returns all visible items that, depending on \a mode, are either inside or-
419 intersect with the specified \a rect and return a list sorted using \a order.-
420-
421 The default value for \a mode is Qt::IntersectsItemShape; all items whose-
422 exact shape intersects with or is contained by \a rect are returned.-
423-
424 \a deviceTransform is the transformation apply to the view.-
425-
426 This method use the estimation of the index (estimateItems) and refine-
427 the list to get an exact result. If you want to implement your own-
428 refinement algorithm you can reimplement this method.-
429-
430 \sa estimateItems()-
431-
432*/-
433QList<QGraphicsItem *> QGraphicsSceneIndex::items(const QRectF &rect, Qt::ItemSelectionMode mode,-
434 Qt::SortOrder order, const QTransform &deviceTransform) const-
435{-
436 Q_D(const QGraphicsSceneIndex);-
437 QRectF exposeRect = rect;-
438 _q_adjustRect(&exposeRect);-
439 QList<QGraphicsItem *> itemList;-
440 d->items_helper(exposeRect, &QtPrivate::intersect_rect, &itemList, deviceTransform, mode, order, &rect);-
441 return itemList;
never executed: return itemList;
0
442}-
443-
444/*!-
445 \fn QList<QGraphicsItem *> QGraphicsSceneIndex::items(const QPolygonF-
446 &polygon, Qt::ItemSelectionMode mode, Qt::SortOrder order, const-
447 QTransform &deviceTransform) const-
448-
449 \overload-
450-
451 Returns all visible items that, depending on \a mode, are either inside or-
452 intersect with the specified \a polygon and return a list sorted using \a order.-
453-
454 The default value for \a mode is Qt::IntersectsItemShape; all items whose-
455 exact shape intersects with or is contained by \a polygon are returned.-
456-
457 \a deviceTransform is the transformation apply to the view.-
458-
459 This method use the estimation of the index (estimateItems) and refine-
460 the list to get an exact result. If you want to implement your own-
461 refinement algorithm you can reimplement this method.-
462-
463 \sa estimateItems()-
464-
465*/-
466QList<QGraphicsItem *> QGraphicsSceneIndex::items(const QPolygonF &polygon, Qt::ItemSelectionMode mode,-
467 Qt::SortOrder order, const QTransform &deviceTransform) const-
468{-
469 Q_D(const QGraphicsSceneIndex);-
470 QList<QGraphicsItem *> itemList;-
471 QRectF exposeRect = polygon.boundingRect();-
472 _q_adjustRect(&exposeRect);-
473 QPainterPath path;-
474 path.addPolygon(polygon);-
475 d->items_helper(exposeRect, &QtPrivate::intersect_path, &itemList, deviceTransform, mode, order, &path);-
476 return itemList;
never executed: return itemList;
0
477}-
478-
479/*!-
480 \fn QList<QGraphicsItem *> QGraphicsSceneIndex::items(const QPainterPath-
481 &path, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform-
482 &deviceTransform) const-
483-
484 \overload-
485-
486 Returns all visible items that, depending on \a mode, are either inside or-
487 intersect with the specified \a path and return a list sorted using \a order.-
488-
489 The default value for \a mode is Qt::IntersectsItemShape; all items whose-
490 exact shape intersects with or is contained by \a path are returned.-
491-
492 \a deviceTransform is the transformation apply to the view.-
493-
494 This method use the estimation of the index (estimateItems) and refine-
495 the list to get an exact result. If you want to implement your own-
496 refinement algorithm you can reimplement this method.-
497-
498 \sa estimateItems()-
499-
500*/-
501QList<QGraphicsItem *> QGraphicsSceneIndex::items(const QPainterPath &path, Qt::ItemSelectionMode mode,-
502 Qt::SortOrder order, const QTransform &deviceTransform) const-
503{-
504 Q_D(const QGraphicsSceneIndex);-
505 QList<QGraphicsItem *> itemList;-
506 QRectF exposeRect = path.controlPointRect();-
507 _q_adjustRect(&exposeRect);-
508 d->items_helper(exposeRect, &QtPrivate::intersect_path, &itemList, deviceTransform, mode, order, &path);-
509 return itemList;
never executed: return itemList;
0
510}-
511-
512/*!-
513 This virtual function return an estimation of items at position \a point.-
514 This method return a list sorted using \a order.-
515*/-
516QList<QGraphicsItem *> QGraphicsSceneIndex::estimateItems(const QPointF &point, Qt::SortOrder order) const-
517{-
518 return estimateItems(QRectF(point, QSize(1, 1)), order);
never executed: return estimateItems(QRectF(point, QSize(1, 1)), order);
0
519}-
520-
521QList<QGraphicsItem *> QGraphicsSceneIndex::estimateTopLevelItems(const QRectF &rect, Qt::SortOrder order) const-
522{-
523 Q_D(const QGraphicsSceneIndex);-
524 Q_UNUSED(rect);-
525 QGraphicsScenePrivate *scened = d->scene->d_func();-
526 scened->ensureSortedTopLevelItems();-
527 if (order == Qt::DescendingOrder) {
order == Qt::DescendingOrderDescription
TRUEnever evaluated
FALSEnever evaluated
0
528 QList<QGraphicsItem *> sorted;-
529 const int numTopLevelItems = scened->topLevelItems.size();-
530 sorted.reserve(numTopLevelItems);-
531 for (int i = numTopLevelItems - 1; i >= 0; --i)
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
532 sorted << scened->topLevelItems.at(i);
never executed: sorted << scened->topLevelItems.at(i);
0
533 return sorted;
never executed: return sorted;
0
534 }-
535 return scened->topLevelItems;
never executed: return scened->topLevelItems;
0
536}-
537-
538/*!-
539 \fn QList<QGraphicsItem *> QGraphicsSceneIndex::items(Qt::SortOrder order = Qt::DescendingOrder) const-
540-
541 This pure virtual function all items in the index and sort them using-
542 \a order.-
543*/-
544-
545-
546/*!-
547 Notifies the index that the scene's scene rect has changed. \a rect-
548 is thew new scene rect.-
549-
550 \sa QGraphicsScene::sceneRect()-
551*/-
552void QGraphicsSceneIndex::updateSceneRect(const QRectF &rect)-
553{-
554 Q_UNUSED(rect);-
555}
never executed: end of block
0
556-
557/*!-
558 This virtual function removes all items in the scene index.-
559*/-
560void QGraphicsSceneIndex::clear()-
561{-
562 const QList<QGraphicsItem *> allItems = items();-
563 for (int i = 0 ; i < allItems.size(); ++i)
i < allItems.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
564 removeItem(allItems.at(i));
never executed: removeItem(allItems.at(i));
0
565}
never executed: end of block
0
566-
567/*!-
568 \fn virtual void QGraphicsSceneIndex::addItem(QGraphicsItem *item) = 0-
569-
570 This pure virtual function inserts an \a item to the scene index.-
571-
572 \sa removeItem(), deleteItem()-
573*/-
574-
575/*!-
576 \fn virtual void QGraphicsSceneIndex::removeItem(QGraphicsItem *item) = 0-
577-
578 This pure virtual function removes an \a item to the scene index.-
579-
580 \sa addItem(), deleteItem()-
581*/-
582-
583/*!-
584 This method is called when an \a item has been deleted.-
585 The default implementation call removeItem. Be carefull,-
586 if your implementation of removeItem use pure virtual method-
587 of QGraphicsItem like boundingRect(), then you should reimplement-
588 this method.-
589-
590 \sa addItem(), removeItem()-
591*/-
592void QGraphicsSceneIndex::deleteItem(QGraphicsItem *item)-
593{-
594 removeItem(item);-
595}
never executed: end of block
0
596-
597/*!-
598 This virtual function is called by QGraphicsItem to notify the index-
599 that some part of the \a item 's state changes. By reimplementing this-
600 function, your can react to a change, and in some cases, (depending on \a-
601 change,) adjustments in the index can be made.-
602-
603 \a change is the parameter of the item that is changing. \a value is the-
604 value that changed; the type of the value depends on \a change.-
605-
606 The default implementation does nothing.-
607-
608 \sa QGraphicsItem::GraphicsItemChange-
609*/-
610void QGraphicsSceneIndex::itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const void *const value)-
611{-
612 Q_UNUSED(item);-
613 Q_UNUSED(change);-
614 Q_UNUSED(value);-
615}
never executed: end of block
0
616-
617/*!-
618 Notify the index for a geometry change of an \a item.-
619-
620 \sa QGraphicsItem::prepareGeometryChange()-
621*/-
622void QGraphicsSceneIndex::prepareBoundingRectChange(const QGraphicsItem *item)-
623{-
624 Q_UNUSED(item);-
625}
never executed: end of block
0
626-
627QT_END_NAMESPACE-
628-
629#include "moc_qgraphicssceneindex_p.cpp"-
630-
631#endif // QT_NO_GRAPHICSVIEW-
Source codeSwitch to Preprocessed file

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