Eeschema: schematic I/O plugin preparation work.
Rename PART_LIB GetEntryNames() and RemoveEntry() to GetAliasNames() and RemoveAlias() respectively for improved readability. Rename PART_LIBS FindLibraryEntry() to FindLibraryAlias() improved readability. Remove commented out PART_LIBS::FindLibraryEntries(). Remove PART_LIB::GetFirstEntry() and update all effect code accordingly. Remove unused PART_LIB::SetFileName() method. Remove unused PART_LIBS::RemoveAllLibraries() method.
This commit is contained in:
parent
d167407d1a
commit
fc07716aed
|
@ -93,7 +93,7 @@ PART_LIB::~PART_LIB()
|
|||
}
|
||||
|
||||
|
||||
void PART_LIB::GetEntryNames( wxArrayString& aNames )
|
||||
void PART_LIB::GetAliasNames( wxArrayString& aNames )
|
||||
{
|
||||
for( LIB_ALIAS_MAP::iterator it = m_amap.begin(); it!=m_amap.end(); it++ )
|
||||
{
|
||||
|
@ -149,15 +149,6 @@ LIB_ALIAS* PART_LIB::FindAlias( const wxString& aName )
|
|||
}
|
||||
|
||||
|
||||
LIB_ALIAS* PART_LIB::GetFirstEntry()
|
||||
{
|
||||
if( m_amap.size() )
|
||||
return m_amap.begin()->second;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
LIB_PART* PART_LIB::FindPart( const wxString& aName )
|
||||
{
|
||||
#if 0 && defined(DEBUG)
|
||||
|
@ -249,7 +240,7 @@ bool PART_LIB::AddPart( LIB_PART* aPart )
|
|||
wxString aliasname = my_part->m_aliases[i]->GetName();
|
||||
|
||||
if( LIB_ALIAS* alias = FindAlias( aliasname ) )
|
||||
RemoveEntry( alias );
|
||||
RemoveAlias( alias );
|
||||
|
||||
m_amap[ aliasname ] = my_part->m_aliases[i];
|
||||
}
|
||||
|
@ -261,7 +252,7 @@ bool PART_LIB::AddPart( LIB_PART* aPart )
|
|||
}
|
||||
|
||||
|
||||
LIB_ALIAS* PART_LIB::RemoveEntry( LIB_ALIAS* aEntry )
|
||||
LIB_ALIAS* PART_LIB::RemoveAlias( LIB_ALIAS* aEntry )
|
||||
{
|
||||
wxCHECK_MSG( aEntry != NULL, NULL, wxT( "NULL pointer cannot be removed from library." ) );
|
||||
|
||||
|
@ -312,7 +303,7 @@ LIB_PART* PART_LIB::ReplacePart( LIB_PART* aOldPart, LIB_PART* aNewPart )
|
|||
/* Remove the old root component. The component will automatically be deleted
|
||||
* when all it's aliases are deleted. Do not place any code that accesses
|
||||
* aOldPart inside this loop that gets evaluated after the last alias is
|
||||
* removed in RemoveEntry(). Failure to heed this warning will result in a
|
||||
* removed in RemoveAlias(). Failure to heed this warning will result in a
|
||||
* segfault.
|
||||
*/
|
||||
size_t i = aOldPart->m_aliases.size();
|
||||
|
@ -320,7 +311,7 @@ LIB_PART* PART_LIB::ReplacePart( LIB_PART* aOldPart, LIB_PART* aNewPart )
|
|||
while( i > 0 )
|
||||
{
|
||||
i -= 1;
|
||||
RemoveEntry( aOldPart->m_aliases[ i ] );
|
||||
RemoveAlias( aOldPart->m_aliases[ i ] );
|
||||
}
|
||||
|
||||
LIB_PART* my_part = new LIB_PART( *aNewPart, this );
|
||||
|
@ -859,7 +850,7 @@ LIB_PART* PART_LIBS::FindLibPart( const wxString& aPartName, const wxString& aLi
|
|||
}
|
||||
|
||||
|
||||
LIB_ALIAS* PART_LIBS::FindLibraryEntry( const wxString& aEntryName, const wxString& aLibraryName )
|
||||
LIB_ALIAS* PART_LIBS::FindLibraryAlias( const wxString& aEntryName, const wxString& aLibraryName )
|
||||
{
|
||||
LIB_ALIAS* entry = NULL;
|
||||
|
||||
|
@ -890,24 +881,17 @@ void PART_LIBS::FindLibraryNearEntries( std::vector<LIB_ALIAS*>& aCandidates,
|
|||
if( !!aLibraryName && lib.GetName() != aLibraryName )
|
||||
continue;
|
||||
|
||||
LIB_ALIAS* entry = lib.GetFirstEntry();
|
||||
wxArrayString aliasNames;
|
||||
|
||||
if( ! entry )
|
||||
lib.GetAliasNames( aliasNames );
|
||||
|
||||
if( aliasNames.IsEmpty() )
|
||||
continue;
|
||||
|
||||
wxString first_entry_name = entry->GetName();
|
||||
wxString entry_name = first_entry_name;
|
||||
|
||||
for( ;; )
|
||||
for( size_t i = 0; i < aliasNames.size(); i++ )
|
||||
{
|
||||
if( entry_name.CmpNoCase( aEntryName ) == 0 )
|
||||
aCandidates.push_back( entry );
|
||||
|
||||
entry = lib.GetNextEntry( entry_name );
|
||||
entry_name = entry->GetName();
|
||||
|
||||
if( first_entry_name == entry_name )
|
||||
break;
|
||||
if( aliasNames[i].CmpNoCase( aEntryName ) == 0 )
|
||||
aCandidates.push_back( lib.FindAlias( aliasNames[i] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -233,8 +233,6 @@ public:
|
|||
*/
|
||||
void RemoveLibrary( const wxString& aName );
|
||||
|
||||
void RemoveAllLibraries() { clear(); }
|
||||
|
||||
/**
|
||||
* Function LoadAllLibraries
|
||||
* loads all of the project's libraries into this container, which should
|
||||
|
@ -301,18 +299,9 @@ public:
|
|||
* @param aLibraryName - Name of the library to search.
|
||||
* @return The entry object if found, otherwise NULL.
|
||||
*/
|
||||
LIB_ALIAS* FindLibraryEntry( const wxString& aEntryName,
|
||||
LIB_ALIAS* FindLibraryAlias( const wxString& aEntryName,
|
||||
const wxString& aLibraryName = wxEmptyString );
|
||||
|
||||
/**
|
||||
* Function FindLibraryEntries
|
||||
* searches all libraries in the list for an entry, returns all matches.
|
||||
*
|
||||
* @param aEntryName - Name of entry to search for (case sensitive).
|
||||
* @param aEntries - a std::vector to store entries
|
||||
*/
|
||||
// void FindLibraryEntries( const wxString& aEntryName, std::vector<LIB_ALIAS*>& aEntries );
|
||||
|
||||
/**
|
||||
* Function FindLibraryNearEntries
|
||||
* Searches all libraries in the list for an entry, using a case insensitive comparison.
|
||||
|
@ -436,7 +425,7 @@ public:
|
|||
*
|
||||
* @param aNames - String array to place entry names into.
|
||||
*/
|
||||
void GetEntryNames( wxArrayString& aNames );
|
||||
void GetAliasNames( wxArrayString& aNames );
|
||||
|
||||
/**
|
||||
* Load a string array with the names of entries of type POWER in this library.
|
||||
|
@ -509,7 +498,7 @@ public:
|
|||
* @param aEntry - Entry to remove from library.
|
||||
* @return The next entry in the library or NULL if the library is empty.
|
||||
*/
|
||||
LIB_ALIAS* RemoveEntry( LIB_ALIAS* aEntry );
|
||||
LIB_ALIAS* RemoveAlias( LIB_ALIAS* aEntry );
|
||||
|
||||
/**
|
||||
* Replace an existing part entry in the library.
|
||||
|
@ -520,13 +509,6 @@ public:
|
|||
*/
|
||||
LIB_PART* ReplacePart( LIB_PART* aOldPart, LIB_PART* aNewPart );
|
||||
|
||||
/**
|
||||
* Return the first entry in the library.
|
||||
*
|
||||
* @return The first entry or NULL if the library has no entries.
|
||||
*/
|
||||
LIB_ALIAS* GetFirstEntry();
|
||||
|
||||
/**
|
||||
* Find next library entry by \a aName.
|
||||
*
|
||||
|
@ -583,18 +565,6 @@ public:
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function SetFileName
|
||||
* sets the part library file name.
|
||||
*
|
||||
* @param aFileName - New library file name.
|
||||
*/
|
||||
void SetFileName( const wxString& aFileName )
|
||||
{
|
||||
if( aFileName != fileName.GetFullName() )
|
||||
fileName = aFileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function LoadLibrary
|
||||
* allocates and loads a part library file.
|
||||
|
|
|
@ -141,7 +141,7 @@ void COMPONENT_TREE_SEARCH_CONTAINER::AddLibrary( PART_LIB& aLib )
|
|||
if( m_filter == CMP_FILTER_POWER )
|
||||
aLib.GetEntryTypePowerNames( all_aliases );
|
||||
else
|
||||
aLib.GetEntryNames( all_aliases );
|
||||
aLib.GetAliasNames( all_aliases );
|
||||
|
||||
AddAliasList( aLib.GetName(), all_aliases, &aLib );
|
||||
|
||||
|
@ -164,7 +164,7 @@ void COMPONENT_TREE_SEARCH_CONTAINER::AddAliasList( const wxString& aNodeName,
|
|||
if( aOptionalLib )
|
||||
a = aOptionalLib->FindAlias( aName );
|
||||
else
|
||||
a = m_libs->FindLibraryEntry( aName, wxEmptyString );
|
||||
a = m_libs->FindLibraryAlias( aName, wxEmptyString );
|
||||
|
||||
if( a == NULL )
|
||||
continue;
|
||||
|
|
|
@ -352,7 +352,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions()
|
|||
{
|
||||
PART_LIBS* libs = Prj().SchLibs();
|
||||
|
||||
if( libs->FindLibraryEntry( newname ) == NULL )
|
||||
if( libs->FindLibraryAlias( newname ) == NULL )
|
||||
{
|
||||
wxString msg = wxString::Format( _(
|
||||
"Component '%s' not found!" ), GetChars( newname ) );
|
||||
|
|
|
@ -78,18 +78,20 @@ void LIB_EDIT_FRAME::OnImportPart( wxCommandEvent& event )
|
|||
return;
|
||||
}
|
||||
|
||||
LIB_ALIAS* entry = lib->GetFirstEntry();
|
||||
wxArrayString aliasNames;
|
||||
|
||||
if( !entry )
|
||||
lib->GetAliasNames( aliasNames );
|
||||
|
||||
if( aliasNames.IsEmpty() )
|
||||
{
|
||||
wxString msg = wxString::Format( _(
|
||||
"Part library file '%s' is empty." ),
|
||||
GetChars( fn.GetFullPath() )
|
||||
);
|
||||
wxString msg = wxString::Format( _( "Part library file '%s' is empty." ),
|
||||
GetChars( fn.GetFullPath() ) );
|
||||
DisplayError( this, msg );
|
||||
return;
|
||||
}
|
||||
|
||||
LIB_ALIAS* entry = lib->FindAlias( aliasNames[0] );
|
||||
|
||||
if( LoadOneLibraryPartAux( entry, lib.get() ) )
|
||||
{
|
||||
DisplayLibInfos();
|
||||
|
|
|
@ -147,7 +147,7 @@ void LIB_EDIT_FRAME::LoadOneLibraryPart( wxCommandEvent& event )
|
|||
{
|
||||
// Not found in the active library: search inside the full list
|
||||
// (can happen when using Viewlib to load a component)
|
||||
libEntry = Prj().SchLibs()->FindLibraryEntry( cmp_name );
|
||||
libEntry = Prj().SchLibs()->FindLibraryAlias( cmp_name );
|
||||
|
||||
if( libEntry )
|
||||
{
|
||||
|
@ -527,7 +527,7 @@ void LIB_EDIT_FRAME::DeleteOnePart( wxCommandEvent& event )
|
|||
}
|
||||
}
|
||||
|
||||
lib->GetEntryNames( nameList );
|
||||
lib->GetAliasNames( nameList );
|
||||
|
||||
if( nameList.IsEmpty() )
|
||||
{
|
||||
|
@ -567,7 +567,7 @@ void LIB_EDIT_FRAME::DeleteOnePart( wxCommandEvent& event )
|
|||
|
||||
if( !part || !part->HasAlias( libEntry->GetName() ) )
|
||||
{
|
||||
lib->RemoveEntry( libEntry );
|
||||
lib->RemoveAlias( libEntry );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -581,7 +581,7 @@ void LIB_EDIT_FRAME::DeleteOnePart( wxCommandEvent& event )
|
|||
return;
|
||||
}
|
||||
|
||||
LIB_ALIAS* nextEntry = lib->RemoveEntry( libEntry );
|
||||
LIB_ALIAS* nextEntry = lib->RemoveAlias( libEntry );
|
||||
|
||||
if( nextEntry != NULL )
|
||||
{
|
||||
|
|
|
@ -357,7 +357,7 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component, PART_LIBS*
|
|||
}
|
||||
|
||||
wxString msg;
|
||||
LIB_ALIAS* libEntry = aLibs->FindLibraryEntry( Component->GetPartName() );
|
||||
LIB_ALIAS* libEntry = aLibs->FindLibraryAlias( Component->GetPartName() );
|
||||
|
||||
if( !Component->GetFlags() )
|
||||
{
|
||||
|
@ -412,7 +412,7 @@ void AddMenusForEditComponent( wxMenu* PopMenu, SCH_COMPONENT* Component, PART_L
|
|||
|
||||
wxString msg;
|
||||
LIB_PART* part = NULL;
|
||||
LIB_ALIAS* libEntry = aLibs->FindLibraryEntry( Component->GetPartName() );
|
||||
LIB_ALIAS* libEntry = aLibs->FindLibraryAlias( Component->GetPartName() );
|
||||
|
||||
if( libEntry )
|
||||
part = libEntry->GetPart();
|
||||
|
|
|
@ -251,7 +251,7 @@ public:
|
|||
{
|
||||
wxString part_name( each_component->GetPartName() );
|
||||
|
||||
LIB_ALIAS* case_sensitive_match = aRescuer.GetLibs()->FindLibraryEntry( part_name );
|
||||
LIB_ALIAS* case_sensitive_match = aRescuer.GetLibs()->FindLibraryAlias( part_name );
|
||||
std::vector<LIB_ALIAS*> case_insensitive_matches;
|
||||
aRescuer.GetLibs()->FindLibraryNearEntries( case_insensitive_matches, part_name );
|
||||
|
||||
|
|
|
@ -299,7 +299,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
{
|
||||
if( PART_LIBS* libs = Prj().SchLibs() )
|
||||
{
|
||||
LIB_ALIAS* entry = libs->FindLibraryEntry( ( (SCH_COMPONENT*) item )->GetPartName() );
|
||||
LIB_ALIAS* entry = libs->FindLibraryAlias( ( (SCH_COMPONENT*) item )->GetPartName() );
|
||||
|
||||
if( entry && !!entry->GetDocFileName() )
|
||||
{
|
||||
|
|
|
@ -1172,7 +1172,7 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
|
|||
{
|
||||
if( PART_LIBS* libs = Prj().SchLibs() )
|
||||
{
|
||||
LIB_ALIAS* entry = libs->FindLibraryEntry( component->GetPartName() );
|
||||
LIB_ALIAS* entry = libs->FindLibraryAlias( component->GetPartName() );
|
||||
|
||||
if( !entry ) // Should not occur
|
||||
return;
|
||||
|
|
|
@ -44,7 +44,7 @@ static void DisplayCmpDocAndKeywords( wxString& aName, void* aData )
|
|||
|
||||
wxASSERT( libs );
|
||||
|
||||
LIB_ALIAS* part = libs->FindLibraryEntry( aName );
|
||||
LIB_ALIAS* part = libs->FindLibraryAlias( aName );
|
||||
|
||||
if( !part )
|
||||
return;
|
||||
|
@ -120,7 +120,7 @@ bool SCH_BASE_FRAME::DisplayListComponentsInLib( PART_LIB* aLibrary,
|
|||
if( aLibrary == NULL )
|
||||
return false;
|
||||
|
||||
aLibrary->GetEntryNames( nameList );
|
||||
aLibrary->GetAliasNames( nameList );
|
||||
|
||||
wxArrayString headers;
|
||||
headers.Add( wxT("Component") );
|
||||
|
|
|
@ -109,7 +109,13 @@ void LIB_EDIT_FRAME::LoadOneSymbol()
|
|||
wxMessageBox( msg, _( "Warning" ), wxOK | wxICON_EXCLAMATION, this );
|
||||
}
|
||||
|
||||
LIB_PART* first = lib->GetFirstEntry()->GetPart();
|
||||
wxArrayString aliasNames;
|
||||
|
||||
lib->GetAliasNames( aliasNames );
|
||||
|
||||
wxCHECK_RET( !aliasNames.IsEmpty(), "No aliases found in library " + filename );
|
||||
|
||||
LIB_PART* first = lib->FindAlias( aliasNames[0] )->GetPart();
|
||||
LIB_ITEMS& drawList = first->GetDrawItemList();
|
||||
|
||||
for( LIB_ITEM& item : drawList )
|
||||
|
|
|
@ -406,7 +406,7 @@ void LIB_VIEW_FRAME::ReCreateListCmp()
|
|||
if( m_listPowerCmpOnly )
|
||||
lib->GetEntryTypePowerNames( nameList );
|
||||
else
|
||||
lib->GetEntryNames( nameList );
|
||||
lib->GetAliasNames( nameList );
|
||||
|
||||
m_cmpList->Append( nameList );
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ void LIB_VIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
break;
|
||||
|
||||
case ID_LIBVIEW_VIEWDOC:
|
||||
entry = Prj().SchLibs()->FindLibraryEntry( m_entryName, m_libraryName );
|
||||
entry = Prj().SchLibs()->FindLibraryAlias( m_entryName, m_libraryName );
|
||||
|
||||
if( entry && !entry->GetDocFileName().IsEmpty() )
|
||||
{
|
||||
|
@ -253,7 +253,7 @@ void LIB_VIEW_FRAME::ViewOneLibraryContent( PART_LIB* Lib, int Flag )
|
|||
|
||||
void LIB_VIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
|
||||
{
|
||||
LIB_ALIAS* entry = Prj().SchLibs()->FindLibraryEntry( m_entryName, m_libraryName );
|
||||
LIB_ALIAS* entry = Prj().SchLibs()->FindLibraryAlias( m_entryName, m_libraryName );
|
||||
|
||||
if( !entry )
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue