2009-02-04 15:25:03 +00:00
|
|
|
/****************************/
|
2009-08-27 11:41:56 +00:00
|
|
|
/* EESchema - database.cpp */
|
2009-02-04 15:25:03 +00:00
|
|
|
/****************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "confirm.h"
|
|
|
|
#include "eda_doc.h"
|
|
|
|
#include "kicad_string.h"
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "program.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "class_library.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
#include <boost/foreach.hpp>
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/*
|
2009-11-03 13:26:31 +00:00
|
|
|
* Routine name selection of a component library for loading,
|
|
|
|
* Keys leading the list of the keywords filter
|
|
|
|
* If Keys = "", research components that correspond
|
|
|
|
* BufName mask (with * and?)
|
2009-02-04 15:25:03 +00:00
|
|
|
*
|
2009-11-03 13:26:31 +00:00
|
|
|
* Returns
|
|
|
|
* TRUE if the selected component
|
|
|
|
* FALSE canceled order
|
|
|
|
* Place the name of the component has loaded, select from a list in
|
|
|
|
* BufName
|
2009-02-04 15:25:03 +00:00
|
|
|
*/
|
2009-08-27 11:41:56 +00:00
|
|
|
wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys,
|
|
|
|
wxString& BufName )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-08-27 11:41:56 +00:00
|
|
|
wxArrayString nameList;
|
|
|
|
wxString msg;
|
2009-02-04 15:25:03 +00:00
|
|
|
|
|
|
|
BufName.MakeUpper();
|
|
|
|
Keys.MakeUpper();
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Review the list of libraries for counting. */
|
2009-09-18 14:56:05 +00:00
|
|
|
BOOST_FOREACH( CMP_LIBRARY& lib, CMP_LIBRARY::GetLibraryList() )
|
2009-02-04 15:25:03 +00:00
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
lib.SearchEntryNames( nameList, BufName, Keys );
|
2009-02-04 15:25:03 +00:00
|
|
|
}
|
|
|
|
|
2009-08-27 11:41:56 +00:00
|
|
|
if( nameList.IsEmpty() )
|
2009-02-04 15:25:03 +00:00
|
|
|
{
|
2009-08-27 11:41:56 +00:00
|
|
|
msg = _( "No components found matching " );
|
|
|
|
if( !BufName.IsEmpty() )
|
2009-02-04 15:25:03 +00:00
|
|
|
{
|
2009-08-27 11:41:56 +00:00
|
|
|
msg += _( "name search criteria <" ) + BufName + wxT( "> " );
|
2009-02-04 15:25:03 +00:00
|
|
|
if( !Keys.IsEmpty() )
|
2009-08-27 11:41:56 +00:00
|
|
|
msg += _( "and " );
|
2009-02-04 15:25:03 +00:00
|
|
|
}
|
|
|
|
|
2009-08-27 11:41:56 +00:00
|
|
|
if( !Keys.IsEmpty() )
|
|
|
|
msg += _( "key search criteria <" ) + Keys + wxT( "> " );
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2009-08-27 11:41:56 +00:00
|
|
|
DisplayError( frame, msg );
|
|
|
|
|
|
|
|
return wxEmptyString;
|
2009-02-04 15:25:03 +00:00
|
|
|
}
|
|
|
|
|
2009-08-27 11:41:56 +00:00
|
|
|
wxSingleChoiceDialog dlg( frame, wxEmptyString, _( "Select Component" ),
|
|
|
|
nameList );
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2009-08-27 11:41:56 +00:00
|
|
|
if( dlg.ShowModal() == wxID_CANCEL || dlg.GetStringSelection().IsEmpty() )
|
|
|
|
return wxEmptyString;
|
|
|
|
|
|
|
|
return dlg.GetStringSelection();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
void DisplayCmpDoc( wxString& Name )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
CMP_LIB_ENTRY* CmpEntry = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
CmpEntry = CMP_LIBRARY::FindLibraryEntry( Name );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
if( CmpEntry == NULL )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-09-02 18:12:45 +00:00
|
|
|
wxLogDebug( wxT( "Selected component <%s>, m_Doc: <%s>, m_KeyWord: <%s>." ),
|
2009-10-16 17:18:23 +00:00
|
|
|
GetChars( Name ), GetChars( CmpEntry->m_Doc ),
|
|
|
|
GetChars( CmpEntry->m_KeyWord ) );
|
2009-09-02 18:12:45 +00:00
|
|
|
|
2009-08-27 11:41:56 +00:00
|
|
|
Name = wxT( "Description: " ) + CmpEntry->m_Doc;
|
|
|
|
Name += wxT( "\nKey Words: " ) + CmpEntry->m_KeyWord;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|