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

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