Qt 4.8
Public Types | Public Functions | Public Variables | List of all members
AnchorData Struct Reference

Represents an edge (anchor) in the internal graph. More...

#include <qgraphicsanchorlayout_p.h>

Inheritance diagram for AnchorData:
QSimplexVariable ParallelAnchorData SequentialAnchorData

Public Types

enum  Dependency { Independent = 0, Master, Slave }
 
enum  Type { Normal = 0, Sequential, Parallel }
 

Public Functions

 AnchorData ()
 
void dump (int indent=2)
 
void refreshSizeHints (const QLayoutStyleInfo *styleInfo=0)
 
QString toString () const
 
virtual void updateChildrenSizes ()
 
virtual ~AnchorData ()
 
- Public Functions inherited from QSimplexVariable
 QSimplexVariable ()
 

Public Variables

uint dependency: 2
 
AnchorVertexfrom
 
QGraphicsAnchorgraphicsAnchor
 
uint isCenterAnchor: 1
 
uint isLayoutAnchor: 1
 
QGraphicsLayoutItemitem
 
qreal maxPrefSize
 
qreal maxSize
 
qreal minPrefSize
 
qreal minSize
 
QString name
 
uint orientation: 1
 
qreal prefSize
 
qreal sizeAtMaximum
 
qreal sizeAtMinimum
 
qreal sizeAtPreferred
 
AnchorVertexto
 
uint type: 2
 
- Public Variables inherited from QSimplexVariable
int index
 
qreal result
 

Detailed Description

Represents an edge (anchor) in the internal graph.

Warning
This function is not part of the public interface.

Definition at line 113 of file qgraphicsanchorlayout_p.h.

Enumerations

◆ Dependency

Enumerator
Independent 
Master 
Slave 

Definition at line 120 of file qgraphicsanchorlayout_p.h.

◆ Type

Enumerator
Normal 
Sequential 
Parallel 

Definition at line 114 of file qgraphicsanchorlayout_p.h.

Constructors and Destructors

◆ AnchorData()

AnchorData::AnchorData ( )
inline

Definition at line 126 of file qgraphicsanchorlayout_p.h.

127  : QSimplexVariable(), from(0), to(0),
128  minSize(0), prefSize(0), maxSize(0),
129  minPrefSize(0), maxPrefSize(0),
131  sizeAtMaximum(0), item(0), graphicsAnchor(0),
132  type(Normal), isLayoutAnchor(false),
133  isCenterAnchor(false), orientation(0),
QGraphicsLayoutItem * item
QGraphicsAnchor * graphicsAnchor
AnchorVertex * to
AnchorVertex * from

◆ ~AnchorData()

AnchorData::~AnchorData ( )
virtual

Definition at line 166 of file qgraphicsanchorlayout_p.cpp.

167 {
168  if (graphicsAnchor) {
169  // Remove reference to ourself to avoid double removal in
170  // QGraphicsAnchorPrivate dtor.
171  graphicsAnchor->d_func()->data = 0;
172 
173  delete graphicsAnchor;
174  }
175 }
QGraphicsAnchor * graphicsAnchor

Functions

◆ dump()

void AnchorData::dump ( int  indent = 2)

Definition at line 562 of file qgraphicsanchorlayout_p.cpp.

Referenced by dump().

562  {
563  if (type == Parallel) {
564  qDebug("%*s type: parallel:", indent, "");
565  ParallelAnchorData *p = static_cast<ParallelAnchorData *>(this);
566  p->firstEdge->dump(indent+2);
567  p->secondEdge->dump(indent+2);
568  } else if (type == Sequential) {
569  SequentialAnchorData *s = static_cast<SequentialAnchorData *>(this);
570  int kids = s->m_edges.count();
571  qDebug("%*s type: sequential(%d):", indent, "", kids);
572  for (int i = 0; i < kids; ++i) {
573  s->m_edges.at(i)->dump(indent+2);
574  }
575  } else {
576  qDebug("%*s type: Normal:", indent, "");
577  }
578 }
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
Q_CORE_EXPORT void qDebug(const char *,...)
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
void dump(int indent=2)
QVector< AnchorData * > m_edges

◆ refreshSizeHints()

void AnchorData::refreshSizeHints ( const QLayoutStyleInfo styleInfo = 0)

Definition at line 178 of file qgraphicsanchorlayout_p.cpp.

Referenced by QGraphicsAnchorLayoutPrivate::createCenterAnchors(), QGraphicsAnchorLayoutPrivate::createItemEdges(), QGraphicsAnchorLayoutPrivate::refreshAllSizeHints(), and QGraphicsAnchorLayoutPrivate::removeCenterAnchors().

