34 const std::vector<wxString>& aSchFileExtensions,
35 const std::vector<wxString>& aPcbFileExtensions ) :
37 m_schExtenstions( aSchFileExtensions ), m_pcbExtenstions( aPcbFileExtensions )
54 wxString suffix = wxString::Format(
"_%d", ++attempt );
63 msg.Printf(
_(
"Cannot copy file '%s'\n"
65 "The project cannot be imported." ),
66 aSrc.GetFullPath(), aFileCopy.GetFullPath() );
68 wxMessageDialog fileCopyErrorDlg(
m_frame, msg,
_(
"Error" ), wxOK_DEFAULT | wxICON_ERROR );
69 fileCopyErrorDlg.ShowModal();
86 wxString appImportFile;
87 std::vector<wxString> neededExts;
104 std::vector<SCOPED_FILE_REMOVER> copiedFiles;
106 for( wxString ext : neededExts )
108 if( ext == wxS(
"INPUT" ) )
112 candidate.SetExt( ext );
114 if( !candidate.FileExists() )
117 wxFileName targetFile(
m_TargetProj.GetPath(), candidate.GetName(), candidate.GetExt() );
119 if( !targetFile.FileExists() )
121 bool copied = wxCopyFile( candidate.GetFullPath(), targetFile.GetFullPath(),
false );
126 copiedFiles.emplace_back( targetFile.GetFullPath() );
131 if( appImportFile.empty() && targetFile.FileExists() )
132 appImportFile = targetFile.GetFullPath();
135 if( appImportFile.empty() )
140 std::string packet =
StrPrintf(
"%d\n%s", aImportedFileType,
TO_UTF8( appImportFile ) );
143 if( !frame->IsShown() )
147 if( frame->IsIconized() )
148 frame->Iconize(
false );
IMPORT_PROJ_HELPER(KICAD_MANAGER_FRAME *aframe, const std::vector< wxString > &aSchFileExtensions, const std::vector< wxString > &aPcbFileExtensions)
void FindEmptyTargetDir()
Appends a new directory with the name of the project file Keep iterating until an empty directory is ...
std::vector< wxString > m_pcbExtenstions
KICAD_MANAGER_FRAME * m_frame
void ImportFiles(int aImportedSchFileType, int aImportedPcbFileType)
Converts imported files to kicad type files.
void OutputCopyError(const wxFileName &aSrc, const wxFileName &aFileCopy)
void ImportIndividualFile(KICAD_T aKicad_T, int aImportedFileType)
std::vector< wxString > m_schExtenstions
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.
SCOPED_FILE_REMOVER(const wxString &aFile)
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
This file contains miscellaneous commonly used macros and functions.
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.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition of file extensions used in Kicad.