Qt 4.8
Classes | Macros | Functions
qgraphicsitem_p.h File Reference
#include "qgraphicsitem.h"
#include "qset.h"
#include "qpixmapcache.h"
#include <private/qgraphicsview_p.h>
#include "qgraphicstransform.h"
#include <private/qgraphicstransform_p.h>
#include <private/qgraphicseffect_p.h>
#include <qgraphicseffect.h>
#include <QtCore/qpoint.h>

Go to the source code of this file.

Classes

class  QDeclarativeListProperty< T >
 The QDeclarativeListProperty class allows applications to expose list-like properties to QML. More...
 
class  QGraphicsItemCache
 
struct  QGraphicsItemCache::DeviceData
 
class  QGraphicsItemEffectSourcePrivate
 
struct  QGraphicsItemPaintInfo
 
class  QGraphicsItemPrivate
 
struct  QGraphicsItemPrivate::ExtraStruct
 
struct  QGraphicsItemPrivate::TransformData
 

Macros

#define QDECLARATIVELISTPROPERTY
 

Functions

bool qt_closestItemFirst (const QGraphicsItem *item1, const QGraphicsItem *item2)
 Returns true if item1 is on top of item2. More...
 
bool qt_closestItemLast (const QGraphicsItem *item1, const QGraphicsItem *item2)
 Returns true if item2 is on top of item1. More...
 
bool qt_closestLeaf (const QGraphicsItem *item1, const QGraphicsItem *item2)
 
bool qt_notclosestLeaf (const QGraphicsItem *item1, const QGraphicsItem *item2)
 

Macro Definition Documentation

◆ QDECLARATIVELISTPROPERTY

#define QDECLARATIVELISTPROPERTY

Definition at line 75 of file qgraphicsitem_p.h.

Function Documentation

◆ qt_closestItemFirst()

bool qt_closestItemFirst ( const QGraphicsItem item1,
const QGraphicsItem item2 
)
inline

Returns true if item1 is on top of item2.

The items don't need to be siblings.

Warning
This function is not part of the public interface.

Definition at line 729 of file qgraphicsitem_p.h.

Referenced by QGraphicsScenePrivate::gestureEventHandler(), qt_closestItemLast(), and QGraphicsSceneBspTreeIndexPrivate::sortItems().

730 {
731  // Siblings? Just check their z-values.
732  const QGraphicsItemPrivate *d1 = item1->d_ptr.data();
733  const QGraphicsItemPrivate *d2 = item2->d_ptr.data();
734  if (d1->parent == d2->parent)
735  return qt_closestLeaf(item1, item2);
736 
737  // Find common ancestor, and each item's ancestor closest to the common
738  // ancestor.
739  int item1Depth = d1->depth();
740  int item2Depth = d2->depth();
741  const QGraphicsItem *p = item1;
742  const QGraphicsItem *t1 = item1;
743  while (item1Depth > item2Depth && (p = p->d_ptr->parent)) {
744  if (p == item2) {
745  // item2 is one of item1's ancestors; item1 is on top
747  }
748  t1 = p;
749  --item1Depth;
750  }
751  p = item2;
752  const QGraphicsItem *t2 = item2;
753  while (item2Depth > item1Depth && (p = p->d_ptr->parent)) {
754  if (p == item1) {
755  // item1 is one of item2's ancestors; item1 is not on top
757  }
758  t2 = p;
759  --item2Depth;
760  }
761 
762  // item1Ancestor is now at the same level as item2Ancestor, but not the same.
763  const QGraphicsItem *p1 = t1;
764  const QGraphicsItem *p2 = t2;
765  while (t1 && t1 != t2) {
766  p1 = t1;
767  p2 = t2;
768  t1 = t1->d_ptr->parent;
769  t2 = t2->d_ptr->parent;
770  }
771 
772  // in case we have a common ancestor, we compare the immediate children in the ancestor's path.
773  // otherwise we compare the respective items' topLevelItems directly.
774  return qt_closestLeaf(p1, p2);
775 }
QGraphicsItem * parent
QScopedPointer< QGraphicsItemPrivate > d_ptr
T * data() const
Returns the value of the pointer referenced by this object.
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
bool qt_closestLeaf(const QGraphicsItem *item1, const QGraphicsItem *item2)

◆ qt_closestItemLast()

bool qt_closestItemLast ( const QGraphicsItem item1,
const QGraphicsItem item2 
)
inline

Returns true if item2 is on top of item1.

The items don't need to be siblings.

Warning
This function is not part of the public interface.

Definition at line 783 of file qgraphicsitem_p.h.

Referenced by QGraphicsSceneBspTreeIndexPrivate::sortItems().

784 {
785  return qt_closestItemFirst(item2, item1);
786 }
bool qt_closestItemFirst(const QGraphicsItem *item1, const QGraphicsItem *item2)
Returns true if item1 is on top of item2.

◆ qt_closestLeaf()

bool qt_closestLeaf ( const QGraphicsItem item1,
const QGraphicsItem item2 
)
inline
Warning
This function is not part of the public interface.

Definition at line 791 of file qgraphicsitem_p.h.

Referenced by QGraphicsSceneBspTreeIndexPrivate::_q_updateSortCache(), QGraphicsSceneBspTreeIndexPrivate::climbTree(), qt_closestItemFirst(), qt_notclosestLeaf(), and QGraphicsSceneBspTreeIndexPrivate::sortItems().

792 {
793  // Return true if sibling item1 is on top of item2.
794  const QGraphicsItemPrivate *d1 = item1->d_ptr.data();
795  const QGraphicsItemPrivate *d2 = item2->d_ptr.data();
798  if (f1 != f2)
799  return f2;
800  if (d1->z != d2->z)
801  return d1->z > d2->z;
802  return d1->siblingIndex > d2->siblingIndex;
803 }
QScopedPointer< QGraphicsItemPrivate > d_ptr
T * data() const
Returns the value of the pointer referenced by this object.

◆ qt_notclosestLeaf()

bool qt_notclosestLeaf ( const QGraphicsItem item1,
const QGraphicsItem item2 
)
inline
Warning
This function is not part of the public interface.

Definition at line 808 of file qgraphicsitem_p.h.

Referenced by QGraphicsItemPrivate::ensureSortedChildren(), QGraphicsScenePrivate::ensureSortedTopLevelItems(), and QGraphicsSceneBspTreeIndexPrivate::sortItems().

809 { return qt_closestLeaf(item2, item1); }
bool qt_closestLeaf(const QGraphicsItem *item1, const QGraphicsItem *item2)