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