summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicsscene.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.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.cpp')
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp46
1 files changed, 15 insertions, 31 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 3b1c8ad..85d05e9 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -1085,36 +1085,6 @@ QGraphicsWidget *QGraphicsScenePrivate::windowForItem(const QGraphicsItem *item)
return 0;
}
-QList<QGraphicsItem *> QGraphicsScenePrivate::topLevelItemsInStackingOrder(const QTransform *const viewTransform,
- const QRectF &sceneRect)
-{
- if (indexMethod == QGraphicsScene::NoIndex || sceneRect.isNull()) {
- ensureSortedTopLevelItems();
- return topLevelItems;
- }
-
- const QList<QGraphicsItem *> tmp = index->estimateItems(sceneRect, Qt::SortOrder(-1),
- viewTransform ? *viewTransform : QTransform());
- // estimateItems returns a list of *all* items, but we are only interested
- // in the top-levels (those that are within the rect themselves and those that
- // have descendants within the rect).
- // ### Look into how we can add this feature to the BSP.
- QList<QGraphicsItem *> tli;
- for (int i = 0; i < tmp.size(); ++i) {
- QGraphicsItem *topLevelItem = tmp.at(i)->topLevelItem();
- if (!topLevelItem->d_ptr->itemDiscovered) {
- tli << topLevelItem;
- topLevelItem->d_ptr->itemDiscovered = 1;
- }
- }
- // Reset discovered bit.
- for (int i = 0; i < tli.size(); ++i)
- tli.at(i)->d_ptr->itemDiscovered = 0;
-
- qSort(tli.begin(), tli.end(), qt_notclosestLeaf);
- return tli;
-}
-
/*!
\internal
@@ -1759,7 +1729,7 @@ QList<QGraphicsItem *> QGraphicsScene::collidingItems(const QGraphicsItem *item,
// Does not support ItemIgnoresTransformations.
QList<QGraphicsItem *> tmp;
- foreach (QGraphicsItem *itemInVicinity, d->index->estimateItems(item->sceneBoundingRect(), Qt::AscendingOrder, QTransform())) {
+ foreach (QGraphicsItem *itemInVicinity, d->index->estimateItems(item->sceneBoundingRect(), Qt::AscendingOrder)) {
if (item != itemInVicinity && item->collidesWithItem(itemInVicinity, mode))
tmp << itemInVicinity;
}
@@ -4209,6 +4179,20 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte
}
}
+void QGraphicsScenePrivate::drawItems(QPainter *painter, const QTransform *const viewTransform,
+ QRegion *exposedRegion, QWidget *widget)
+{
+ QRectF exposedSceneRect;
+ if (exposedRegion && indexMethod != QGraphicsScene::NoIndex) {
+ exposedSceneRect = exposedRegion->boundingRect().adjusted(-1, -1, 1, 1);
+ if (viewTransform)
+ exposedSceneRect = viewTransform->inverted().mapRect(exposedSceneRect);
+ }
+ const QList<QGraphicsItem *> tli = index->estimateTopLevelItems(exposedSceneRect, Qt::DescendingOrder);
+ for (int i = 0; i < tli.size(); ++i)
+ drawSubtreeRecursive(tli.at(i), painter, viewTransform, exposedRegion, widget);
+}
+
void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *painter,
const QTransform *const viewTransform,
QRegion *exposedRegion, QWidget *widget,