32 const wxString& aFile,
33 const wxString& aSchFileExtension,
34 const wxString& aPcbFileExtension ) :
36 m_sch( aFile ), m_pcb( m_sch ), m_pro( m_sch )
38 m_sch.SetExt( aSchFileExtension );
39 m_pcb.SetExt( aPcbFileExtension );
52 return m_pro.GetPath();
58 m_pro.SetPath( aPath );
64 return m_pro.GetFullPath();
70 return m_pro.GetName();
78 wxString newDir =
m_pro.GetName();
81 m_pro.AppendDir( newDir );
83 while(
m_pro.DirExists() )
85 m_pro.RemoveLastDir();
87 m_pro.AppendDir( newDir + suffix );
95 if( !
m_pro.IsAbsolute() )
104 wxFileName fileCopy(
m_pro );
106 wxFileName src, dest;
116 fileCopy.SetExt( src.GetExt() );
118 if( src.Exists() && !fileCopy.SameAs( src ) )
120 if( !wxCopyFile( src.GetFullPath(), fileCopy.GetFullPath(),
true ) )
148 msg.Printf(
_(
"Cannot copy file '%s'\n"
150 "The project cannot be imported." ),
151 aSrc.GetFullPath(), aFileCopy.GetFullPath() );
153 wxMessageDialog fileCopyErrorDlg(
m_frame, msg,
_(
"Error" ), wxOK_DEFAULT | wxICON_ERROR );
154 fileCopyErrorDlg.ShowModal();
160 wxFileName fileCopy, importedFile;
165 importedFile =
m_sch;
171 importedFile =
m_pcb;
179 if( fileCopy.FileExists() )
184 StrPrintf(
"%d\n%s", aImportedFileType,
TO_UTF8( fileCopy.GetFullPath() ) );
187 if( !frame->IsShown() )
191 if( frame->IsIconized() )
192 frame->Iconize(
false );
196 if( !fileCopy.SameAs( importedFile ) )
197 wxRemoveFile( fileCopy.GetFullPath() );
203 int aImportedPcbFileType )
void AssociateFilesWithProj(int aImportedSchFileType, int aImportedPcbFileType)
Converts imported files to kicad type files.
wxString GetProjFullPath()
const wxFileName & GetProj()
bool CopyImportedFile(KICAD_T aKicad_T, bool displayError=true)
void SetProjPath(const wxString aPath)
IMPORT_PROJ_HELPER(KICAD_MANAGER_FRAME *aframe, const wxString &aFile, const wxString &aSchFileExtension, const wxString &aPcbFileExtension)
void CreateEmptyDirForProject()
Appends a new directory with the name of the project file Keep iterating until an empty directory is ...
KICAD_MANAGER_FRAME * m_frame
void SetProjAbsolutePath()
void OutputCopyError(const wxFileName &aSrc, const wxFileName &aFileCopy)
void AssociateFileWithProj(KICAD_T aKicad_T, int aImportedFileType)
bool CopyImportedFiles(bool displayError=true)
Copies project files to the destination directory.
The main KiCad project manager frame.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
const std::string ProjectFileExtension
This file contains miscellaneous commonly used macros and functions.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
int StrPrintf(std::string *result, const char *format,...)
This is like sprintf() but the output is appended to a std::string instead of to a character array.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition of file extensions used in Kicad.