Fixed various inconsistencies with deleting properties, added wxPGProperty::DeleteChildren()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57442 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1443,6 +1443,11 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Deletes children of the property.
|
||||||
|
*/
|
||||||
|
void DeleteChildren();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Removes entry from property's wxPGChoices and editor control (if it is
|
Removes entry from property's wxPGChoices and editor control (if it is
|
||||||
active).
|
active).
|
||||||
@@ -2073,9 +2078,6 @@ public:
|
|||||||
/** Returns index of given child property. */
|
/** Returns index of given child property. */
|
||||||
int Index( const wxPGProperty* p ) const;
|
int Index( const wxPGProperty* p ) const;
|
||||||
|
|
||||||
/** Deletes all sub-properties. */
|
|
||||||
void Empty();
|
|
||||||
|
|
||||||
// Puts correct indexes to children
|
// Puts correct indexes to children
|
||||||
void FixIndicesOfChildren( unsigned int starthere = 0 );
|
void FixIndicesOfChildren( unsigned int starthere = 0 );
|
||||||
|
|
||||||
@@ -2205,6 +2207,9 @@ protected:
|
|||||||
|
|
||||||
void DoSetName(const wxString& str) { m_name = str; }
|
void DoSetName(const wxString& str) { m_name = str; }
|
||||||
|
|
||||||
|
/** Deletes all sub-properties. */
|
||||||
|
void Empty();
|
||||||
|
|
||||||
void InitAfterAdded( wxPropertyGridPageState* pageState,
|
void InitAfterAdded( wxPropertyGridPageState* pageState,
|
||||||
wxPropertyGrid* propgrid );
|
wxPropertyGrid* propgrid );
|
||||||
|
|
||||||
|
@@ -907,6 +907,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool AreChildrenComponents() const;
|
bool AreChildrenComponents() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Deletes children of the property.
|
||||||
|
*/
|
||||||
|
void DeleteChildren();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Removes entry from property's wxPGChoices and editor control (if it is active).
|
Removes entry from property's wxPGChoices and editor control (if it is active).
|
||||||
|
|
||||||
|
@@ -2276,6 +2276,17 @@ void wxPGProperty::Empty()
|
|||||||
m_children.clear();
|
m_children.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxPGProperty::DeleteChildren()
|
||||||
|
{
|
||||||
|
wxPropertyGridPageState* state = m_parentState;
|
||||||
|
|
||||||
|
while ( GetChildCount() )
|
||||||
|
{
|
||||||
|
wxPGProperty* child = Item(GetChildCount()-1);
|
||||||
|
state->DoDelete(child, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void wxPGProperty::ChildChanged( wxVariant& WXUNUSED(thisValue),
|
void wxPGProperty::ChildChanged( wxVariant& WXUNUSED(thisValue),
|
||||||
int WXUNUSED(childIndex),
|
int WXUNUSED(childIndex),
|
||||||
wxVariant& WXUNUSED(childValue) ) const
|
wxVariant& WXUNUSED(childValue) ) const
|
||||||
|
@@ -245,17 +245,17 @@ void wxPropertyGridPageState::InitNonCatMode()
|
|||||||
|
|
||||||
if ( m_properties->GetChildCount() )
|
if ( m_properties->GetChildCount() )
|
||||||
{
|
{
|
||||||
// Copy items.
|
//
|
||||||
wxPropertyGridIterator it( this, wxPG_ITERATE_DEFAULT|wxPG_ITERATE_CATEGORIES );
|
// Prepare m_abcArray
|
||||||
|
wxPropertyGridIterator it( this, wxPG_ITERATE_PROPERTIES );
|
||||||
|
|
||||||
for ( ; !it.AtEnd(); it.Next() )
|
for ( ; !it.AtEnd(); it.Next() )
|
||||||
{
|
{
|
||||||
wxPGProperty* p = it.GetProperty();
|
wxPGProperty* p = it.GetProperty();
|
||||||
wxPGProperty* parent = p->GetParent();
|
wxPGProperty* parent = p->GetParent();
|
||||||
if ( p->HasFlag(wxPG_PROP_MISC_PARENT) &&
|
if ( parent->IsCategory() || parent->IsRoot() )
|
||||||
( parent == m_properties || (parent->IsCategory() || parent->IsRoot()) ) )
|
|
||||||
{
|
{
|
||||||
m_abcArray->AddChild2( p );
|
m_abcArray->AddChild2(p);
|
||||||
p->m_parent = &m_regularArray;
|
p->m_parent = &m_regularArray;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1698,57 +1698,41 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
|
|||||||
wxCHECK_RET( item != &m_regularArray && item != m_abcArray,
|
wxCHECK_RET( item != &m_regularArray && item != m_abcArray,
|
||||||
wxT("wxPropertyGrid: Do not attempt to remove the root item.") );
|
wxT("wxPropertyGrid: Do not attempt to remove the root item.") );
|
||||||
|
|
||||||
size_t i;
|
|
||||||
unsigned int indinparent = item->GetIndexInParent();
|
unsigned int indinparent = item->GetIndexInParent();
|
||||||
|
|
||||||
wxPGProperty* pwc = (wxPGProperty*)item;
|
wxPGProperty* pwc = (wxPGProperty*)item;
|
||||||
|
wxPGProperty* parent = item->GetParent();
|
||||||
|
|
||||||
wxCHECK_RET( !item->GetParent()->HasFlag(wxPG_PROP_AGGREGATE),
|
wxCHECK_RET( !parent->HasFlag(wxPG_PROP_AGGREGATE),
|
||||||
wxT("wxPropertyGrid: Do not attempt to remove sub-properties.") );
|
wxT("wxPropertyGrid: Do not attempt to remove sub-properties.") );
|
||||||
|
|
||||||
if ( item->IsCategory() )
|
// Delete children
|
||||||
|
if ( item->GetChildCount() && !item->HasFlag(wxPG_PROP_AGGREGATE) )
|
||||||
{
|
{
|
||||||
// deleting a category
|
// deleting a category
|
||||||
|
if ( item->IsCategory() )
|
||||||
// erase category entries from the hash table
|
|
||||||
for ( i=0; i<pwc->GetChildCount(); i++ )
|
|
||||||
{
|
{
|
||||||
wxPGProperty* sp = pwc->Item( i );
|
if ( pwc == m_currentCategory )
|
||||||
if ( sp->GetBaseName().Len() ) m_dictName.erase(sp->GetBaseName());
|
m_currentCategory = (wxPropertyCategory*) NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pwc == m_currentCategory )
|
item->DeleteChildren();
|
||||||
m_currentCategory = (wxPropertyCategory*) NULL;
|
|
||||||
|
|
||||||
if ( m_abcArray )
|
|
||||||
{
|
|
||||||
// Remove children from non-categorized array.
|
|
||||||
for ( i=0; i<pwc->GetChildCount(); i++ )
|
|
||||||
{
|
|
||||||
wxPGProperty * p = pwc->Item( i );
|
|
||||||
wxASSERT( p != NULL );
|
|
||||||
if ( !p->IsCategory() )
|
|
||||||
m_abcArray->RemoveChild(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( IsInNonCatMode() )
|
|
||||||
m_abcArray->FixIndicesOfChildren();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !IsInNonCatMode() )
|
if ( !IsInNonCatMode() )
|
||||||
{
|
{
|
||||||
// categorized mode - non-categorized array
|
// categorized mode - non-categorized array
|
||||||
|
|
||||||
// Remove from non-cat array, but only if parent is in it
|
// Remove from non-cat array
|
||||||
if ( !item->IsCategory() && item->GetParent()->IsCategory() )
|
if ( !item->IsCategory() &&
|
||||||
|
(parent->IsCategory() || parent->IsRoot()) )
|
||||||
{
|
{
|
||||||
if ( m_abcArray )
|
if ( m_abcArray )
|
||||||
m_abcArray->RemoveChild(item);
|
m_abcArray->RemoveChild(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
// categorized mode - categorized array
|
// categorized mode - categorized array
|
||||||
wxArrayPGProperty& parentsChildren = item->m_parent->m_children;
|
wxArrayPGProperty& parentsChildren = parent->m_children;
|
||||||
parentsChildren.erase( parentsChildren.begin() + indinparent );
|
parentsChildren.erase( parentsChildren.begin() + indinparent );
|
||||||
item->m_parent->FixIndicesOfChildren();
|
item->m_parent->FixIndicesOfChildren();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user