#include "qgraphicsscene.h"
#include "qgraphicsitem.h"
#include "qgraphicsitem_p.h"
#include "qgraphicsscene_p.h"
#include "qgraphicssceneevent.h"
#include "qgraphicsview.h"
#include <private/qobject_p.h>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qlist.h>
#include <QtCore/qrect.h>
#include <QtCore/qset.h>
#include <QtCore/qtimer.h>
#include <QtGui/qevent.h>
#include <QtGui/qmatrix.h>
#include <QtGui/qpainter.h>
#include <QtGui/qpolygon.h>
#include <QtGui/qstyleoption.h>
#include <QtGui/qtooltip.h>
#include <math.h>
#include <qdebug.h>
#include "moc_qgraphicsscene.cpp"
Include dependency graph for qgraphicsscene.cpp:

Go to the source code of this file.
Functions | |
| static int | intmaxlog (int n) |
| bool | qt_closestLeaf (const QGraphicsItem *item1, const QGraphicsItem *item2) |
| bool | qt_closestItemFirst (const QGraphicsItem *item1, const QGraphicsItem *item2) |
| static int intmaxlog | ( | int | n | ) | [inline, static] |
Definition at line 291 of file qgraphicsscene.cpp.
References qMax().
Referenced by QGraphicsScenePrivate::_q_generateBspTree().
Here is the call graph for this function:

| bool qt_closestItemFirst | ( | const QGraphicsItem * | item1, | |
| const QGraphicsItem * | item2 | |||
| ) |
Definition at line 697 of file qgraphicsscene.cpp.
References QVector< T >::at(), QGraphicsItem::d_ptr, QVector< T >::first(), i, QGraphicsItemPrivate::parent, QVector< T >::prepend(), qt_closestLeaf(), QVector< T >::resize(), and QVector< T >::size().
Referenced by QGraphicsScenePrivate::sortItems().
00698 { 00699 // Siblings? Just check their z-values. 00700 if (item1->d_ptr->parent == item2->d_ptr->parent) 00701 return qt_closestLeaf(item1, item2); 00702 00703 // Find item1's ancestors. If item2 is among them, return true (item1 is 00704 // above item2). 00705 QVector<const QGraphicsItem *> ancestors1; 00706 const QGraphicsItem *parent1 = item1; 00707 do { 00708 if (parent1 == item2) 00709 return true; 00710 ancestors1.prepend(parent1); 00711 } while ((parent1 = parent1->d_ptr->parent)); 00712 00713 // Find item2's ancestors. If item1 is among them, return false (item2 is 00714 // above item1). 00715 QVector<const QGraphicsItem *> ancestors2; 00716 const QGraphicsItem *parent2 = item2; 00717 do { 00718 if (parent2 == item1) 00719 return false; 00720 ancestors2.prepend(parent2); 00721 } while ((parent2 = parent2->d_ptr->parent)); 00722 00723 // Truncate the largest ancestor list. 00724 int size1 = ancestors1.size(); 00725 int size2 = ancestors2.size(); 00726 if (size1 > size2) { 00727 ancestors1.resize(size2); 00728 } else if (size2 > size1) { 00729 ancestors2.resize(size1); 00730 } 00731 00732 // Compare items from the two ancestors lists and find a match. Then 00733 // compare item1's and item2's toplevels relative to the common ancestor. 00734 for (int i = ancestors1.size() - 2; i >= 0; --i) { 00735 const QGraphicsItem *a1 = ancestors1.at(i); 00736 const QGraphicsItem *a2 = ancestors2.at(i); 00737 if (a1 == a2) 00738 return qt_closestLeaf(ancestors1.at(i + 1), ancestors2.at(i + 1)); 00739 } 00740 00741 // No common ancestor? Then just compare the items' toplevels directly. 00742 return qt_closestLeaf(ancestors1.first(), ancestors2.first()); 00743 }
Here is the call graph for this function:

| bool qt_closestLeaf | ( | const QGraphicsItem * | item1, | |
| const QGraphicsItem * | item2 | |||
| ) | [inline] |
Definition at line 687 of file qgraphicsscene.cpp.
References QGraphicsItem::d_ptr, and QGraphicsItemPrivate::z.
Referenced by qt_closestItemFirst().
00688 { 00689 qreal z1 = item1->d_ptr->z; 00690 qreal z2 = item2->d_ptr->z; 00691 return z1 != z2 ? z1 > z2 : item1 > item2; 00692 }
1.5.1