Пример #1
0
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);
}
Пример #2
0
void QDeclarativeBasePositioner::componentComplete()
{
    Q_D(QDeclarativeBasePositioner);
    QDeclarativeItem::componentComplete();
    positionedItems.reserve(d->QGraphicsItemPrivate::children.count());
    prePositioning();
}
Пример #3
0
void QDeclarativeGrid::setFlow(Flow flow)
{
    if (m_flow != flow) {
        m_flow = flow;
        prePositioning();
        emit flowChanged();
    }
}
Пример #4
0
void QDeclarativeGrid::setRows(const int rows)
{
    if (rows == m_rows)
        return;
    m_rows = rows;
    prePositioning();
    emit rowsChanged();
}
Пример #5
0
void QDeclarativeGrid::setColumns(const int columns)
{
    if (columns == m_columns)
        return;
    m_columns = columns;
    prePositioning();
    emit columnsChanged();
}
Пример #6
0
void QDeclarativeGrid::setLayoutDirection(Qt::LayoutDirection layoutDirection)
{
    if (m_layoutDirection != layoutDirection) {
        m_layoutDirection = layoutDirection;
        prePositioning();
        emit layoutDirectionChanged();
    }
}
Пример #7
0
void QDeclarativeFlow::setFlow(Flow flow)
{
    Q_D(QDeclarativeFlow);
    if (d->flow != flow) {
        d->flow = flow;
        prePositioning();
        emit flowChanged();
    }
}
Пример #8
0
void QDeclarativeBasePositioner::setSpacing(int s)
{
    Q_D(QDeclarativeBasePositioner);
    if (s==d->spacing)
        return;
    d->spacing = s;
    prePositioning();
    emit spacingChanged();
}
Пример #9
0
void QDeclarativeFlow::setLayoutDirection(Qt::LayoutDirection layoutDirection)
{
    Q_D(QDeclarativeFlow);
    if (d->layoutDirection != layoutDirection) {
        d->layoutDirection = layoutDirection;
        prePositioning();
        emit layoutDirectionChanged();
    }
}
Пример #10
0
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();;
    }
}
Пример #11
0
void QDeclarativeBasePositioner::graphicsWidgetGeometryChanged()
{
    prePositioning();
}