KiCad: add support for missing file format extensions.
Don't rename symbol libraries when performing a project "Save As.." except for the legacy cache library. Changing library file names breaks the symbol library table. This was the less painful option than updating the symbol library table. Fixes https://gitlab.com/kicad/code/kicad/issues/4605
This commit is contained in:
parent
235b24430b
commit
616ac50cfb
|
@ -2,8 +2,8 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2004-2020 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -246,18 +246,9 @@ void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aProje
|
|||
if( destPath.StartsWith( aProjectBasePath + pathSep ) )
|
||||
destPath.Replace( aProjectBasePath, aNewProjectBasePath, false );
|
||||
|
||||
#if 0
|
||||
// WAYNE STAMBAUGH TODO:
|
||||
// If we end up with a symbol equivalent to ".pretty" we'll want to handle it here....
|
||||
wxString srcProjectSymbolLib = pathSep + aProjectName + ".sym_lib_dir_extension" + pathSep;
|
||||
wxString newProjectSymbolLib = pathSep + aNewProjectName + ".sym_lib_dir_extension" + pathSep;
|
||||
|
||||
destPath.Replace( srcProjectSymbolLib, newProjectSymbolLib, true );
|
||||
#endif
|
||||
|
||||
destFile.SetPath( destPath );
|
||||
|
||||
if( ext == "sch" || ext == "sch-bak" )
|
||||
if( ext == "sch" || ext == "sch-bak" || ext == "kicad_sch" || ext == "kicad_sch-bak" )
|
||||
{
|
||||
if( destFile.GetName() == aProjectName )
|
||||
destFile.SetName( aNewProjectName );
|
||||
|
@ -278,14 +269,10 @@ void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aProje
|
|||
// Symbols are not project-specific. Keep their source names.
|
||||
CopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
|
||||
}
|
||||
else if( ext == "lib" )
|
||||
else if( ext == "lib" || ext == "dcm" || ext == "kicad_sym" )
|
||||
{
|
||||
if( destFile.GetName() == aProjectName )
|
||||
destFile.SetName( aNewProjectName );
|
||||
else if( destFile.GetName() == aProjectName + "-cache" )
|
||||
if( destFile.GetName() == aProjectName + "-cache" )
|
||||
destFile.SetName( aNewProjectName + "-cache" );
|
||||
else if( destFile.GetName() == aProjectName + "-rescue" )
|
||||
destFile.SetName( aNewProjectName + "-rescue" );
|
||||
|
||||
CopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ class TREE_PROJECT_FRAME;
|
|||
class ACTION_TOOLBAR;
|
||||
class KICAD_SETTINGS;
|
||||
|
||||
// Identify the type of files handled by Kicad manager
|
||||
// Identify the type of files handled by KiCad manager
|
||||
//
|
||||
// When changing this enum please verify (and perhaps update)
|
||||
// TREE_PROJECT_FRAME::GetFileExt(),
|
||||
|
@ -57,7 +57,7 @@ enum TreeFileType {
|
|||
TREE_DIRECTORY,
|
||||
TREE_CMP_LINK, // cmp/footprint link file (.cmp)
|
||||
TREE_REPORT, // report file (.rpt)
|
||||
TREE_FP_PLACE, // fooprints position (place) file (.pos)
|
||||
TREE_FP_PLACE, // footprints position (place) file (.pos)
|
||||
TREE_DRILL, // Excellon drill file (.drl)
|
||||
TREE_DRILL_NC, // Similar Excellon drill file (.nc)
|
||||
TREE_DRILL_XNC, // Similar Excellon drill file (.xnc)
|
||||
|
@ -65,6 +65,7 @@ enum TreeFileType {
|
|||
TREE_PAGE_LAYOUT_DESCR, // Page layout and title block descr file (.kicad_wks)
|
||||
TREE_FOOTPRINT_FILE, // footprint file (.kicad_mod)
|
||||
TREE_SCHEMATIC_LIBFILE, // schematic library file (.lib)
|
||||
TREE_SEXPR_SYMBOL_LIB_FILE, // s-expression symbol library file (.kicad_sym)
|
||||
TREE_MAX
|
||||
};
|
||||
|
||||
|
@ -115,7 +116,7 @@ public:
|
|||
void PrintMsg( const wxString& aText );
|
||||
|
||||
/**
|
||||
* Prints the current working directory name and the projet name on the text panel.
|
||||
* Prints the current working directory name and the project name on the text panel.
|
||||
*/
|
||||
void PrintPrjInfo();
|
||||
|
||||
|
@ -149,7 +150,7 @@ public:
|
|||
|
||||
/**
|
||||
* Called by sending a event with id = ID_INIT_WATCHED_PATHS
|
||||
* rebuild the list of wahtched paths
|
||||
* rebuild the list of watched paths
|
||||
*/
|
||||
void OnChangeWatchedPaths( wxCommandEvent& aEvent );
|
||||
|
||||
|
|
|
@ -374,6 +374,8 @@ public:
|
|||
|| ext == "sch-bak"
|
||||
|| ext == "sym"
|
||||
|| ext == "lib"
|
||||
|| ext == "dcm"
|
||||
|| ext == "kicad_sym"
|
||||
|| ext == "net"
|
||||
|| destFile.GetName() == "sym-lib-table" )
|
||||
{
|
||||
|
@ -410,7 +412,7 @@ public:
|
|||
}
|
||||
else
|
||||
{
|
||||
// Everything we don't recognize just gets a straight copy
|
||||
// Everything we don't recognize just gets a straight copy.
|
||||
wxString destPath = destFile.GetPath();
|
||||
wxString destName = destFile.GetName();
|
||||
|
||||
|
@ -421,26 +423,11 @@ public:
|
|||
}
|
||||
|
||||
if( destName == m_projectName )
|
||||
{
|
||||
destFile.SetName( m_newProjectName );
|
||||
}
|
||||
else if( destName.StartsWith( m_projectName + "-" ) )
|
||||
{
|
||||
destName.Replace( m_projectName, m_newProjectName, false );
|
||||
destFile.SetName( destName );
|
||||
}
|
||||
|
||||
CopyFile( aSrcFilePath, destFile.GetFullPath(), m_errors );
|
||||
}
|
||||
|
||||
/* TODO: what about these?
|
||||
KiCadFootprintLibPathExtension;
|
||||
GedaPcbFootprintLibFileExtension;
|
||||
EagleFootprintLibPathExtension;
|
||||
SpecctraDsnFileExtension;
|
||||
IpcD356FileExtension;
|
||||
*/
|
||||
|
||||
return wxDIR_CONTINUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ static const wxChar* s_allowedExtensionsToList[] = {
|
|||
wxT( "^.*\\.rpt$" ), // Report files
|
||||
wxT( "^.*\\.csv$" ), // Report files in comma separated format
|
||||
wxT( "^.*\\.pos$" ), // Footprint position files
|
||||
wxT( "^.*\\.cmp$" ), // Cvpcb cmp/footprint link files
|
||||
wxT( "^.*\\.cmp$" ), // CvPcb cmp/footprint link files
|
||||
wxT( "^.*\\.drl$" ), // Excellon drill files
|
||||
wxT( "^.*\\.nc$" ), // Excellon NC drill files (alternate file ext)
|
||||
wxT( "^.*\\.xnc$" ), // Excellon NC drill files (alternate file ext)
|
||||
|
@ -264,27 +264,28 @@ wxString TREE_PROJECT_FRAME::GetFileExt( TreeFileType type )
|
|||
{
|
||||
switch( type )
|
||||
{
|
||||
case TREE_PROJECT: return ProjectFileExtension;
|
||||
case TREE_LEGACY_SCHEMATIC: return LegacySchematicFileExtension;
|
||||
case TREE_SEXPR_SCHEMATIC: return KiCadSchematicFileExtension;
|
||||
case TREE_LEGACY_PCB: return LegacyPcbFileExtension;
|
||||
case TREE_SEXPR_PCB: return KiCadPcbFileExtension;
|
||||
case TREE_GERBER: return GerberFileExtensionWildCard;
|
||||
case TREE_HTML: return HtmlFileExtension;
|
||||
case TREE_PDF: return PdfFileExtension;
|
||||
case TREE_TXT: return TextFileExtension;
|
||||
case TREE_NET: return NetlistFileExtension;
|
||||
case TREE_CMP_LINK: return ComponentFileExtension;
|
||||
case TREE_REPORT: return ReportFileExtension;
|
||||
case TREE_FP_PLACE: return FootprintPlaceFileExtension;
|
||||
case TREE_DRILL: return DrillFileExtension;
|
||||
case TREE_DRILL_NC: return "nc";
|
||||
case TREE_DRILL_XNC: return "xnc";
|
||||
case TREE_SVG: return SVGFileExtension;
|
||||
case TREE_PAGE_LAYOUT_DESCR: return PageLayoutDescrFileExtension;
|
||||
case TREE_FOOTPRINT_FILE: return KiCadFootprintFileExtension;
|
||||
case TREE_SCHEMATIC_LIBFILE: return LegacySymbolLibFileExtension;
|
||||
default: return wxEmptyString;
|
||||
case TREE_PROJECT: return ProjectFileExtension;
|
||||
case TREE_LEGACY_SCHEMATIC: return LegacySchematicFileExtension;
|
||||
case TREE_SEXPR_SCHEMATIC: return KiCadSchematicFileExtension;
|
||||
case TREE_LEGACY_PCB: return LegacyPcbFileExtension;
|
||||
case TREE_SEXPR_PCB: return KiCadPcbFileExtension;
|
||||
case TREE_GERBER: return GerberFileExtensionWildCard;
|
||||
case TREE_HTML: return HtmlFileExtension;
|
||||
case TREE_PDF: return PdfFileExtension;
|
||||
case TREE_TXT: return TextFileExtension;
|
||||
case TREE_NET: return NetlistFileExtension;
|
||||
case TREE_CMP_LINK: return ComponentFileExtension;
|
||||
case TREE_REPORT: return ReportFileExtension;
|
||||
case TREE_FP_PLACE: return FootprintPlaceFileExtension;
|
||||
case TREE_DRILL: return DrillFileExtension;
|
||||
case TREE_DRILL_NC: return "nc";
|
||||
case TREE_DRILL_XNC: return "xnc";
|
||||
case TREE_SVG: return SVGFileExtension;
|
||||
case TREE_PAGE_LAYOUT_DESCR: return PageLayoutDescrFileExtension;
|
||||
case TREE_FOOTPRINT_FILE: return KiCadFootprintFileExtension;
|
||||
case TREE_SCHEMATIC_LIBFILE: return LegacySymbolLibFileExtension;
|
||||
case TREE_SEXPR_SYMBOL_LIB_FILE: return KiCadSymbolLibFileExtension;
|
||||
default: return wxEmptyString;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -226,6 +226,7 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* aTreePrjFrame )
|
|||
break;
|
||||
|
||||
case TREE_SCHEMATIC_LIBFILE:
|
||||
case TREE_SEXPR_SYMBOL_LIB_FILE:
|
||||
toolMgr->RunAction( KICAD_MANAGER_ACTIONS::editSymbols, true );
|
||||
packet = fullFileName.ToStdString();
|
||||
kiway.ExpressMail( FRAME_SCH_LIB_EDITOR, MAIL_LIB_EDIT, packet );
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004-2012 Jean-Pierre Charras
|
||||
* Copyright (C) 2004-2012 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -77,6 +77,7 @@ TREEPROJECTFILES::TREEPROJECTFILES( TREE_PROJECT_FRAME* parent )
|
|||
m_ImageList->Add( KiBitmap( pagelayout_load_xpm ) ); // TREE_PAGE_LAYOUT_DESCR
|
||||
m_ImageList->Add( KiBitmap( module_xpm ) ); // TREE_FOOTPRINT_FILE
|
||||
m_ImageList->Add( KiBitmap( library_xpm ) ); // TREE_SCHEMATIC_LIBFILE
|
||||
m_ImageList->Add( KiBitmap( library_xpm ) ); // TREE_SEXPR_SYMBOL_LIB_FILE
|
||||
|
||||
SetImageList( m_ImageList );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue