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

#include <qdeclarativeanchors_p_p.h>

Inheritance diagram for QDeclarativeAnchorsPrivate:
QObjectPrivate QDeclarativeItemChangeListener QObjectData

Public Functions

void _q_widgetDestroyed (QObject *)
 
void _q_widgetGeometryChanged ()
 
void addDepend (QGraphicsObject *)
 
QDeclarativeAnchorsPrivateanchorPrivate ()
 
bool calcStretch (const QDeclarativeAnchorLine &edge1, const QDeclarativeAnchorLine &edge2, qreal offset1, qreal offset2, QDeclarativeAnchorLine::AnchorLine line, qreal &stretch)
 
void centerInChanged ()
 
bool checkHAnchorValid (QDeclarativeAnchorLine anchor) const
 
bool checkHValid () const
 
bool checkVAnchorValid (QDeclarativeAnchorLine anchor) const
 
bool checkVValid () const
 
void clearItem (QGraphicsObject *)
 
void fillChanged ()
 
bool isItemComplete () const
 
bool isMirrored () const
 
void itemGeometryChanged (QDeclarativeItem *, const QRectF &, const QRectF &)
 
 QDeclarativeAnchorsPrivate (QGraphicsObject *i)
 
void remDepend (QGraphicsObject *)
 
void setItemHeight (qreal)
 
void setItemPos (const QPointF &)
 
void setItemSize (const QSizeF &)
 
void setItemWidth (qreal)
 
void setItemX (qreal)
 
void setItemY (qreal)
 
void updateHorizontalAnchors ()
 
void updateMe ()
 
void updateOnComplete ()
 
void updateVerticalAnchors ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 
- Public Functions inherited from QDeclarativeItemChangeListener
virtual void itemDestroyed (QDeclarativeItem *)
 
virtual void itemOpacityChanged (QDeclarativeItem *)
 
virtual void itemSiblingOrderChanged (QDeclarativeItem *)
 
virtual void itemVisibilityChanged (QDeclarativeItem *)
 

Public Variables

QDeclarativeAnchorLine baseline
 
qreal baselineOffset
 
QDeclarativeAnchorLine bottom
 
qreal bottomMargin
 
QGraphicsObjectcenterIn
 
bool componentComplete:1
 
QGraphicsObjectfill
 
QDeclarativeAnchorLine hCenter
 
qreal hCenterOffset
 
QGraphicsObjectitem
 
QDeclarativeAnchorLine left
 
qreal leftMargin
 
qreal margins
 
QDeclarativeAnchorLine right
 
qreal rightMargin
 
QDeclarativeAnchorLine top
 
qreal topMargin
 
uint updatingCenterIn:2
 
uint updatingFill:2
 
uint updatingHorizontalAnchor:2
 
bool updatingMe:1
 
uint updatingVerticalAnchor:2
 
QDeclarativeAnchors::Anchors usedAnchors
 
QDeclarativeAnchorLine vCenter
 
qreal vCenterOffset
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Additional Inherited Members

- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 

Detailed Description

Definition at line 89 of file qdeclarativeanchors_p_p.h.

Constructors and Destructors

◆ QDeclarativeAnchorsPrivate()

QDeclarativeAnchorsPrivate::QDeclarativeAnchorsPrivate ( QGraphicsObject i)
inline

Definition at line 93 of file qdeclarativeanchors_p_p.h.

98  {
99  }
QDeclarativeAnchors::Anchors usedAnchors

Functions

◆ _q_widgetDestroyed()

void QDeclarativeAnchorsPrivate::_q_widgetDestroyed ( QObject obj)

Definition at line 393 of file qdeclarativeanchors.cpp.

394 {
395  clearItem(qobject_cast<QGraphicsObject*>(obj));
396 }
void clearItem(QGraphicsObject *)

◆ _q_widgetGeometryChanged()

void QDeclarativeAnchorsPrivate::_q_widgetGeometryChanged ( )

◆ addDepend()

void QDeclarativeAnchorsPrivate::addDepend ( QGraphicsObject item)

Definition at line 269 of file qdeclarativeanchors.cpp.

