Show component history at the top and preselect it

This was the behavior before the factoring out of COMPONENT_TREE. Moving
the history at the top just required inserting it at the right point;
fixing preselect involved wxEVT_INIT_DIALOG not propagating to the
panel. Simple solution was to move the parts of that event handler to
the constructor as they didn't have to be in an event handler anyway.

Fixes: lp:1707538
* https://bugs.launchpad.net/kicad/+bug/1707538
This commit is contained in:
Chris Pavlina 2017-08-19 00:39:55 -06:00
parent 6be2f2934e
commit a20cce0753
3 changed files with 20 additions and 28 deletions

View File

@ -126,14 +126,6 @@ SCH_BASE_FRAME::COMPONENT_SELECTION SCH_BASE_FRAME::SelectComponentFromLibrary(
}
if( !loaded )
{
for( PART_LIB& lib : *libs )
{
adapter->AddLibrary( lib );
}
}
if( !aHistoryList.empty() )
{
@ -146,6 +138,14 @@ SCH_BASE_FRAME::COMPONENT_SELECTION SCH_BASE_FRAME::SelectComponentFromLibrary(
adapter->SetPreselectNode( aHistoryList[0].Name, aHistoryList[0].Unit );
}
if( !loaded )
{
for( PART_LIB& lib : *libs )
{
adapter->AddLibrary( lib );
}
}
if( !aHighlight.IsEmpty() )
adapter->SetPreselectNode( aHighlight, /* aUnit */ 0 );

View File

@ -80,12 +80,23 @@ COMPONENT_TREE::COMPONENT_TREE( wxWindow* aParent,
SetSizer( sizer );
Bind( wxEVT_INIT_DIALOG, &COMPONENT_TREE::onInitDialog, this );
m_tree_ctrl->Bind( wxEVT_DATAVIEW_ITEM_ACTIVATED, &COMPONENT_TREE::onTreeActivate, this );
m_tree_ctrl->Bind( wxEVT_DATAVIEW_SELECTION_CHANGED, &COMPONENT_TREE::onTreeSelect, this );
Bind( COMPONENT_PRESELECTED, &COMPONENT_TREE::onPreselect, this );
// If wxTextCtrl::SetHint() is called before binding wxEVT_TEXT, the event
// handler will intermittently fire.
if( m_query_ctrl )
{
m_query_ctrl->SetHint( _( "Search" ) );
m_query_ctrl->SetFocus();
m_query_ctrl->SetValue( wxEmptyString );
}
// There may be a part preselected in the model. Make sure it is displayed.
postPreselectEvent();
Layout();
sizer->Fit( this );
}
@ -127,22 +138,6 @@ void COMPONENT_TREE::postSelectEvent()
}
void COMPONENT_TREE::onInitDialog( wxInitDialogEvent& aEvent )
{
// If wxTextCtrl::SetHint() is called before binding wxEVT_TEXT, the event
// handler will intermittently fire.
if( m_query_ctrl )
{
m_query_ctrl->SetHint( _( "Search" ) );
m_query_ctrl->SetFocus();
m_query_ctrl->SetValue( wxEmptyString );
}
// There may be a part preselected in the model. Make sure it is displayed.
postPreselectEvent();
}
void COMPONENT_TREE::onQueryText( wxCommandEvent& aEvent )
{
m_adapter->UpdateSearchString( m_query_ctrl->GetLineText( 0 ) );

View File

@ -74,9 +74,6 @@ protected:
*/
void postSelectEvent();
// Event handlers
void onInitDialog( wxInitDialogEvent& aEvent );
void onQueryText( wxCommandEvent& aEvent );
void onQueryEnter( wxCommandEvent& aEvent );
void onQueryCharHook( wxKeyEvent& aEvent );