Encapsulate wxPGProperty::m_children member variable.
Implement RemoveChild and SortChildren methods to perform operations on m_children member variable. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78428 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -2427,6 +2427,12 @@ protected:
|
||||
// Removes child property with given pointer. Does not delete it.
|
||||
void RemoveChild( wxPGProperty* p );
|
||||
|
||||
// Removes child property at given index. Does not delete it.
|
||||
void RemoveChild(unsigned int index);
|
||||
|
||||
// Sorts children using specified comparison function.
|
||||
void SortChildren(int (*fCmp)(wxPGProperty**, wxPGProperty**));
|
||||
|
||||
void DoEnable( bool enable );
|
||||
|
||||
void DoPreAddChild( int index, wxPGProperty* prop );
|
||||
|
@@ -2359,6 +2359,21 @@ void wxPGProperty::RemoveChild( wxPGProperty* p )
|
||||
}
|
||||
}
|
||||
|
||||
void wxPGProperty::RemoveChild(unsigned int index)
|
||||
{
|
||||
m_children.erase(m_children.begin()+index);
|
||||
}
|
||||
|
||||
void wxPGProperty::SortChildren(int (*fCmp)(wxPGProperty**, wxPGProperty**))
|
||||
{
|
||||
m_children.Sort(fCmp);
|
||||
|
||||
#if 0
|
||||
// For wxVector w/ wxUSE_STL=1, you would use code like this instead:
|
||||
std::sort(m_children.begin(), m_children.end(), fCmp);
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxPGProperty::AdaptListToValue( wxVariant& list, wxVariant* value ) const
|
||||
{
|
||||
wxASSERT( GetChildCount() );
|
||||
|
@@ -711,21 +711,9 @@ void wxPropertyGridPageState::DoSortChildren( wxPGProperty* p,
|
||||
return;
|
||||
|
||||
if ( GetGrid()->GetSortFunction() )
|
||||
p->m_children.Sort( wxPG_SortFunc_ByFunction );
|
||||
p->SortChildren(wxPG_SortFunc_ByFunction);
|
||||
else
|
||||
p->m_children.Sort( wxPG_SortFunc_ByLabel );
|
||||
|
||||
#if 0
|
||||
//
|
||||
// For wxVector w/ wxUSE_STL=1, you would use code like this instead:
|
||||
//
|
||||
if ( GetGrid()->GetSortFunction() )
|
||||
std::sort(p->m_children.begin(), p->m_children.end(),
|
||||
wxPG_SortFunc_ByFunction);
|
||||
else
|
||||
std::sort(p->m_children.begin(), p->m_children.end(),
|
||||
wxPG_SortFunc_ByLabel);
|
||||
#endif
|
||||
p->SortChildren(wxPG_SortFunc_ByLabel);
|
||||
|
||||
// Fix indices
|
||||
p->FixIndicesOfChildren();
|
||||
@@ -2075,8 +2063,7 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
|
||||
}
|
||||
|
||||
// categorized mode - categorized array
|
||||
wxArrayPGProperty& parentsChildren = parent->m_children;
|
||||
parentsChildren.erase( parentsChildren.begin() + indinparent );
|
||||
parent->RemoveChild(indinparent);
|
||||
item->m_parent->FixIndicesOfChildren();
|
||||
}
|
||||
else
|
||||
@@ -2102,14 +2089,13 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
|
||||
}
|
||||
}
|
||||
}
|
||||
cat_parent->m_children.erase(cat_parent->m_children.begin()+cat_index);
|
||||
cat_parent->RemoveChild(cat_index);
|
||||
|
||||
// non-categorized mode - non-categorized array
|
||||
if ( !item->IsCategory() )
|
||||
{
|
||||
wxASSERT( item->m_parent == m_abcArray );
|
||||
wxArrayPGProperty& parentsChildren = item->m_parent->m_children;
|
||||
parentsChildren.erase(parentsChildren.begin() + indinparent);
|
||||
item->m_parent->RemoveChild(indinparent);
|
||||
item->m_parent->FixIndicesOfChildren(indinparent);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user