libedit: no units in the new Delete Part dialog

This commit is contained in:
Chris Pavlina 2017-02-05 09:07:47 -05:00
parent 4cd7514c8e
commit 431abcff0c
3 changed files with 18 additions and 2 deletions

View File

@ -104,6 +104,7 @@ COMPONENT_TREE_SEARCH_CONTAINER::COMPONENT_TREE_SEARCH_CONTAINER( PART_LIBS* aLi
m_libraries_added( 0 ),
m_components_added( 0 ),
m_preselect_unit_number( -1 ),
m_show_units( true ),
m_libs( aLibs ),
m_filter( CMP_FILTER_NONE )
{
@ -127,6 +128,12 @@ void COMPONENT_TREE_SEARCH_CONTAINER::SetPreselectNode( const wxString& aCompone
}
void COMPONENT_TREE_SEARCH_CONTAINER::ShowUnits( bool aShowUnits )
{
m_show_units = aShowUnits;
}
void COMPONENT_TREE_SEARCH_CONTAINER::SetTree( wxTreeCtrl* aTree )
{
m_tree = aTree;
@ -198,7 +205,7 @@ void COMPONENT_TREE_SEARCH_CONTAINER::AddAliasList( const wxString& aNodeName,
a, a->GetName(), display_info, search_text );
m_nodes.push_back( alias_node );
if( a->GetPart()->IsMulti() ) // Add all units as sub-nodes.
if( m_show_units && a->GetPart()->IsMulti() ) // Add all units as sub-nodes.
{
for( int u = 1; u <= a->GetPart()->GetUnitCount(); ++u )
{

View File

@ -89,6 +89,13 @@ public:
*/
void SetPreselectNode( const wxString& aComponentName, int aUnit );
/**
* Set whether units should be shown under parts. Default: true
*
* Must be called before AddLibrary, as this is when the list is populated!
*/
void ShowUnits( bool aShowUnits );
/** Function SetTree
* Set the tree to be manipulated.
* Each update of the search term will update the tree, with the most
@ -136,6 +143,7 @@ private:
wxString m_preselect_node_name;
int m_preselect_unit_number;
bool m_show_units;
PART_LIBS* m_libs; // no ownership

View File

@ -540,8 +540,9 @@ void LIB_EDIT_FRAME::DeleteOnePart( wxCommandEvent& event )
COMPONENT_TREE_SEARCH_CONTAINER search_container( Prj().SchLibs() );
wxString name = part ? part->GetName() : wxString( wxEmptyString );
search_container.AddLibrary( *lib );
search_container.SetPreselectNode( name, /* aUnit */ 0 );
search_container.ShowUnits( false );
search_container.AddLibrary( *lib );
wxString dialogTitle;
dialogTitle.Printf( _( "Delete Component (%u items loaded)" ), search_container.GetComponentsCount() );