eeschema: now display lib list in alphabetic order in viewlib and get component.
Solved a minor bug in Search in lib command when attempt to search a component name in non loaded libraries
This commit is contained in:
parent
d31c0995f9
commit
6f63197662
|
@ -257,30 +257,6 @@ void FreeCmpLibrary (wxWindow* frame, const wxString& LibName)
|
|||
}
|
||||
|
||||
|
||||
/******************************/
|
||||
/** GetLibNames()
|
||||
* Routine to return pointers to all library names.
|
||||
* User is responsible to deallocate memory
|
||||
*/
|
||||
/******************************/
|
||||
const wxChar** GetLibNames()
|
||||
{
|
||||
int ii, NumOfLibs = NumOfLibraries();
|
||||
const wxChar** Names;
|
||||
LibraryStruct* Lib;
|
||||
|
||||
Names = (const wxChar**) MyZMalloc( sizeof(wxChar*) * (NumOfLibs + 1) );
|
||||
for( ii = 0, Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext, ii++ )
|
||||
{
|
||||
Names[ii] = Lib->m_Name.GetData();
|
||||
}
|
||||
|
||||
Names[ii] = NULL;
|
||||
|
||||
return Names;
|
||||
}
|
||||
|
||||
|
||||
/** Function LibraryEntryCompare
|
||||
* Routine to compare two EDA_LibComponentStruct for the PriorQue module.
|
||||
* Comparison (insensitive case) is based on Part name.
|
||||
|
|
|
@ -627,12 +627,12 @@ SCH_ITEM* WinEDA_SchematicFrame::FindSchematicItem(
|
|||
void WinEDA_FindFrame::LocatePartInLibs( wxCommandEvent& event )
|
||||
/*************************************************************/
|
||||
|
||||
/* Recherche exhaustive d'un composant en librairies, meme non chargees
|
||||
/* Search for a given component.
|
||||
* The serach is made in loaded libraries,
|
||||
* and if not found in all libraries found in lib paths.
|
||||
*/
|
||||
{
|
||||
wxString Text, FindList;
|
||||
const wxChar** ListNames;
|
||||
LibraryStruct* Lib = NULL;
|
||||
EDA_LibComponentStruct* LibEntry;
|
||||
bool FoundInLib = FALSE; // True si reference trouvee ailleurs qu'en cache
|
||||
|
||||
|
@ -643,33 +643,23 @@ void WinEDA_FindFrame::LocatePartInLibs( wxCommandEvent& event )
|
|||
}
|
||||
s_OldStringFound = Text;
|
||||
|
||||
int ii, nbitems, NumOfLibs = NumOfLibraries();
|
||||
if( NumOfLibs == 0 )
|
||||
if( NumOfLibraries() == 0 )
|
||||
{
|
||||
DisplayError( this, _( "No libraries are loaded" ) );
|
||||
Close(); return;
|
||||
}
|
||||
|
||||
ListNames = GetLibNames();
|
||||
|
||||
nbitems = 0;
|
||||
for( ii = 0; ii < NumOfLibs; ii++ ) /* Recherche de la librairie */
|
||||
|
||||
int nbitemsFound = 0;
|
||||
for( LibraryStruct* Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext )
|
||||
{
|
||||
bool IsLibCache;
|
||||
Lib = FindLibrary( ListNames[ii] );
|
||||
if( Lib == NULL )
|
||||
break;
|
||||
if( Lib->m_Name.Contains( wxT( ".cache" ) ) )
|
||||
IsLibCache = TRUE;
|
||||
else
|
||||
IsLibCache = FALSE;
|
||||
LibEntry = (EDA_LibComponentStruct*) PQFirst( &Lib->m_Entries, FALSE );
|
||||
while( LibEntry )
|
||||
{
|
||||
if( WildCompareString( Text, LibEntry->m_Name.m_Text, FALSE ) )
|
||||
{
|
||||
nbitems++;
|
||||
if( !IsLibCache )
|
||||
nbitemsFound++;
|
||||
if( !Lib->m_IsLibCache )
|
||||
FoundInLib = TRUE;
|
||||
if( !FindList.IsEmpty() )
|
||||
FindList += wxT( "\n" );
|
||||
|
@ -681,11 +671,9 @@ void WinEDA_FindFrame::LocatePartInLibs( wxCommandEvent& event )
|
|||
}
|
||||
}
|
||||
|
||||
free( ListNames );
|
||||
|
||||
if( !FoundInLib )
|
||||
{
|
||||
if( nbitems )
|
||||
if( nbitemsFound )
|
||||
FindList = wxT( "\n" ) + Text + _( " found only in cache" );
|
||||
else
|
||||
FindList = Text + _( " not found" );
|
||||
|
@ -719,7 +707,7 @@ int WinEDA_FindFrame::ExploreAllLibraries( const wxString& wildmask, wxString& F
|
|||
|
||||
for( unsigned ii = 0; ii < wxGetApp().GetLibraryPathList().GetCount(); ii++ )
|
||||
{
|
||||
path = wxGetApp().GetLibraryPathList()[ii];
|
||||
path = wxGetApp().GetLibraryPathList()[ii] + STRING_DIR_SEP;
|
||||
FullFileName = wxFindFirstFile( path + wxT( "*." ) + CompLibFileExtension );
|
||||
|
||||
while( !FullFileName.IsEmpty() )
|
||||
|
|
|
@ -80,7 +80,6 @@ LibraryStruct * LoadLibraryName(WinEDA_DrawFrame * frame,
|
|||
const wxString & FullLibName, const wxString & LibName);
|
||||
void LoadLibraries( WinEDA_SchematicFrame* frame );
|
||||
void FreeCmpLibrary(wxWindow * frame, const wxString & LibName);
|
||||
const wxChar **GetLibNames();
|
||||
|
||||
void SnapLibItemPoint(int OrigX, int OrigY, int *ClosestX, int *ClosestY,
|
||||
SCH_COMPONENT *DrawLibItem);
|
||||
|
|
|
@ -114,22 +114,19 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
|
|||
* @return bool - true if success writing else false.
|
||||
*/
|
||||
{
|
||||
const wxChar** LibNames;
|
||||
wxString Name, msg;
|
||||
Ki_PageDescr* PlotSheet;
|
||||
|
||||
wxString datetime = DateAndTime( );
|
||||
|
||||
LibNames = GetLibNames();
|
||||
for( int ii = 0; LibNames[ii] != NULL; ii++ )
|
||||
bool first = true;
|
||||
for( LibraryStruct* Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext )
|
||||
{
|
||||
if( ii > 0 )
|
||||
if( first )
|
||||
Name += wxT( "," );
|
||||
Name += LibNames[ii];
|
||||
Name += Lib->m_Name;
|
||||
first = false;
|
||||
}
|
||||
|
||||
MyFree( LibNames );
|
||||
|
||||
// Creates header
|
||||
if( fprintf( aFile, "%s %s %d", EESCHEMA_FILE_STAMP,
|
||||
SCHEMATIC_HEAD_STRING, EESCHEMA_VERSION ) == EOF )
|
||||
|
|
|
@ -24,15 +24,15 @@
|
|||
/***************************************************************/
|
||||
LibraryStruct * SelectLibraryFromList(WinEDA_DrawFrame * frame)
|
||||
/***************************************************************/
|
||||
/* Routine pour selectionner une librairie a partir d'une liste
|
||||
/** Function SelectLibraryFromList
|
||||
* Displays a list of current loaded libraries, and allows the user to select a library
|
||||
* This list is sorted, with the library cache always at end of the list
|
||||
*/
|
||||
{
|
||||
int ii, NumOfLibs = NumOfLibraries();
|
||||
LibraryStruct *Lib = NULL;
|
||||
static wxString OldLibName;
|
||||
WinEDAListBox * ListBox;
|
||||
wxString LibName;
|
||||
const wxChar ** ListNames;
|
||||
|
||||
if (NumOfLibs == 0)
|
||||
{
|
||||
|
@ -40,20 +40,38 @@ const wxChar ** ListNames;
|
|||
return(NULL) ;
|
||||
}
|
||||
|
||||
ListNames = GetLibNames();
|
||||
ListBox = new WinEDAListBox(frame, _("Select Lib"),
|
||||
ListNames, OldLibName, NULL,
|
||||
WinEDAListBox ListBox(frame, _("Select Lib"),
|
||||
NULL, OldLibName, NULL,
|
||||
wxColour(255,255,255)); // Library browser background color
|
||||
ListBox->MoveMouseToOrigin();
|
||||
|
||||
ii = ListBox->ShowModal(); ListBox->Destroy();
|
||||
wxArrayString libNamesList;
|
||||
LibraryStruct * libcache = NULL;
|
||||
for( LibraryStruct * Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext )
|
||||
{
|
||||
if ( Lib->m_IsLibCache )
|
||||
libcache = Lib;
|
||||
else
|
||||
libNamesList.Add( Lib->m_Name );
|
||||
}
|
||||
|
||||
libNamesList.Sort();
|
||||
|
||||
// Add lib cache
|
||||
if ( libcache )
|
||||
libNamesList.Add( libcache->m_Name );
|
||||
|
||||
ListBox.InsertItems(libNamesList);
|
||||
|
||||
|
||||
ListBox.MoveMouseToOrigin();
|
||||
|
||||
ii = ListBox.ShowModal();
|
||||
|
||||
if (ii >= 0) /* Recherche de la librairie */
|
||||
{
|
||||
Lib = FindLibrary(ListNames[ii]);
|
||||
}
|
||||
{
|
||||
Lib = FindLibrary(libNamesList[ii]);
|
||||
}
|
||||
|
||||
free (ListNames);
|
||||
return(Lib);
|
||||
}
|
||||
|
||||
|
|
|
@ -302,22 +302,44 @@ int WinEDA_ViewlibFrame::BestZoom()
|
|||
/******************************************/
|
||||
void WinEDA_ViewlibFrame::ReCreateListLib()
|
||||
/******************************************/
|
||||
/** Function ReCreateListLib
|
||||
* Creates or recreates the list of current loaded libraries.
|
||||
* This list is sorted, with the library cache always at end of the list
|
||||
*/
|
||||
{
|
||||
int ii;
|
||||
LibraryStruct* Lib;
|
||||
LibraryStruct * libcache = NULL;
|
||||
bool found = FALSE;
|
||||
|
||||
if( m_LibList == NULL )
|
||||
return;
|
||||
|
||||
m_LibList->Clear();
|
||||
for( ii = 0, Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext, ii++ )
|
||||
|
||||
wxArrayString libNamesList;
|
||||
for( LibraryStruct* Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext )
|
||||
{
|
||||
m_LibList->Append(Lib->m_Name);
|
||||
if( g_CurrentViewLibraryName.Cmp( Lib->m_Name ) == 0 )
|
||||
if ( Lib->m_IsLibCache )
|
||||
libcache = Lib;
|
||||
else
|
||||
libNamesList.Add( Lib->m_Name );
|
||||
}
|
||||
|
||||
libNamesList.Sort();
|
||||
|
||||
// Add lib cache
|
||||
if ( libcache )
|
||||
libNamesList.Add( libcache->m_Name );
|
||||
|
||||
m_LibList->Append(libNamesList);
|
||||
|
||||
// Search for a previous selection:
|
||||
for ( unsigned ii = 0; ii < m_LibList->GetCount(); ii++ )
|
||||
{
|
||||
if( g_CurrentViewLibraryName.Cmp( m_LibList->GetString(ii) ) == 0 )
|
||||
{
|
||||
m_LibList->SetSelection( ii, TRUE );
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue