Commit da4055ae authored by jean-pierre charras's avatar jean-pierre charras

Kicad: refinements in project_template.cpp.

Eeschema: schematic libraries in a sub path of standard libraries paths are now better handled.
parent fc6d7381
......@@ -314,6 +314,15 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
wxFileName fn;
// Build libs paths, to find later a relative path:
wxArrayString paths;
for( unsigned ll=0; ll < m_DefaultLibraryPathslistBox->GetCount(); ++ll )
paths.Add( m_DefaultLibraryPathslistBox->GetString( ll ) );
for( unsigned ll=0; ll < m_listUserPaths->GetCount(); ++ll )
paths.Add( m_listUserPaths->GetString( ll ) );
for( unsigned jj = 0; jj < filenames.GetCount(); jj++ )
{
fn = filenames[jj];
......@@ -321,10 +330,23 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
if( jj == 0 )
prj.SetRString( PROJECT::SCH_LIB_PATH, fn.GetPath() );
// Remove extension:
// Extension is not stored, so remove extension:
fn.SetExt( wxEmptyString );
libfilename = fn.GetName();
// Try to use relative path:
for( unsigned ll = 0; ll < paths.GetCount(); ll++ )
{
wxFileName relfn = fn;
relfn.MakeRelativeTo( paths[ll] );
if( relfn.GetPath()[0] != '.' )
{
fn = relfn;
break;
}
}
libfilename = fn.GetFullPath();
// Add or insert new library name, if not already in list
if( m_ListLibr->FindString( libfilename, fn.IsCaseSensitive() ) == wxNOT_FOUND )
......
......@@ -121,17 +121,32 @@ wxBitmap* PROJECT_TEMPLATE::GetIcon()
bool PROJECT_TEMPLATE::CreateProject( wxFileName& aNewProjectPath )
{
// CreateProject copy the files from template to the new project folder
// and rename files which have the same name as the template .pro file
bool result = true;
std::vector<wxFileName> srcFiles = GetFileList();
// Find the template file name base. this is the name of the .pro templte file
wxString basename;
for( size_t i=0; i < srcFiles.size(); i++ )
{
if( srcFiles[i].GetExt() == wxT( "pro" ) )
{
basename = srcFiles[i].GetName();
break;
}
}
for( size_t i=0; i < srcFiles.size(); i++ )
{
// Replace the template path
wxFileName destination = srcFiles[i];
// Replace the template filename with the project filename for the new project creation
destination.SetName( aNewProjectPath.GetName() );
wxString currname = destination.GetName();
currname.Replace( basename, aNewProjectPath.GetName() );
destination.SetName( currname );
// Replace the template path with the project path for the new project creation
// but keep the sub directory name, if exists
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment