summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicsscene_bsp.cpp
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@trolltech.com>2009-04-07 18:06:38 (GMT)
committerAlexis Menard <alexis.menard@trolltech.com>2009-04-07 18:06:38 (GMT)
commite2e30d5c0ca99a47cc142465436d5e0a3f616b82 (patch)
treeb9fe22cfc7fa816ff9128a2ea264ca6de020056c /src/gui/graphicsview/qgraphicsscene_bsp.cpp
parent9e5293822b849ed37742054cf1f4c0bb1b1e7156 (diff)
downloadQt-e2e30d5c0ca99a47cc142465436d5e0a3f616b82.zip
Qt-e2e30d5c0ca99a47cc142465436d5e0a3f616b82.tar.gz
Qt-e2e30d5c0ca99a47cc142465436d5e0a3f616b82.tar.bz2
Fixes: Make the bsp tree inherits from the new API
Diffstat (limited to 'src/gui/graphicsview/qgraphicsscene_bsp.cpp')
-rw-r--r--src/gui/graphicsview/qgraphicsscene_bsp.cpp31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene_bsp.cpp b/src/gui/graphicsview/qgraphicsscene_bsp.cpp
index f8fa450..c295cb3 100644
--- a/src/gui/graphicsview/qgraphicsscene_bsp.cpp
+++ b/src/gui/graphicsview/qgraphicsscene_bsp.cpp
@@ -100,7 +100,7 @@ QGraphicsSceneBspTree::~QGraphicsSceneBspTree()
void QGraphicsSceneBspTree::initialize(const QRectF &rect, int depth)
{
- this->rect = rect;
+ sceneRect = rect;
leafCnt = 0;
nodes.resize((1 << (depth + 1)) - 1);
nodes.fill(Node());
@@ -117,19 +117,36 @@ void QGraphicsSceneBspTree::clear()
leaves.clear();
}
-void QGraphicsSceneBspTree::insertItem(QGraphicsItem *item, const QRectF &rect)
+QRectF QGraphicsSceneBspTree::rect() const
+{
+ return sceneRect;
+}
+
+void QGraphicsSceneBspTree::setRect(const QRectF &rect)
+{
+ sceneRect = rect;
+}
+
+void QGraphicsSceneBspTree::insertItem(QGraphicsItem *item)
{
insertVisitor->item = item;
- climbTree(insertVisitor, rect);
+ climbTree(insertVisitor, item->sceneBoundingRect());
+}
+
+void QGraphicsSceneBspTree::insertItems(const QList<QGraphicsItem *> &items)
+{
+ foreach(QGraphicsItem *item, items) {
+ insertItem(item);
+ }
}
-void QGraphicsSceneBspTree::removeItem(QGraphicsItem *item, const QRectF &rect)
+void QGraphicsSceneBspTree::removeItem(QGraphicsItem *item)
{
removeVisitor->item = item;
- climbTree(removeVisitor, rect);
+ climbTree(removeVisitor, item->sceneBoundingRect());
}
-void QGraphicsSceneBspTree::removeItems(const QSet<QGraphicsItem *> &items)
+void QGraphicsSceneBspTree::removeItems(const QList<QGraphicsItem *> &items)
{
for (int i = 0; i < leaves.size(); ++i) {
QList<QGraphicsItem *> newItemList;
@@ -302,7 +319,7 @@ void QGraphicsSceneBspTree::climbTree(QGraphicsSceneBspTreeVisitor *visitor, con
QRectF QGraphicsSceneBspTree::rectForIndex(int index) const
{
if (index <= 0)
- return rect;
+ return sceneRect;
int parentIdx = parentIndex(index);
QRectF rect = rectForIndex(parentIdx);