Qt 4.8
Signals | Public Functions | Protected Functions | Private Functions | Properties | List of all members
QDeclarativeContents Class Reference

#include <qdeclarativeitem_p.h>

Inheritance diagram for QDeclarativeContents:
QObject QDeclarativeItemChangeListener

Signals

void rectChanged (QRectF)
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 

Public Functions

void calcGeometry ()
 
void childAdded (QDeclarativeItem *item)
 
void childRemoved (QDeclarativeItem *item)
 
void complete ()
 
 QDeclarativeContents (QDeclarativeItem *item)
 
QRectF rectF () const
 
 ~QDeclarativeContents ()
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 
- Public Functions inherited from QDeclarativeItemChangeListener
virtual QDeclarativeAnchorsPrivateanchorPrivate ()
 
virtual void itemOpacityChanged (QDeclarativeItem *)
 
virtual void itemSiblingOrderChanged (QDeclarativeItem *)
 
virtual void itemVisibilityChanged (QDeclarativeItem *)
 

Protected Functions

void itemDestroyed (QDeclarativeItem *item)
 
void itemGeometryChanged (QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry)
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 

Private Functions

void calcHeight (QDeclarativeItem *changed=0)
 
void calcWidth (QDeclarativeItem *changed=0)
 

Properties

qreal m_height
 
QDeclarativeItemm_item
 
qreal m_width
 
qreal m_x
 
qreal m_y
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Static Public Functions inherited from QObject
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 receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
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. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 83 of file qdeclarativeitem_p.h.

Constructors and Destructors

◆ QDeclarativeContents()

QDeclarativeContents::QDeclarativeContents ( QDeclarativeItem item)

Definition at line 268 of file qdeclarativeitem.cpp.

268  : m_item(item), m_x(0), m_y(0), m_width(0), m_height(0)
269 {
270  //### optimize
271  connect(this, SIGNAL(rectChanged(QRectF)), m_item, SIGNAL(childrenRectChanged(QRectF)));
272 }
QDeclarativeItem * m_item
void rectChanged(QRectF)
#define SIGNAL(a)
Definition: qobjectdefs.h:227
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
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

◆ ~QDeclarativeContents()

QDeclarativeContents::~QDeclarativeContents ( )

Definition at line 274 of file qdeclarativeitem.cpp.

275 {
277  for (int i = 0; i < children.count(); ++i) {
278  QDeclarativeItem *child = qobject_cast<QDeclarativeItem *>(children.at(i));
279  if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects?
280  continue;
282  }
283 }
QList< QGraphicsItem * > childItems() const
Returns a list of this item&#39;s children.
QDeclarativeItem * m_item
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
T * qobject_cast(QObject *object)
Definition: qobject.h:375
The QDeclarativeItem class provides the most basic of all visual items in QML.
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static QDeclarativeItemPrivate * get(QDeclarativeItem *item)
void removeItemChangeListener(QDeclarativeItemChangeListener *, ChangeTypes types)
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

Functions

◆ calcGeometry()

void QDeclarativeContents::calcGeometry ( )
inline

Definition at line 95 of file qdeclarativeitem_p.h.

Referenced by childRemoved(), complete(), and itemDestroyed().

95 { calcWidth(); calcHeight(); }
void calcHeight(QDeclarativeItem *changed=0)
void calcWidth(QDeclarativeItem *changed=0)

◆ calcHeight()

void QDeclarativeContents::calcHeight ( QDeclarativeItem changed = 0)
private

Definition at line 290 of file qdeclarativeitem.cpp.

Referenced by calcGeometry(), childAdded(), and itemGeometryChanged().

291 {
292  qreal oldy = m_y;
293  qreal oldheight = m_height;
294 
295  if (changed) {
296  qreal top = oldy;
297  qreal bottom = oldy + oldheight;
298  qreal y = changed->y();
299  if (y + changed->height() > bottom)
300  bottom = y + changed->height();
301  if (y < top)
302  top = y;
303  m_y = top;
304  m_height = bottom - top;
305  } else {
306  qreal top = FLT_MAX;
307  qreal bottom = 0;
309  for (int i = 0; i < children.count(); ++i) {
310  QDeclarativeItem *child = qobject_cast<QDeclarativeItem *>(children.at(i));
311  if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects?
312  continue;
313  qreal y = child->y();
314  if (y + child->height() > bottom)
315  bottom = y + child->height();
316  if (y < top)
317  top = y;
318  }
319  if (!children.isEmpty())
320  m_y = top;
321  m_height = qMax(bottom - top, qreal(0.0));
322  }
323 
324  if (m_height != oldheight || m_y != oldy)
326 }
double qreal
Definition: qglobal.h:1193
QList< QGraphicsItem * > childItems() const
Returns a list of this item&#39;s children.
QDeclarativeItem * m_item
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
T * qobject_cast(QObject *object)
Definition: qobject.h:375
void rectChanged(QRectF)
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
The QDeclarativeItem class provides the most basic of all visual items in QML.
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
#define emit
Definition: qobjectdefs.h:76
qreal y() const
This convenience function is equivalent to calling pos().
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ calcWidth()

void QDeclarativeContents::calcWidth ( QDeclarativeItem changed = 0)
private

Definition at line 328 of file qdeclarativeitem.cpp.

Referenced by calcGeometry(), childAdded(), and itemGeometryChanged().

