Qt 4.8
Public Functions | Public Variables | List of all members
QGraphicsLayoutPrivate Class Reference

#include <qgraphicslayout_p.h>

Inheritance diagram for QGraphicsLayoutPrivate:
QGraphicsLayoutItemPrivate QGraphicsAnchorLayoutPrivate QGraphicsGridLayoutPrivate QGraphicsLinearLayoutPrivate

Public Functions

void activateRecursive (QGraphicsLayoutItem *item)
 
void addChildLayoutItem (QGraphicsLayoutItem *item)
 This function is called from subclasses to add a layout item layoutItem to a layout. More...
 
void getMargin (qreal *result, qreal userMargin, QStyle::PixelMetric pm) const
 
 QGraphicsLayoutPrivate ()
 
void reparentChildItems (QGraphicsItem *newParent)
 
Qt::LayoutDirection visualDirection () const
 
- Public Functions inherited from QGraphicsLayoutItemPrivate
QSizeFeffectiveSizeHints (const QSizeF &constraint) const
 
void ensureUserSizeHints ()
 Ensures that userSizeHints is allocated. More...
 
bool hasHeightForWidth () const
 
bool hasWidthForHeight () const
 
void init ()
 
QGraphicsItemparentItem () const
 Returns the parent item of this layout, or 0 if this layout is not installed on any widget. More...
 
 QGraphicsLayoutItemPrivate (QGraphicsLayoutItem *parent, bool isLayout)
 
void setSize (Qt::SizeHint which, const QSizeF &size)
 Sets the user size hint which to size. More...
 
void setSizeComponent (Qt::SizeHint which, SizeComponent component, qreal value)
 Sets the width of the user size hint which to width. More...
 
virtual ~QGraphicsLayoutItemPrivate ()
 

Public Variables

bool activated
 
qreal bottom
 
qreal left
 
qreal right
 
qreal top
 
- Public Variables inherited from QGraphicsLayoutItemPrivate
QSizeF cachedConstraint
 
QSizeF cachedSizeHints [Qt::NSizeHints]
 
QSizeF cachedSizeHintsWithConstraints [Qt::NSizeHints]
 
QRectF geom
 
QGraphicsItemgraphicsItem
 
quint32 isLayout: 1
 
quint32 ownedByLayout: 1
 
QGraphicsLayoutItemparent
 
QGraphicsLayoutItemq_ptr
 
quint32 sizeHintCacheDirty: 1
 
quint32 sizeHintWithConstraintCacheDirty: 1
 
QSizePolicy sizePolicy
 
QSizeFuserSizeHints
 

Additional Inherited Members

- Public Types inherited from QGraphicsLayoutItemPrivate
enum  SizeComponent { Width, Height }
 
- Static Public Functions inherited from QGraphicsLayoutItemPrivate
static QGraphicsLayoutItemPrivateget (QGraphicsLayoutItem *q)
 
static const QGraphicsLayoutItemPrivateget (const QGraphicsLayoutItem *q)
 

Detailed Description

Definition at line 130 of file qgraphicslayout_p.h.

Constructors and Destructors

◆ QGraphicsLayoutPrivate()

QGraphicsLayoutPrivate::QGraphicsLayoutPrivate ( )
inline

Definition at line 135 of file qgraphicslayout_p.h.

135  : QGraphicsLayoutItemPrivate(0, true), left(-1.0), top(-1.0), right(-1.0), bottom(-1.0),
136  activated(true) { }
QGraphicsLayoutItemPrivate(QGraphicsLayoutItem *parent, bool isLayout)

Functions

◆ activateRecursive()

void QGraphicsLayoutPrivate::activateRecursive ( QGraphicsLayoutItem item)

Definition at line 182 of file qgraphicslayout_p.cpp.

