Pinned libs can also be found in program settings.

This commit is contained in:
Jeff Young 2022-07-23 19:30:32 +01:00
parent 8eee766791
commit fa679d3601
5 changed files with 44 additions and 12 deletions

View File

@ -23,6 +23,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <pgm_base.h>
#include <bitmaps.h>
#include <confirm.h>
#include <eda_dde.h>
@ -961,6 +962,7 @@ void CVPCB_MAINFRAME::BuildSymbolsListBox()
void CVPCB_MAINFRAME::BuildLibrariesListBox()
{
COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
PROJECT_FILE& project = Kiway().Prj().GetProjectFile();
FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs();
std::set<wxString> pinnedMatches;
@ -969,10 +971,15 @@ void CVPCB_MAINFRAME::BuildLibrariesListBox()
auto process =
[&]( const wxString& aNickname )
{
if( alg::contains( project.m_PinnedFootprintLibs, aNickname ) )
if( alg::contains( project.m_PinnedFootprintLibs, aNickname )
|| alg::contains( cfg->m_Session.pinned_fp_libs, aNickname ) )
{
pinnedMatches.insert( aNickname );
}
else
{
otherMatches.insert( aNickname );
}
};

View File

@ -23,6 +23,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <pgm_base.h>
#include <confirm.h>
#include <kiway.h>
#include <widgets/infobar.h>
@ -104,7 +105,8 @@ void SYMBOL_EDIT_FRAME::SelectActiveLibrary( const wxString& aLibrary )
wxString SYMBOL_EDIT_FRAME::SelectLibraryFromList()
{
PROJECT& prj = Prj();
COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
PROJECT& prj = Prj();
if( prj.SchSymbolLibTable()->IsEmpty() )
{
@ -125,7 +127,8 @@ wxString SYMBOL_EDIT_FRAME::SelectLibraryFromList()
if( m_libMgr->IsLibraryReadOnly( name ) )
continue;
if( alg::contains( prj.GetProjectFile().m_PinnedSymbolLibs, name ) )
if( alg::contains( prj.GetProjectFile().m_PinnedSymbolLibs, name )
|| alg::contains( cfg->m_Session.pinned_symbol_libs, name ) )
{
wxArrayString item;
@ -140,7 +143,8 @@ wxString SYMBOL_EDIT_FRAME::SelectLibraryFromList()
if( m_libMgr->IsLibraryReadOnly( name ) )
continue;
if( !alg::contains( prj.GetProjectFile().m_PinnedSymbolLibs, name ) )
if( !alg::contains( prj.GetProjectFile().m_PinnedSymbolLibs, name )
&& !alg::contains( cfg->m_Session.pinned_symbol_libs, name ) )
{
wxArrayString item;
@ -578,6 +582,7 @@ static int ID_MAKE_NEW_LIBRARY = 4173;
EDA_LIST_DIALOG* SYMBOL_EDIT_FRAME::buildSaveAsDialog( const wxString& aSymbolName,
const wxString& aLibraryPreselect )
{
COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
PROJECT_FILE& project = Kiway().Prj().GetProjectFile();
SYMBOL_LIB_TABLE* tbl = Prj().SchSymbolLibTable();
std::vector<wxString> libNicknames = tbl->GetLogicalLibs();
@ -589,7 +594,8 @@ EDA_LIST_DIALOG* SYMBOL_EDIT_FRAME::buildSaveAsDialog( const wxString& aSymbolNa
for( const wxString& nickname : libNicknames )
{
if( alg::contains( project.m_PinnedSymbolLibs, nickname ) )
if( alg::contains( project.m_PinnedSymbolLibs, nickname )
|| alg::contains( cfg->m_Session.pinned_symbol_libs, nickname ) )
{
wxArrayString item;
item.Add( LIB_TREE_MODEL_ADAPTER::GetPinningSymbol() + nickname );
@ -600,7 +606,8 @@ EDA_LIST_DIALOG* SYMBOL_EDIT_FRAME::buildSaveAsDialog( const wxString& aSymbolNa
for( const wxString& nickname : libNicknames )
{
if( !alg::contains( project.m_PinnedSymbolLibs, nickname ) )
if( !alg::contains( project.m_PinnedSymbolLibs, nickname )
&& !alg::contains( cfg->m_Session.pinned_symbol_libs, nickname ) )
{
wxArrayString item;
item.Add( nickname );

View File

@ -560,6 +560,7 @@ bool SYMBOL_VIEWER_FRAME::ReCreateLibList()
m_libList->Clear();
COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
PROJECT_FILE& project = Kiway().Prj().GetProjectFile();
std::vector<wxString> libs = Prj().SchSymbolLibTable()->GetLogicalLibs();
std::set<wxString> pinnedMatches;
@ -586,10 +587,15 @@ bool SYMBOL_VIEWER_FRAME::ReCreateLibList()
return;
}
if( alg::contains( project.m_PinnedSymbolLibs, aLib ) )
if( alg::contains( project.m_PinnedSymbolLibs, aLib )
|| alg::contains( cfg->m_Session.pinned_symbol_libs, aLib ) )
{
pinnedMatches.insert( aLib );
}
else
{
otherMatches.insert( aLib );
}
};
if( m_libFilter->GetValue().IsEmpty() )

View File

@ -1016,6 +1016,7 @@ static int ID_MAKE_NEW_LIBRARY = 4173;
EDA_LIST_DIALOG* FOOTPRINT_EDIT_FRAME::buildSaveAsDialog( const wxString& aFootprintName,
const wxString& aLibraryPreselect )
{
COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
PROJECT_FILE& project = Kiway().Prj().GetProjectFile();
FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs();
std::vector<wxString> nicknames = tbl->GetLogicalLibs();
@ -1027,7 +1028,8 @@ EDA_LIST_DIALOG* FOOTPRINT_EDIT_FRAME::buildSaveAsDialog( const wxString& aFootp
for( const wxString& nickname : nicknames )
{
if( alg::contains( project.m_PinnedFootprintLibs, nickname ) )
if( alg::contains( project.m_PinnedFootprintLibs, nickname )
|| alg::contains( cfg->m_Session.pinned_fp_libs, nickname ) )
{
wxArrayString item;
@ -1039,7 +1041,8 @@ EDA_LIST_DIALOG* FOOTPRINT_EDIT_FRAME::buildSaveAsDialog( const wxString& aFootp
for( const wxString& nickname : nicknames )
{
if( !alg::contains( project.m_PinnedFootprintLibs, nickname ) )
if( !alg::contains( project.m_PinnedFootprintLibs, nickname )
&& !alg::contains( cfg->m_Session.pinned_fp_libs, nickname ) )
{
wxArrayString item;
@ -1340,6 +1343,7 @@ wxString PCB_BASE_FRAME::SelectLibrary( const wxString& aNicknameExisting )
headers.Add( _( "Nickname" ) );
headers.Add( _( "Description" ) );
COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
PROJECT_FILE& project = Kiway().Prj().GetProjectFile();
FP_LIB_TABLE* fptbl = Prj().PcbFootprintLibs();
std::vector< wxArrayString > itemsToDisplay;
@ -1347,7 +1351,8 @@ wxString PCB_BASE_FRAME::SelectLibrary( const wxString& aNicknameExisting )
for( const wxString& nickname : nicknames )
{
if( alg::contains( project.m_PinnedFootprintLibs, nickname ) )
if( alg::contains( project.m_PinnedFootprintLibs, nickname )
|| alg::contains( cfg->m_Session.pinned_fp_libs, nickname ) )
{
wxArrayString item;
@ -1359,7 +1364,8 @@ wxString PCB_BASE_FRAME::SelectLibrary( const wxString& aNicknameExisting )
for( const wxString& nickname : nicknames )
{
if( !alg::contains( project.m_PinnedFootprintLibs, nickname ) )
if( !alg::contains( project.m_PinnedFootprintLibs, nickname )
&& !alg::contains( cfg->m_Session.pinned_fp_libs, nickname ) )
{
wxArrayString item;

View File

@ -442,6 +442,7 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList()
{
m_libList->Clear();
COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
PROJECT_FILE& project = Kiway().Prj().GetProjectFile();
std::vector<wxString> nicknames = Prj().PcbFootprintLibs()->GetLogicalLibs();
std::set<wxString> pinnedMatches;
@ -450,10 +451,15 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList()
auto process =
[&]( const wxString& aNickname )
{
if( alg::contains( project.m_PinnedFootprintLibs, aNickname ) )
if( alg::contains( project.m_PinnedFootprintLibs, aNickname )
|| alg::contains( cfg->m_Session.pinned_fp_libs, aNickname ) )
{
pinnedMatches.insert( aNickname );
}
else
{
otherMatches.insert( aNickname );
}
};
if( m_libFilter->GetValue().IsEmpty() )