diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-06-19 10:58:26 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-06-19 12:39:19 (GMT) |
commit | 933bddab13c2cec231beb623f77c7fbb0bbbccd5 (patch) | |
tree | 77bbbe35cf03a84923d3dbed725939838194514c /src/gui/graphicsview/qgraphicsscene_p.h | |
parent | fbe0edc109a252efb6f2f53d04537c33f2e91fba (diff) | |
download | Qt-933bddab13c2cec231beb623f77c7fbb0bbbccd5.zip Qt-933bddab13c2cec231beb623f77c7fbb0bbbccd5.tar.gz Qt-933bddab13c2cec231beb623f77c7fbb0bbbccd5.tar.bz2 |
Refactor QGraphicsScene::drawSubtreeRecursive.
It's easier to read and maintain the code now. This version is also
faster than the old one and makes it easier to implement another
cut-off I'm working on.
All auto-tests still pass. Examples/demos run fine.
Diffstat (limited to 'src/gui/graphicsview/qgraphicsscene_p.h')
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene_p.h | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index a8f6699..2f63e5b 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -206,6 +206,7 @@ public: void mousePressEventHandler(QGraphicsSceneMouseEvent *mouseEvent); QGraphicsWidget *windowForItem(const QGraphicsItem *item) const; + QList<QGraphicsItem *> topLevelItemsInStackingOrder(const QTransform *const, QRegion *); void recursive_items_helper(QGraphicsItem *item, QRectF rect, QList<QGraphicsItem *> *items, const QTransform &parentTransform, const QTransform &viewTransform, Qt::ItemSelectionMode mode, Qt::SortOrder order, qreal parentOpacity = 1.0) const; @@ -259,10 +260,18 @@ public: void drawItemHelper(QGraphicsItem *item, QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget, bool painterStateProtection); - - void drawSubtreeRecursive(QGraphicsItem *item, QPainter *painter, const QTransform &viewTransform, - QRegion *exposedRegion, QWidget *widget, - QList<QGraphicsItem *> *topLevelItems = 0, qreal parentOpacity = qreal(1.0)); + + inline void drawItems(QPainter *painter, const QTransform *const viewTransform, + QRegion *exposedRegion, QWidget *widget) + { + const QList<QGraphicsItem *> tli = topLevelItemsInStackingOrder(viewTransform, exposedRegion); + for (int i = 0; i < tli.size(); ++i) + drawSubtreeRecursive(tli.at(i), painter, viewTransform, exposedRegion, widget); + return; + } + + void drawSubtreeRecursive(QGraphicsItem *item, QPainter *painter, const QTransform *const, + QRegion *exposedRegion, QWidget *widget, qreal parentOpacity = qreal(1.0)); void markDirty(QGraphicsItem *item, const QRectF &rect = QRectF(), bool invalidateChildren = false, bool maybeDirtyClipPath = false, bool force = false, bool ignoreOpacity = false, bool removingItemFromScene = false); |