summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicssceneindex.cpp
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-07-02 16:01:33 (GMT)
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-07-02 17:02:28 (GMT)
commit1d651e82459c0480cb3e803a9d9452092ac9d502 (patch)
treed6739ae76e73287dfb60fa1c5eced3444cdff5cc /src/gui/graphicsview/qgraphicssceneindex.cpp
parentc4ae87721e011fe44f301c4039f0651a05394162 (diff)
downloadQt-1d651e82459c0480cb3e803a9d9452092ac9d502.zip
Qt-1d651e82459c0480cb3e803a9d9452092ac9d502.tar.gz
Qt-1d651e82459c0480cb3e803a9d9452092ac9d502.tar.bz2
More re-factoring of QGraphicsSceneIndex.
New method: QGraphicsSceneIndex::estimateTopLevelItems. QGraphicsSceneIndex::estimateItems returns *all* items within the rect, but we are only interested in the top-levels (those that are within the rect themselves or have descendants within the rect) when doing recursive drawing/item-lookup. All auto-tests pass. Demos/examples/manualtests run fine.
Diffstat (limited to 'src/gui/graphicsview/qgraphicssceneindex.cpp')
-rw-r--r--src/gui/graphicsview/qgraphicssceneindex.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/gui/graphicsview/qgraphicssceneindex.cpp b/src/gui/graphicsview/qgraphicssceneindex.cpp
index d6281e2..5626051 100644
--- a/src/gui/graphicsview/qgraphicssceneindex.cpp
+++ b/src/gui/graphicsview/qgraphicssceneindex.cpp
@@ -482,12 +482,25 @@ QList<QGraphicsItem *> QGraphicsSceneIndex::items(const QPainterPath &path, Qt::
/*!
This virtual function return an estimation of items at position \a point.
This method return a list sorted using \a order.
- \a deviceTransform is the transformation apply to the view.
*/
-QList<QGraphicsItem *> QGraphicsSceneIndex::estimateItems(const QPointF &point, Qt::SortOrder order,
- const QTransform &deviceTransform) const
+QList<QGraphicsItem *> QGraphicsSceneIndex::estimateItems(const QPointF &point, Qt::SortOrder order) const
+{
+ return estimateItems(QRectF(point, QSize(1, 1)), order);
+}
+
+QList<QGraphicsItem *> QGraphicsSceneIndex::estimateTopLevelItems(const QRectF &rect, Qt::SortOrder order) const
{
- return estimateItems(QRectF(point, QSize(1,1)), order, deviceTransform);
+ Q_D(const QGraphicsSceneIndex);
+ Q_UNUSED(rect);
+ QGraphicsScenePrivate *scened = d->scene->d_func();
+ scened->ensureSortedTopLevelItems();
+ if (order == Qt::AscendingOrder) {
+ QList<QGraphicsItem *> sorted;
+ for (int i = scened->topLevelItems.size() - 1; i >= 0; --i)
+ sorted << scened->topLevelItems.at(i);
+ return sorted;
+ }
+ return scened->topLevelItems;
}
/*!