summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicsscene_bsp.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/qgraphicsscene_bsp.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/qgraphicsscene_bsp.cpp')
-rw-r--r--src/gui/graphicsview/qgraphicsscene_bsp.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene_bsp.cpp b/src/gui/graphicsview/qgraphicsscene_bsp.cpp
index 7d30749..fb4b9a4 100644
--- a/src/gui/graphicsview/qgraphicsscene_bsp.cpp
+++ b/src/gui/graphicsview/qgraphicsscene_bsp.cpp
@@ -70,12 +70,15 @@ class QGraphicsSceneFindItemBspTreeVisitor : public QGraphicsSceneBspTreeVisitor
{
public:
QList<QGraphicsItem *> *foundItems;
+ bool onlyTopLevelItems;
void visit(QList<QGraphicsItem *> *items)
{
for (int i = 0; i < items->size(); ++i) {
QGraphicsItem *item = items->at(i);
- if (!item->d_func()->itemDiscovered && item->isVisible()) {
+ if (onlyTopLevelItems && item->d_ptr->parent)
+ item = item->topLevelItem();
+ if (!item->d_func()->itemDiscovered && item->d_ptr->visible) {
item->d_func()->itemDiscovered = 1;
foundItems->prepend(item);
}
@@ -143,10 +146,11 @@ void QGraphicsSceneBspTree::removeItems(const QSet<QGraphicsItem *> &items)
}
}
-QList<QGraphicsItem *> QGraphicsSceneBspTree::items(const QRectF &rect) const
+QList<QGraphicsItem *> QGraphicsSceneBspTree::items(const QRectF &rect, bool onlyTopLevelItems) const
{
QList<QGraphicsItem *> tmp;
findVisitor->foundItems = &tmp;
+ findVisitor->onlyTopLevelItems = onlyTopLevelItems;
climbTree(findVisitor, rect);
// Reset discovery bits.
for (int i = 0; i < tmp.size(); ++i)