39#include <wx/filedlg.h>
46 SetTitle( wxString::Format(
_(
"Project file: '%s'" ),
Prj().GetProjectFullName() ) );
56 if( !
project.m_EquivalenceFiles.empty() )
60 for(
const auto& entry :
project.m_EquivalenceFiles )
71 for(
int row = 0; row <
m_gridEnvVars->GetTable()->GetRowsCount(); row++ )
75 if( wxGetEnv(
m_gridEnvVars->GetCellValue( row, 0 ), &evValue ) )
83 GetSizer()->SetSizeHints(
this );
92 if( editorname.IsEmpty() )
94 wxMessageBox(
_(
"No text editor selected in KiCad. Please choose one." ) );
98 wxArrayInt selections;
101 for(
unsigned ii = 0; ii < selections.GetCount(); ii++ )
111 project.m_EquivalenceFiles.clear();
124 EndModal( wxID_CANCEL );
130 wxArrayInt selections;
133 if ( selections.GetCount() <= 0 )
136 if( selections[0] == 0 )
141 for(
size_t ii = 0; ii < selections.GetCount(); ii++ )
143 int jj = selections[ii];
144 std::swap( libnames[jj], libnames[jj-1] );
150 for(
size_t ii = 0; ii < selections.GetCount(); ii++ )
152 int jj = selections[ii];
160 wxArrayInt selections;
163 if ( selections.GetCount() <= 0 )
172 for(
int ii = selections.GetCount()-1; ii >= 0; ii-- )
174 int jj = selections[ii];
175 std::swap( libnames[jj], libnames[jj+1] );
181 for(
size_t ii = 0; ii < selections.GetCount(); ii++ )
183 int jj = selections[ii];
194 wxArrayInt selections;
197 std::sort( selections.begin(), selections.end() );
199 for(
int ii = selections.GetCount()-1; ii >= 0; ii-- )
208 int row = selectedRows.GetCount() ? selectedRows[0] :
m_gridEnvVars->GetGridCursorRow();
209 wxString libpath =
m_gridEnvVars->GetCellValue( wxGridCellCoords( row, 1 ) );
211 wxFileDialog dlg(
this,
_(
"Footprint Association File" ), libpath, wxEmptyString,
214 if( dlg.ShowModal() != wxID_OK )
217 wxArrayString filenames;
218 dlg.GetPaths( filenames );
220 for(
unsigned jj = 0; jj < filenames.GetCount(); jj++ )
222 wxFileName fn = filenames[jj];
225 for( row = 0; row <
m_gridEnvVars->GetTable()->GetRowsCount(); row++ )
227 libpath =
m_gridEnvVars->GetCellValue( wxGridCellCoords( row, 1 ) );
229 if( fn.MakeRelativeTo( libpath ) )
231 filepath.Printf( wxT(
"${%s}%c%s" ),
233 wxFileName::GetPathSeparator(),
239 if( filepath.IsEmpty() )
240 filepath = filenames[jj];
243 if(
m_filesListBox->FindString( filepath, wxFileName::IsCaseSensitive() ) == wxNOT_FOUND )
245 filepath.Replace( wxT(
"\\" ), wxT(
"/" ) );
250 DisplayError(
this, wxString::Format(
_(
"File '%s' already exists in list." ),
251 filepath.GetData() ) );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
Class DIALOG_CONFIG_EQUFILES_BASE.
STD_BITMAP_BUTTON * m_bpMoveUp
STD_BITMAP_BUTTON * m_bpAdd
STD_BITMAP_BUTTON * m_bpMoveDown
wxListBox * m_filesListBox
STD_BITMAP_BUTTON * m_bpEdit
STD_BITMAP_BUTTON * m_bpDelete
DIALOG_CONFIG_EQUFILES(wxWindow *parent)
void OnCloseWindow(wxCloseEvent &event) override
void OnOkClick(wxCommandEvent &event) override
void OnButtonMoveDown(wxCommandEvent &event) override
void OnAddFiles(wxCommandEvent &event) override
void OnEditEquFile(wxCommandEvent &event) override
void OnRemoveFiles(wxCommandEvent &event) override
void OnButtonMoveUp(wxCommandEvent &event) override
void SetupStandardButtons(std::map< int, wxString > aLabels={})
static const wxString GlobalPathEnvVariableName()
Return the name of the environment variable used to hold the directory of locally installed "KiCad sp...
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
virtual const wxString & GetTextEditor(bool aCanShowFileChooser=true)
Return the path to the preferred text editor application.
virtual SETTINGS_MANAGER & GetSettingsManager() const
The backing store for a PROJECT, in JSON format.
virtual PROJECT_FILE & GetProjectFile() const
bool SaveProject(const wxString &aFullPath=wxEmptyString, PROJECT *aProject=nullptr)
Saves a loaded project.
void ClearRows()
wxWidgets recently added an ASSERT which fires if the position is greater than or equal to the number...
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
This file is part of the common library.
int ExecuteFile(const wxString &aEditorName, const wxString &aFileName, wxProcess *aCallback, bool aFileForKicad)
Call the executable file aEditorName with the parameter aFileName.
static wxString EquFileWildcard()
PGM_BASE & Pgm()
The global Program "get" accessor.
#define PROJECT_VAR_NAME
A variable name whose value holds the current project directory.
Definition of file extensions used in Kicad.