QVariant QDeclarativeBasePositioner::itemChange(GraphicsItemChange change, const QVariant &value) { Q_D(QDeclarativeBasePositioner); if (change == ItemChildAddedChange){ QGraphicsItem* item = value.value<QGraphicsItem*>(); QDeclarativeItem* child = 0; if(item) child = qobject_cast<QDeclarativeItem*>(item->toGraphicsObject()); if (child) prePositioning(); } else if (change == ItemChildRemovedChange) { QGraphicsItem* item = value.value<QGraphicsItem*>(); QDeclarativeItem* child = 0; if(item) child = qobject_cast<QDeclarativeItem*>(item->toGraphicsObject()); if (child) { QDeclarativeBasePositioner::PositionedItem posItem(child); int idx = positionedItems.find(posItem); if (idx >= 0) { d->unwatchChanges(child); positionedItems.remove(idx); } prePositioning(); } } return QDeclarativeItem::itemChange(change, value); }
void QDeclarativeBasePositioner::componentComplete() { Q_D(QDeclarativeBasePositioner); QDeclarativeItem::componentComplete(); positionedItems.reserve(d->QGraphicsItemPrivate::children.count()); prePositioning(); }
void QDeclarativeGrid::setFlow(Flow flow) { if (m_flow != flow) { m_flow = flow; prePositioning(); emit flowChanged(); } }
void QDeclarativeGrid::setRows(const int rows) { if (rows == m_rows) return; m_rows = rows; prePositioning(); emit rowsChanged(); }
void QDeclarativeGrid::setColumns(const int columns) { if (columns == m_columns) return; m_columns = columns; prePositioning(); emit columnsChanged(); }
void QDeclarativeGrid::setLayoutDirection(Qt::LayoutDirection layoutDirection) { if (m_layoutDirection != layoutDirection) { m_layoutDirection = layoutDirection; prePositioning(); emit layoutDirectionChanged(); } }
void QDeclarativeFlow::setFlow(Flow flow) { Q_D(QDeclarativeFlow); if (d->flow != flow) { d->flow = flow; prePositioning(); emit flowChanged(); } }
void QDeclarativeBasePositioner::setSpacing(int s) { Q_D(QDeclarativeBasePositioner); if (s==d->spacing) return; d->spacing = s; prePositioning(); emit spacingChanged(); }
void QDeclarativeFlow::setLayoutDirection(Qt::LayoutDirection layoutDirection) { Q_D(QDeclarativeFlow); if (d->layoutDirection != layoutDirection) { d->layoutDirection = layoutDirection; prePositioning(); emit layoutDirectionChanged(); } }
void QDeclarativeGrid::setLayoutDirection(Qt::LayoutDirection layoutDirection) { QDeclarativeBasePositionerPrivate *d = static_cast<QDeclarativeBasePositionerPrivate*>(QDeclarativeBasePositionerPrivate::get(this)); if (d->layoutDirection != layoutDirection) { d->layoutDirection = layoutDirection; // For RTL layout the positioning changes when the width changes. if (d->layoutDirection == Qt::RightToLeft) d->addItemChangeListener(d, QDeclarativeItemPrivate::Geometry); else d->removeItemChangeListener(d, QDeclarativeItemPrivate::Geometry); prePositioning(); emit layoutDirectionChanged();; } }
void QDeclarativeBasePositioner::graphicsWidgetGeometryChanged() { prePositioning(); }