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 <eda_draw_frame.h>
|
||||||
#include <string_utils.h>
|
#include <string_utils.h>
|
||||||
#include <macros.h>
|
#include <macros.h>
|
||||||
|
#include "lib_tree_model_adapter.h"
|
||||||
|
|
||||||
// wxWidgets spends *far* too long calculating column widths (most of it, believe it or
|
// 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).
|
// 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,
|
EDA_LIST_DIALOG::EDA_LIST_DIALOG( wxWindow* aParent, const wxString& aTitle,
|
||||||
const wxArrayString& aItemHeaders,
|
const wxArrayString& aItemHeaders,
|
||||||
const std::vector<wxArrayString>& aItemList,
|
const std::vector<wxArrayString>& aItemList,
|
||||||
const wxString& aPreselectText ) :
|
const wxString& aPreselectText, bool aSortList ) :
|
||||||
EDA_LIST_DIALOG_BASE( aParent, wxID_ANY, aTitle )
|
EDA_LIST_DIALOG_BASE( aParent, wxID_ANY, aTitle ),
|
||||||
|
m_itemsList( aItemList ),
|
||||||
|
m_sortList( aSortList )
|
||||||
{
|
{
|
||||||
m_itemsList = aItemList;
|
|
||||||
|
|
||||||
m_filterBox->SetHint( _( "Filter" ) );
|
m_filterBox->SetHint( _( "Filter" ) );
|
||||||
|
|
||||||
initDialog( aItemHeaders, aPreselectText );
|
initDialog( aItemHeaders, aPreselectText );
|
||||||
|
@ -149,7 +149,8 @@ wxString EDA_LIST_DIALOG::GetTextSelection( int aColumn )
|
||||||
wxCHECK_MSG( unsigned( aColumn ) < unsigned( m_listBox->GetColumnCount() ), wxEmptyString,
|
wxCHECK_MSG( unsigned( aColumn ) < unsigned( m_listBox->GetColumnCount() ), wxEmptyString,
|
||||||
wxT( "Invalid list control column." ) );
|
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.
|
if( item >= 0 ) // if something is selected.
|
||||||
{
|
{
|
||||||
|
@ -160,10 +161,13 @@ wxString EDA_LIST_DIALOG::GetTextSelection( int aColumn )
|
||||||
info.m_col = aColumn;
|
info.m_col = aColumn;
|
||||||
|
|
||||||
if( m_listBox->GetItem( info ) )
|
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()
|
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_lib_table.h>
|
||||||
#include <symbol_library_manager.h>
|
#include <symbol_library_manager.h>
|
||||||
#include <symbol_tree_pane.h>
|
#include <symbol_tree_pane.h>
|
||||||
|
#include <project/project_file.h>
|
||||||
#include <widgets/lib_tree.h>
|
#include <widgets/lib_tree.h>
|
||||||
#include <sch_plugins/legacy/sch_legacy_plugin.h>
|
#include <sch_plugins/legacy/sch_legacy_plugin.h>
|
||||||
#include <sch_plugins/kicad/sch_sexpr_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< wxArrayString > itemsToDisplay;
|
||||||
std::vector< wxString > libNicknames = prj.SchSymbolLibTable()->GetLogicalLibs();
|
std::vector< wxString > libNicknames = prj.SchSymbolLibTable()->GetLogicalLibs();
|
||||||
|
|
||||||
// Conversion from wxArrayString to vector of ArrayString
|
|
||||||
for( const wxString& name : libNicknames )
|
for( const wxString& name : libNicknames )
|
||||||
{
|
{
|
||||||
wxArrayString item;
|
|
||||||
|
|
||||||
// Exclude read only libraries.
|
// Exclude read only libraries.
|
||||||
if( m_libMgr->IsLibraryReadOnly( name ) )
|
if( m_libMgr->IsLibraryReadOnly( name ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
item.Add( name );
|
if( alg::contains( prj.GetProjectFile().m_PinnedSymbolLibs, name ) )
|
||||||
itemsToDisplay.push_back( item );
|
{
|
||||||
|
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 );
|
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 )
|
if( dlg.ShowModal() != wxID_OK )
|
||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
|
@ -559,6 +578,7 @@ static int ID_MAKE_NEW_LIBRARY = 4173;
|
||||||
EDA_LIST_DIALOG* SYMBOL_EDIT_FRAME::buildSaveAsDialog( const wxString& aSymbolName,
|
EDA_LIST_DIALOG* SYMBOL_EDIT_FRAME::buildSaveAsDialog( const wxString& aSymbolName,
|
||||||
const wxString& aLibraryPreselect )
|
const wxString& aLibraryPreselect )
|
||||||
{
|
{
|
||||||
|
PROJECT_FILE& project = Kiway().Prj().GetProjectFile();
|
||||||
SYMBOL_LIB_TABLE* tbl = Prj().SchSymbolLibTable();
|
SYMBOL_LIB_TABLE* tbl = Prj().SchSymbolLibTable();
|
||||||
std::vector<wxString> libNicknames = tbl->GetLogicalLibs();
|
std::vector<wxString> libNicknames = tbl->GetLogicalLibs();
|
||||||
wxArrayString headers;
|
wxArrayString headers;
|
||||||
|
@ -569,14 +589,28 @@ EDA_LIST_DIALOG* SYMBOL_EDIT_FRAME::buildSaveAsDialog( const wxString& aSymbolNa
|
||||||
|
|
||||||
for( const wxString& nickname : libNicknames )
|
for( const wxString& nickname : libNicknames )
|
||||||
{
|
{
|
||||||
wxArrayString item;
|
if( alg::contains( project.m_PinnedSymbolLibs, nickname ) )
|
||||||
item.Add( nickname );
|
{
|
||||||
item.Add( tbl->GetDescription( nickname ) );
|
wxArrayString item;
|
||||||
itemsToDisplay.push_back( 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,
|
EDA_LIST_DIALOG* dlg = new EDA_LIST_DIALOG( this, _( "Save Symbol As" ), headers,
|
||||||
itemsToDisplay, aLibraryPreselect );
|
itemsToDisplay, aLibraryPreselect, false );
|
||||||
|
|
||||||
dlg->SetListLabel( _( "Save in library:" ) );
|
dlg->SetListLabel( _( "Save in library:" ) );
|
||||||
dlg->SetOKLabel( _( "Save" ) );
|
dlg->SetOKLabel( _( "Save" ) );
|
||||||
|
|
|
@ -52,7 +52,8 @@ public:
|
||||||
*/
|
*/
|
||||||
EDA_LIST_DIALOG( wxWindow* aParent, const wxString& aTitle, const wxArrayString& aItemHeaders,
|
EDA_LIST_DIALOG( wxWindow* aParent, const wxString& aTitle, const wxArrayString& aItemHeaders,
|
||||||
const std::vector<wxArrayString>& aItemList,
|
const std::vector<wxArrayString>& aItemList,
|
||||||
const wxString& aPreselectText = wxEmptyString );
|
const wxString& aPreselectText = wxEmptyString,
|
||||||
|
bool aSortList = true );
|
||||||
|
|
||||||
void SetListLabel( const wxString& aLabel );
|
void SetListLabel( const wxString& aLabel );
|
||||||
void SetOKLabel( const wxString& aLabel );
|
void SetOKLabel( const wxString& aLabel );
|
||||||
|
@ -81,6 +82,7 @@ private:
|
||||||
private:
|
private:
|
||||||
// The list of items, locally stored
|
// The list of items, locally stored
|
||||||
std::vector<wxArrayString> m_itemsList;
|
std::vector<wxArrayString> m_itemsList;
|
||||||
|
bool m_sortList;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
#include <env_paths.h>
|
#include <env_paths.h>
|
||||||
#include <paths.h>
|
#include <paths.h>
|
||||||
#include <settings/settings_manager.h>
|
#include <settings/settings_manager.h>
|
||||||
|
#include <project/project_file.h>
|
||||||
#include <footprint_editor_settings.h>
|
#include <footprint_editor_settings.h>
|
||||||
#include "footprint_viewer_frame.h"
|
#include "footprint_viewer_frame.h"
|
||||||
#include "tools/pad_tool.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,
|
EDA_LIST_DIALOG* FOOTPRINT_EDIT_FRAME::buildSaveAsDialog( const wxString& aFootprintName,
|
||||||
const wxString& aLibraryPreselect )
|
const wxString& aLibraryPreselect )
|
||||||
{
|
{
|
||||||
|
PROJECT_FILE& project = Kiway().Prj().GetProjectFile();
|
||||||
FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs();
|
FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs();
|
||||||
std::vector<wxString> nicknames = tbl->GetLogicalLibs();
|
std::vector<wxString> nicknames = tbl->GetLogicalLibs();
|
||||||
wxArrayString headers;
|
wxArrayString headers;
|
||||||
|
@ -1025,14 +1027,30 @@ EDA_LIST_DIALOG* FOOTPRINT_EDIT_FRAME::buildSaveAsDialog( const wxString& aFootp
|
||||||
|
|
||||||
for( const wxString& nickname : nicknames )
|
for( const wxString& nickname : nicknames )
|
||||||
{
|
{
|
||||||
wxArrayString item;
|
if( alg::contains( project.m_PinnedFootprintLibs, nickname ) )
|
||||||
item.Add( nickname );
|
{
|
||||||
item.Add( tbl->GetDescription( nickname ) );
|
wxArrayString item;
|
||||||
itemsToDisplay.push_back( 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,
|
EDA_LIST_DIALOG* dlg = new EDA_LIST_DIALOG( this, _( "Save Footprint As" ), headers,
|
||||||
itemsToDisplay, aLibraryPreselect );
|
itemsToDisplay, aLibraryPreselect, false );
|
||||||
|
|
||||||
dlg->SetListLabel( _( "Save in library:" ) );
|
dlg->SetListLabel( _( "Save in library:" ) );
|
||||||
dlg->SetOKLabel( _( "Save" ) );
|
dlg->SetOKLabel( _( "Save" ) );
|
||||||
|
@ -1322,22 +1340,37 @@ wxString PCB_BASE_FRAME::SelectLibrary( const wxString& aNicknameExisting )
|
||||||
headers.Add( _( "Nickname" ) );
|
headers.Add( _( "Nickname" ) );
|
||||||
headers.Add( _( "Description" ) );
|
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< wxArrayString > itemsToDisplay;
|
||||||
std::vector< wxString > nicknames = fptbl->GetLogicalLibs();
|
std::vector< wxString > nicknames = fptbl->GetLogicalLibs();
|
||||||
|
|
||||||
for( const wxString& nickname : nicknames )
|
for( const wxString& nickname : nicknames )
|
||||||
{
|
{
|
||||||
wxArrayString item;
|
if( alg::contains( project.m_PinnedFootprintLibs, nickname ) )
|
||||||
|
{
|
||||||
|
wxArrayString item;
|
||||||
|
|
||||||
item.Add( nickname );
|
item.Add( LIB_TREE_MODEL_ADAPTER::GetPinningSymbol() + nickname );
|
||||||
item.Add( fptbl->GetDescription( nickname ) );
|
item.Add( fptbl->GetDescription( nickname ) );
|
||||||
|
itemsToDisplay.push_back( item );
|
||||||
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 )
|
if( dlg.ShowModal() != wxID_OK )
|
||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
|
|
Loading…
Reference in New Issue