27#include <wx/textfile.h>
28#include <wx/filename.h>
53 wxTreeCtrl* parent ) :
69 if( state < 0 || state >=
m_parent->GetImageCount() / ( treeEnumMax - 2 ) )
73 int imgid =
static_cast<int>(
m_type ) - 1 + state * ( treeEnumMax - 1 );
74 m_parent->SetItemImage( GetId(), imgid );
75 m_parent->SetItemImage( GetId(), imgid, wxTreeItemIcon_Selected );
117 const wxString sep = wxFileName().GetPathSeparator();
122 newFile = dirs + sep +
name;
131 wxString full_ext = wxT(
"." ) + ext;
133 if( check && !ext.IsEmpty() && !newFile.Lower().EndsWith( full_ext ) )
136 "Do you want to continue ?" ),
137 _(
"Rename File" ), wxYES_NO | wxICON_QUESTION );
139 if( wxID_YES != dialog.ShowModal() )
143 if( !wxRenameFile(
GetFileName(), newFile,
false ) )
146 wxICON_ERROR | wxOK );
164 wxString dialogMsg = wxString::Format(
_(
"Can not move '%s' to recycle bin."),
167 wxString dialogMsg = wxString::Format(
_(
"Can not move '%s' to trash."),
190 std::set<wxString>& aSheetFiles )
192 if( aSheetFiles.count( aRootSchematic ) )
195 aSheetFiles.insert( aRootSchematic );
199 if( !file.Open( aRootSchematic ) )
202 wxFileName rootFn( aRootSchematic );
203 wxString rootDir = rootFn.GetPath();
206 wxRegEx sheetfileRe(
"\\(property\\s+\"Sheetfile\"\\s+\"([^\"]+)\"" );
208 for( wxString line = file.GetFirstLine(); !file.Eof(); line = file.GetNextLine() )
210 if( sheetfileRe.Matches( line ) )
212 wxString sheetFile = sheetfileRe.GetMatch( line, 1 );
215 wxFileName sheetFn( sheetFile );
217 if( !sheetFn.IsAbsolute() )
218 sheetFn.MakeAbsolute( rootDir );
220 wxString fullPath = sheetFn.GetFullPath();
222 if( wxFileExists( fullPath ) )
232 wxTreeItemId
id = GetId();
263 if( rootSchematic.IsEmpty() )
266 if( fullFileName == rootSchematic )
273 std::set<wxString> hierarchyFiles;
275 if( !rootSchematic.IsEmpty() && wxFileExists( rootSchematic ) )
281 wxFileName topSheet(
info.filename );
282 topSheet.MakeAbsolute(
Prj().GetProjectPath() );
284 if( topSheet.FileExists() )
288 bool isInHierarchy = hierarchyFiles.count( fullFileName ) > 0;
304 packet = fullFileName.ToStdString();
337 wxLaunchDefaultBrowser( fullFileName );
357 packet = fullFileName.ToStdString();
364 packet = fullFileName.ToStdString();
369 wxLaunchDefaultApplication( fullFileName );
static TOOL_ACTION editPCB
static TOOL_ACTION editOtherPCB
static TOOL_ACTION editOtherSch
static TOOL_ACTION editSchematic
static TOOL_ACTION openTextEditor
static TOOL_ACTION editDrawingSheet
static TOOL_ACTION editFootprints
static TOOL_ACTION viewGerbers
static TOOL_ACTION editSymbols
The main KiCad project manager frame.
const wxString SchLegacyFileName()
const wxString SchFileName()
void OpenJobsFile(const wxFileName &aFileName, bool aCreate=false, bool aResaveProjectPreferences=true)
const wxString PcbLegacyFileName()
bool LoadProject(const wxFileName &aProjectFileName)
Loads a new project.
const wxString PcbFileName()
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.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
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, bool aFromOtherThread=false)
Send aPayload to aDestination from aSource.
bool CanDelete() const
Determine if a file can be deleted via the project tree pane.
void SetRootFile(bool aValue)
bool Rename(const wxString &name, bool check=true)
const wxString & GetFileName() const
void SetType(TREE_FILE_TYPE aType)
void SetPopulated(bool aValue)
TREE_FILE_TYPE GetType() const
void SetFileName(const wxString &name)
const wxString GetDir() const
void Activate(PROJECT_TREE_PANE *aTreePrjFrame)
Window to display the tree files.
PROJECT_TREE * m_TreeProject
KICAD_MANAGER_FRAME * m_Parent
static wxString GetFileExt(TREE_FILE_TYPE type)
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
#define KICAD_MESSAGE_DIALOG
@ FRAME_SCH_SYMBOL_EDITOR
bool OpenPDF(const wxString &file)
Run the PDF viewer and display a PDF file.
@ MAIL_SCH_NAVIGATE_TO_SHEET
static void ScanSchematicHierarchy(const wxString &aRootSchematic, std::set< wxString > &aSheetFiles)
Scan a schematic file hierarchy to collect all sheet file paths.
Information about a top-level schematic sheet.