270 {
271  if (!item)
272  return;
273  QGraphicsItemPrivate * itemPrivate = QGraphicsItemPrivate::get(item);
274  if (itemPrivate->isDeclarativeItem) {
278  } else if(itemPrivate->isWidget) {
280  QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
281  QObject::connect(widget, SIGNAL(destroyed(QObject*)), q, SLOT(_q_widgetDestroyed(QObject*)));
282  QObject::connect(widget, SIGNAL(geometryChanged()), q, SLOT(_q_widgetGeometryChanged()));
283  }
284 }
QPointer< QWidget > widget
#define SLOT(a)
Definition: qobjectdefs.h:226
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_Q(Class)
Definition: qglobal.h:2483
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
void addItemChangeListener(QDeclarativeItemChangeListener *listener, ChangeTypes types)
static const QGraphicsItemPrivate * get(const QGraphicsItem *item)
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ anchorPrivate()

QDeclarativeAnchorsPrivate* QDeclarativeAnchorsPrivate::anchorPrivate ( )
inlinevirtual

Reimplemented from QDeclarativeItemChangeListener.

Definition at line 128 of file qdeclarativeanchors_p_p.h.

128 { return this; }

◆ calcStretch()

bool QDeclarativeAnchorsPrivate::calcStretch ( const QDeclarativeAnchorLine edge1,
const QDeclarativeAnchorLine edge2,
qreal  offset1,
qreal  offset2,
QDeclarativeAnchorLine::AnchorLine  line,
qreal stretch 
)

Definition at line 485 of file qdeclarativeanchors.cpp.

491 {
492  bool edge1IsParent = (edge1.item == item->parentItem());
493  bool edge2IsParent = (edge2.item == item->parentItem());
494  bool edge1IsSibling = (edge1.item->parentItem() == item->parentItem());
495  bool edge2IsSibling = (edge2.item->parentItem() == item->parentItem());
496 
497  bool invalid = false;
498  if ((edge2IsParent && edge1IsParent) || (edge2IsSibling && edge1IsSibling)) {
499  stretch = (position(edge2.item, edge2.anchorLine) + offset2)
500  - (position(edge1.item, edge1.anchorLine) + offset1);
501  } else if (edge2IsParent && edge1IsSibling) {
502  stretch = (position(edge2.item, edge2.anchorLine) + offset2)
503  - (position(item->parentObject(), line)
504  + position(edge1.item, edge1.anchorLine) + offset1);
505  } else if (edge2IsSibling && edge1IsParent) {
506  stretch = (position(item->parentObject(), line) + position(edge2.item, edge2.anchorLine) + offset2)
507  - (position(edge1.item, edge1.anchorLine) + offset1);
508  } else
509  invalid = true;
510 
511  return invalid;
512 }
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
QGraphicsObject * parentObject() const
Returns a pointer to the item&#39;s parent, cast to a QGraphicsObject.
QGraphicsItem * parentItem() const
Returns a pointer to this item&#39;s parent item.

◆ centerInChanged()

void QDeclarativeAnchorsPrivate::centerInChanged ( )

Definition at line 203 of file qdeclarativeanchors.cpp.

