Fixed filtering in component chooser on Windows

Please never ask me about the SetSortOrder() part. When it is set to
'true', wxDataViewCtrl::EnsureVisible() does not always work correctly,
so sometimes the best search result is not shown in the window (no
pattern found). Now it is set to 'false' to avoid the described
behavior, but the sorting order is reversed on Windows, not on Linux.
I could not test it on OSX, but I am sure it paints walls in your room
pink. /me burst into tears.

Fixes: lp:1738696
* https://bugs.launchpad.net/kicad/+bug/1738696
This commit is contained in:
Maciej Suminski 2017-12-19 14:06:26 +01:00
parent 29e1d3d98a
commit a1b7060189
1 changed files with 11 additions and 8 deletions

View File

@ -145,7 +145,6 @@ void CMP_TREE_MODEL_ADAPTER_BASE::AddAliasList(
void CMP_TREE_MODEL_ADAPTER_BASE::UpdateSearchString( wxString const& aSearch ) void CMP_TREE_MODEL_ADAPTER_BASE::UpdateSearchString( wxString const& aSearch )
{ {
wxWindowUpdateLocker updateLock( m_widget );
m_tree.ResetScore(); m_tree.ResetScore();
wxStringTokenizer tokenizer( aSearch ); wxStringTokenizer tokenizer( aSearch );
@ -159,13 +158,18 @@ void CMP_TREE_MODEL_ADAPTER_BASE::UpdateSearchString( wxString const& aSearch )
} }
m_tree.SortNodes(); m_tree.SortNodes();
Cleared();
{
wxWindowUpdateLocker updateLock( m_widget );
Cleared();
#ifndef __WINDOWS__ #ifndef __WINDOWS__
// The fastest method to update wxDataViewCtrl is to rebuild from scratch by calling Cleared(). // The fastest method to update wxDataViewCtrl is to rebuild from
// Linux requires to reassociate model to display data, but Windows will create multiple // scratch by calling Cleared(). Linux requires to reassociate model to
// associations. // display data, but Windows will create multiple associations.
AttachTo( m_widget ); AttachTo( m_widget );
#endif #endif
}
ShowResults() || ShowPreselect() || ShowSingleLibrary(); ShowResults() || ShowPreselect() || ShowSingleLibrary();
} }
@ -173,7 +177,6 @@ void CMP_TREE_MODEL_ADAPTER_BASE::UpdateSearchString( wxString const& aSearch )
void CMP_TREE_MODEL_ADAPTER_BASE::AttachTo( wxDataViewCtrl* aDataViewCtrl ) void CMP_TREE_MODEL_ADAPTER_BASE::AttachTo( wxDataViewCtrl* aDataViewCtrl )
{ {
wxWindowUpdateLocker updateLock( aDataViewCtrl );
m_widget = aDataViewCtrl; m_widget = aDataViewCtrl;
aDataViewCtrl->SetIndent( kDataViewIndent ); aDataViewCtrl->SetIndent( kDataViewIndent );
aDataViewCtrl->AssociateModel( this ); aDataViewCtrl->AssociateModel( this );
@ -186,7 +189,7 @@ void CMP_TREE_MODEL_ADAPTER_BASE::AttachTo( wxDataViewCtrl* aDataViewCtrl )
ColWidth( m_tree, 0, part_head ) ); ColWidth( m_tree, 0, part_head ) );
m_col_desc = aDataViewCtrl->AppendTextColumn( desc_head, 1, wxDATAVIEW_CELL_INERT, m_col_desc = aDataViewCtrl->AppendTextColumn( desc_head, 1, wxDATAVIEW_CELL_INERT,
ColWidth( m_tree, 1, desc_head ) ); ColWidth( m_tree, 1, desc_head ) );
m_col_part->SetSortOrder( true ); m_col_part->SetSortOrder( 0 );
} }