45 const std::vector<wxString>& aSchFileExtensions,
46 const std::vector<wxString>& aPcbFileExtensions ) :
48 m_schExtenstions( aSchFileExtensions ), m_pcbExtenstions( aPcbFileExtensions )
65 wxString suffix = wxString::Format(
"_%d", ++attempt );
74 msg.Printf(
_(
"Cannot copy file '%s'\n"
76 "The project cannot be imported." ),
77 aSrc.GetFullPath(), aFileCopy.GetFullPath() );
79 wxMessageDialog fileCopyErrorDlg(
m_frame, msg,
_(
"Error" ), wxOK_DEFAULT | wxICON_ERROR );
80 fileCopyErrorDlg.ShowModal();
97 wxString appImportFile;
98 std::vector<wxString> neededExts;
115 std::vector<SCOPED_FILE_REMOVER> copiedFiles;
117 for( wxString ext : neededExts )
119 if( ext == wxS(
"INPUT" ) )
123 candidate.SetExt( ext );
125 if( !candidate.FileExists() )
128 wxFileName targetFile(
m_TargetProj.GetPath(), candidate.GetName(), candidate.GetExt() );
130 if( !targetFile.FileExists() )
132 bool copied = wxCopyFile( candidate.GetFullPath(), targetFile.GetFullPath(),
false );
137 copiedFiles.emplace_back( targetFile.GetFullPath() );
142 if( appImportFile.empty() && targetFile.FileExists() )
143 appImportFile = targetFile.GetFullPath();
146 if( appImportFile.empty() )
151 std::stringstream ss;
152 ss << aImportedFileType <<
'\n' <<
TO_UTF8( appImportFile );
155 ss <<
'\n' << key <<
'\n' << value.wx_str();
157 std::string packet = ss.str();
160 if( !frame->IsShownOnScreen() )
164 if( frame->IsIconized() )
165 frame->Iconize(
false );
175 if( fname.GetExt() == wxS(
"epro" ) || fname.GetExt() == wxS(
"zip" ) )
179 std::map<wxString, EASYEDAPRO::PRJ_SCHEMATIC> prjSchematics =
project.at(
"schematics" );
180 std::map<wxString, EASYEDAPRO::PRJ_BOARD> prjBoards =
project.at(
"boards" );
181 std::map<wxString, wxString> prjPcbNames =
project.at(
"pcbs" );
183 std::vector<IMPORT_PROJECT_DESC> toImport =
186 if( toImport.size() > 1 )
189 if( toImport.size() == 1 )
209 if( aImportedSchFileType == SCH_IO_MGR::SCH_EASYEDAPRO
static std::vector< IMPORT_PROJECT_DESC > RunModal(wxWindow *aParent, const std::vector< IMPORT_PROJECT_DESC > &aProjectDesc)
Create and show a dialog (modal) and returns the data from it after completion.
void EasyEDAProProjectHandler()
IMPORT_PROJ_HELPER(KICAD_MANAGER_FRAME *aframe, const std::vector< wxString > &aSchFileExtensions, const std::vector< wxString > &aPcbFileExtensions)
std::map< std::string, UTF8 > m_properties
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.
std::vector< IMPORT_PROJECT_DESC > ProjectToSelectorDialog(const nlohmann::json &aProject, bool aPcbOnly=false, bool aSchOnly=false)
nlohmann::json ReadProjectOrDeviceFile(const wxString &aZipFileName)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Describes how non-KiCad boards and schematics should be imported as KiCad projects.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition of file extensions used in Kicad.