204 {
206  if (!centerIn || fill || !isItemComplete())
207  return;
208 
209  if (updatingCenterIn < 2) {
211 
212  qreal effectiveHCenterOffset = q->mirrored() ? -hCenterOffset : hCenterOffset;
213  if (centerIn == item->parentItem()) {
214  QPointF p(hcenter(item->parentItem()) - hcenter(item) + effectiveHCenterOffset,
216  setItemPos(p);
217 
218  } else if (centerIn->parentItem() == item->parentItem()) {
219  QPointF p(centerIn->x() + hcenter(centerIn) - hcenter(item) + effectiveHCenterOffset,
221  setItemPos(p);
222  }
223 
225  } else {
226  // ### Make this certain :)
227  qmlInfo(item) << QDeclarativeAnchors::tr("Possible anchor loop detected on centerIn.");
228  }
229 }
double qreal
Definition: qglobal.h:1193
qreal y
the y position of the item
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
static qreal vcenter(QGraphicsItem *i)
#define Q_Q(Class)
Definition: qglobal.h:2483
QGraphicsItem * parentItem() const
Returns a pointer to this item&#39;s parent item.
static qreal hcenter(QGraphicsItem *i)
qreal x
the x position of the item
QDeclarativeInfo qmlInfo(const QObject *me)
void setItemPos(const QPointF &)

◆ checkHAnchorValid()

bool QDeclarativeAnchorsPrivate::checkHAnchorValid ( QDeclarativeAnchorLine  anchor) const

Definition at line 1106 of file qdeclarativeanchors.cpp.

1107 {
1108  if (!anchor.item) {
1109  qmlInfo(item) << QDeclarativeAnchors::tr("Cannot anchor to a null item.");
1110  return false;
1111  } else if (anchor.anchorLine & QDeclarativeAnchorLine::Vertical_Mask) {
1112  qmlInfo(item) << QDeclarativeAnchors::tr("Cannot anchor a horizontal edge to a vertical edge.");
1113  return false;
1114  } else if (anchor.item != item->parentItem() && anchor.item->parentItem() != item->parentItem()){
1115  qmlInfo(item) << QDeclarativeAnchors::tr("Cannot anchor to an item that isn't a parent or sibling.");
1116  return false;
1117  } else if (anchor.item == item) {
1118  qmlInfo(item) << QDeclarativeAnchors::tr("Cannot anchor item to self.");
1119  return false;
1120  }
1121 
1122  return true;
1123 }
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QGraphicsItem * parentItem() const
Returns a pointer to this item&#39;s parent item.
QDeclarativeInfo qmlInfo(const QObject *me)

◆ checkHValid()

bool QDeclarativeAnchorsPrivate::checkHValid ( ) const

Definition at line 1094 of file qdeclarativeanchors.cpp.

1095 {
1099  qmlInfo(item) << QDeclarativeAnchors::tr("Cannot specify left, right, and hcenter anchors.");
1100  return false;
1101  }
1102 
1103  return true;
1104 }
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QDeclarativeAnchors::Anchors usedAnchors
QDeclarativeInfo qmlInfo(const QObject *me)

◆ checkVAnchorValid()

bool QDeclarativeAnchorsPrivate::checkVAnchorValid ( QDeclarativeAnchorLine  anchor) const

Definition at line 1143 of file qdeclarativeanchors.cpp.

1144 {
1145  if (!anchor.item) {
1146  qmlInfo(item) << QDeclarativeAnchors::tr("Cannot anchor to a null item.");
1147  return false;
1149  qmlInfo(item) << QDeclarativeAnchors::tr("Cannot anchor a vertical edge to a horizontal edge.");
1150  return false;
1151  } else if (anchor.item != item->parentItem() && anchor.item->parentItem() != item->parentItem()){
1152  qmlInfo(item) << QDeclarativeAnchors::tr("Cannot anchor to an item that isn't a parent or sibling.");
1153  return false;
1154  } else if (anchor.item == item){
1155  qmlInfo(item) << QDeclarativeAnchors::tr("Cannot anchor item to self.");
1156  return false;
1157  }
1158 
1159  return true;
1160 }
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QGraphicsItem * parentItem() const
Returns a pointer to this item&#39;s parent item.
QDeclarativeInfo qmlInfo(const QObject *me)

◆ checkVValid()

bool QDeclarativeAnchorsPrivate::checkVValid ( ) const

Definition at line 1125 of file qdeclarativeanchors.cpp.

1126 {
1130  qmlInfo(item) << QDeclarativeAnchors::tr("Cannot specify top, bottom, and vcenter anchors.");
1131  return false;
1135  usedAnchors & QDeclarativeAnchors::VCenterAnchor)) {
1136  qmlInfo(item) << QDeclarativeAnchors::tr("Baseline anchor cannot be used in conjunction with top, bottom, or vcenter anchors.");
1137  return false;
1138  }
1139 
1140  return true;
1141 }
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QDeclarativeAnchors::Anchors usedAnchors
QDeclarativeInfo qmlInfo(const QObject *me)

◆ clearItem()

void QDeclarativeAnchorsPrivate::clearItem ( QGraphicsObject item)

Definition at line 231 of file qdeclarativeanchors.cpp.

Referenced by QDeclarativeItem::~QDeclarativeItem().

232 {
233  if (!item)
234  return;
235  if (fill == item)
236  fill = 0;
237  if (centerIn == item)
238  centerIn = 0;
239  if (left.item == item) {
240  left.item = 0;
241  usedAnchors &= ~QDeclarativeAnchors::LeftAnchor;
242  }
243  if (right.item == item) {
244  right.item = 0;
245  usedAnchors &= ~QDeclarativeAnchors::RightAnchor;
246  }
247  if (top.item == item) {
248  top.item = 0;
249  usedAnchors &= ~QDeclarativeAnchors::TopAnchor;
250  }
251  if (bottom.item == item) {
252  bottom.item = 0;
253  usedAnchors &= ~QDeclarativeAnchors::BottomAnchor;
254  }
255  if (vCenter.item == item) {
256  vCenter.item = 0;
257  usedAnchors &= ~QDeclarativeAnchors::VCenterAnchor;
258  }
259  if (hCenter.item == item) {
260  hCenter.item = 0;
261  usedAnchors &= ~QDeclarativeAnchors::HCenterAnchor;
262  }
263  if (baseline.item == item) {
264  baseline.item = 0;
265  usedAnchors &= ~QDeclarativeAnchors::BaselineAnchor;
266  }
267 }
QDeclarativeAnchors::Anchors usedAnchors

◆ fillChanged()

void QDeclarativeAnchorsPrivate::fillChanged ( )

Definition at line 176 of file qdeclarativeanchors.cpp.

177 {
179  if (!fill || !isItemComplete())
180  return;
181 
182  if (updatingFill < 2) {
183  ++updatingFill;
184 
185  qreal horizontalMargin = q->mirrored() ? rightMargin : leftMargin;
186 
187  if (fill == item->parentItem()) { //child-parent
188  setItemPos(QPointF(horizontalMargin, topMargin));
189  } else if (fill->parentItem() == item->parentItem()) { //siblings
190  setItemPos(QPointF(fill->x()+horizontalMargin, fill->y()+topMargin));
191  }
193  setItemSize(QSizeF(fillPrivate->width()-leftMargin-rightMargin, fillPrivate->height()-topMargin-bottomMargin));
194 
195  --updatingFill;
196  } else {
197  // ### Make this certain :)
198  qmlInfo(item) << QDeclarativeAnchors::tr("Possible anchor loop detected on fill.");
199  }
200 
201 }
double qreal
Definition: qglobal.h:1193
qreal y
the y position of the item
virtual qreal height() const
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
#define Q_Q(Class)
Definition: qglobal.h:2483
void setItemSize(const QSizeF &)
QGraphicsItem * parentItem() const
Returns a pointer to this item&#39;s parent item.
virtual qreal width() const
static const QGraphicsItemPrivate * get(const QGraphicsItem *item)
qreal x
the x position of the item
QDeclarativeInfo qmlInfo(const QObject *me)
void setItemPos(const QPointF &)

◆ isItemComplete()

bool QDeclarativeAnchorsPrivate::isItemComplete ( ) const

Definition at line 303 of file qdeclarativeanchors.cpp.

304 {
305  return componentComplete;
306 }

◆ isMirrored()

bool QDeclarativeAnchorsPrivate::isMirrored ( ) const

◆ itemGeometryChanged()

void QDeclarativeAnchorsPrivate::itemGeometryChanged ( QDeclarativeItem ,
const QRectF newG,
const QRectF oldG 
)
virtual

Reimplemented from QDeclarativeItemChangeListener.

Definition at line 406 of file qdeclarativeanchors.cpp.

407 {
408  fillChanged();
409  centerInChanged();
410  if (newG.x() != oldG.x() || newG.width() != oldG.width())
412  if (newG.y() != oldG.y() || newG.height() != oldG.height())
414 }
qreal y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:667
qreal height() const
Returns the height of the rectangle.
Definition: qrect.h:710
qreal width() const
Returns the width of the rectangle.
Definition: qrect.h:707
qreal x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:664

◆ remDepend()

