qskSetItemGeometry added

This commit is contained in:
Uwe Rathmann 2018-03-24 18:05:57 +01:00
parent 5447aa30fa
commit de6ab7f7aa
4 changed files with 27 additions and 13 deletions

View File

@ -54,6 +54,19 @@ QRectF qskItemGeometry( const QQuickItem* item )
return QRectF( d->x, d->y, d->width, d->height );
}
void qskSetItemGeometry( QQuickItem* item, const QRectF& rect )
{
if ( auto control = qobject_cast< QskControl* >( item ) )
{
control->setGeometry( rect );
}
else
{
item->setPosition( rect.topLeft() );
item->setSize( rect.size() );
}
}
bool qskIsItemComplete( const QQuickItem* item )
{
return QQuickItemPrivate::get( item )->componentComplete;
@ -270,7 +283,7 @@ Q_GLOBAL_STATIC( QskControlRegistry, qskRegistry )
class QskControlPrivate final : public QQuickItemPrivate
{
Q_DECLARE_PUBLIC(QskControl)
Q_DECLARE_PUBLIC( QskControl )
public:
QskControlPrivate():
@ -309,7 +322,7 @@ public:
}
}
void mirrorChange() override
virtual void mirrorChange() override final
{
Q_Q( QskControl );
qskSendEventTo( q, QEvent::LayoutDirectionChange );
@ -540,6 +553,11 @@ void QskControl::setGeometry( qreal x, qreal y, qreal width, qreal height )
if ( dirtyType & QQuickItemPrivate::Size )
d->dirty( QQuickItemPrivate::Size );
/*
Unfortunately geometryChanged is protected and we can't implement
this code as qskSetItemGeometry - further hacking required: TODO ...
*/
geometryChanged( QRectF( d->x, d->y, d->width, d->height ), oldRect );
}
}
@ -1419,10 +1437,7 @@ void QskControl::updatePolish()
for ( auto child : children )
{
if ( !QQuickItemPrivate::get( child )->isTransparentForPositioner() )
{
child->setPosition( rect.topLeft() );
child->setSize( rect.size() );
}
qskSetItemGeometry( child, rect );
}
}

View File

@ -253,8 +253,10 @@ QSK_EXPORT bool qskIsAncestorOf( const QQuickItem* item, const QQuickItem *child
QSK_EXPORT bool qskIsTransparentForPositioner( const QQuickItem* );
QSK_EXPORT bool qskIsTabFence( const QQuickItem* );
QSK_EXPORT bool qskIsShortcutScope( const QQuickItem* );
QSK_EXPORT QRectF qskItemRect( const QQuickItem* );
QSK_EXPORT QRectF qskItemGeometry( const QQuickItem* );
QSK_EXPORT void qskSetItemGeometry( QQuickItem*, const QRectF& );
QSK_EXPORT QQuickItem* qskNearestFocusScope( const QQuickItem* );
QSK_EXPORT QList<QQuickItem *> qskPaintOrderChildItems( const QQuickItem* );

View File

@ -73,6 +73,7 @@ namespace
QCoreApplication::postEvent( window, new QEvent( QEvent::LayoutRequest ) );
}
}
private:
QQuickItem* m_item;
};
@ -423,16 +424,13 @@ void QskWindow::layoutItems()
if ( !d->autoLayoutChildren )
return;
const QSizeF sz( contentItem()->width(), contentItem()->height() );
const QRectF rect = qskItemGeometry( contentItem() );
const auto children = contentItem()->childItems();
for ( auto child : children )
{
if ( !qskIsTransparentForPositioner( child ) )
{
child->setPosition( contentItem()->position() );
child->setSize( sz );
}
qskSetItemGeometry( child, rect );
}
}

View File

@ -168,8 +168,7 @@ void QskLayoutItem::setGeometry( const QRectF& rect )
}
m_isGeometryDirty = false;
m_item->setPosition( rect.topLeft() );
m_item->setSize( rect.size() );
qskSetItemGeometry( m_item, rect );
}
bool QskLayoutItem::hasDynamicConstraint() const