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

#include <qgraphicsanchorlayout_p.h>

Inheritance diagram for SequentialAnchorData:
AnchorData QSimplexVariable

Public Functions

void calculateSizeHints ()
 
 SequentialAnchorData (const QVector< AnchorVertex *> &vertices, const QVector< AnchorData *> &edges)
 
virtual void updateChildrenSizes ()
 
- Public Functions inherited from AnchorData
 AnchorData ()
 
void dump (int indent=2)
 
void refreshSizeHints (const QLayoutStyleInfo *styleInfo=0)
 
QString toString () const
 
virtual ~AnchorData ()
 
- Public Functions inherited from QSimplexVariable
 QSimplexVariable ()
 

Public Variables

QVector< AnchorVertex * > m_children
 
QVector< AnchorData * > m_edges
 
- Public Variables inherited from AnchorData
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
 

Additional Inherited Members

- Public Types inherited from AnchorData
enum  Dependency { Independent = 0, Master, Slave }
 
enum  Type { Normal = 0, Sequential, Parallel }
 

Detailed Description

Definition at line 191 of file qgraphicsanchorlayout_p.h.

Constructors and Destructors

◆ SequentialAnchorData()

SequentialAnchorData::SequentialAnchorData ( const QVector< AnchorVertex *> &  vertices,
const QVector< AnchorData *> &  edges 
)
inline

Definition at line 193 of file qgraphicsanchorlayout_p.h.

194  : AnchorData(), m_children(vertices), m_edges(edges)
195  {
198 #ifdef QT_DEBUG
199  name = QString::fromAscii("%1 -- %2").arg(vertices.first()->toString(), vertices.last()->toString());
200 #endif
201  }
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
T & first()
Returns a reference to the first item in the vector.
Definition: qvector.h:260
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
QVector< AnchorVertex * > m_children
T & last()
Returns a reference to the last item in the vector.
Definition: qvector.h:262
QVector< AnchorData * > m_edges

Functions

◆ calculateSizeHints()

void SequentialAnchorData::calculateSizeHints ( )

Definition at line 523 of file qgraphicsanchorlayout_p.cpp.

Referenced by createSequence().

524 {
525  minSize = 0;
526  prefSize = 0;
527  maxSize = 0;
528  minPrefSize = 0;
529  maxPrefSize = 0;
530 
531  AnchorVertex *prev = from;
532 
533  for (int i = 0; i < m_edges.count(); ++i) {
534  AnchorData *edge = m_edges.at(i);
535 
536  const bool edgeIsForward = (edge->from == prev);
537  if (edgeIsForward) {
538  minSize += edge->minSize;
539  prefSize += edge->prefSize;
540  maxSize += edge->maxSize;
541  minPrefSize += edge->minPrefSize;
542  maxPrefSize += edge->maxPrefSize;
543  prev = edge->to;
544  } else {
545  Q_ASSERT(prev == edge->to);
546  minSize -= edge->maxSize;
547  prefSize -= edge->prefSize;
548  maxSize -= edge->minSize;
549  minPrefSize -= edge->maxPrefSize;
550  maxPrefSize -= edge->minPrefSize;
551  prev = edge->from;
552  }
553  }
554 
555  // See comment in AnchorData::refreshSizeHints() about sizeAt* values
559 }
Represents an edge (anchor) in the internal graph.
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
AnchorVertex * to
AnchorVertex * from
QVector< AnchorData * > m_edges

◆ updateChildrenSizes()

void SequentialAnchorData::updateChildrenSizes ( )
virtual

Reimplemented from AnchorData.

Definition at line 479 of file qgraphicsanchorlayout_p.cpp.

480 {
481  // Band here refers if the value is in the Minimum To Preferred
482  // band (the lower band) or the Preferred To Maximum (the upper band).
483 
490 
491  // XXX This is not safe if Vertex simplification takes place after the sequential
492  // anchor is created. In that case, "prev" will be a group-vertex, different from
493  // "from" or "to", that _contains_ one of them.
494  AnchorVertex *prev = from;
495 
496  for (int i = 0; i < m_edges.count(); ++i) {
497  AnchorData *e = m_edges.at(i);
498 
499  const bool edgeIsForward = (e->from == prev);
500  if (edgeIsForward) {
501  e->sizeAtMinimum = interpolate(minFactor, e->minSize, e->minPrefSize,
502  e->prefSize, e->maxPrefSize, e->maxSize);
503  e->sizeAtPreferred = interpolate(prefFactor, e->minSize, e->minPrefSize,
504  e->prefSize, e->maxPrefSize, e->maxSize);
505  e->sizeAtMaximum = interpolate(maxFactor, e->minSize, e->minPrefSize,
506  e->prefSize, e->maxPrefSize, e->maxSize);
507  prev = e->to;
508  } else {
509  Q_ASSERT(prev == e->to);
510  e->sizeAtMinimum = interpolate(minFactor, e->maxSize, e->maxPrefSize,
511  e->prefSize, e->minPrefSize, e->minSize);
512  e->sizeAtPreferred = interpolate(prefFactor, e->maxSize, e->maxPrefSize,
513  e->prefSize, e->minPrefSize, e->minSize);
514  e->sizeAtMaximum = interpolate(maxFactor, e->maxSize, e->maxPrefSize,
515  e->prefSize, e->minPrefSize, e->minSize);
516  prev = e->from;
517  }
518 
519  e->updateChildrenSizes();
520  }
521 }
Represents an edge (anchor) in the internal graph.
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
static qreal interpolate(const QPair< QGraphicsAnchorLayoutPrivate::Interval, qreal > &factor, qreal min, qreal minPref, qreal pref, qreal maxPref, qreal max)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static QPair< QGraphicsAnchorLayoutPrivate::Interval, qreal > getFactor(qreal value, qreal min, qreal minPref, qreal pref, qreal maxPref, qreal max)
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
AnchorVertex * to
AnchorVertex * from
QVector< AnchorData * > m_edges
virtual void updateChildrenSizes()

Properties

◆ m_children

QVector<AnchorVertex*> SequentialAnchorData::m_children

Definition at line 206 of file qgraphicsanchorlayout_p.h.

◆ m_edges

QVector<AnchorData*> SequentialAnchorData::m_edges

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