Fix save as and save copy as for project files.
This commit is contained in:
parent
d79057b83a
commit
f7cc6d1e1e
|
@ -932,6 +932,22 @@ void SETTINGS_MANAGER::SaveProjectAs( const wxString& aFullPath )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SETTINGS_MANAGER::SaveProjectCopy( const wxString& aFullPath )
|
||||||
|
{
|
||||||
|
PROJECT_FILE* project = m_project_files.at( Prj().GetProjectFullName() );
|
||||||
|
wxString oldName = project->GetFilename();
|
||||||
|
wxFileName fn( aFullPath );
|
||||||
|
|
||||||
|
project->SetFilename( fn.GetName() );
|
||||||
|
project->SaveToFile( fn.GetPath() );
|
||||||
|
project->SetFilename( oldName );
|
||||||
|
|
||||||
|
Prj().GetLocalSettings().SetFilename( fn.GetName() );
|
||||||
|
Prj().GetLocalSettings().SaveToFile( fn.GetPath() );
|
||||||
|
Prj().GetLocalSettings().SetFilename( oldName );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SETTINGS_MANAGER::loadProjectFile( PROJECT& aProject )
|
bool SETTINGS_MANAGER::loadProjectFile( PROJECT& aProject )
|
||||||
{
|
{
|
||||||
wxFileName fullFn( aProject.GetProjectFullName() );
|
wxFileName fullFn( aProject.GetProjectFullName() );
|
||||||
|
|
|
@ -278,6 +278,11 @@ public:
|
||||||
*/
|
*/
|
||||||
void SaveProjectAs( const wxString& aFullPath );
|
void SaveProjectAs( const wxString& aFullPath );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves a copy of the current project under the given path
|
||||||
|
*/
|
||||||
|
void SaveProjectCopy( const wxString& aFullPath );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the full path to where project backups should be stored
|
* @return the full path to where project backups should be stored
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -932,54 +932,29 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool addToHistory,
|
||||||
|
|
||||||
// TODO: this will break if we ever go multi-board
|
// TODO: this will break if we ever go multi-board
|
||||||
wxFileName projectFile( pcbFileName );
|
wxFileName projectFile( pcbFileName );
|
||||||
bool projectFileExists = false;
|
|
||||||
|
|
||||||
projectFile.SetExt( ProjectFileExtension );
|
projectFile.SetExt( ProjectFileExtension );
|
||||||
projectFileExists = projectFile.FileExists();
|
|
||||||
|
|
||||||
if( aChangeProject && !projectFileExists )
|
if( !projectFile.FileExists() && aChangeProject )
|
||||||
|
GetSettingsManager()->SaveProjectAs( projectFile.GetFullPath() );
|
||||||
|
|
||||||
|
if( projectFile.FileExists() )
|
||||||
{
|
{
|
||||||
// If this is a new board, project filename won't be set yet
|
|
||||||
if( projectFile.GetFullPath() != Prj().GetProjectFullName() )
|
|
||||||
{
|
|
||||||
GetBoard()->ClearProject();
|
|
||||||
|
|
||||||
SETTINGS_MANAGER* mgr = GetSettingsManager();
|
|
||||||
|
|
||||||
mgr->SaveProject( Prj().GetProjectFullName() );
|
|
||||||
mgr->UnloadProject( &Prj() );
|
|
||||||
|
|
||||||
// If no project to load then initialize project text vars with board properties
|
|
||||||
if( !mgr->LoadProject( projectFile.GetFullPath() ) )
|
|
||||||
{
|
|
||||||
Prj().GetTextVars() = GetBoard()->GetProperties();
|
|
||||||
|
|
||||||
// TODO: save netclasses from currentProject to new project...
|
|
||||||
}
|
|
||||||
|
|
||||||
GetBoard()->SetProject( &Prj() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( projectFileExists )
|
|
||||||
GetBoard()->SynchronizeProperties();
|
|
||||||
|
|
||||||
wxFileName tempFile( aFileName );
|
|
||||||
tempFile.SetName( wxT( "." ) + tempFile.GetName() );
|
|
||||||
tempFile.SetExt( tempFile.GetExt() + wxT( "$" ) );
|
|
||||||
|
|
||||||
GetBoard()->SynchronizeNetsAndNetClasses();
|
|
||||||
|
|
||||||
// Save various DRC parameters, such as violation severities (which may have been
|
// Save various DRC parameters, such as violation severities (which may have been
|
||||||
// edited via the DRC dialog as well as the Board Setup dialog), DRC exclusions, etc.
|
// edited via the DRC dialog as well as the Board Setup dialog), DRC exclusions, etc.
|
||||||
SaveProjectSettings();
|
SaveProjectSettings();
|
||||||
|
|
||||||
GetSettingsManager()->SaveProject();
|
GetBoard()->SynchronizeProperties();
|
||||||
|
GetBoard()->SynchronizeNetsAndNetClasses();
|
||||||
|
}
|
||||||
|
|
||||||
|
wxFileName tempFile( aFileName );
|
||||||
wxString upperTxt;
|
wxString upperTxt;
|
||||||
wxString lowerTxt;
|
wxString lowerTxt;
|
||||||
|
|
||||||
|
tempFile.SetName( wxT( "." ) + tempFile.GetName() );
|
||||||
|
tempFile.SetExt( tempFile.GetExt() + wxT( "$" ) );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::KICAD_SEXP ) );
|
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::KICAD_SEXP ) );
|
||||||
|
@ -1080,6 +1055,10 @@ bool PCB_EDIT_FRAME::SavePcbCopy( const wxString& aFileName, bool aCreateProject
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save various DRC parameters, such as violation severities (which may have been
|
||||||
|
// edited via the DRC dialog as well as the Board Setup dialog), DRC exclusions, etc.
|
||||||
|
SaveProjectSettings();
|
||||||
|
|
||||||
GetBoard()->SynchronizeNetsAndNetClasses();
|
GetBoard()->SynchronizeNetsAndNetClasses();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -1100,42 +1079,12 @@ bool PCB_EDIT_FRAME::SavePcbCopy( const wxString& aFileName, bool aCreateProject
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( aCreateProject )
|
|
||||||
{
|
|
||||||
wxFileName projectFile( pcbFileName );
|
wxFileName projectFile( pcbFileName );
|
||||||
|
|
||||||
projectFile.SetExt( ProjectFileExtension );
|
projectFile.SetExt( ProjectFileExtension );
|
||||||
|
|
||||||
if( !projectFile.FileExists() )
|
if( aCreateProject && !projectFile.FileExists() )
|
||||||
{
|
GetSettingsManager()->SaveProjectCopy( projectFile.GetFullPath() );
|
||||||
wxString currentProject = Prj().GetProjectFullName();
|
|
||||||
|
|
||||||
SETTINGS_MANAGER* mgr = GetSettingsManager();
|
|
||||||
|
|
||||||
// Shelve the current project
|
|
||||||
GetBoard()->ClearProject();
|
|
||||||
|
|
||||||
mgr->SaveProject( currentProject );
|
|
||||||
mgr->UnloadProject( &Prj() );
|
|
||||||
|
|
||||||
// Create a new project for the saved-as-copy
|
|
||||||
|
|
||||||
// If no project to load then initialize project text vars with board properties
|
|
||||||
if( !mgr->LoadProject( projectFile.GetFullPath() ) )
|
|
||||||
{
|
|
||||||
Prj().GetTextVars() = GetBoard()->GetProperties();
|
|
||||||
|
|
||||||
// TODO: save netclasses from currentProject to new project...
|
|
||||||
}
|
|
||||||
|
|
||||||
mgr->SaveProject();
|
|
||||||
|
|
||||||
// Now go back to our own project
|
|
||||||
mgr->UnloadProject( &Prj() );
|
|
||||||
mgr->LoadProject( currentProject );
|
|
||||||
|
|
||||||
GetBoard()->SetProject( &Prj() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DisplayInfoMessage( this, wxString::Format( _( "Board copied to:\n\"%s\"" ),
|
DisplayInfoMessage( this, wxString::Format( _( "Board copied to:\n\"%s\"" ),
|
||||||
pcbFileName.GetFullPath() ) );
|
pcbFileName.GetFullPath() ) );
|
||||||
|
|
Loading…
Reference in New Issue