summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview
diff options
context:
space:
mode:
authorAriya Hidayat <ariya.hidayat@trolltech.com>2009-03-19 10:26:24 (GMT)
committerAlexis Menard <alexis.menard@trolltech.com>2009-04-07 18:25:21 (GMT)
commitce77e1d327653c2c0724d6d4a45564c25d98eda8 (patch)
tree04f1d093aaa87bb95f5f530b442153c56776c470 /src/gui/graphicsview
parentf4c03e0eec3b39145471f25d0a1cdcdba604790c (diff)
downloadQt-ce77e1d327653c2c0724d6d4a45564c25d98eda8.zip
Qt-ce77e1d327653c2c0724d6d4a45564c25d98eda8.tar.gz
Qt-ce77e1d327653c2c0724d6d4a45564c25d98eda8.tar.bz2
Fixes: Move the bsp depth variable to the BSP tree class.
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp16
-rw-r--r--src/gui/graphicsview/qgraphicsscene_bsp.cpp2
-rw-r--r--src/gui/graphicsview/qgraphicsscene_bsp_p.h2
3 files changed, 15 insertions, 5 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index f8f8e98..6aab9df 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -329,7 +329,6 @@ static void _q_hoverFromMouseEvent(QGraphicsSceneHoverEvent *hover, const QGraph
QGraphicsScenePrivate::QGraphicsScenePrivate()
: changedSignalMask(0),
indexMethod(QGraphicsScene::BspTreeIndex),
- bspTreeDepth(0),
lastItemCount(0),
index(new QGraphicsSceneBspTree()),
hasSceneRect(false),
@@ -540,7 +539,9 @@ void QGraphicsScenePrivate::_q_updateIndex()
// Determine whether we should regenerate the BSP tree.
if (indexMethod == QGraphicsScene::BspTreeIndex) {
- int depth = bspTreeDepth;
+ QGraphicsSceneBspTree *bspTree = qobject_cast<QGraphicsSceneBspTree*>(index);
+ Q_ASSERT(bspTree);
+ int depth = bspTree->depth;
if (depth == 0) {
int oldDepth = intmaxlog(lastItemCount);
depth = intmaxlog(indexedItems.size());
@@ -2472,7 +2473,8 @@ QGraphicsSceneIndex* QGraphicsScene::sceneIndex() const
int QGraphicsScene::bspTreeDepth() const
{
Q_D(const QGraphicsScene);
- return d->bspTreeDepth;
+ QGraphicsSceneBspTree *bspTree = qobject_cast<QGraphicsSceneBspTree*>(d->index);
+ return bspTree ? bspTree->depth : 0;
}
void QGraphicsScene::setBspTreeDepth(int depth)
{
@@ -2485,7 +2487,13 @@ void QGraphicsScene::setBspTreeDepth(int depth)
return;
}
- d->bspTreeDepth = depth;
+ QGraphicsSceneBspTree *bspTree = qobject_cast<QGraphicsSceneBspTree*>(d->index);
+ if (!bspTree) {
+ qWarning("QGraphicsScene::setBspTreeDepth: can not apply if indexing method is not BSP");
+ return;
+ }
+
+ bspTree->depth = depth;
d->resetIndex();
}
diff --git a/src/gui/graphicsview/qgraphicsscene_bsp.cpp b/src/gui/graphicsview/qgraphicsscene_bsp.cpp
index 29c54bb..a81b14d 100644
--- a/src/gui/graphicsview/qgraphicsscene_bsp.cpp
+++ b/src/gui/graphicsview/qgraphicsscene_bsp.cpp
@@ -84,7 +84,7 @@ public:
};
QGraphicsSceneBspTree::QGraphicsSceneBspTree(QObject *parent)
- : QGraphicsSceneIndex(parent), leafCnt(0)
+ : QGraphicsSceneIndex(parent), depth(0), leafCnt(0)
{
insertVisitor = new QGraphicsSceneInsertItemBspTreeVisitor;
removeVisitor = new QGraphicsSceneRemoveItemBspTreeVisitor;
diff --git a/src/gui/graphicsview/qgraphicsscene_bsp_p.h b/src/gui/graphicsview/qgraphicsscene_bsp_p.h
index 8b7d753..69d9eee 100644
--- a/src/gui/graphicsview/qgraphicsscene_bsp_p.h
+++ b/src/gui/graphicsview/qgraphicsscene_bsp_p.h
@@ -102,6 +102,8 @@ public:
int leafCount() const;
+ int depth;
+
private:
inline int firstChildIndex(int index) const