6#include "QskIndexedLayoutBox.h"
9class QskIndexedLayoutBox::PrivateData
13 : autoAddChildren( true )
14 , blockChildAddedRemoved( false )
18 bool autoAddChildren : 1;
19 bool blockChildAddedRemoved : 1;
24 , m_data( new PrivateData() )
35 if ( on != m_data->autoAddChildren )
37 m_data->autoAddChildren = on;
44 return m_data->autoAddChildren;
48 QQuickItem::ItemChange change,
const QQuickItem::ItemChangeData& value )
52 case QQuickItem::ItemChildAddedChange:
54 if ( m_data->autoAddChildren && !m_data->blockChildAddedRemoved )
56 if ( qskPlacementPolicy( value.item ).
isEffective() )
57 autoAddItem( value.item );
62 case QQuickItem::ItemChildRemovedChange:
64 if ( !m_data->blockChildAddedRemoved )
65 autoRemoveItem( value.item );
70 case QQuickItem::ItemSceneChange:
89void QskIndexedLayoutBox::reparentItem( QQuickItem* item )
91 if ( item->parent() ==
nullptr )
92 item->setParent(
this );
94 if ( item->parentItem() !=
this )
96 m_data->blockChildAddedRemoved =
true;
97 item->setParentItem(
this );
98 m_data->blockChildAddedRemoved =
false;
102void QskIndexedLayoutBox::unparentItem( QQuickItem* item )
104 if ( item->parentItem() ==
this )
106 m_data->blockChildAddedRemoved =
true;
107 item->setParentItem(
nullptr );
108 m_data->blockChildAddedRemoved =
false;
112#include "moc_QskIndexedLayoutBox.cpp"
void itemChange(ItemChange, const ItemChangeData &) override
void itemChange(ItemChange, const ItemChangeData &) override
void setAutoAddChildren(bool on=true)
En/Disable auto appending of children.
QskIndexedLayoutBox(QQuickItem *parent=nullptr)
Constructor.
bool autoAddChildren
Flag controlling whether to automatically append children to the layout.
~QskIndexedLayoutBox() override
Destructor.
void autoAddChildrenChanged()
constexpr bool isEffective() const noexcept