invalidation on changes of visisbility added
This commit is contained in:
parent
4c156706a5
commit
1e733c4e5c
|
@ -10,9 +10,6 @@
|
||||||
|
|
||||||
static void qskSetItemActive( QObject* receiver, const QQuickItem* item, bool on )
|
static void qskSetItemActive( QObject* receiver, const QQuickItem* item, bool on )
|
||||||
{
|
{
|
||||||
if ( ( item == nullptr ) || ( qskControlCast( item ) != nullptr ) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
For QQuickItems not being derived from QskControl we manually
|
For QQuickItems not being derived from QskControl we manually
|
||||||
send QEvent::LayoutRequest events.
|
send QEvent::LayoutRequest events.
|
||||||
|
@ -32,15 +29,11 @@ static void qskSetItemActive( QObject* receiver, const QQuickItem* item, bool on
|
||||||
|
|
||||||
QObject::connect( item, &QQuickItem::implicitHeightChanged,
|
QObject::connect( item, &QQuickItem::implicitHeightChanged,
|
||||||
receiver, sendLayoutRequest );
|
receiver, sendLayoutRequest );
|
||||||
|
|
||||||
QObject::connect( item, &QQuickItem::visibleChanged,
|
|
||||||
receiver, sendLayoutRequest );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QObject::disconnect( item, &QQuickItem::implicitWidthChanged, receiver, nullptr );
|
QObject::disconnect( item, &QQuickItem::implicitWidthChanged, receiver, nullptr );
|
||||||
QObject::disconnect( item, &QQuickItem::implicitHeightChanged, receiver, nullptr );
|
QObject::disconnect( item, &QQuickItem::implicitHeightChanged, receiver, nullptr );
|
||||||
QObject::disconnect( item, &QQuickItem::visibleChanged, receiver, nullptr );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +85,13 @@ QskGridBox::QskGridBox( QQuickItem* parent )
|
||||||
|
|
||||||
QskGridBox::~QskGridBox()
|
QskGridBox::~QskGridBox()
|
||||||
{
|
{
|
||||||
|
auto& engine = m_data->engine;
|
||||||
|
|
||||||
|
for ( int i = 0; i < engine.count(); i++ )
|
||||||
|
{
|
||||||
|
if ( auto item = engine.itemAt( i ) )
|
||||||
|
setItemActive( item, false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int QskGridBox::addItem( QQuickItem* item,
|
int QskGridBox::addItem( QQuickItem* item,
|
||||||
|
@ -144,7 +144,7 @@ int QskGridBox::addItem( QQuickItem* item,
|
||||||
if ( item->parentItem() != this )
|
if ( item->parentItem() != this )
|
||||||
item->setParentItem( this );
|
item->setParentItem( this );
|
||||||
|
|
||||||
qskSetItemActive( this, item, true );
|
setItemActive( item, true );
|
||||||
index = engine.insertItem( item, itemGrid );
|
index = engine.insertItem( item, itemGrid );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ void QskGridBox::removeAt( int index )
|
||||||
auto& engine = m_data->engine;
|
auto& engine = m_data->engine;
|
||||||
|
|
||||||
if ( auto item = engine.itemAt( index ) )
|
if ( auto item = engine.itemAt( index ) )
|
||||||
qskSetItemActive( this, item, false );
|
setItemActive( item, false );
|
||||||
|
|
||||||
engine.removeAt( index );
|
engine.removeAt( index );
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ void QskGridBox::clear( bool autoDelete )
|
||||||
{
|
{
|
||||||
if ( auto item = itemAtIndex( i ) )
|
if ( auto item = itemAtIndex( i ) )
|
||||||
{
|
{
|
||||||
qskSetItemActive( this, item, false );
|
setItemActive( item, false );
|
||||||
|
|
||||||
if( autoDelete && ( item->parent() == this ) )
|
if( autoDelete && ( item->parent() == this ) )
|
||||||
delete item;
|
delete item;
|
||||||
|
@ -352,6 +352,23 @@ void QskGridBox::invalidate()
|
||||||
polish();
|
polish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QskGridBox::setItemActive( QQuickItem* item, bool on )
|
||||||
|
{
|
||||||
|
if ( on )
|
||||||
|
{
|
||||||
|
QObject::connect( item, &QQuickItem::visibleChanged,
|
||||||
|
this, &QskGridBox::invalidate );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QObject::disconnect( item, &QQuickItem::visibleChanged,
|
||||||
|
this, &QskGridBox::invalidate );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( qskControlCast( item ) == nullptr )
|
||||||
|
qskSetItemActive( this, item, on );
|
||||||
|
}
|
||||||
|
|
||||||
void QskGridBox::updateLayout()
|
void QskGridBox::updateLayout()
|
||||||
{
|
{
|
||||||
if ( !maybeUnresized() )
|
if ( !maybeUnresized() )
|
||||||
|
|
|
@ -122,6 +122,8 @@ class QSK_EXPORT QskGridBox : public QskBox
|
||||||
QSizeF layoutSizeHint( Qt::SizeHint, const QSizeF& ) const override;
|
QSizeF layoutSizeHint( Qt::SizeHint, const QSizeF& ) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void setItemActive( QQuickItem*, bool );
|
||||||
|
|
||||||
class PrivateData;
|
class PrivateData;
|
||||||
std::unique_ptr< PrivateData > m_data;
|
std::unique_ptr< PrivateData > m_data;
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,9 +10,6 @@
|
||||||
|
|
||||||
static void qskSetItemActive( QObject* receiver, const QQuickItem* item, bool on )
|
static void qskSetItemActive( QObject* receiver, const QQuickItem* item, bool on )
|
||||||
{
|
{
|
||||||
if ( ( item == nullptr ) || ( qskControlCast( item ) != nullptr ) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
For QQuickItems not being derived from QskControl we manually
|
For QQuickItems not being derived from QskControl we manually
|
||||||
send QEvent::LayoutRequest events.
|
send QEvent::LayoutRequest events.
|
||||||
|
@ -32,15 +29,11 @@ static void qskSetItemActive( QObject* receiver, const QQuickItem* item, bool on
|
||||||
|
|
||||||
QObject::connect( item, &QQuickItem::implicitHeightChanged,
|
QObject::connect( item, &QQuickItem::implicitHeightChanged,
|
||||||
receiver, sendLayoutRequest );
|
receiver, sendLayoutRequest );
|
||||||
|
|
||||||
QObject::connect( item, &QQuickItem::visibleChanged,
|
|
||||||
receiver, sendLayoutRequest );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QObject::disconnect( item, &QQuickItem::implicitWidthChanged, receiver, nullptr );
|
QObject::disconnect( item, &QQuickItem::implicitWidthChanged, receiver, nullptr );
|
||||||
QObject::disconnect( item, &QQuickItem::implicitHeightChanged, receiver, nullptr );
|
QObject::disconnect( item, &QQuickItem::implicitHeightChanged, receiver, nullptr );
|
||||||
QObject::disconnect( item, &QQuickItem::visibleChanged, receiver, nullptr );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +66,13 @@ QskLinearBox::QskLinearBox( Qt::Orientation orientation, uint dimension, QQuickI
|
||||||
|
|
||||||
QskLinearBox::~QskLinearBox()
|
QskLinearBox::~QskLinearBox()
|
||||||
{
|
{
|
||||||
|
auto& engine = m_data->engine;
|
||||||
|
|
||||||
|
for ( int i = 0; i < engine.count(); i++ )
|
||||||
|
{
|
||||||
|
if ( auto item = engine.itemAt( i ) )
|
||||||
|
setItemActive( item, false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int QskLinearBox::count() const
|
int QskLinearBox::count() const
|
||||||
|
@ -112,7 +112,7 @@ void QskLinearBox::removeItemInternal( int index, bool unparent )
|
||||||
|
|
||||||
if ( item )
|
if ( item )
|
||||||
{
|
{
|
||||||
qskSetItemActive( this, engine.itemAt( index ), false );
|
setItemActive( item, false );
|
||||||
|
|
||||||
if ( !unparent )
|
if ( !unparent )
|
||||||
{
|
{
|
||||||
|
@ -144,7 +144,7 @@ void QskLinearBox::clear( bool autoDelete )
|
||||||
|
|
||||||
if( item )
|
if( item )
|
||||||
{
|
{
|
||||||
qskSetItemActive( this, item, false );
|
setItemActive( item, false );
|
||||||
|
|
||||||
if( autoDelete && ( item->parent() == this ) )
|
if( autoDelete && ( item->parent() == this ) )
|
||||||
delete item;
|
delete item;
|
||||||
|
@ -180,6 +180,23 @@ void QskLinearBox::invalidate()
|
||||||
polish();
|
polish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QskLinearBox::setItemActive( QQuickItem* item, bool on )
|
||||||
|
{
|
||||||
|
if ( on )
|
||||||
|
{
|
||||||
|
QObject::connect( item, &QQuickItem::visibleChanged,
|
||||||
|
this, &QskLinearBox::invalidate );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QObject::disconnect( item, &QQuickItem::visibleChanged,
|
||||||
|
this, &QskLinearBox::invalidate );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( qskControlCast( item ) == nullptr )
|
||||||
|
qskSetItemActive( this, item, on );
|
||||||
|
}
|
||||||
|
|
||||||
void QskLinearBox::updateLayout()
|
void QskLinearBox::updateLayout()
|
||||||
{
|
{
|
||||||
if ( !maybeUnresized() )
|
if ( !maybeUnresized() )
|
||||||
|
@ -435,7 +452,7 @@ int QskLinearBox::insertItem( int index, QQuickItem* item )
|
||||||
item->stackAfter( children.last() );
|
item->stackAfter( children.last() );
|
||||||
}
|
}
|
||||||
|
|
||||||
qskSetItemActive( this, item, true );
|
setItemActive( item, true );
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
// Is there a way to block consecutive calls ???
|
// Is there a way to block consecutive calls ???
|
||||||
|
|
|
@ -114,6 +114,7 @@ class QSK_EXPORT QskLinearBox : public QskIndexedLayoutBox
|
||||||
void autoRemoveItem( QQuickItem* ) override final;
|
void autoRemoveItem( QQuickItem* ) override final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void setItemActive( QQuickItem*, bool );
|
||||||
void removeItemInternal( int index, bool autoDelete );
|
void removeItemInternal( int index, bool autoDelete );
|
||||||
|
|
||||||
class PrivateData;
|
class PrivateData;
|
||||||
|
|
Loading…
Reference in New Issue