Fix a couple of issues in new Save As command.
Handle symbols as well as strings in the "source" lists of netlist files. Handle Protex gerber file extensions. Check for project_name-whatever pattern for files that we don't recognize (such as project_name-NPTH-drl_map.ps)
This commit is contained in:
parent
122ec64c02
commit
04b0feb365
|
@ -29,7 +29,7 @@
|
|||
*/
|
||||
#include <regex>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
|
||||
#include <wx/regex.h>
|
||||
|
||||
bool compareFileExtensions( const std::string& aExtension,
|
||||
const std::vector<std::string>& aReference, bool aCaseSensitive )
|
||||
|
@ -153,6 +153,14 @@ const std::string PngFileExtension( "png" );
|
|||
const std::string JpegFileExtension( "jpg" );
|
||||
|
||||
|
||||
bool IsProtelExtension( const wxString& ext )
|
||||
{
|
||||
static wxRegEx protelRE( wxT( "(gm1)|(g[tb][lapos])|(g\\d\\d*)" ), wxRE_ICASE );
|
||||
|
||||
return protelRE.Matches( ext );
|
||||
}
|
||||
|
||||
|
||||
wxString AllFilesWildcard()
|
||||
{
|
||||
return _( "All files" ) + AddFileExtListToFilter( {} );
|
||||
|
|
|
@ -374,7 +374,13 @@ void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aProje
|
|||
&& node->GetChild( 0 )->GetSymbol() == "source" )
|
||||
{
|
||||
auto pathNode = dynamic_cast<SEXPR::SEXPR_STRING*>( node->GetChild( 1 ) );
|
||||
wxString path( pathNode->m_value );
|
||||
auto symNode = dynamic_cast<SEXPR::SEXPR_SYMBOL*>( node->GetChild( 1 ) );
|
||||
wxString path;
|
||||
|
||||
if( pathNode )
|
||||
path = pathNode->m_value;
|
||||
else if( symNode )
|
||||
path = symNode->m_value;
|
||||
|
||||
if( path == aProjectName + ".sch" )
|
||||
path = aNewProjectName + ".sch";
|
||||
|
@ -383,7 +389,10 @@ void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aProje
|
|||
else if( path.StartsWith( aProjectBasePath ) )
|
||||
path.Replace( aProjectBasePath, aNewProjectBasePath, false );
|
||||
|
||||
pathNode->m_value = path;
|
||||
if( pathNode )
|
||||
pathNode->m_value = path;
|
||||
else if( symNode )
|
||||
symNode->m_value = path;
|
||||
}
|
||||
} );
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <gerbview.h>
|
||||
#include <gerbview_frame.h>
|
||||
#include <gestfich.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include "json11.hpp"
|
||||
|
||||
const wxChar* g_GerberPageSizeList[] =
|
||||
|
@ -155,7 +156,7 @@ void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aProje
|
|||
destFile.SetPath( destPath );
|
||||
}
|
||||
|
||||
if( ext == "gbr" )
|
||||
if( ext == "gbr" || IsProtelExtension( ext ) )
|
||||
{
|
||||
wxString destFileName = destFile.GetName();
|
||||
|
||||
|
|
|
@ -148,6 +148,9 @@ extern const std::string IpcD356FileExtension;
|
|||
extern const std::string PngFileExtension;
|
||||
extern const std::string JpegFileExtension;
|
||||
|
||||
|
||||
bool IsProtelExtension( const wxString& ext );
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -399,7 +399,8 @@ public:
|
|||
}
|
||||
else if( ext == "gbr"
|
||||
|| ext == "gbrjob"
|
||||
|| ext == "drl" )
|
||||
|| ext == "drl"
|
||||
|| IsProtelExtension( ext ) )
|
||||
{
|
||||
KIFACE* gerbview = m_frame->Kiway().KiFACE( KIWAY::FACE_GERBVIEW );
|
||||
gerbview->SaveFileAs( m_projectDirPath, m_projectName, m_newProjectDirPath,
|
||||
|
@ -409,6 +410,7 @@ public:
|
|||
{
|
||||
// Everything we don't recognize just gets a straight copy
|
||||
wxString destPath = destFile.GetPath();
|
||||
wxString destName = destFile.GetName();
|
||||
|
||||
if( destPath.StartsWith( m_projectDirPath ) )
|
||||
{
|
||||
|
@ -416,8 +418,15 @@ public:
|
|||
destFile.SetPath( destPath );
|
||||
}
|
||||
|
||||
if( destFile.GetName() == m_projectName )
|
||||
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 );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue