void SettersGettersModel::DeleteItem(const wxDataViewItem& item) { SettersGettersModel_Item* node = reinterpret_cast<SettersGettersModel_Item*>(item.m_pItem); if ( node ) { SettersGettersModel_Item* parent = node->GetParent(); wxDataViewItem parentItem(parent); ItemDeleted(parentItem, item); // this will also remove it from its model parent children list if ( parent == NULL ) { // root item, remove it from the roots array wxVector<SettersGettersModel_Item*>::iterator where = std::find(m_data.begin(), m_data.end(), node); if ( where != m_data.end() ) { m_data.erase(where); } } // If there are no more children, change the item back to 'normal' if ( parent && parent->GetChildren().empty() ) DoChangeItemType(parentItem, false); wxDELETE(node); } if ( IsEmpty() ) Cleared(); }
unsigned int SettersGettersModel::GetChildren(const wxDataViewItem& item, wxDataViewItemArray& children) const { if(item.GetID() == NULL) { // Root for(size_t i=0; i<m_data.size(); ++i) { children.Add( wxDataViewItem( m_data.at(i) ) ); } return children.size(); } children.Clear(); SettersGettersModel_Item* node = reinterpret_cast<SettersGettersModel_Item*>(item.m_pItem); if ( node ) { for(size_t i=0; i<node->GetChildren().size(); ++i) { children.Add( wxDataViewItem( node->GetChildren().at(i) ) ); } } return children.GetCount(); }
bool SettersGettersModel::HasChildren(const wxDataViewItem& item) const { if ( !item.IsOk() ) return false; SettersGettersModel_Item* node = reinterpret_cast<SettersGettersModel_Item*>(item.GetID()); if ( !node ) { return false; } return !node->GetChildren().empty(); }