Added pinning support to various EDA_LIST_DIALOGs.
Footprint Save As, Symbol Save As, etc.
This commit is contained in:
parent
05219e4d9a
commit
eb27a3f8b9
|
@ -27,7 +27,7 @@
|
|||
#include <eda_draw_frame.h>
|
||||
#include <string_utils.h>
|
||||
#include <macros.h>
|
||||
|
||||
#include "lib_tree_model_adapter.h"
|
||||
|
||||
// wxWidgets spends *far* too long calculating column widths (most of it, believe it or
|
||||
// not, in repeatedly creating/destroying a wxDC to do the measurement in).
|
||||
|
@ -39,11 +39,11 @@ static int DEFAULT_COL_WIDTHS[] = { 200, 600 };
|
|||
EDA_LIST_DIALOG::EDA_LIST_DIALOG( wxWindow* aParent, const wxString& aTitle,
|
||||
const wxArrayString& aItemHeaders,
|
||||
const std::vector<wxArrayString>& aItemList,
|
||||
const wxString& aPreselectText ) :
|
||||
EDA_LIST_DIALOG_BASE( aParent, wxID_ANY, aTitle )
|
||||
const wxString& aPreselectText, bool aSortList ) :
|
||||
EDA_LIST_DIALOG_BASE( aParent, wxID_ANY, aTitle ),
|
||||
m_itemsList( aItemList ),
|
||||
m_sortList( aSortList )
|
||||
{
|
||||
m_itemsList = aItemList;
|
||||
|
||||
m_filterBox->SetHint( _( "Filter" ) );
|
||||
|
||||
initDialog( aItemHeaders, aPreselectText );
|
||||
|
@ -149,7 +149,8 @@ wxString EDA_LIST_DIALOG::GetTextSelection( int aColumn )
|
|||
wxCHECK_MSG( unsigned( aColumn ) < unsigned( m_listBox->GetColumnCount() ), wxEmptyString,
|
||||
wxT( "Invalid list control column." ) );
|
||||
|
||||
long item = m_listBox->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
|
||||
long item = m_listBox->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
|
||||
wxString text;
|
||||
|
||||
if( item >= 0 ) // if something is selected.
|
||||
{
|
||||
|
@ -160,10 +161,13 @@ wxString EDA_LIST_DIALOG::GetTextSelection( int aColumn )
|
|||
info.m_col = aColumn;
|
||||
|
||||
if( m_listBox->GetItem( info ) )
|
||||
return info.m_text;
|
||||
text = info.m_text;
|
||||
|
||||
if( text.StartsWith( LIB_TREE_MODEL_ADAPTER::GetPinningSymbol() ) )
|
||||
text = text.substr( LIB_TREE_MODEL_ADAPTER::GetPinningSymbol().length() );
|
||||
}
|
||||
|
||||
return wxEmptyString;
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
|
@ -233,5 +237,6 @@ static int wxCALLBACK myCompareFunction( wxIntPtr aItem1, wxIntPtr aItem2,
|
|||
|
||||
void EDA_LIST_DIALOG::sortList()
|
||||
{
|
||||
m_listBox->SortItems( myCompareFunction, 0 );
|
||||
if( m_sortList )
|
||||
m_listBox->SortItems( myCompareFunction, 0 );
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <symbol_lib_table.h>
|
||||
#include <symbol_library_manager.h>
|
||||
#include <symbol_tree_pane.h>
|
||||
#include <project/project_file.h>
|
||||
#include <widgets/lib_tree.h>
|
||||
#include <sch_plugins/legacy/sch_legacy_plugin.h>
|
||||
#include <sch_plugins/kicad/sch_sexpr_plugin.h>
|
||||
|
@ -118,22 +119,40 @@ wxString SYMBOL_EDIT_FRAME::SelectLibraryFromList()
|
|||
std::vector< wxArrayString > itemsToDisplay;
|
||||
std::vector< wxString > libNicknames = prj.SchSymbolLibTable()->GetLogicalLibs();
|
||||
|
||||
// Conversion from wxArrayString to vector of ArrayString
|
||||
for( const wxString& name : libNicknames )
|
||||
{
|
||||
wxArrayString item;
|
||||
|
||||
// Exclude read only libraries.
|
||||
if( m_libMgr->IsLibraryReadOnly( name ) )
|
||||
continue;
|
||||
|
||||
item.Add( name );
|
||||
itemsToDisplay.push_back( item );
|
||||
if( alg::contains( prj.GetProjectFile().m_PinnedSymbolLibs, name ) )
|
||||
{
|
||||
wxArrayString item;
|
||||
|
||||
item.Add( LIB_TREE_MODEL_ADAPTER::GetPinningSymbol() + name );
|
||||
itemsToDisplay.push_back( item );
|
||||
}
|
||||
}
|
||||
|
||||
for( const wxString& name : libNicknames )
|
||||
{
|
||||
// Exclude read only libraries.
|
||||
if( m_libMgr->IsLibraryReadOnly( name ) )
|
||||
continue;
|
||||
|
||||
if( !alg::contains( prj.GetProjectFile().m_PinnedSymbolLibs, name ) )
|
||||
{
|
||||
wxArrayString item;
|
||||
|
||||
item.Add( name );
|
||||
itemsToDisplay.push_back( item );
|
||||
}
|
||||
}
|
||||
|
||||
wxString oldLibName = prj.GetRString( PROJECT::SCH_LIB_SELECT );
|
||||
|
||||
EDA_LIST_DIALOG dlg( this, _( "Select Symbol Library" ), headers, itemsToDisplay, oldLibName );
|
||||
EDA_LIST_DIALOG dlg( this, _( "Select Symbol Library" ), headers, itemsToDisplay, oldLibName,
|
||||
false );
|
||||
|
||||
if( dlg.ShowModal() != wxID_OK )
|
||||
return wxEmptyString;
|
||||
|
@ -559,6 +578,7 @@ static int ID_MAKE_NEW_LIBRARY = 4173;
|
|||
EDA_LIST_DIALOG* SYMBOL_EDIT_FRAME::buildSaveAsDialog( const wxString& aSymbolName,
|
||||
const wxString& aLibraryPreselect )
|
||||
{
|
||||
PROJECT_FILE& project = Kiway().Prj().GetProjectFile();
|
||||
SYMBOL_LIB_TABLE* tbl = Prj().SchSymbolLibTable();
|
||||
std::vector<wxString> libNicknames = tbl->GetLogicalLibs();
|
||||
wxArrayString headers;
|
||||
|
@ -569,14 +589,28 @@ EDA_LIST_DIALOG* SYMBOL_EDIT_FRAME::buildSaveAsDialog( const wxString& aSymbolNa
|
|||
|
||||
for( const wxString& nickname : libNicknames )
|
||||
{
|
||||
wxArrayString item;
|
||||
item.Add( nickname );
|
||||
item.Add( tbl->GetDescription( nickname ) );
|
||||
itemsToDisplay.push_back( item );
|
||||
if( alg::contains( project.m_PinnedSymbolLibs, nickname ) )
|
||||
{
|
||||
wxArrayString item;
|
||||
item.Add( LIB_TREE_MODEL_ADAPTER::GetPinningSymbol() + nickname );
|
||||
item.Add( tbl->GetDescription( nickname ) );
|
||||
itemsToDisplay.push_back( item );
|
||||
}
|
||||
}
|
||||
|
||||
for( const wxString& nickname : libNicknames )
|
||||
{
|
||||
if( !alg::contains( project.m_PinnedSymbolLibs, nickname ) )
|
||||
{
|
||||
wxArrayString item;
|
||||
item.Add( nickname );
|
||||
item.Add( tbl->GetDescription( nickname ) );
|
||||
itemsToDisplay.push_back( item );
|
||||
}
|
||||
}
|
||||
|
||||
EDA_LIST_DIALOG* dlg = new EDA_LIST_DIALOG( this, _( "Save Symbol As" ), headers,
|
||||
itemsToDisplay, aLibraryPreselect );
|
||||
itemsToDisplay, aLibraryPreselect, false );
|
||||
|
||||
dlg->SetListLabel( _( "Save in library:" ) );
|
||||
dlg->SetOKLabel( _( "Save" ) );
|
||||
|
|
|
@ -52,7 +52,8 @@ public:
|
|||
*/
|
||||
EDA_LIST_DIALOG( wxWindow* aParent, const wxString& aTitle, const wxArrayString& aItemHeaders,
|
||||
const std::vector<wxArrayString>& aItemList,
|
||||
const wxString& aPreselectText = wxEmptyString );
|
||||
const wxString& aPreselectText = wxEmptyString,
|
||||
bool aSortList = true );
|
||||
|
||||
void SetListLabel( const wxString& aLabel );
|
||||
void SetOKLabel( const wxString& aLabel );
|
||||
|
@ -81,6 +82,7 @@ private:
|
|||
private:
|
||||
// The list of items, locally stored
|
||||
std::vector<wxArrayString> m_itemsList;
|
||||
bool m_sortList;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include <env_paths.h>
|
||||
#include <paths.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <project/project_file.h>
|
||||
#include <footprint_editor_settings.h>
|
||||
#include "footprint_viewer_frame.h"
|
||||
#include "tools/pad_tool.h"
|
||||
|
@ -1015,6 +1016,7 @@ static int ID_MAKE_NEW_LIBRARY = 4173;
|
|||
EDA_LIST_DIALOG* FOOTPRINT_EDIT_FRAME::buildSaveAsDialog( const wxString& aFootprintName,
|
||||
const wxString& aLibraryPreselect )
|
||||
{
|
||||
PROJECT_FILE& project = Kiway().Prj().GetProjectFile();
|
||||
FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs();
|
||||
std::vector<wxString> nicknames = tbl->GetLogicalLibs();
|
||||
wxArrayString headers;
|
||||
|
@ -1025,14 +1027,30 @@ EDA_LIST_DIALOG* FOOTPRINT_EDIT_FRAME::buildSaveAsDialog( const wxString& aFootp
|
|||
|
||||
for( const wxString& nickname : nicknames )
|
||||
{
|
||||
wxArrayString item;
|
||||
item.Add( nickname );
|
||||
item.Add( tbl->GetDescription( nickname ) );
|
||||
itemsToDisplay.push_back( item );
|
||||
if( alg::contains( project.m_PinnedFootprintLibs, nickname ) )
|
||||
{
|
||||
wxArrayString item;
|
||||
|
||||
item.Add( LIB_TREE_MODEL_ADAPTER::GetPinningSymbol() + nickname );
|
||||
item.Add( tbl->GetDescription( nickname ) );
|
||||
itemsToDisplay.push_back( item );
|
||||
}
|
||||
}
|
||||
|
||||
for( const wxString& nickname : nicknames )
|
||||
{
|
||||
if( !alg::contains( project.m_PinnedFootprintLibs, nickname ) )
|
||||
{
|
||||
wxArrayString item;
|
||||
|
||||
item.Add( nickname );
|
||||
item.Add( tbl->GetDescription( nickname ) );
|
||||
itemsToDisplay.push_back( item );
|
||||
}
|
||||
}
|
||||
|
||||
EDA_LIST_DIALOG* dlg = new EDA_LIST_DIALOG( this, _( "Save Footprint As" ), headers,
|
||||
itemsToDisplay, aLibraryPreselect );
|
||||
itemsToDisplay, aLibraryPreselect, false );
|
||||
|
||||
dlg->SetListLabel( _( "Save in library:" ) );
|
||||
dlg->SetOKLabel( _( "Save" ) );
|
||||
|
@ -1322,22 +1340,37 @@ wxString PCB_BASE_FRAME::SelectLibrary( const wxString& aNicknameExisting )
|
|||
headers.Add( _( "Nickname" ) );
|
||||
headers.Add( _( "Description" ) );
|
||||
|
||||
FP_LIB_TABLE* fptbl = Prj().PcbFootprintLibs();
|
||||
|
||||
PROJECT_FILE& project = Kiway().Prj().GetProjectFile();
|
||||
FP_LIB_TABLE* fptbl = Prj().PcbFootprintLibs();
|
||||
std::vector< wxArrayString > itemsToDisplay;
|
||||
std::vector< wxString > nicknames = fptbl->GetLogicalLibs();
|
||||
|
||||
for( const wxString& nickname : nicknames )
|
||||
{
|
||||
wxArrayString item;
|
||||
if( alg::contains( project.m_PinnedFootprintLibs, nickname ) )
|
||||
{
|
||||
wxArrayString item;
|
||||
|
||||
item.Add( nickname );
|
||||
item.Add( fptbl->GetDescription( nickname ) );
|
||||
|
||||
itemsToDisplay.push_back( item );
|
||||
item.Add( LIB_TREE_MODEL_ADAPTER::GetPinningSymbol() + nickname );
|
||||
item.Add( fptbl->GetDescription( nickname ) );
|
||||
itemsToDisplay.push_back( item );
|
||||
}
|
||||
}
|
||||
|
||||
EDA_LIST_DIALOG dlg( this, _( "Select Library" ), headers, itemsToDisplay, aNicknameExisting );
|
||||
for( const wxString& nickname : nicknames )
|
||||
{
|
||||
if( !alg::contains( project.m_PinnedFootprintLibs, nickname ) )
|
||||
{
|
||||
wxArrayString item;
|
||||
|
||||
item.Add( nickname );
|
||||
item.Add( fptbl->GetDescription( nickname ) );
|
||||
itemsToDisplay.push_back( item );
|
||||
}
|
||||
}
|
||||
|
||||
EDA_LIST_DIALOG dlg( this, _( "Select Library" ), headers, itemsToDisplay, aNicknameExisting,
|
||||
false );
|
||||
|
||||
if( dlg.ShowModal() != wxID_OK )
|
||||
return wxEmptyString;
|
||||
|
|
Loading…
Reference in New Issue