removeItem fixed
This commit is contained in:
parent
90c515be42
commit
49eb15da83
@ -11,12 +11,12 @@ class QskIndexedLayoutBox::PrivateData
|
||||
public:
|
||||
PrivateData()
|
||||
: autoAddChildren( true )
|
||||
, blockChildAdded( false )
|
||||
, blockChildAddedRemoved( false )
|
||||
{
|
||||
}
|
||||
|
||||
bool autoAddChildren : 1;
|
||||
bool blockChildAdded : 1;
|
||||
bool blockChildAddedRemoved : 1;
|
||||
};
|
||||
|
||||
QskIndexedLayoutBox::QskIndexedLayoutBox( QQuickItem* parent )
|
||||
@ -51,7 +51,7 @@ void QskIndexedLayoutBox::itemChange(
|
||||
{
|
||||
case QQuickItem::ItemChildAddedChange:
|
||||
{
|
||||
if ( m_data->autoAddChildren && !m_data->blockChildAdded )
|
||||
if ( m_data->autoAddChildren && !m_data->blockChildAddedRemoved )
|
||||
{
|
||||
if ( !qskIsTransparentForPositioner( value.item ) )
|
||||
autoAddItem( value.item );
|
||||
@ -61,7 +61,9 @@ void QskIndexedLayoutBox::itemChange(
|
||||
}
|
||||
case QQuickItem::ItemChildRemovedChange:
|
||||
{
|
||||
autoRemoveItem( value.item );
|
||||
if ( !m_data->blockChildAddedRemoved )
|
||||
autoRemoveItem( value.item );
|
||||
|
||||
break;
|
||||
}
|
||||
#if 1
|
||||
@ -91,9 +93,19 @@ void QskIndexedLayoutBox::reparentItem( QQuickItem* item )
|
||||
|
||||
if ( item->parentItem() != this )
|
||||
{
|
||||
m_data->blockChildAdded = true;
|
||||
m_data->blockChildAddedRemoved = true;
|
||||
item->setParentItem( this );
|
||||
m_data->blockChildAdded = false;
|
||||
m_data->blockChildAddedRemoved = false;
|
||||
}
|
||||
}
|
||||
|
||||
void QskIndexedLayoutBox::unparentItem( QQuickItem* item )
|
||||
{
|
||||
if ( item->parentItem() == this )
|
||||
{
|
||||
m_data->blockChildAddedRemoved = true;
|
||||
item->setParentItem( nullptr );
|
||||
m_data->blockChildAddedRemoved = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,9 @@ class QSK_EXPORT QskIndexedLayoutBox : public QskBox
|
||||
|
||||
protected:
|
||||
void itemChange( ItemChange, const ItemChangeData& ) override;
|
||||
|
||||
void reparentItem( QQuickItem* );
|
||||
void unparentItem( QQuickItem* );
|
||||
|
||||
private:
|
||||
virtual void autoAddItem( QQuickItem* ) = 0;
|
||||
|
@ -97,7 +97,7 @@ int QskLinearBox::indexOf( const QQuickItem* item ) const
|
||||
|
||||
void QskLinearBox::removeAt( int index )
|
||||
{
|
||||
removeItemInternal( index, false );
|
||||
removeItemInternal( index, true );
|
||||
}
|
||||
|
||||
void QskLinearBox::removeItemInternal( int index, bool unparent )
|
||||
@ -114,11 +114,8 @@ void QskLinearBox::removeItemInternal( int index, bool unparent )
|
||||
{
|
||||
setItemActive( item, false );
|
||||
|
||||
if ( !unparent )
|
||||
{
|
||||
if ( item->parentItem() == this )
|
||||
item->setParentItem( nullptr );
|
||||
}
|
||||
if ( unparent )
|
||||
unparentItem( item );
|
||||
}
|
||||
|
||||
resetImplicitSize();
|
||||
@ -149,7 +146,7 @@ void QskLinearBox::clear( bool autoDelete )
|
||||
if( autoDelete && ( item->parent() == this ) )
|
||||
delete item;
|
||||
else
|
||||
item->setParentItem( nullptr );
|
||||
unparentItem( item );
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,7 +161,7 @@ void QskLinearBox::autoAddItem( QQuickItem* item )
|
||||
|
||||
void QskLinearBox::autoRemoveItem( QQuickItem* item )
|
||||
{
|
||||
removeItemInternal( indexOf( item ), true );
|
||||
removeItemInternal( indexOf( item ), false );
|
||||
}
|
||||
|
||||
void QskLinearBox::activate()
|
||||
|
@ -117,7 +117,7 @@ class QSK_EXPORT QskLinearBox : public QskIndexedLayoutBox
|
||||
void autoRemoveItem( QQuickItem* ) override final;
|
||||
|
||||
void setItemActive( QQuickItem*, bool );
|
||||
void removeItemInternal( int index, bool autoDelete );
|
||||
void removeItemInternal( int index, bool unparent );
|
||||
|
||||
class PrivateData;
|
||||
std::unique_ptr< PrivateData > m_data;
|
||||
|
@ -253,7 +253,7 @@ void QskStackBox::insertItem(
|
||||
|
||||
void QskStackBox::removeAt( int index )
|
||||
{
|
||||
removeItemInternal( index, false );
|
||||
removeItemInternal( index, true );
|
||||
}
|
||||
|
||||
void QskStackBox::removeItemInternal( int index, bool unparent )
|
||||
@ -261,13 +261,10 @@ void QskStackBox::removeItemInternal( int index, bool unparent )
|
||||
if ( index < 0 || index >= m_data->items.count() )
|
||||
return;
|
||||
|
||||
if ( !unparent )
|
||||
if ( unparent )
|
||||
{
|
||||
if ( auto item = m_data->items[ index ] )
|
||||
{
|
||||
if ( item->parentItem() == this )
|
||||
item->setParentItem( nullptr );
|
||||
}
|
||||
unparentItem( item );
|
||||
}
|
||||
|
||||
m_data->items.removeAt( index );
|
||||
@ -291,7 +288,7 @@ void QskStackBox::autoAddItem( QQuickItem* item )
|
||||
|
||||
void QskStackBox::autoRemoveItem( QQuickItem* item )
|
||||
{
|
||||
removeItemInternal( indexOf( item ), true );
|
||||
removeItemInternal( indexOf( item ), false );
|
||||
}
|
||||
|
||||
void QskStackBox::clear( bool autoDelete )
|
||||
|
@ -81,7 +81,7 @@ class QSK_EXPORT QskStackBox : public QskIndexedLayoutBox
|
||||
void autoAddItem( QQuickItem* ) override final;
|
||||
void autoRemoveItem( QQuickItem* ) override final;
|
||||
|
||||
void removeItemInternal( int index, bool autoDelete );
|
||||
void removeItemInternal( int index, bool unparent );
|
||||
|
||||
class PrivateData;
|
||||
std::unique_ptr< PrivateData > m_data;
|
||||
|
Loading…
x
Reference in New Issue
Block a user