void QDeclarativeAnchorsPrivate::remDepend ( QGraphicsObject item)

Definition at line 286 of file qdeclarativeanchors.cpp.

287 {
288  if (!item)
289  return;
290  QGraphicsItemPrivate * itemPrivate = QGraphicsItemPrivate::get(item);
291  if (itemPrivate->isDeclarativeItem) {
293  static_cast<QDeclarativeItemPrivate *>(itemPrivate);
295  } else if(itemPrivate->isWidget) {
297  QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
298  QObject::disconnect(widget, SIGNAL(destroyed(QObject*)), q, SLOT(_q_widgetDestroyed(QObject*)));
299  QObject::disconnect(widget, SIGNAL(geometryChanged()), q, SLOT(_q_widgetGeometryChanged()));
300  }
301 }
QPointer< QWidget > widget
#define SLOT(a)
Definition: qobjectdefs.h:226
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_Q(Class)
Definition: qglobal.h:2483
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895
void removeItemChangeListener(QDeclarativeItemChangeListener *, ChangeTypes types)
static const QGraphicsItemPrivate * get(const QGraphicsItem *item)
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ setItemHeight()

void QDeclarativeAnchorsPrivate::setItemHeight ( qreal  v)

Definition at line 327 of file qdeclarativeanchors.cpp.

328 {
329  updatingMe = true;
331  updatingMe = false;
332 }
static const QGraphicsItemPrivate * get(const QGraphicsItem *item)
virtual void setHeight(qreal)

◆ setItemPos()

void QDeclarativeAnchorsPrivate::setItemPos ( const QPointF v)

Definition at line 355 of file qdeclarativeanchors.cpp.

356 {
357  updatingMe = true;
358  item->setPos(v);
359  updatingMe = false;
360 }
void setPos(const QPointF &pos)
Sets the position of the item to pos, which is in parent coordinates.

◆ setItemSize()

void QDeclarativeAnchorsPrivate::setItemSize ( const QSizeF v)

Definition at line 362 of file qdeclarativeanchors.cpp.

363 {
364  updatingMe = true;
366  static_cast<QGraphicsWidget *>(item)->resize(v);
368  static_cast<QDeclarativeItem *>(item)->setSize(v);
369  updatingMe = false;
370 }
uint isWidget
Definition: qobject.h:95
static const QGraphicsItemPrivate * get(const QGraphicsItem *item)
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.

◆ setItemWidth()

void QDeclarativeAnchorsPrivate::setItemWidth ( qreal  v)

Definition at line 334 of file qdeclarativeanchors.cpp.

335 {
336  updatingMe = true;
338  updatingMe = false;
339 }
virtual void setWidth(qreal)
static const QGraphicsItemPrivate * get(const QGraphicsItem *item)

◆ setItemX()

void QDeclarativeAnchorsPrivate::setItemX ( qreal  v)

Definition at line 341 of file qdeclarativeanchors.cpp.

342 {
343  updatingMe = true;
344  item->setX(v);
345  updatingMe = false;
346 }
void setX(qreal x)
Set&#39;s the x coordinate of the item&#39;s position.

◆ setItemY()

void QDeclarativeAnchorsPrivate::setItemY ( qreal  v)

Definition at line 348 of file qdeclarativeanchors.cpp.

349 {
350  updatingMe = true;
351  item->setY(v);
352  updatingMe = false;
353 }
void setY(qreal y)
Set&#39;s the y coordinate of the item&#39;s position.

◆ updateHorizontalAnchors()

void QDeclarativeAnchorsPrivate::updateHorizontalAnchors ( )

Definition at line 596 of file qdeclarativeanchors.cpp.

