KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_sym_lib_table.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2017 Wayne Stambaugh <[email protected]>
5 * Copyright (C) 2021 CERN
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22#include <set>
23#include <wx/regex.h>
24
25#include <build_version.h>
26#include <common.h> // For ExpandEnvVarSubstitutions
28#include <project.h>
29#include <panel_sym_lib_table.h>
30#include <lib_id.h>
34#include <widgets/wx_grid.h>
38#include <confirm.h>
39#include <bitmaps.h>
42#include <env_paths.h>
43#include <functional>
44#include <eeschema_id.h>
45#include <env_vars.h>
46#include <sch_io/sch_io.h>
47#include <symbol_edit_frame.h>
48#include <sch_edit_frame.h>
49#include <kiway.h>
50#include <paths.h>
51#include <kiplatform/ui.h>
52#include <pgm_base.h>
54#include <wx/dir.h>
55#include <wx/dirdlg.h>
56#include <wx/filedlg.h>
57#include <wx/msgdlg.h>
58#include <project_sch.h>
62
67{
68 wxString m_Description;
69 wxString m_FileFilter;
70
73 bool m_IsFile;
74 SCH_IO_MGR::SCH_FILE_T m_Plugin;
75};
76
77
82static constexpr int FIRST_MENU_ID = 1000;
83// This must not collide with any SCH_FILE_T enum values so we offset it below.
85
86
88{
89public:
90 SYMBOL_LIB_TABLE_GRID_DATA_MODEL( DIALOG_SHIM* aParent, WX_GRID* aGrid, const LIBRARY_TABLE& aTableToEdit,
91 SYMBOL_LIBRARY_ADAPTER* aAdapter, const wxArrayString& aPluginChoices,
92 wxString* aMRUDirectory, const wxString& aProjectPath ) :
93 LIB_TABLE_GRID_DATA_MODEL( aParent, aGrid, aTableToEdit, aAdapter, aPluginChoices, aMRUDirectory,
94 aProjectPath )
95 {
96 }
97
98 void SetValue( int aRow, int aCol, const wxString &aValue ) override
99 {
100 wxCHECK( aRow < (int) size(), /* void */ );
101
102 LIB_TABLE_GRID_DATA_MODEL::SetValue( aRow, aCol, aValue );
103
104 // If setting a filepath, attempt to auto-detect the format
105 if( aCol == COL_URI )
106 {
107 LIBRARY_TABLE_ROW& row = at( static_cast<size_t>( aRow ) );
108 wxString uri = LIBRARY_MANAGER::ExpandURI( row.URI(), Pgm().GetSettingsManager().Prj() );
109 SCH_IO_MGR::SCH_FILE_T pluginType = SCH_IO_MGR::GuessPluginTypeFromLibPath( uri );
110
111 if( pluginType != SCH_IO_MGR::SCH_FILE_UNKNOWN )
112 SetValue( aRow, COL_TYPE, SCH_IO_MGR::ShowType( pluginType ) );
113 }
114 }
115
116protected:
117 wxString getFileTypes( WX_GRID* aGrid, int aRow ) override
118 {
119 LIB_TABLE_GRID_DATA_MODEL* table = static_cast<LIB_TABLE_GRID_DATA_MODEL*>( aGrid->GetTable() );
120 LIBRARY_TABLE_ROW& tableRow = table->At( aRow );
121
122 if( tableRow.Type() == LIBRARY_TABLE_ROW::TABLE_TYPE_NAME )
123 {
124 wxString filter = _( "Symbol Library Tables" );
125#ifndef __WXOSX__
126 filter << wxString::Format( _( " (%s)|%s" ), FILEEXT::SymbolLibraryTableFileName,
128#else
129 filter << wxString::Format( _( " (%s)|%s" ), wxFileSelectorDefaultWildcardStr,
130 wxFileSelectorDefaultWildcardStr );
131#endif
132 return filter;
133 }
134
135 SCH_IO_MGR::SCH_FILE_T pi_type = SCH_IO_MGR::EnumFromStr( tableRow.Type() );
136 IO_RELEASER<SCH_IO> pi( SCH_IO_MGR::FindPlugin( pi_type ) );
137
138 if( pi )
139 {
140 const IO_BASE::IO_FILE_DESC& desc = pi->GetLibraryDesc();
141
142 if( desc.m_IsFile )
143 return desc.FileFilter();
144 }
145
146 return wxEmptyString;
147 }
148};
149
150
152{
153public:
155 std::function<void( wxCommandEvent& )> aAddHandler ) :
156 LIB_TABLE_GRID_TRICKS( aGrid, aAddHandler ),
157 m_panel( aPanel )
158 {
160 }
161
163 {
164 return true;
165 }
166
167protected:
168 void optionsEditor( int aRow ) override
169 {
170 LIB_TABLE_GRID_DATA_MODEL* tbl = static_cast<LIB_TABLE_GRID_DATA_MODEL*>( m_grid->GetTable() );
171
172 if( tbl->GetNumberRows() > aRow )
173 {
174 LIBRARY_TABLE_ROW& row = tbl->At( static_cast<size_t>( aRow ) );
175 const wxString& options = row.Options();
176 wxString result = options;
177 std::map<std::string, UTF8> choices;
178
179 SCH_IO_MGR::SCH_FILE_T pi_type = SCH_IO_MGR::EnumFromStr( row.Type() );
180 IO_RELEASER<SCH_IO> pi( SCH_IO_MGR::FindPlugin( pi_type ) );
181 pi->GetLibraryOptions( &choices );
182
183 DIALOG_PLUGIN_OPTIONS dlg( wxGetTopLevelParent( m_grid ), row.Nickname(), choices, options, &result );
184 dlg.ShowModal();
185
186 if( options != result )
187 {
188 tbl->OnModify();
189 row.SetOptions( result );
190 m_grid->Refresh();
191 }
192 }
193 }
194
195 void openTable( const LIBRARY_TABLE_ROW& aRow ) override
196 {
197 wxFileName fn( LIBRARY_MANAGER::ExpandURI( aRow.URI(), Pgm().GetSettingsManager().Prj() ) );
198 std::shared_ptr<LIBRARY_TABLE> child = std::make_shared<LIBRARY_TABLE>( fn, LIBRARY_TABLE_SCOPE::GLOBAL,
200
201 if( !child->IsOk() )
202 {
203 wxMessageBox( _( "Unable to load library table." ) );
204 }
205 else
206 {
208
209 m_panel->OpenTable( child, aRow.Nickname() );
210 }
211 }
212
213 wxString getTablePreamble() override
214 {
215 return wxT( "(sym_lib_table" );
216 }
217
222
223protected:
225};
226
227
228void PANEL_SYM_LIB_TABLE::OpenTable( const std::shared_ptr<LIBRARY_TABLE>& aTable, const wxString& aTitle )
229{
230 wxString tabTitle = aTitle;
231
232 if( aTable->IsReadOnly() )
233 tabTitle += wxS( " " ) + _( "(read-only)" );
234
235 for( int ii = 2; ii < (int) m_notebook->GetPageCount(); ++ii )
236 {
237 wxString candidate = m_notebook->GetPageText( ii );
238
239 if( candidate.EndsWith( " *" ) )
240 candidate = candidate.Left( candidate.Length() - 2 );
241
242 if( candidate == tabTitle )
243 {
244 // Something is pretty fishy with wxAuiNotebook::ChangeSelection(); on Mac at least it
245 // results in a re-entrant call where the second call is one page behind.
246 for( int attempts = 0; attempts < 3; ++attempts )
247 m_notebook->ChangeSelection( ii );
248
249 return;
250 }
251 }
252
253 m_nestedTables.push_back( aTable );
254 AddTable( aTable.get(), tabTitle, true );
255
256 // Something is pretty fishy with wxAuiNotebook::ChangeSelection(); on Mac at least it
257 // results in a re-entrant call where the second call is one page behind.
258 for( int attempts = 0; attempts < 3; ++attempts )
259 m_notebook->ChangeSelection( m_notebook->GetPageCount() - 1 );
260}
261
262
263void PANEL_SYM_LIB_TABLE::AddTable( LIBRARY_TABLE* table, const wxString& aTitle, bool aClosable )
264{
266 wxString projectPath = m_project->GetProjectPath();
267
269
270 WX_GRID* grid = get_grid( (int) m_notebook->GetPageCount() - 1 );
271
272 if( table->Path().StartsWith( projectPath ) )
273 {
275 &m_lastProjectLibDir, projectPath ),
276 true /* take ownership */ );
277 }
278 else
279 {
280 wxString* lastGlobalLibDir = nullptr;
281
283 {
284 if( cfg->m_lastSymbolLibDir.IsEmpty() )
285 cfg->m_lastSymbolLibDir = PATHS::GetDefaultUserSymbolsPath();
286
287 lastGlobalLibDir = &cfg->m_lastSymbolLibDir;
288 }
289
291 lastGlobalLibDir, wxEmptyString ),
292 true /* take ownership */ );
293 }
294
295 static_cast<LIB_TABLE_GRID_DATA_MODEL*>( grid->GetTable() )->RecheckRows();
296
297 LIB_TABLE_NOTEBOOK_PANEL* notebookPanel =
298 static_cast<LIB_TABLE_NOTEBOOK_PANEL*>( m_notebook->GetPage( m_notebook->GetPageCount() - 1 ) );
299
300 static_cast<LIB_TABLE_GRID_DATA_MODEL*>( grid->GetTable() )
302 [notebookPanel]()
303 {
304 notebookPanel->MarkDirty();
305 } );
306
307 // add Cut, Copy, and Paste to wxGrids
308 grid->PushEventHandler( new SYMBOL_GRID_TRICKS( this, grid,
309 [this]( wxCommandEvent& event )
310 {
311 appendRowHandler( event );
312 } ) );
313
314 auto autoSizeCol =
315 [&]( int aCol )
316 {
317 int prevWidth = grid->GetColSize( aCol );
318
319 grid->AutoSizeColumn( aCol, false );
320 grid->SetColSize( aCol, std::max( prevWidth, grid->GetColSize( aCol ) ) );
321 };
322
323 // all but COL_OPTIONS, which is edited with Option Editor anyways.
324 autoSizeCol( COL_NICKNAME );
325 autoSizeCol( COL_TYPE );
326 autoSizeCol( COL_URI );
327 autoSizeCol( COL_DESCR );
328
329 if( grid->GetNumberRows() > 0 )
330 {
331 grid->SetGridCursor( 0, COL_NICKNAME );
332 grid->SelectRow( 0 );
333 }
334}
335
336
338 PANEL_SYM_LIB_TABLE_BASE( aParent ),
339 m_project( aProject ),
340 m_parent( aParent ),
342{
343 m_notebook->SetArtProvider( new WX_AUI_TAB_ART() );
344
345 m_lastProjectLibDir = m_project->GetProjectPath();
346
348
349 for( const SCH_IO_MGR::SCH_FILE_T& type : SCH_IO_MGR::SCH_FILE_T_vector )
350 {
351 if( type == SCH_IO_MGR::SCH_NESTED_TABLE )
352 {
354 continue;
355 }
356
357 IO_RELEASER<SCH_IO> pi( SCH_IO_MGR::FindPlugin( type ) );
358
359 if( pi )
361 }
362
363 std::optional<LIBRARY_TABLE*> table = Pgm().GetLibraryManager().Table( LIBRARY_TABLE_TYPE::SYMBOL,
365 wxASSERT( table.has_value() );
366
367 AddTable( table.value(), _( "Global Libraries" ), false /* closable */ );
368
369 std::optional<LIBRARY_TABLE*> projectTable = Pgm().GetLibraryManager().Table( LIBRARY_TABLE_TYPE::SYMBOL,
371
372 if( projectTable.has_value() )
373 AddTable( projectTable.value(), _( "Project Specific Libraries" ), false /* closable */ );
374
375 // add Cut, Copy, and Paste to wxGrids
376 m_path_subs_grid->PushEventHandler( new GRID_TRICKS( m_path_subs_grid ) );
377
379
380 m_path_subs_grid->SetColLabelValue( 0, _( "Name" ) );
381 m_path_subs_grid->SetColLabelValue( 1, _( "Value" ) );
382
383 // Configure button logos
389
390 // For aesthetic reasons, we must set the size of m_browseButton to match the other bitmaps
391 Layout();
392 wxSize buttonSize = m_append_button->GetSize();
393
394 m_browseButton->SetWidthPadding( 4 );
395 m_browseButton->SetMinSize( buttonSize );
396
397 // Populate the browse library options
398 wxMenu* browseMenu = m_browseButton->GetSplitButtonMenu();
399
400 auto joinExtensions =
401 []( const std::vector<std::string>& aExts ) -> wxString
402 {
403 wxString result;
404
405 for( const std::string& ext : aExts )
406 {
407 if( !result.IsEmpty() )
408 result << wxT( ", " );
409
410 result << wxT( "." ) << ext;
411 }
412
413 return result;
414 };
415
416 for( auto& [type, desc] : m_supportedSymFiles )
417 {
418 wxString entryStr = SCH_IO_MGR::ShowType( type );
419
420 if( !desc.m_FileExtensions.empty() )
421 entryStr << wxString::Format( wxS( " (%s)" ), joinExtensions( desc.m_FileExtensions ) );
422
423 browseMenu->Append( type + FIRST_MENU_ID, entryStr );
424 browseMenu->Bind( wxEVT_COMMAND_MENU_SELECTED, &PANEL_SYM_LIB_TABLE::browseLibrariesHandler, this,
425 type + FIRST_MENU_ID );
426
427 // Add folder-based entry right after KiCad file-based entry
428 if( type == SCH_IO_MGR::SCH_KICAD )
429 {
430 wxString folderEntry = SCH_IO_MGR::ShowType( SCH_IO_MGR::SCH_KICAD );
431 folderEntry << wxString::Format( wxS( " (%s)" ), _( "folder with .kicad_sym files" ) );
432 browseMenu->Append( ID_PANEL_SYM_LIB_KICAD_FOLDER, folderEntry );
433 browseMenu->Bind( wxEVT_COMMAND_MENU_SELECTED, &PANEL_SYM_LIB_TABLE::browseLibrariesHandler, this,
435 }
436 }
437
438 Layout();
439
440 m_notebook->Bind( wxEVT_AUINOTEBOOK_PAGE_CLOSE, &PANEL_SYM_LIB_TABLE::onNotebookPageCloseRequest, this );
441 m_notebook->Bind( wxEVT_AUINOTEBOOK_PAGE_CHANGING, &PANEL_SYM_LIB_TABLE::onNotebookPageChangeRequest, this );
443}
444
445
447{
448 wxMenu* browseMenu = m_browseButton->GetSplitButtonMenu();
449
450 for( auto& [type, desc] : m_supportedSymFiles )
451 browseMenu->Unbind( wxEVT_COMMAND_MENU_SELECTED, &PANEL_SYM_LIB_TABLE::browseLibrariesHandler, this, type );
452
453 browseMenu->Unbind( wxEVT_COMMAND_MENU_SELECTED, &PANEL_SYM_LIB_TABLE::browseLibrariesHandler,
455 m_browseButton->Unbind( wxEVT_BUTTON, &PANEL_SYM_LIB_TABLE::browseLibrariesHandler, this );
456
457 // Delete the GRID_TRICKS.
458 // (Notebook page GRID_TRICKS are deleted by LIB_TABLE_NOTEBOOK_PANEL.)
459 m_path_subs_grid->PopEventHandler( true );
460}
461
462
464{
465 for( const SCH_IO_MGR::SCH_FILE_T& type : SCH_IO_MGR::SCH_FILE_T_vector )
466 {
467 IO_RELEASER<SCH_IO> pi( SCH_IO_MGR::FindPlugin( type ) );
468
469 if( !pi )
470 continue;
471
472 if( const IO_BASE::IO_FILE_DESC& desc = pi->GetLibraryDesc() )
473 {
474 if( !desc.m_FileExtensions.empty() )
475 m_supportedSymFiles.emplace( type, desc );
476 }
477 }
478
479 m_supportedSymFiles.emplace( SCH_IO_MGR::SCH_NESTED_TABLE,
480 IO_BASE::IO_FILE_DESC( _( "Table (nested library table)" ), {} ) );
481}
482
483
485{
486 return static_cast<SYMBOL_LIB_TABLE_GRID_DATA_MODEL*>( get_grid( aPage )->GetTable() );
487}
488
489
491{
492 return static_cast<LIB_TABLE_NOTEBOOK_PANEL*>( m_notebook->GetPage( aPage ) )->GetGrid();
493}
494
495
497{
498 // for ALT+A handling, we want the initial focus to be on the first selected grid.
499 m_parent->SetInitialFocus( cur_grid() );
500
501 return true;
502}
503
504
506{
507 for( int page = 0 ; page < (int) m_notebook->GetPageCount(); ++page )
508 {
509 WX_GRID* grid = get_grid( page );
510
512 [&]( int aRow, int aCol )
513 {
514 // show the tabbed panel holding the grid we have flunked:
515 if( m_notebook->GetSelection() != page )
516 m_notebook->SetSelection( page );
517
518 grid->MakeCellVisible( aRow, 0 );
519 grid->SetGridCursor( aRow, aCol );
520 } ) )
521 {
522 return false;
523 }
524 }
525
526 return true;
527}
528
529
531{
532 if( !cur_grid()->CommitPendingChanges() )
533 return;
534
535 SCH_IO_MGR::SCH_FILE_T fileType = SCH_IO_MGR::SCH_FILE_UNKNOWN;
536 bool selectingFolder = false;
537
538 // We are bound both to the menu and button with this one handler
539 if( event.GetEventType() == wxEVT_BUTTON )
540 {
541 // Default to KiCad file format when clicking the button directly
542 fileType = SCH_IO_MGR::SCH_KICAD;
543 }
544 else if( event.GetId() == ID_PANEL_SYM_LIB_KICAD_FOLDER )
545 {
546 // Special case for folder-based KiCad library
547 fileType = SCH_IO_MGR::SCH_KICAD;
548 selectingFolder = true;
549 }
550 else
551 {
552 fileType = static_cast<SCH_IO_MGR::SCH_FILE_T>( event.GetId() - FIRST_MENU_ID );
553 }
554
555 if( fileType == SCH_IO_MGR::SCH_FILE_UNKNOWN )
556 return;
557
558 const ENV_VAR_MAP& envVars = Pgm().GetLocalEnvVariables();
559
561 wxString dummy;
562 wxString* lastDir;
563
564 if( m_notebook->GetSelection() == 0 )
565 lastDir = cfg ? &cfg->m_lastSymbolLibDir : &dummy;
566 else
567 lastDir = &m_lastProjectLibDir;
568
569 wxString title = wxString::Format( _( "Select %s Library" ), SCH_IO_MGR::ShowType( fileType ) );
570 wxWindow* topLevelParent = wxGetTopLevelParent( this );
571 wxArrayString files;
572
573 if( selectingFolder )
574 {
575 wxDirDialog dlg( topLevelParent, title, *lastDir, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST | wxDD_MULTIPLE );
576
577 if( dlg.ShowModal() == wxID_CANCEL )
578 return;
579
580 dlg.GetPaths( files );
581
582 if( !files.IsEmpty() )
583 {
584 wxFileName first( files.front() );
585 *lastDir = first.GetPath();
586 }
587 }
588 else
589 {
590 auto it = m_supportedSymFiles.find( fileType );
591
592 if( it == m_supportedSymFiles.end() )
593 return;
594
595 const IO_BASE::IO_FILE_DESC& fileDesc = it->second;
596
597 wxFileDialog dlg( topLevelParent, title, *lastDir, wxEmptyString, fileDesc.FileFilter(),
598 wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE );
599
601
602 if( dlg.ShowModal() == wxID_CANCEL )
603 return;
604
605 dlg.GetPaths( files );
606 *lastDir = dlg.GetDirectory();
607 }
608
609 bool addDuplicates = false;
610 bool applyToAll = false;
611 wxString warning = _( "Warning: Duplicate Nicknames" );
612 wxString msg = _( "An item nicknamed '%s' already exists." );
613 wxString detailedMsg = _( "One of the nicknames will need to be changed." );
614
615 for( const wxString& filePath : files )
616 {
617 wxFileName fn( filePath );
618 wxString nickname = LIB_ID::FixIllegalChars( fn.GetName(), true );
619 bool doAdd = true;
620
621 if( cur_model()->ContainsNickname( nickname ) )
622 {
623 if( !applyToAll )
624 {
625 addDuplicates = OKOrCancelDialog( topLevelParent, warning,
626 wxString::Format( msg, nickname ), detailedMsg,
627 _( "Skip" ), _( "Add Anyway" ),
628 &applyToAll ) == wxID_CANCEL;
629 }
630
631 doAdd = addDuplicates;
632 }
633
634 if( doAdd && cur_grid()->AppendRows( 1 ) )
635 {
636 int last_row = cur_grid()->GetNumberRows() - 1;
637
638 cur_grid()->SetCellValue( last_row, COL_NICKNAME, nickname );
639 cur_grid()->SetCellValue( last_row, COL_TYPE, SCH_IO_MGR::ShowType( fileType ) );
640
641 // try to use path normalized to an environmental variable or project path
642 wxString path = NormalizePath( filePath, &envVars, m_project->GetProjectPath() );
643
644 // Do not use the project path in the global library table. This will almost
645 // assuredly be wrong for a different project.
646 if( m_notebook->GetSelection() == 0 && path.Contains( wxT( "${KIPRJMOD}" ) ) )
647 path = fn.GetFullPath();
648
649 cur_grid()->SetCellValue( last_row, COL_URI, path );
650 }
651 }
652
653 if( !files.IsEmpty() )
654 {
655 cur_grid()->MakeCellVisible( cur_grid()->GetNumberRows() - 1, COL_ENABLED );
656 cur_grid()->SetGridCursor( cur_grid()->GetNumberRows() - 1, COL_NICKNAME );
657 }
658}
659
660
661void PANEL_SYM_LIB_TABLE::appendRowHandler( wxCommandEvent& event )
662{
664}
665
666
671
672
677
678
683
684
685void PANEL_SYM_LIB_TABLE::onReset( wxCommandEvent& event )
686{
687 if( !cur_grid()->CommitPendingChanges() )
688 return;
689
690 WX_GRID* grid = get_grid( 0 );
691
692 // No need to prompt to preserve an empty table
693 if( grid->GetNumberRows() > 0 && !IsOK( this, wxString::Format( _( "This action will reset your global library "
694 "table on disk and cannot be undone." ) ) ) )
695 {
696 return;
697 }
698
699 wxString* lastGlobalLibDir = nullptr;
700
702 {
703 if( cfg->m_lastSymbolLibDir.IsEmpty() )
704 cfg->m_lastSymbolLibDir = PATHS::GetDefaultUserSymbolsPath();
705
706 lastGlobalLibDir = &cfg->m_lastSymbolLibDir;
707 }
708
710
711 // Go ahead and reload here because this action takes place even if the dialog is canceled
713
714 if( KIFACE *schface = m_parent->Kiway().KiFACE( KIWAY::FACE_SCH ) )
715 schface->PreloadLibraries( &m_parent->Kiway() );
716
717 grid->Freeze();
718
719 wxGridTableBase* table = grid->GetTable();
720 grid->DestroyTable( table );
721
722 std::optional<LIBRARY_TABLE*> newTable = Pgm().GetLibraryManager().Table( LIBRARY_TABLE_TYPE::SYMBOL,
724 wxASSERT( newTable );
725
727
728 grid->SetTable( new SYMBOL_LIB_TABLE_GRID_DATA_MODEL( m_parent, grid, *newTable.value(), adapter, m_pluginChoices,
729 lastGlobalLibDir, wxEmptyString ),
730 true /* take ownership */ );
731
732 LIB_TABLE_NOTEBOOK_PANEL* panel0 = static_cast<LIB_TABLE_NOTEBOOK_PANEL*>( m_notebook->GetPage( 0 ) );
733 panel0->ClearDirty();
734
735 static_cast<LIB_TABLE_GRID_DATA_MODEL*>( grid->GetTable() )->SetChangeCallback(
736 [panel0]()
737 {
738 panel0->MarkDirty();
739 } );
740
741 m_parent->m_GlobalTableChanged = true;
742
743 grid->Thaw();
744
745 if( grid->GetNumberRows() > 0 )
746 {
747 grid->SetGridCursor( 0, COL_NICKNAME );
748 grid->SelectRow( 0 );
749 }
750}
751
752
753void PANEL_SYM_LIB_TABLE::onNotebookPageChangeRequest( wxAuiNotebookEvent& aEvent )
754{
756 aEvent.Veto();
757 else
758 aEvent.Skip();
759}
760
761
762void PANEL_SYM_LIB_TABLE::onPageChange( wxAuiNotebookEvent& event )
763{
764 m_resetGlobal->Enable( m_notebook->GetSelection() == 0 );
765}
766
767
768void PANEL_SYM_LIB_TABLE::onNotebookPageCloseRequest( wxAuiNotebookEvent& aEvent )
769{
770 wxAuiNotebook* notebook = (wxAuiNotebook*) aEvent.GetEventObject();
771 wxWindow* page = notebook->GetPage( aEvent.GetSelection() );
772
773 if( LIB_TABLE_NOTEBOOK_PANEL* panel = dynamic_cast<LIB_TABLE_NOTEBOOK_PANEL*>( page ) )
774 {
775 if( panel->GetClosable() )
776 {
777 if( !panel->GetCanClose() )
778 aEvent.Veto();
779 }
780 else
781 {
782 aEvent.Veto();
783 }
784 }
785}
786
787
789{
790 if( !cur_grid()->CommitPendingChanges() )
791 return;
792
793 wxArrayInt selectedRows = cur_grid()->GetSelectedRows();
794
795 if( selectedRows.empty() && cur_grid()->GetGridCursorRow() >= 0 )
796 selectedRows.push_back( cur_grid()->GetGridCursorRow() );
797
798 wxArrayInt legacyRows;
799 wxString databaseType = SCH_IO_MGR::ShowType( SCH_IO_MGR::SCH_DATABASE );
800 wxString httpType = SCH_IO_MGR::ShowType( SCH_IO_MGR::SCH_HTTP );
801 wxString kicadType = SCH_IO_MGR::ShowType( SCH_IO_MGR::SCH_KICAD );
802 wxString nestedTableType = LIBRARY_TABLE_ROW::TABLE_TYPE_NAME;
803 wxString msg;
804
805 // HTTP and Database libraries are live, dynamic backends that are not file-based.
806 // Migrating them to a static .kicad_sym snapshot is not meaningful and would silently
807 // produce an empty library, destroying the original table entry. Nested library tables
808 // are not symbol libraries at all and likewise cannot be migrated.
809 for( int row : selectedRows )
810 {
811 const wxString& type = cur_grid()->GetCellValue( row, COL_TYPE );
812
813 if( type != databaseType && type != httpType && type != kicadType && type != nestedTableType )
814 legacyRows.push_back( row );
815 }
816
817 if( legacyRows.size() <= 0 )
818 {
819 wxMessageBox( _( "Select one or more rows containing libraries to save as current KiCad format." ) );
820 return;
821 }
822 else
823 {
824 if( legacyRows.size() == 1 )
825 {
826 msg.Printf( _( "Save '%s' as current KiCad format (*.kicad_sym) and replace legacy entry in table?" ),
827 cur_grid()->GetCellValue( legacyRows[0], COL_NICKNAME ) );
828 }
829 else
830 {
831 msg.Printf( _( "Save %d libraries as current KiCad format (*.kicad_sym) and replace legacy entries "
832 "in table?" ),
833 (int) legacyRows.size() );
834 }
835
836 if( !IsOK( m_parent, msg ) )
837 return;
838 }
839
840 for( int row : legacyRows )
841 {
842 wxString relPath = cur_grid()->GetCellValue( row, COL_URI );
843 wxString resolvedPath = ExpandEnvVarSubstitutions( relPath, m_project );
844 wxFileName legacyLib( resolvedPath );
845
846 if( !legacyLib.Exists() )
847 {
848 DisplayErrorMessage( m_parent, wxString::Format( _( "Library '%s' not found." ), relPath ) );
849 continue;
850 }
851
852 wxFileName newLib( resolvedPath );
853 newLib.SetExt( "kicad_sym" );
854
855 if( newLib.Exists() )
856 {
857 msg.Printf( _( "File '%s' already exists. Do you want overwrite this file?" ), newLib.GetFullPath() );
858
859 switch( wxMessageBox( msg, _( "Migrate Library" ), wxYES_NO | wxCANCEL | wxICON_QUESTION, m_parent ) )
860 {
861 case wxYES: break;
862 case wxNO: continue;
863 case wxCANCEL: return;
864 }
865 }
866
867 wxString options = cur_grid()->GetCellValue( row, COL_OPTIONS );
868 std::map<std::string, UTF8> props( LIBRARY_TABLE::ParseOptions( options.ToStdString() ) );
869
870 if( SCH_IO_MGR::ConvertLibrary( &props, legacyLib.GetFullPath(), newLib.GetFullPath() ) )
871 {
872 relPath = NormalizePath( newLib.GetFullPath(), &Pgm().GetLocalEnvVariables(), m_project );
873
874 cur_grid()->SetCellValue( row, COL_URI, relPath );
875 cur_grid()->SetCellValue( row, COL_TYPE, kicadType );
876 cur_grid()->SetCellValue( row, COL_OPTIONS, wxEmptyString );
877 }
878 else
879 {
880 DisplayErrorMessage( m_parent, wxString::Format( _( "Failed to save symbol library file '%s'." ),
881 newLib.GetFullPath() ) );
882 }
883 }
884}
885
886
888{
889 if( !cur_grid()->CommitPendingChanges() )
890 return false;
891
892 if( !verifyTables() )
893 return false;
894
895 bool success = true;
897 int firstNestedTable = 1;
898 std::optional<LIBRARY_TABLE*> globalTable = manager.Table( LIBRARY_TABLE_TYPE::SYMBOL,
900
901 if( globalTable.has_value() && get_model( 0 )->Table() != *globalTable.value() )
902 {
903 m_parent->m_GlobalTableChanged = true;
904 *globalTable.value() = get_model( 0 )->Table();
905
906 globalTable.value()->Save().map_error(
907 [&success]( const LIBRARY_ERROR& aError )
908 {
909 wxMessageBox( _( "Error saving global library table:\n\n" ) + aError.message,
910 _( "File Save Error" ), wxOK | wxICON_ERROR );
911 success = false;
912 } );
913 }
914
915 std::optional<LIBRARY_TABLE*> projectTable = manager.Table( LIBRARY_TABLE_TYPE::SYMBOL,
917
918 if( projectTable.has_value() && get_model( 1 )->Table().Path() == projectTable.value()->Path() )
919 {
920 firstNestedTable = 2;
921
922 if( get_model( 1 )->Table() != *projectTable.value() )
923 {
924 m_parent->m_ProjectTableChanged = true;
925 *projectTable.value() = get_model( 1 )->Table();
926
927 projectTable.value()->Save().map_error(
928 [&success]( const LIBRARY_ERROR& aError )
929 {
930 wxMessageBox( _( "Error saving project library table:\n\n" ) + aError.message,
931 _( "File Save Error" ), wxOK | wxICON_ERROR );
932 success = false;
933 } );
934 }
935 }
936
937 for( int ii = firstNestedTable; ii < (int) m_notebook->GetPageCount(); ++ii )
938 {
939 LIB_TABLE_NOTEBOOK_PANEL* panel = static_cast<LIB_TABLE_NOTEBOOK_PANEL*>( m_notebook->GetPage( ii ) );
940
941 if( panel->TableModified() )
942 success &= panel->SaveTable();
943 }
944
946 return success;
947}
948
949
951{
952 wxRegEx re( ".*?(\\$\\{(.+?)\\})|(\\$\\((.+?)\\)).*?", wxRE_ADVANCED );
953 wxASSERT( re.IsValid() ); // wxRE_ADVANCED is required.
954
955 std::set< wxString > unique;
956
957 // clear the table
958 m_path_subs_grid->ClearRows();
959
960 for( int page = 0 ; page < (int) m_notebook->GetPageCount(); ++page )
961 {
963
964 for( int row = 0; row < model->GetNumberRows(); ++row )
965 {
966 wxString uri = model->GetValue( row, COL_URI );
967
968 while( re.Matches( uri ) )
969 {
970 wxString envvar = re.GetMatch( uri, 2 );
971
972 // if not ${...} form then must be $(...)
973 if( envvar.IsEmpty() )
974 envvar = re.GetMatch( uri, 4 );
975
976 // ignore duplicates
977 unique.insert( envvar );
978
979 // delete the last match and search again
980 uri.Replace( re.GetMatch( uri, 0 ), wxEmptyString );
981 }
982 }
983 }
984
985 // Make sure this special environment variable shows up even if it was
986 // not used yet. It is automatically set by KiCad to the directory holding
987 // the current project.
988 unique.insert( PROJECT_VAR_NAME );
989 unique.insert( ENV_VAR::GetVersionedEnvVarName( wxS( "SYMBOL_DIR" ) ) );
990
991 for( const wxString& evName : unique )
992 {
993 int row = m_path_subs_grid->GetNumberRows();
994 m_path_subs_grid->AppendRows( 1 );
995
996 m_path_subs_grid->SetCellValue( row, 0, wxT( "${" ) + evName + wxT( "}" ) );
997 m_path_subs_grid->SetCellEditor( row, 0, new GRID_CELL_READONLY_TEXT_EDITOR() );
998
999 wxString evValue;
1000 wxGetEnv( evName, &evValue );
1001 m_path_subs_grid->SetCellValue( row, 1, evValue );
1002 m_path_subs_grid->SetCellEditor( row, 1, new GRID_CELL_READONLY_TEXT_EDITOR() );
1003 }
1004
1005 adjustPathSubsGridColumns( m_path_subs_grid->GetRect().GetWidth() );
1006}
1007
1008
1010{
1011 // Account for scroll bars
1012 aWidth -= ( m_path_subs_grid->GetSize().x - m_path_subs_grid->GetClientSize().x );
1013
1014 m_path_subs_grid->AutoSizeColumn( 0 );
1015 m_path_subs_grid->SetColSize( 0, std::max( 72, m_path_subs_grid->GetColSize( 0 ) ) );
1016 m_path_subs_grid->SetColSize( 1, std::max( 120, aWidth - m_path_subs_grid->GetColSize( 0 ) ) );
1017}
1018
1019
1020void PANEL_SYM_LIB_TABLE::onSizeGrid( wxSizeEvent& event )
1021{
1022 adjustPathSubsGridColumns( event.GetSize().GetX() );
1023
1024 event.Skip();
1025}
1026
1027
1028void InvokeSchEditSymbolLibTable( KIWAY* aKiway, wxWindow *aParent )
1029{
1030 auto symbolEditor = static_cast<SYMBOL_EDIT_FRAME*>( aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false ) );
1031 wxString msg;
1032
1033 // Refuse to open the dialog re-entrantly while a library sync is running. A
1034 // sync can yield the event loop (via the progress dialog), which dispatches any
1035 // pending UI events — including clicks that accumulated while the app was busy.
1036 // Opening the dialog mid-sync corrupts the library tree. Reschedule instead.
1037 if( symbolEditor && symbolEditor->IsSyncLibrariesInProgress() )
1038 {
1039 symbolEditor->CallAfter( [aKiway, aParent]()
1040 {
1041 InvokeSchEditSymbolLibTable( aKiway, aParent );
1042 } );
1043 return;
1044 }
1045
1046 if( symbolEditor )
1047 {
1048 // This prevents an ugly crash on OSX (https://bugs.launchpad.net/kicad/+bug/1765286)
1049 symbolEditor->FreezeLibraryTree();
1050
1051 if( symbolEditor->HasLibModifications() )
1052 {
1053 msg = _( "Modifications have been made to one or more symbol libraries.\n"
1054 "Changes must be saved or discarded before the symbol library table can be modified." );
1055
1056 switch( UnsavedChangesDialog( aParent, msg ) )
1057 {
1058 case wxID_YES: symbolEditor->SaveAll(); break;
1059 case wxID_NO: symbolEditor->RevertAll(); break;
1060 default:
1061 case wxID_CANCEL: symbolEditor->ThawLibraryTree(); return;
1062 }
1063 }
1064 }
1065
1066 DIALOG_EDIT_LIBRARY_TABLES dlg( aParent, _( "Symbol Libraries" ) );
1067 dlg.SetKiway( &dlg, aKiway );
1068
1069 PANEL_SYM_LIB_TABLE* panel = new PANEL_SYM_LIB_TABLE( &dlg, &aKiway->Prj() );
1070 dlg.InstallPanel( panel, panel->GetNotebook() );
1071
1072 // User can choose to save changes on a Cancel, so don't exit on wxID_CANCEL.
1073 dlg.ShowModal();
1074
1075 if( dlg.m_GlobalTableChanged )
1077
1078 if( dlg.m_ProjectTableChanged )
1079 {
1080 // Trigger a reload of the table and cancel an in-progress background load
1082 }
1083
1084 // Trigger a reload in case any libraries have been added or removed
1085 if( KIFACE *schface = aKiway->KiFACE( KIWAY::FACE_SCH ) )
1086 schface->PreloadLibraries( aKiway );
1087
1088 if( symbolEditor )
1089 symbolEditor->ThawLibraryTree();
1090}
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:106
void InstallPanel(wxPanel *aPanel, wxAuiNotebook *aNotebook)
An options editor in the form of a two column name/value spreadsheet like (table) UI.
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition dialog_shim.h:80
int ShowModal() override
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Definition grid_tricks.h:57
WX_GRID * m_grid
I don't own the grid, but he owns me.
void SetTooltipEnable(int aCol, bool aEnable=true)
Enable the tooltip for a column.
Definition grid_tricks.h:71
void SetKiway(wxWindow *aDest, KIWAY *aKiway)
It is only used for debugging, since "this" is not a wxWindow*.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:340
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition kiway.cpp:388
virtual KIFACE * KiFACE(FACE_T aFaceId, bool doLoad=true)
Return the KIFACE* given a FACE_T.
Definition kiway.cpp:207
@ FACE_SCH
eeschema DSO
Definition kiway.h:347
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
Definition kiway.cpp:201
static wxString ExpandURI(const wxString &aShortURI, const PROJECT &aProject)
std::optional< LIBRARY_TABLE * > Table(LIBRARY_TABLE_TYPE aType, LIBRARY_TABLE_SCOPE aScope)
Retrieves a given table; creating a new empty project table if a valid project is loaded and the give...
void ApplyLibOverrides(LIBRARY_TABLE &aTable)
Applies stored user overrides (disabled/hidden) to rows of a read-only table.
static bool CreateGlobalTable(LIBRARY_TABLE_TYPE aType, bool aPopulateDefaultLibraries)
void LoadGlobalTables(std::initializer_list< LIBRARY_TABLE_TYPE > aTablesToLoad={})
(Re)loads the global library tables in the given list, or all tables if no list is given
void ProjectChanged()
Notify all adapters that the project has changed.
void SetOptions(const wxString &aOptions)
const wxString & Type() const
static const wxString TABLE_TYPE_NAME
const wxString & URI() const
const wxString & Nickname() const
const wxString & Options() const
LIBRARY_RESULT< void > Save()
static std::map< std::string, UTF8 > ParseOptions(const std::string &aOptionsList)
static UTF8 FixIllegalChars(const UTF8 &aLibItemName, bool aLib)
Replace illegal LIB_ID item name characters with underscores '_'.
Definition lib_id.cpp:205
This abstract base class mixes any object derived from #LIB_TABLE into wxGridTableBase so the result ...
virtual LIBRARY_TABLE_ROW & at(size_t aIndex)
void SetChangeCallback(std::function< void()> aCallback)
LIBRARY_TABLE_ROW & At(size_t aIndex)
void SetValue(int aRow, int aCol, const wxString &aValue) override
LIB_TABLE_GRID_DATA_MODEL(DIALOG_SHIM *aParent, WX_GRID *aGrid, const LIBRARY_TABLE &aTableToEdit, LIBRARY_MANAGER_ADAPTER *aAdapter, const wxArrayString &aPluginChoices, wxString *aMRUDirectory, const wxString &aProjectPath)
static void MoveUpHandler(WX_GRID *aGrid)
LIB_TABLE_GRID_TRICKS(WX_GRID *aGrid)
static void DeleteRowHandler(WX_GRID *aGrid)
static void AppendRowHandler(WX_GRID *aGrid, const wxString &aType)
static bool VerifyTable(WX_GRID *aGrid, bool aSupportsVisibilityColumn, std::function< void(int aRow, int aCol)> aErrorHandler)
static void MoveDownHandler(WX_GRID *aGrid)
static void AddTable(wxAuiNotebook *aNotebook, const wxString &aTitle, bool aClosable)
PANEL_SYM_LIB_TABLE_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
STD_BITMAP_BUTTON * m_move_down_button
Dialog to show and edit symbol library tables.
void moveUpHandler(wxCommandEvent &event) override
SYMBOL_LIB_TABLE_GRID_DATA_MODEL * get_model(int aPage) const
void onReset(wxCommandEvent &event) override
void browseLibrariesHandler(wxCommandEvent &event)
void deleteRowHandler(wxCommandEvent &event) override
WX_GRID * get_grid(int aPage) const
void onNotebookPageCloseRequest(wxAuiNotebookEvent &aEvent)
void onPageChange(wxAuiNotebookEvent &event) override
void AddTable(LIBRARY_TABLE *table, const wxString &aTitle, bool aClosable)
bool verifyTables()
Trim important fields, removes blank row entries, and checks for duplicates.
void adjustPathSubsGridColumns(int aWidth)
wxAuiNotebook * GetNotebook() const
void OpenTable(const std::shared_ptr< LIBRARY_TABLE > &table, const wxString &aTitle)
void onSizeGrid(wxSizeEvent &event) override
std::vector< std::shared_ptr< LIBRARY_TABLE > > m_nestedTables
void onConvertLegacyLibraries(wxCommandEvent &event) override
void onNotebookPageChangeRequest(wxAuiNotebookEvent &aEvent)
std::map< SCH_IO_MGR::SCH_FILE_T, IO_BASE::IO_FILE_DESC > m_supportedSymFiles
bool TransferDataToWindow() override
wxArrayString m_pluginChoices
void moveDownHandler(wxCommandEvent &event) override
PANEL_SYM_LIB_TABLE(DIALOG_EDIT_LIBRARY_TABLES *aParent, PROJECT *m_project)
SYMBOL_LIB_TABLE_GRID_DATA_MODEL * cur_model() const
void populateEnvironReadOnlyTable()
Populate the readonly environment variable table with names and values by examining all the full_uri ...
WX_GRID * cur_grid() const
DIALOG_EDIT_LIBRARY_TABLES * m_parent
bool TransferDataFromWindow() override
void appendRowHandler(wxCommandEvent &event) override
static wxString GetDefaultUserSymbolsPath()
Gets the default path we point users to create projects.
Definition paths.cpp:82
virtual ENV_VAR_MAP & GetLocalEnvVariables() const
Definition pgm_base.cpp:792
virtual LIBRARY_MANAGER & GetLibraryManager() const
Definition pgm_base.h:125
static SYMBOL_LIBRARY_ADAPTER * SymbolLibAdapter(PROJECT *aProject)
Accessor for project symbol library manager adapter.
Container for project specific data.
Definition project.h:63
static bool ConvertLibrary(std::map< std::string, UTF8 > *aOldFileProps, const wxString &aOldFilePath, const wxString &aNewFilepath, REPORTER *aReporter=nullptr)
Convert a schematic symbol library to the latest KiCad format.
static SCH_FILE_T EnumFromStr(const wxString &aFileType)
Return the #SCH_FILE_T from the corresponding plugin type name: "kicad", "legacy",...
static const wxString ShowType(SCH_FILE_T aFileType)
Return a brief name for a plugin, given aFileType enum.
static SCH_FILE_T GuessPluginTypeFromLibPath(const wxString &aLibPath, int aCtl=0)
Return a plugin type given a symbol library using the file extension of aLibPath.
The symbol library editor main window.
SYMBOL_GRID_TRICKS(PANEL_SYM_LIB_TABLE *aPanel, WX_GRID *aGrid, std::function< void(wxCommandEvent &)> aAddHandler)
bool supportsVisibilityColumn() override
wxString getTablePreamble() override
PANEL_SYM_LIB_TABLE * m_panel
void openTable(const LIBRARY_TABLE_ROW &aRow) override
void optionsEditor(int aRow) override
static bool SupportsVisibilityColumn()
An interface to the global shared library manager that is schematic-specific and linked to one projec...
SYMBOL_LIB_TABLE_GRID_DATA_MODEL(DIALOG_SHIM *aParent, WX_GRID *aGrid, const LIBRARY_TABLE &aTableToEdit, SYMBOL_LIBRARY_ADAPTER *aAdapter, const wxArrayString &aPluginChoices, wxString *aMRUDirectory, const wxString &aProjectPath)
void SetValue(int aRow, int aCol, const wxString &aValue) override
wxString getFileTypes(WX_GRID *aGrid, int aRow) override
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject)
Replace any environment variable & text variable references with their values.
Definition common.cpp:776
int OKOrCancelDialog(wxWindow *aParent, const wxString &aWarning, const wxString &aMessage, const wxString &aDetailedMessage, const wxString &aOKLabel, const wxString &aCancelLabel, bool *aApplyToAll)
Display a warning dialog with aMessage and returns the user response.
Definition confirm.cpp:165
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition confirm.cpp:274
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition confirm.cpp:217
int UnsavedChangesDialog(wxWindow *parent, const wxString &aMessage, bool *aApplyToAll)
A specialized version of HandleUnsavedChanges which handles an apply-to-all checkbox.
Definition confirm.cpp:60
This file is part of the common library.
#define _(s)
wxString NormalizePath(const wxFileName &aFilePath, const ENV_VAR_MAP *aEnvVars, const wxString &aProjectPath)
Normalize a file path to an environmental variable, if possible.
Definition env_paths.cpp:73
Helper functions to substitute paths with environmental variables.
Functions related to environment variables, including help functions.
@ FRAME_SCH_SYMBOL_EDITOR
Definition frame_type.h:31
static const std::string SymbolLibraryTableFileName
std::map< wxString, ENV_VAR_ITEM > ENV_VAR_MAP
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
Definition io_mgr.h:33
PROJECT & Prj()
Definition kicad.cpp:727
KICOMMON_API wxString GetVersionedEnvVarName(const wxString &aBaseName)
Construct a versioned environment variable based on this KiCad major version.
Definition env_vars.cpp:78
void AllowNetworkFileSystems(wxDialog *aDialog)
Configure a file dialog to show network and virtual file systems.
Definition wxgtk/ui.cpp:521
static constexpr int FIRST_MENU_ID
Special menu ID for folder-based KiCad symbol library format.
static constexpr int ID_PANEL_SYM_LIB_KICAD_FOLDER
void InvokeSchEditSymbolLibTable(KIWAY *aKiway, wxWindow *aParent)
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
#define PROJECT_VAR_NAME
A variable name whose value holds the current project directory.
Definition project.h:38
T * GetAppSettings(const char *aFilename)
std::vector< FAB_LAYER_COLOR > dummy
MODEL3D_FORMAT_TYPE fileType(const char *aFileName)
Container that describes file type info.
Definition io_base.h:43
bool m_IsFile
Whether the library is a folder or a file.
Definition io_base.h:51
wxString FileFilter() const
Definition io_base.cpp:40
Implement a participant in the KIWAY alchemy.
Definition kiway.h:153
wxString message
Container that describes file type info for the add a library options.
bool m_IsFile
Whether the library is a folder or a file.
wxString m_Description
Description shown in the file picker dialog.
wxString m_FileFilter
Filter used for file pickers if m_IsFile is true.
DESIGN_BLOCK_IO_MGR::DESIGN_BLOCK_FILE_T m_Plugin
wxString m_FolderSearchExtension
In case of folders it stands for extensions of files stored inside.
std::string path
KIBIS_MODEL * model
wxString result
Test unit parsing edge cases and error handling.
Definition of file extensions used in Kicad.