diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-06-30 11:00:32 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-06-30 13:08:23 (GMT) |
commit | 6ee3fb750377eeedf161d96fef02c5fa336810e9 (patch) | |
tree | 8ef2e692e888a0ba537c8fb2df62a003809fe92b /src/gui/graphicsview/qgraphicssceneindex_p.h | |
parent | 4dcb46a3796fbd9baf1ba6dcddcc9944e69e3153 (diff) | |
download | Qt-6ee3fb750377eeedf161d96fef02c5fa336810e9.zip Qt-6ee3fb750377eeedf161d96fef02c5fa336810e9.tar.gz Qt-6ee3fb750377eeedf161d96fef02c5fa336810e9.tar.bz2 |
More re-factoring of QGraphicsSceneIndex.
Mostly re-factoring of QGraphicsSceneIndexPrivate::recursive_items_helper
so it can re-use code from the scene (topLevelItemsInStackingOrder). That also
means we'll use the bsp tree in case of NoIndex instead of always looping
through the top-levels. This function is now almost identical to
QGraphicsScenePrivate::drawSubtreeRecursive, so it might be worth
looking into how we can abstract it even more and have one common
recursive function.
Diffstat (limited to 'src/gui/graphicsview/qgraphicssceneindex_p.h')
-rw-r--r-- | src/gui/graphicsview/qgraphicssceneindex_p.h | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/src/gui/graphicsview/qgraphicssceneindex_p.h b/src/gui/graphicsview/qgraphicssceneindex_p.h index dc6a740..122d7ae 100644 --- a/src/gui/graphicsview/qgraphicssceneindex_p.h +++ b/src/gui/graphicsview/qgraphicssceneindex_p.h @@ -53,11 +53,13 @@ // We mean it. // +#include "qgraphicsscene_p.h" +#include "qgraphicsscene.h" +#include <private/qobject_p.h> + #include <QtCore/qnamespace.h> #include <QtCore/qobject.h> #include <QtGui/qtransform.h> -#include <QtGui/qgraphicsitem.h> -#include <private/qobject_p.h> QT_BEGIN_HEADER @@ -67,7 +69,6 @@ QT_MODULE(Gui) #if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW -class QGraphicsScene; class QGraphicsSceneIndexIntersector; class QGraphicsSceneIndexPointIntersector; class QGraphicsSceneIndexRectIntersector; @@ -138,12 +139,31 @@ public: QGraphicsSceneIndexIntersector *intersector, QList<QGraphicsItem *> *items, const QTransform &parentTransform, const QTransform &viewTransform, Qt::ItemSelectionMode mode, Qt::SortOrder order, qreal parentOpacity = 1.0) const; - QGraphicsScene *scene; - QGraphicsSceneIndexPointIntersector *pointIntersector; - QGraphicsSceneIndexRectIntersector *rectIntersector; - QGraphicsSceneIndexPathIntersector *pathIntersector; + inline void items_helper(const QRectF &rect, QGraphicsSceneIndexIntersector *intersector, + QList<QGraphicsItem *> *items, const QTransform &viewTransform, + Qt::ItemSelectionMode mode, Qt::SortOrder order) const; + + QGraphicsScene *scene; + QGraphicsSceneIndexPointIntersector *pointIntersector; + QGraphicsSceneIndexRectIntersector *rectIntersector; + QGraphicsSceneIndexPathIntersector *pathIntersector; }; +inline void QGraphicsSceneIndexPrivate::items_helper(const QRectF &rect, QGraphicsSceneIndexIntersector *intersector, + QList<QGraphicsItem *> *items, const QTransform &viewTransform, + Qt::ItemSelectionMode mode, Qt::SortOrder order) const +{ + const QList<QGraphicsItem *> tli = scene->d_func()->topLevelItemsInStackingOrder(&viewTransform, rect); + const QTransform identity; + for (int i = 0; i < tli.size(); ++i) + recursive_items_helper(tli.at(i), rect, intersector, items, identity, viewTransform, mode, order); + if (order == Qt::AscendingOrder) { + const int n = items->size(); + for (int i = 0; i < n / 2; ++i) + items->swap(i, n - i - 1); + } +} + class QGraphicsSceneIndexIntersector { public: |