179 {
180  QSizePolicy::Policy policy;
181  qreal minSizeHint;
182  qreal prefSizeHint;
183  qreal maxSizeHint;
184 
185  if (item) {
186  // It is an internal anchor, fetch size information from the item
187  if (isLayoutAnchor) {
188  minSize = 0;
189  prefSize = 0;
191  if (isCenterAnchor)
192  maxSize /= 2;
193 
196  return;
197  } else {
199  policy = item->sizePolicy().horizontalPolicy();
200  minSizeHint = item->effectiveSizeHint(Qt::MinimumSize).width();
201  prefSizeHint = item->effectiveSizeHint(Qt::PreferredSize).width();
202  maxSizeHint = item->effectiveSizeHint(Qt::MaximumSize).width();
203  } else {
204  policy = item->sizePolicy().verticalPolicy();
205  minSizeHint = item->effectiveSizeHint(Qt::MinimumSize).height();
206  prefSizeHint = item->effectiveSizeHint(Qt::PreferredSize).height();
207  maxSizeHint = item->effectiveSizeHint(Qt::MaximumSize).height();
208  }
209 
210  if (isCenterAnchor) {
211  minSizeHint /= 2;
212  prefSizeHint /= 2;
213  maxSizeHint /= 2;
214  }
215  }
216  } else {
217  // It is a user-created anchor, fetch size information from the associated QGraphicsAnchor
219  QGraphicsAnchorPrivate *anchorPrivate = graphicsAnchor->d_func();
220 
221  // Policy, min and max sizes are straightforward
222  policy = anchorPrivate->sizePolicy;
223  minSizeHint = 0;
224  maxSizeHint = QWIDGETSIZE_MAX;
225 
226  // Preferred Size
227  if (anchorPrivate->hasSize) {
228  // Anchor has user-defined size
229  prefSizeHint = anchorPrivate->preferredSize;
230  } else {
231  // Fetch size information from style
233  qreal s = styleInfo->defaultSpacing(orient);
234  if (s < 0) {
237  s = styleInfo->perItemSpacing(controlTypeFrom, controlTypeTo, orient);
238 
239  // ### Currently we do not support negative anchors inside the graph.
240  // To avoid those being created by a negative style spacing, we must
241  // make this test.
242  if (s < 0)
243  s = 0;
244  }
245  prefSizeHint = s;
246  }
247  }
248 
249  // Fill minSize, prefSize and maxSize based on policy and sizeHints
250  applySizePolicy(policy, minSizeHint, prefSizeHint, maxSizeHint,
251  &minSize, &prefSize, &maxSize);
252 
255 
256  // Set the anchor effective sizes to preferred.
257  //
258  // Note: The idea here is that all items should remain at their
259  // preferred size unless where that's impossible. In cases where
260  // the item is subject to restrictions (anchored to the layout
261  // edges, for instance), the simplex solver will be run to
262  // recalculate and override the values we set here.
266 }
QSizeF effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const
Returns the effective size hint for this QGraphicsLayoutItem.
double qreal
Definition: qglobal.h:1193
QGraphicsLayoutItem * item
qreal width() const
Returns the width.
Definition: qsize.h:284
Qt::AnchorPoint m_edge
Policy horizontalPolicy() const
Definition: qsizepolicy.h:118
qreal height() const
Returns the height.
Definition: qsize.h:287
#define QWIDGETSIZE_MAX
Defines the maximum size for a QWidget object.
Definition: qwidget.h:1087
QGraphicsAnchor * graphicsAnchor
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static void applySizePolicy(QSizePolicy::Policy policy, qreal minSizeHint, qreal prefSizeHint, qreal maxSizeHint, qreal *minSize, qreal *prefSize, qreal *maxSize)
static Orientation edgeOrientation(Qt::AnchorPoint edge)
QGraphicsLayoutItem * m_item
qreal perItemSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation) const
AnchorVertex * to
AnchorVertex * from
QSizePolicy sizePolicy() const
Returns the current size policy.
qreal defaultSpacing(Qt::Orientation o) const
Policy verticalPolicy() const
Definition: qsizepolicy.h:119
QSizePolicy::Policy sizePolicy
Orientation
Definition: qnamespace.h:174
ControlType controlType() const
Definition: qlayout.cpp:1670

◆ toString()

QString AnchorData::toString ( ) const
inline

Definition at line 185 of file qgraphicsanchorlayout_p.h.

Referenced by ParallelAnchorData::ParallelAnchorData(), and GraphPath::toString().

186 {
187  return QString::fromAscii("Anchor(%1)").arg(name);
188 }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186

◆ updateChildrenSizes()

virtual void AnchorData::updateChildrenSizes ( )
inlinevirtual

Properties

◆ dependency

uint AnchorData::dependency

◆ from

AnchorVertex* AnchorData::from

◆ graphicsAnchor

QGraphicsAnchor* AnchorData::graphicsAnchor

◆ isCenterAnchor

uint AnchorData::isCenterAnchor

◆ isLayoutAnchor

uint AnchorData::isLayoutAnchor

◆ item

QGraphicsLayoutItem* AnchorData::item

◆ maxPrefSize

qreal AnchorData::maxPrefSize

◆ maxSize

qreal AnchorData::maxSize

◆ minPrefSize

qreal AnchorData::minPrefSize

◆ minSize

qreal AnchorData::minSize

◆ name

QString AnchorData::name

◆ orientation

uint AnchorData::orientation

◆ prefSize

qreal AnchorData::prefSize

◆ sizeAtMaximum

qreal AnchorData::sizeAtMaximum

◆ sizeAtMinimum

qreal AnchorData::sizeAtMinimum

◆ sizeAtPreferred

qreal AnchorData::sizeAtPreferred

◆ to

AnchorVertex* AnchorData::to

◆ type

uint AnchorData::type

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