Correct minor bishaviours in Expand() and Collapse()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59379 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2009-03-06 19:32:07 +00:00
parent d2ee27fe25
commit 7d83595849

View File

@@ -2957,10 +2957,13 @@ void wxDataViewMainWindow::OnExpanding( unsigned int row )
} }
else else
{ {
#if 0
// Why should we select the next row here???
SelectRow( row, false ); SelectRow( row, false );
SelectRow( row + 1, true ); SelectRow( row + 1, true );
ChangeCurrentRow( row + 1 ); ChangeCurrentRow( row + 1 );
SendSelectionChangedEvent( GetItemByRow(row+1)); SendSelectionChangedEvent( GetItemByRow(row+1));
#endif
} }
} }
else else
@@ -2973,10 +2976,15 @@ void wxDataViewMainWindow::OnCollapsing(unsigned int row)
if (IsVirtualList()) if (IsVirtualList())
return; return;
wxDataViewTreeNode * node = GetTreeNodeByRow(row); wxDataViewTreeNode *node = GetTreeNodeByRow(row);
if( node != NULL ) if (!node)
return;
if( !node->HasChildren())
{ {
wxDataViewTreeNode * nd = node; delete node;
return;
}
if( node->HasChildren() && node->IsOpen() ) if( node->HasChildren() && node->IsOpen() )
{ {
@@ -3035,7 +3043,7 @@ void wxDataViewMainWindow::OnCollapsing(unsigned int row)
m_count = -1; m_count = -1;
UpdateDisplay(); UpdateDisplay();
SendExpanderEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED,nd->GetItem()); SendExpanderEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED,node->GetItem());
} }
else else
{ {
@@ -3052,9 +3060,6 @@ void wxDataViewMainWindow::OnCollapsing(unsigned int row)
} }
} }
} }
if( !nd->HasChildren())
delete nd;
}
} }
wxDataViewTreeNode * wxDataViewMainWindow::FindNode( const wxDataViewItem & item ) wxDataViewTreeNode * wxDataViewMainWindow::FindNode( const wxDataViewItem & item )
@@ -4313,6 +4318,7 @@ void wxDataViewCtrl::Expand( const wxDataViewItem & item )
void wxDataViewCtrl::Collapse( const wxDataViewItem & item ) void wxDataViewCtrl::Collapse( const wxDataViewItem & item )
{ {
int row = m_clientArea->GetRowByItem( item ); int row = m_clientArea->GetRowByItem( item );
wxPrintf( "row %d\n", row );
if (row != -1) if (row != -1)
m_clientArea->Collapse(row); m_clientArea->Collapse(row);
} }