183 {
184  if (item->isLayout()) {
185  QGraphicsLayout *layout = static_cast<QGraphicsLayout *>(item);
186  if (layout->d_func()->activated) {
188  return;
189  } else {
190  layout->invalidate(); // ### LOOKS SUSPICIOUSLY WRONG!!???
191  }
192  }
193 
194  for (int i = layout->count() - 1; i >= 0; --i) {
195  QGraphicsLayoutItem *childItem = layout->itemAt(i);
196  if (childItem)
197  activateRecursive(childItem);
198  }
199  layout->d_func()->activated = true;
200  }
201 }
virtual void invalidate()
Clears any cached geometry and size hint information in the layout, and posts a LayoutRequest event t...
void activateRecursive(QGraphicsLayoutItem *item)
const char * layout
The QGraphicsLayoutItem class can be inherited to allow your custom items to be managed by layouts...
static bool instantInvalidatePropagation()
bool isLayout() const
Returns true if this QGraphicsLayoutItem is a layout (e.g., is inherited by an object that arranges o...
virtual int count() const =0
This pure virtual function must be reimplemented in a subclass of QGraphicsLayout to return the numbe...
The QGraphicsLayout class provides the base class for all layouts in Graphics View.
virtual QGraphicsLayoutItem * itemAt(int i) const =0
This pure virtual function must be reimplemented in a subclass of QGraphicsLayout to return a pointer...

◆ addChildLayoutItem()

void QGraphicsLayoutPrivate::addChildLayoutItem ( QGraphicsLayoutItem layoutItem)

This function is called from subclasses to add a layout item layoutItem to a layout.

Warning
This function is not part of the public interface.

It takes care of automatically reparenting graphics items, if needed.

If layoutItem is a is already in a layout, it will remove it from that layout.

Definition at line 150 of file qgraphicslayout_p.cpp.

Referenced by QGraphicsAnchorLayoutPrivate::addAnchor().

151 {
153  if (QGraphicsLayoutItem *maybeLayout = layoutItem->parentLayoutItem()) {
154  if (maybeLayout->isLayout())
155  removeLayoutItemFromLayout(static_cast<QGraphicsLayout*>(maybeLayout), layoutItem);
156  }
157  layoutItem->setParentLayoutItem(q);
158  if (layoutItem->isLayout()) {
159  if (QGraphicsItem *parItem = parentItem()) {
160  static_cast<QGraphicsLayout*>(layoutItem)->d_func()->reparentChildItems(parItem);
161  }
162  } else {
163  if (QGraphicsItem *item = layoutItem->graphicsItem()) {
164  QGraphicsItem *newParent = parentItem();
165  QGraphicsItem *oldParent = item->parentItem();
166  if (oldParent == newParent || !newParent)
167  return;
168 
169 #ifdef QT_DEBUG
170  if (oldParent && item->isWidget()) {
171  QGraphicsWidget *w = static_cast<QGraphicsWidget*>(item);
172  qWarning("QGraphicsLayout::addChildLayoutItem: %s \"%s\" in wrong parent; moved to correct parent",
174  }
175 #endif
176 
177  item->setParentItem(newParent);
178  }
179  }
180 }
QGraphicsItem * graphicsItem() const
Returns the QGraphicsItem that this layout item represents.
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
void setParentLayoutItem(QGraphicsLayoutItem *parent)
Sets the parent of this QGraphicsLayoutItem to parent.
#define Q_Q(Class)
Definition: qglobal.h:2483
Q_CORE_EXPORT void qWarning(const char *,...)
The QGraphicsLayoutItem class can be inherited to allow your custom items to be managed by layouts...
QGraphicsItem * parentItem() const
Returns the parent item of this layout, or 0 if this layout is not installed on any widget...
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
bool isLayout() const
Returns true if this QGraphicsLayoutItem is a layout (e.g., is inherited by an object that arranges o...
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
QGraphicsItem * parentItem() const
Returns a pointer to this item&#39;s parent item.
QGraphicsLayoutItem * parentLayoutItem() const
Returns the parent of this QGraphicsLayoutItem, or 0 if there is no parent, or if the parent does not...
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
QString objectName() const
The QGraphicsLayout class provides the base class for all layouts in Graphics View.
bool isWidget() const
Returns true if this item is a widget (i.
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
static bool removeLayoutItemFromLayout(QGraphicsLayout *lay, QGraphicsLayoutItem *layoutItem)
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ getMargin()

void QGraphicsLayoutPrivate::getMargin ( qreal result,
qreal  userMargin,
QStyle::PixelMetric  pm 
) const

Definition at line 87 of file qgraphicslayout_p.cpp.

88 {
89  if (!result)
90  return;
91  Q_Q(const QGraphicsLayout);
92 
94  if (userMargin >= 0.0) {
95  *result = userMargin;
96  } else if (!parent) {
97  *result = 0.0;
98  } else if (parent->isLayout()) { // sublayouts have 0 margin by default
99  *result = 0.0;
100  } else {
101  *result = 0.0;
102  if (QGraphicsItem *layoutParentItem = parentItem()) {
103  if (layoutParentItem->isWidget())
104  *result = (qreal)static_cast<QGraphicsWidget*>(layoutParentItem)->style()->pixelMetric(pm, 0);
105  }
106  }
107 }
double qreal
Definition: qglobal.h:1193
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
#define Q_Q(Class)
Definition: qglobal.h:2483
The QGraphicsLayoutItem class can be inherited to allow your custom items to be managed by layouts...
QGraphicsItem * parentItem() const
Returns the parent item of this layout, or 0 if this layout is not installed on any widget...
bool isLayout() const
Returns true if this QGraphicsLayoutItem is a layout (e.g., is inherited by an object that arranges o...
QGraphicsLayoutItem * parentLayoutItem() const
Returns the parent of this QGraphicsLayoutItem, or 0 if there is no parent, or if the parent does not...
The QGraphicsLayout class provides the base class for all layouts in Graphics View.
QGraphicsLayoutItem * parent
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ reparentChildItems()

void QGraphicsLayoutPrivate::reparentChildItems ( QGraphicsItem newParent)
Warning
This function is not part of the public interface.

mw is the new parent. all items in the layout will be a child of mw.

Definition at line 58 of file qgraphicslayout_p.cpp.

59 {
61  int n = q->count();
62  //bool mwVisible = mw && mw->isVisible();
63  for (int i = 0; i < n; ++i) {
64  QGraphicsLayoutItem *layoutChild = q->itemAt(i);
65  if (!layoutChild) {
66  // Skip stretch items
67  continue;
68  }
69  if (layoutChild->isLayout()) {
70  QGraphicsLayout *l = static_cast<QGraphicsLayout*>(layoutChild);
71  l->d_func()->reparentChildItems(newParent);
72  } else if (QGraphicsItem *itemChild = layoutChild->graphicsItem()){
73  QGraphicsItem *childParent = itemChild->parentItem();
74 #ifdef QT_DEBUG
75  if (childParent && childParent != newParent && itemChild->isWidget() && qt_graphicsLayoutDebug()) {
76  QGraphicsWidget *w = static_cast<QGraphicsWidget*>(layoutChild);
77  qWarning("QGraphicsLayout::addChildLayout: widget %s \"%s\" in wrong parent; moved to correct parent",
79  }
80 #endif
81  if (childParent != newParent)
82  itemChild->setParentItem(newParent);
83  }
84  }
85 }
QGraphicsItem * graphicsItem() const
Returns the QGraphicsItem that this layout item represents.
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
bool qt_graphicsLayoutDebug()
#define Q_Q(Class)
Definition: qglobal.h:2483
Q_CORE_EXPORT void qWarning(const char *,...)
The QGraphicsLayoutItem class can be inherited to allow your custom items to be managed by layouts...
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
bool isLayout() const
Returns true if this QGraphicsLayoutItem is a layout (e.g., is inherited by an object that arranges o...
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
QGraphicsItem * parentItem() const
Returns a pointer to this item&#39;s parent item.
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
QString objectName() const
The QGraphicsLayout class provides the base class for all layouts in Graphics View.
bool isWidget() const
Returns true if this item is a widget (i.
QFactoryLoader * l
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ visualDirection()

Qt::LayoutDirection QGraphicsLayoutPrivate::visualDirection ( ) const

Definition at line 109 of file qgraphicslayout_p.cpp.

Referenced by QGraphicsAnchorLayoutPrivate::setItemsGeometries().

110 {
111  if (QGraphicsItem *maybeWidget = parentItem()) {
112  if (maybeWidget->isWidget())
113  return static_cast<QGraphicsWidget*>(maybeWidget)->layoutDirection();
114  }
116 }
static Qt::LayoutDirection layoutDirection()
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
QGraphicsItem * parentItem() const
Returns the parent item of this layout, or 0 if this layout is not installed on any widget...

Properties

◆ activated

bool QGraphicsLayoutPrivate::activated

Definition at line 146 of file qgraphicslayout_p.h.

◆ bottom

qreal QGraphicsLayoutPrivate::bottom

Definition at line 145 of file qgraphicslayout_p.h.

◆ left

qreal QGraphicsLayoutPrivate::left

◆ right

qreal QGraphicsLayoutPrivate::right

◆ top

qreal QGraphicsLayoutPrivate::top

The documentation for this class was generated from the following files: