X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/13499080f059a1163f91ecc108f3751f0b26bb6b..ccd5d46c7b69632eaa231e8fc7801dd5af2faaa8:/src/generic/datavgen.cpp diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 4465439568..32691b07ab 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -2423,7 +2423,10 @@ bool wxDataViewMainWindow::IsExpanded( unsigned int row ) const return false; if (!node->HasChildren()) + { + delete node; return false; + } return node->IsOpen(); } @@ -3038,6 +3041,7 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event ) // select single line SelectAllRows( false ); SelectRow( m_lineSelectSingleOnUp, true ); + SendSelectionChangedEvent( GetItemByRow(m_lineSelectSingleOnUp) ); } //Process the event of user clicking the expander @@ -3523,18 +3527,33 @@ int wxDataViewCtrl::GetSelections( wxDataViewItemArray & sel ) const void wxDataViewCtrl::SetSelections( const wxDataViewItemArray & sel ) { wxDataViewSelection selection(wxDataViewSelectionCmp); + + wxDataViewItem last_parent; + int len = sel.GetCount(); for( int i = 0; i < len; i ++ ) { - int row = m_clientArea->GetRowByItem( sel[i] ); + wxDataViewItem item = sel[i]; + wxDataViewItem parent = GetModel()->GetParent( item ); + if (parent) + { + if (parent != last_parent) + ExpandAncestors(item); + } + + last_parent = parent; + int row = m_clientArea->GetRowByItem( item ); if( row >= 0 ) selection.Add( static_cast(row) ); } + m_clientArea->SetSelections( selection ); } void wxDataViewCtrl::Select( const wxDataViewItem & item ) { + ExpandAncestors( item ); + int row = m_clientArea->GetRowByItem( item ); if( row >= 0 ) { @@ -3658,6 +3677,8 @@ void wxDataViewCtrl::EnsureVisible( int row, int column ) void wxDataViewCtrl::EnsureVisible( const wxDataViewItem & item, const wxDataViewColumn * column ) { + ExpandAncestors( item ); + m_clientArea->RecalculateDisplay(); int row = m_clientArea->GetRowByItem(item);