329 {
330  qreal oldx = m_x;
331  qreal oldwidth = m_width;
332 
333  if (changed) {
334  qreal left = oldx;
335  qreal right = oldx + oldwidth;
336  qreal x = changed->x();
337  if (x + changed->width() > right)
338  right = x + changed->width();
339  if (x < left)
340  left = x;
341  m_x = left;
342  m_width = right - left;
343  } else {
344  qreal left = FLT_MAX;
345  qreal right = 0;
347  for (int i = 0; i < children.count(); ++i) {
348  QDeclarativeItem *child = qobject_cast<QDeclarativeItem *>(children.at(i));
349  if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects?
350  continue;
351  qreal x = child->x();
352  if (x + child->width() > right)
353  right = x + child->width();
354  if (x < left)
355  left = x;
356  }
357  if (!children.isEmpty())
358  m_x = left;
359  m_width = qMax(right - left, qreal(0.0));
360  }
361 
362  if (m_width != oldwidth || m_x != oldx)
364 }
double qreal
Definition: qglobal.h:1193
QList< QGraphicsItem * > childItems() const
Returns a list of this item&#39;s children.
QDeclarativeItem * m_item
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
T * qobject_cast(QObject *object)
Definition: qobject.h:375
void rectChanged(QRectF)
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
The QDeclarativeItem class provides the most basic of all visual items in QML.
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
#define emit
Definition: qobjectdefs.h:76
qreal x() const
This convenience function is equivalent to calling pos().
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ childAdded()

void QDeclarativeContents::childAdded ( QDeclarativeItem item)

Definition at line 404 of file qdeclarativeitem.cpp.

405 {
406  if (item)
408  calcWidth(item);
409  calcHeight(item);
410 }
void calcHeight(QDeclarativeItem *changed=0)
void addItemChangeListener(QDeclarativeItemChangeListener *listener, ChangeTypes types)
void calcWidth(QDeclarativeItem *changed=0)
static QDeclarativeItemPrivate * get(QDeclarativeItem *item)

◆ childRemoved()

void QDeclarativeContents::childRemoved ( QDeclarativeItem item)

Definition at line 397 of file qdeclarativeitem.cpp.

398 {
399  if (item)
401  calcGeometry();
402 }
static QDeclarativeItemPrivate * get(QDeclarativeItem *item)
void removeItemChangeListener(QDeclarativeItemChangeListener *, ChangeTypes types)

◆ complete()

void QDeclarativeContents::complete ( )

Definition at line 366 of file qdeclarativeitem.cpp.

Referenced by calcGeometry().

367 {
369  for (int i = 0; i < children.count(); ++i) {
370  QDeclarativeItem *child = qobject_cast<QDeclarativeItem *>(children.at(i));
371  if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects?
372  continue;
374  //###what about changes to visibility?
375  }
376 
377  calcGeometry();
378 }
QList< QGraphicsItem * > childItems() const
Returns a list of this item&#39;s children.
QDeclarativeItem * m_item
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
T * qobject_cast(QObject *object)
Definition: qobject.h:375
The QDeclarativeItem class provides the most basic of all visual items in QML.
void addItemChangeListener(QDeclarativeItemChangeListener *listener, ChangeTypes types)
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static QDeclarativeItemPrivate * get(QDeclarativeItem *item)
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ itemDestroyed()

void QDeclarativeContents::itemDestroyed ( QDeclarativeItem item)
protectedvirtual

Reimplemented from QDeclarativeItemChangeListener.

Definition at line 390 of file qdeclarativeitem.cpp.

Referenced by calcGeometry().

391 {
392  if (item)
394  calcGeometry();
395 }
static QDeclarativeItemPrivate * get(QDeclarativeItem *item)
void removeItemChangeListener(QDeclarativeItemChangeListener *, ChangeTypes types)

◆ itemGeometryChanged()

void QDeclarativeContents::itemGeometryChanged ( QDeclarativeItem item,
const QRectF newGeometry,
const QRectF oldGeometry 
)
protectedvirtual

Reimplemented from QDeclarativeItemChangeListener.

Definition at line 380 of file qdeclarativeitem.cpp.

Referenced by calcGeometry().

381 {
382  Q_UNUSED(changed)
383  //### we can only pass changed if the left edge has moved left, or the right edge has moved right
384  if (newGeometry.width() != oldGeometry.width() || newGeometry.x() != oldGeometry.x())
385  calcWidth(/*changed*/);
386  if (newGeometry.height() != oldGeometry.height() || newGeometry.y() != oldGeometry.y())
387  calcHeight(/*changed*/);
388 }
qreal y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:667
void calcHeight(QDeclarativeItem *changed=0)
qreal height() const
Returns the height of the rectangle.
Definition: qrect.h:710
void calcWidth(QDeclarativeItem *changed=0)
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
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ rectChanged

void QDeclarativeContents::rectChanged ( QRectF  )
signal

◆ rectF()

QRectF QDeclarativeContents::rectF ( ) const

Definition at line 285 of file qdeclarativeitem.cpp.

Referenced by calcHeight(), and calcWidth().

286 {
287  return QRectF(m_x, m_y, m_width, m_height);
288 }
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511

Properties

◆ m_height

qreal QDeclarativeContents::m_height
private

Definition at line 114 of file qdeclarativeitem_p.h.

Referenced by calcHeight(), and rectF().

◆ m_item

QDeclarativeItem* QDeclarativeContents::m_item
private

◆ m_width

qreal QDeclarativeContents::m_width
private

Definition at line 113 of file qdeclarativeitem_p.h.

Referenced by calcWidth(), and rectF().

◆ m_x

qreal QDeclarativeContents::m_x
private

Definition at line 111 of file qdeclarativeitem_p.h.

Referenced by calcWidth(), and rectF().

◆ m_y

qreal QDeclarativeContents::m_y
private

Definition at line 112 of file qdeclarativeitem_p.h.

Referenced by calcHeight(), and rectF().


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