597 {
599  if (fill || centerIn || !isItemComplete())
600  return;
601 
602  if (updatingHorizontalAnchor < 3) {
604  qreal effectiveRightMargin, effectiveLeftMargin, effectiveHorizontalCenterOffset;
605  QDeclarativeAnchorLine effectiveLeft, effectiveRight, effectiveHorizontalCenter;
606  QDeclarativeAnchors::Anchor effectiveLeftAnchor, effectiveRightAnchor;
607  if (q->mirrored()) {
608  effectiveLeftAnchor = QDeclarativeAnchors::RightAnchor;
609  effectiveRightAnchor = QDeclarativeAnchors::LeftAnchor;
610  effectiveLeft.item = right.item;
611  effectiveLeft.anchorLine = reverseAnchorLine(right.anchorLine);
612  effectiveRight.item = left.item;
613  effectiveRight.anchorLine = reverseAnchorLine(left.anchorLine);
614  effectiveHorizontalCenter.item = hCenter.item;
615  effectiveHorizontalCenter.anchorLine = reverseAnchorLine(hCenter.anchorLine);
616  effectiveLeftMargin = rightMargin;
617  effectiveRightMargin = leftMargin;
618  effectiveHorizontalCenterOffset = -hCenterOffset;
619  } else {
620  effectiveLeftAnchor = QDeclarativeAnchors::LeftAnchor;
621  effectiveRightAnchor = QDeclarativeAnchors::RightAnchor;
622  effectiveLeft = left;
623  effectiveRight = right;
624  effectiveHorizontalCenter = hCenter;
625  effectiveLeftMargin = leftMargin;
626  effectiveRightMargin = rightMargin;
627  effectiveHorizontalCenterOffset = hCenterOffset;
628  }
629 
631  if (usedAnchors & effectiveLeftAnchor) {
632  //Handle stretching
633  bool invalid = true;
634  qreal width = 0.0;
635  if (usedAnchors & effectiveRightAnchor) {
636  invalid = calcStretch(effectiveLeft, effectiveRight, effectiveLeftMargin, -effectiveRightMargin, QDeclarativeAnchorLine::Left, width);
638  invalid = calcStretch(effectiveLeft, effectiveHorizontalCenter, effectiveLeftMargin, effectiveHorizontalCenterOffset, QDeclarativeAnchorLine::Left, width);
639  width *= 2;
640  }
641  if (!invalid)
642  setItemWidth(width);
643 
644  //Handle left
645  if (effectiveLeft.item == item->parentItem()) {
646  setItemX(adjustedPosition(effectiveLeft.item, effectiveLeft.anchorLine) + effectiveLeftMargin);
647  } else if (effectiveLeft.item->parentItem() == item->parentItem()) {
648  setItemX(position(effectiveLeft.item, effectiveLeft.anchorLine) + effectiveLeftMargin);
649  }
650  } else if (usedAnchors & effectiveRightAnchor) {
651  //Handle stretching (left + right case is handled in updateLeftAnchor)
652  if (usedAnchors & QDeclarativeAnchors::HCenterAnchor) {
653  qreal width = 0.0;
654  bool invalid = calcStretch(effectiveHorizontalCenter, effectiveRight, effectiveHorizontalCenterOffset, -effectiveRightMargin,
656  if (!invalid)
657  setItemWidth(width*2);
658  }
659 
660  //Handle right
661  if (effectiveRight.item == item->parentItem()) {
662  setItemX(adjustedPosition(effectiveRight.item, effectiveRight.anchorLine) - itemPrivate->width() - effectiveRightMargin);
663  } else if (effectiveRight.item->parentItem() == item->parentItem()) {
664  setItemX(position(effectiveRight.item, effectiveRight.anchorLine) - itemPrivate->width() - effectiveRightMargin);
665  }
666  } else if (usedAnchors & QDeclarativeAnchors::HCenterAnchor) {
667  //Handle hCenter
668  if (effectiveHorizontalCenter.item == item->parentItem()) {
669  setItemX(adjustedPosition(effectiveHorizontalCenter.item, effectiveHorizontalCenter.anchorLine) - hcenter(item) + effectiveHorizontalCenterOffset);
670  } else if (effectiveHorizontalCenter.item->parentItem() == item->parentItem()) {
671  setItemX(position(effectiveHorizontalCenter.item, effectiveHorizontalCenter.anchorLine) - hcenter(item) + effectiveHorizontalCenterOffset);
672  }
673  }
675  } else {
676  // ### Make this certain :)
677  qmlInfo(item) << QDeclarativeAnchors::tr("Possible anchor loop detected on horizontal anchor.");
678  }
679 }
double qreal
Definition: qglobal.h:1193
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
static qreal adjustedPosition(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
#define Q_Q(Class)
Definition: qglobal.h:2483
bool calcStretch(const QDeclarativeAnchorLine &edge1, const QDeclarativeAnchorLine &edge2, qreal offset1, qreal offset2, QDeclarativeAnchorLine::AnchorLine line, qreal &stretch)
QDeclarativeAnchors::Anchors usedAnchors
QDeclarativeAnchorLine::AnchorLine reverseAnchorLine(QDeclarativeAnchorLine::AnchorLine anchorLine)
QGraphicsItem * parentItem() const
Returns a pointer to this item&#39;s parent item.
virtual qreal width() const
static const QGraphicsItemPrivate * get(const QGraphicsItem *item)
static qreal hcenter(QGraphicsItem *i)
QDeclarativeInfo qmlInfo(const QObject *me)

◆ updateMe()

void QDeclarativeAnchorsPrivate::updateMe ( )

Definition at line 372 of file qdeclarativeanchors.cpp.

◆ updateOnComplete()

void QDeclarativeAnchorsPrivate::updateOnComplete ( )

◆ updateVerticalAnchors()

void QDeclarativeAnchorsPrivate::updateVerticalAnchors ( )

Definition at line 514 of file qdeclarativeanchors.cpp.

Referenced by QDeclarativeItem::setBaselineOffset().

515 {
516  if (fill || centerIn || !isItemComplete())
517  return;
518 
519  if (updatingVerticalAnchor < 2) {
523  //Handle stretching
524  bool invalid = true;
525  qreal height = 0.0;
530  height *= 2;
531  }
532  if (!invalid)
533  setItemHeight(height);
534 
535  //Handle top
536  if (top.item == item->parentItem()) {
538  } else if (top.item->parentItem() == item->parentItem()) {
540  }
541  } else if (usedAnchors & QDeclarativeAnchors::BottomAnchor) {
542  //Handle stretching (top + bottom case is handled above)
543  if (usedAnchors & QDeclarativeAnchors::VCenterAnchor) {
544  qreal height = 0.0;
547  if (!invalid)
548  setItemHeight(height*2);
549  }
550 
551  //Handle bottom
552  if (bottom.item == item->parentItem()) {
554  } else if (bottom.item->parentItem() == item->parentItem()) {
556  }
557  } else if (usedAnchors & QDeclarativeAnchors::VCenterAnchor) {
558  //(stetching handled above)
559 
560  //Handle vCenter
561  if (vCenter.item == item->parentItem()) {
563  - vcenter(item) + vCenterOffset);
564  } else if (vCenter.item->parentItem() == item->parentItem()) {
566  }
568  //Handle baseline
569  if (baseline.item == item->parentItem()) {
570  if (itemPrivate->isDeclarativeItem)
572  - static_cast<QDeclarativeItem *>(item)->baselineOffset() + baselineOffset);
573  } else if (baseline.item->parentItem() == item->parentItem()) {
574  if (itemPrivate->isDeclarativeItem)
576  - static_cast<QDeclarativeItem *>(item)->baselineOffset() + baselineOffset);
577  }
578  }
580  } else {
581  // ### Make this certain :)
582  qmlInfo(item) << QDeclarativeAnchors::tr("Possible anchor loop detected on vertical anchor.");
583  }
584 }
double qreal
Definition: qglobal.h:1193
virtual qreal height() const
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
static qreal vcenter(QGraphicsItem *i)
static qreal adjustedPosition(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
bool calcStretch(const QDeclarativeAnchorLine &edge1, const QDeclarativeAnchorLine &edge2, qreal offset1, qreal offset2, QDeclarativeAnchorLine::AnchorLine line, qreal &stretch)
QDeclarativeAnchors::Anchors usedAnchors
QGraphicsItem * parentItem() const
Returns a pointer to this item&#39;s parent item.
static const QGraphicsItemPrivate * get(const QGraphicsItem *item)
QDeclarativeInfo qmlInfo(const QObject *me)

Properties

◆ baseline

QDeclarativeAnchorLine QDeclarativeAnchorsPrivate::baseline

Definition at line 154 of file qdeclarativeanchors_p_p.h.

◆ baselineOffset

qreal QDeclarativeAnchorsPrivate::baselineOffset

Definition at line 163 of file qdeclarativeanchors_p_p.h.

◆ bottom

QDeclarativeAnchorLine QDeclarativeAnchorsPrivate::bottom

Definition at line 151 of file qdeclarativeanchors_p_p.h.

◆ bottomMargin

qreal QDeclarativeAnchorsPrivate::bottomMargin

Definition at line 159 of file qdeclarativeanchors_p_p.h.

◆ centerIn

QGraphicsObject* QDeclarativeAnchorsPrivate::centerIn

Definition at line 146 of file qdeclarativeanchors_p_p.h.

◆ componentComplete

bool QDeclarativeAnchorsPrivate::componentComplete

Definition at line 107 of file qdeclarativeanchors_p_p.h.

◆ fill

QGraphicsObject* QDeclarativeAnchorsPrivate::fill

Definition at line 145 of file qdeclarativeanchors_p_p.h.

◆ hCenter

QDeclarativeAnchorLine QDeclarativeAnchorsPrivate::hCenter

Definition at line 153 of file qdeclarativeanchors_p_p.h.

◆ hCenterOffset

qreal QDeclarativeAnchorsPrivate::hCenterOffset

Definition at line 162 of file qdeclarativeanchors_p_p.h.

◆ item

QGraphicsObject* QDeclarativeAnchorsPrivate::item

Definition at line 142 of file qdeclarativeanchors_p_p.h.

Referenced by QDeclarativeItem::~QDeclarativeItem().

◆ left

QDeclarativeAnchorLine QDeclarativeAnchorsPrivate::left

Definition at line 148 of file qdeclarativeanchors_p_p.h.

◆ leftMargin

qreal QDeclarativeAnchorsPrivate::leftMargin

Definition at line 156 of file qdeclarativeanchors_p_p.h.

◆ margins

qreal QDeclarativeAnchorsPrivate::margins

Definition at line 160 of file qdeclarativeanchors_p_p.h.

◆ right

QDeclarativeAnchorLine QDeclarativeAnchorsPrivate::right

Definition at line 149 of file qdeclarativeanchors_p_p.h.

◆ rightMargin

qreal QDeclarativeAnchorsPrivate::rightMargin

Definition at line 157 of file qdeclarativeanchors_p_p.h.

◆ top

QDeclarativeAnchorLine QDeclarativeAnchorsPrivate::top

Definition at line 150 of file qdeclarativeanchors_p_p.h.

◆ topMargin

qreal QDeclarativeAnchorsPrivate::topMargin

Definition at line 158 of file qdeclarativeanchors_p_p.h.

◆ updatingCenterIn

uint QDeclarativeAnchorsPrivate::updatingCenterIn

Definition at line 112 of file qdeclarativeanchors_p_p.h.

◆ updatingFill

uint QDeclarativeAnchorsPrivate::updatingFill

Definition at line 111 of file qdeclarativeanchors_p_p.h.

◆ updatingHorizontalAnchor

uint QDeclarativeAnchorsPrivate::updatingHorizontalAnchor

Definition at line 109 of file qdeclarativeanchors_p_p.h.

◆ updatingMe

bool QDeclarativeAnchorsPrivate::updatingMe

Definition at line 108 of file qdeclarativeanchors_p_p.h.

◆ updatingVerticalAnchor

uint QDeclarativeAnchorsPrivate::updatingVerticalAnchor

Definition at line 110 of file qdeclarativeanchors_p_p.h.

◆ usedAnchors

QDeclarativeAnchors::Anchors QDeclarativeAnchorsPrivate::usedAnchors

Definition at line 143 of file qdeclarativeanchors_p_p.h.

◆ vCenter

QDeclarativeAnchorLine QDeclarativeAnchorsPrivate::vCenter

Definition at line 152 of file qdeclarativeanchors_p_p.h.

◆ vCenterOffset

qreal QDeclarativeAnchorsPrivate::vCenterOffset

Definition at line 161 of file qdeclarativeanchors_p_p.h.


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