KiCad PCB EDA Suite
TREE_PROJECT_FRAME Class Reference

class TREE_PROJECT_FRAME Window to display the tree files More...

#include <tree_project_frame.h>

Inheritance diagram for TREE_PROJECT_FRAME:

Public Member Functions

 TREE_PROJECT_FRAME (KICAD_MANAGER_FRAME *parent)
 class TREE_PROJECT_FRAME is the frame that shows the tree list of files and subdirs inside the working directory Files are filtered (see s_allowedExtensionsToList) so only useful files are shown. More...
 
 ~TREE_PROJECT_FRAME ()
 
void ReCreateTreePrj ()
 Create or modify the tree showing project file names. More...
 
void FileWatcherReset ()
 Reinit the watched paths Should be called after opening a new project to rebuild the list of watched paths. More...
 

Public Attributes

KICAD_MANAGER_FRAMEm_Parent
 
TREEPROJECTFILESm_TreeProject
 

Protected Member Functions

TREEPROJECT_ITEMGetSelectedData ()
 Function GetSelectedData return the item data from item currently selected (highlighted) Note this is not necessary the "clicked" item, because when expanding, collapsing an item this item is not selected. More...
 
TREEPROJECT_ITEMGetItemIdData (wxTreeItemId aId)
 Function GetItemIdData return the item data corresponding to a wxTreeItemId identifier. More...
 

Static Protected Member Functions

static wxString GetFileExt (TreeFileType type)
 
static wxString GetFileWildcard (TreeFileType type)
 

Private Member Functions

void OnSelect (wxTreeEvent &Event)
 Called on a double click on an item. More...
 
void OnExpand (wxTreeEvent &Event)
 Called on a click on the + or - button of an item with children. More...
 
void OnRight (wxTreeEvent &Event)
 Called on a right click on an item. More...
 
void OnOpenSelectedFileWithTextEditor (wxCommandEvent &event)
 Function OnOpenSelectedFileWithTextEditor Called via the popup menu, when right clicking on a file name Call the text editor to open the selected file in the tree project. More...
 
void OnDeleteFile (wxCommandEvent &event)
 Function OnDeleteFile Called via the popup menu, when right clicking on a file name or a directory name to delete the selected file or directory in the tree project. More...
 
void OnRenameFile (wxCommandEvent &event)
 Function OnRenameFile Called via the popup menu, when right clicking on a file name or a directory name to rename the selected file or directory in the tree project. More...
 
void OnCreateNewDirectory (wxCommandEvent &event)
 Function OnCreateNewDirectory Creates a new subdirectory inside the current kicad project directory the user is prompted to enter a directory name. More...
 
void ClearFilters ()
 
const std::vector< wxString > & GetFilters ()
 
void RemoveFilter (const wxString &filter)
 
bool AddItemToTreeProject (const wxString &aName, wxTreeItemId &aRoot, bool aRecurse=true)
 Function AddItemToTreeProject. More...
 
wxTreeItemId findSubdirTreeItem (const wxString &aSubDir)
 Function findSubdirTreeItem searches for the item in tree project which is the node of the subdirectory aSubDir. More...
 
void OnFileSystemEvent (wxFileSystemWatcherEvent &event)
 called when a file or directory is modified/created/deleted The tree project is modified when a file or directory is created/deleted/renamed to reflect the file change More...
 

Private Attributes

wxTreeItemId m_root
 
std::vector< wxString > m_filters
 
wxFileSystemWatcher * m_watcher
 

Friends

class TREEPROJECT_ITEM
 

Detailed Description

class TREE_PROJECT_FRAME Window to display the tree files

Definition at line 47 of file tree_project_frame.h.

Constructor & Destructor Documentation

TREE_PROJECT_FRAME::TREE_PROJECT_FRAME ( KICAD_MANAGER_FRAME parent)

class TREE_PROJECT_FRAME is the frame that shows the tree list of files and subdirs inside the working directory Files are filtered (see s_allowedExtensionsToList) so only useful files are shown.

Definition at line 125 of file tree_project_frame.cpp.

References OnFileSystemEvent(), and s_allowedExtensionsToList.

125  :
126  wxSashLayoutWindow( parent, ID_LEFT_FRAME,
127  wxDefaultPosition, wxDefaultSize,
128  wxNO_BORDER | wxTAB_TRAVERSAL )
129 {
130  m_Parent = parent;
131  m_TreeProject = NULL;
132 
133  m_watcher = NULL;
134  Connect( wxEVT_FSWATCHER,
135  wxFileSystemWatcherEventHandler( TREE_PROJECT_FRAME::OnFileSystemEvent ) );
136 
137  /*
138  * Filtering is now inverted: the filters are actually used to _enable_ support
139  * for a given file type.
140  */
141 
142  // NOTE: sch filter must be first because of a test in AddFile() below
143  m_filters.push_back( wxT( "^.*\\.sch$" ) );
144 
145  for( int ii = 0; s_allowedExtensionsToList[ii] != NULL; ii++ )
146  m_filters.push_back( s_allowedExtensionsToList[ii] );
147 
148  m_filters.push_back( wxT( "^no KiCad files found" ) );
149 
150  ReCreateTreePrj();
151 }
TREEPROJECTFILES * m_TreeProject
void OnFileSystemEvent(wxFileSystemWatcherEvent &event)
called when a file or directory is modified/created/deleted The tree project is modified when a file ...
KICAD_MANAGER_FRAME * m_Parent
void ReCreateTreePrj()
Create or modify the tree showing project file names.
wxFileSystemWatcher * m_watcher
std::vector< wxString > m_filters
static const wxChar * s_allowedExtensionsToList[]
TREE_PROJECT_FRAME::~TREE_PROJECT_FRAME ( )

Definition at line 154 of file tree_project_frame.cpp.

References m_watcher.

155 {
156  if( m_watcher )
157  {
158  m_watcher->RemoveAll();
159  m_watcher->SetOwner( NULL );
160  delete m_watcher;
161  }
162 }
wxFileSystemWatcher * m_watcher

Member Function Documentation

bool TREE_PROJECT_FRAME::AddItemToTreeProject ( const wxString &  aName,
wxTreeItemId &  aRoot,
bool  aRecurse = true 
)
private

Function AddItemToTreeProject.

Add the file or directory aName to the project tree

Parameters
aName= the filename or the directory name to add in tree
aRoot= the wxTreeItemId item where to add sub tree items
aRecurse= true to add file or subdir names to the current tree item false to stop file add.
Returns
true if the file (or directory) is added.

Definition at line 399 of file tree_project_frame.cpp.

References GetFileExt(), TREEPROJECT_ITEM::GetFileName(), GetItemIdData(), KICAD_MANAGER_FRAME::GetProjectFileName(), m_filters, m_Parent, m_root, m_TreeProject, TREEPROJECT_ITEM::SetPopulated(), TREEPROJECT_ITEM::SetRootFile(), TREEPROJECT_ITEM::SetState(), TREE_DIRECTORY, TREE_MAX, TREE_PROJECT, TREE_UNKNOWN, and TREEPROJECT_ITEM.

Referenced by OnExpand(), OnFileSystemEvent(), and ReCreateTreePrj().

401 {
402  wxTreeItemId cellule;
403 
404  // Check the file type
405  TreeFileType type = TREE_UNKNOWN;
406 
407  // Skip not visible files and dirs
408  wxFileName fn( aName );
409 
410  // Files/dirs names starting by "." are not visible files under unices.
411  // Skip them also under Windows
412  if( fn.GetName().StartsWith( wxT( "." ) ) )
413  return false;
414 
415  if( wxDirExists( aName ) )
416  {
417  type = TREE_DIRECTORY;
418  }
419  else
420  {
421  // Filter
422  wxRegEx reg;
423 
424  bool isSchematic = false;
425  bool addFile = false;
426 
427  for( unsigned i = 0; i < m_filters.size(); i++ )
428  {
429  wxCHECK2_MSG( reg.Compile( m_filters[i], wxRE_ICASE ), continue,
430  wxT( "Regular expression " ) + m_filters[i] +
431  wxT( " failed to compile." ) );
432 
433  if( reg.Matches( aName ) )
434  {
435  addFile = true;
436 
437  if( i==0 )
438  isSchematic = true;
439 
440  break;
441  }
442  }
443 
444  if( !addFile )
445  return false;
446 
447  // only show the schematic if it is a top level schematic. Eeschema
448  // cannot open a schematic and display it properly unless it starts
449  // at the top of the hierarchy. The schematic is top level only if
450  // there is a line in the header saying:
451  // "Sheet 1 "
452  // However if the file has the same name as the project, it is always
453  // shown, because it is expected the root sheet.
454  // (and to fix an issue (under XP but could exist under other OS),
455  // when a .sch file is created, the file
456  // create is sent to the wxFileSystemWatcher, but the file still has 0 byte
457  // so it cannot detected as root sheet
458  // This is an ugly fix.
459  if( isSchematic )
460  {
461  wxString fullFileName = aName.BeforeLast( '.' );
462  wxString rootName;
463  TREEPROJECT_ITEM* itemData = GetItemIdData( m_root );
464  if( itemData )
465  rootName = itemData->GetFileName().BeforeLast( '.' );
466 
467  if( fullFileName != rootName )
468  {
469  char line[128]; // small because we just need a few bytes from the start of a line
470  FILE* fp;
471 
472  fullFileName = aName;
473  fp = wxFopen( fullFileName, wxT( "rt" ) );
474 
475  if( fp == NULL )
476  return false;
477 
478  addFile = false;
479 
480  // check the first 100 lines for the "Sheet 1" string
481  for( int i = 0; i<100; ++i )
482  {
483  if( !fgets( line, sizeof(line), fp ) )
484  break;
485 
486  if( !strncmp( line, "Sheet 1 ", 8 ) )
487  {
488  addFile = true;
489  break;
490  }
491  }
492 
493  fclose( fp );
494 
495  if( !addFile )
496  return false; // it is a non-top-level schematic
497  }
498  }
499 
500  for( int i = TREE_PROJECT; i < TREE_MAX; i++ )
501  {
502  wxString ext = GetFileExt( (TreeFileType) i );
503 
504  if( ext == wxT( "" ) )
505  continue;
506 
507  reg.Compile( wxString::FromAscii( "^.*\\" ) + ext +
508  wxString::FromAscii( "$" ), wxRE_ICASE );
509 
510  if( reg.Matches( aName ) )
511  {
512  type = (TreeFileType) i;
513  break;
514  }
515  }
516  }
517 
518  // also check to see if it is already there.
519  wxTreeItemIdValue cookie;
520  wxTreeItemId kid = m_TreeProject->GetFirstChild( aRoot, cookie );
521 
522  while( kid.IsOk() )
523  {
524  TREEPROJECT_ITEM* itemData = GetItemIdData( kid );
525 
526  if( itemData )
527  {
528  if( itemData->GetFileName() == aName )
529  {
530  return true; // well, we would have added it, but it is already here!
531  }
532  }
533 
534  kid = m_TreeProject->GetNextChild( aRoot, cookie );
535  }
536 
537  // Append the item (only appending the filename not the full path):
538  wxString file = wxFileNameFromPath( aName );
539  cellule = m_TreeProject->AppendItem( aRoot, file );
540  TREEPROJECT_ITEM* data = new TREEPROJECT_ITEM( type, aName, m_TreeProject );
541 
542  m_TreeProject->SetItemData( cellule, data );
543  data->SetState( 0 );
544 
545  // Mark root files (files which have the same aName as the project)
546  wxFileName project( m_Parent->GetProjectFileName() );
547  wxFileName currfile( file );
548 
549  if( currfile.GetName().CmpNoCase( project.GetName() ) == 0 )
550  data->SetRootFile( true );
551  else
552  data->SetRootFile( false );
553 
554  // This section adds dirs and files found in the subdirs
555  // in this case AddFile is recursive, but for the first level only.
556  if( TREE_DIRECTORY == type && aRecurse )
557  {
558  wxDir dir( aName );
559 
560  if( dir.IsOpened() ) // protected dirs will not open properly.
561  {
562  wxString dir_filename;
563 
564  data->SetPopulated( true );
565 
566  if( dir.GetFirst( &dir_filename ) )
567  {
568  do // Add name in tree, but do not recurse
569  {
570  wxString path = aName + wxFileName::GetPathSeparator() + dir_filename;
571  AddItemToTreeProject( path, cellule, false );
572  } while( dir.GetNext( &dir_filename ) );
573  }
574  }
575 
576  // Sort filenames by alphabetic order
577  m_TreeProject->SortChildren( cellule );
578  }
579 
580  return true;
581 }
Class TREEPROJECT_ITEM handles one item (a file or a directory name) for the tree file...
TreeFileType
Definition: kicad.h:52
void SetRootFile(bool aValue)
TREEPROJECTFILES * m_TreeProject
friend class TREEPROJECT_ITEM
KICAD_MANAGER_FRAME * m_Parent
Definition: kicad.h:72
const wxString GetProjectFileName()
Definition: mainframe.cpp:144
TREEPROJECT_ITEM * GetItemIdData(wxTreeItemId aId)
Function GetItemIdData return the item data corresponding to a wxTreeItemId identifier.
const wxString & GetFileName() const
bool AddItemToTreeProject(const wxString &aName, wxTreeItemId &aRoot, bool aRecurse=true)
Function AddItemToTreeProject.
std::vector< wxString > m_filters
static wxString GetFileExt(TreeFileType type)
void SetPopulated(bool aValue)
void TREE_PROJECT_FRAME::ClearFilters ( )
inlineprivate

Definition at line 143 of file tree_project_frame.h.

144  {
145  m_filters.clear();
146  }
std::vector< wxString > m_filters
void TREE_PROJECT_FRAME::FileWatcherReset ( )

Reinit the watched paths Should be called after opening a new project to rebuild the list of watched paths.

Should be called atfer the main loop event handler is started

Definition at line 998 of file tree_project_frame.cpp.

References TREEPROJECT_ITEM::GetFileName(), GetItemIdData(), KICAD_MANAGER_FRAME::GetProjectFileName(), TREEPROJECT_ITEM::GetType(), TREEPROJECT_ITEM::IsPopulated(), m_Parent, m_root, m_TreeProject, m_watcher, TO_UTF8, and TREE_DIRECTORY.

Referenced by KICAD_MANAGER_FRAME::OnChangeWatchedPaths(), and OnExpand().

999 {
1000  // Prepare file watcher:
1001  if( m_watcher )
1002  {
1003  m_watcher->RemoveAll();
1004  }
1005  else
1006  {
1007  m_watcher = new wxFileSystemWatcher();
1008  m_watcher->SetOwner( this );
1009  }
1010 
1011  // Add directories which should be monitored.
1012  // under windows, we add the curr dir and all subdirs
1013  // under unix, we add only the curr dir and the populated subdirs
1014  // see http://docs.wxwidgets.org/trunk/classwx_file_system_watcher.htm
1015  // under unix, the file watcher needs more work to be efficient
1016  // moreover, under wxWidgets 2.9.4, AddTree does not work properly.
1017 
1018  // We can see wxString under a debugger, not a wxFileName
1019  wxString prj_dir = wxPathOnly( m_Parent->GetProjectFileName() );
1020  wxFileName fn;
1021  fn.AssignDir( prj_dir );
1022  fn.DontFollowLink();
1023 
1024 #ifdef __WINDOWS__
1025  m_watcher->AddTree( fn );
1026 #else
1027  m_watcher->Add( fn );
1028 
1029  // Add subdirs
1030  wxTreeItemIdValue cookie;
1031  wxTreeItemId root_id = m_root;
1032 
1033  std::stack < wxTreeItemId > subdirs_id;
1034 
1035  wxTreeItemId kid = m_TreeProject->GetFirstChild( root_id, cookie );
1036 
1037  while( 1 )
1038  {
1039  if( !kid.IsOk() )
1040  {
1041  if( subdirs_id.empty() ) // all items were explored
1042  break;
1043  else
1044  {
1045  root_id = subdirs_id.top();
1046  subdirs_id.pop();
1047  kid = m_TreeProject->GetFirstChild( root_id, cookie );
1048 
1049  if( !kid.IsOk() )
1050  continue;
1051  }
1052  }
1053 
1054  TREEPROJECT_ITEM* itemData = GetItemIdData( kid );
1055 
1056  if( itemData && itemData->GetType() == TREE_DIRECTORY )
1057  {
1058  // we can see wxString under a debugger, not a wxFileName
1059  wxString path = itemData->GetFileName();
1060 
1061  wxLogDebug( "%s: add '%s'\n", __func__, TO_UTF8( path ) );
1062 
1063  if( wxFileName::IsDirReadable( path ) ) // linux whines about watching protected dir
1064  {
1065  fn.AssignDir( path );
1066  m_watcher->Add( fn );
1067 
1068  // if kid is a subdir, push in list to explore it later
1069  if( itemData->IsPopulated() && m_TreeProject->GetChildrenCount( kid ) )
1070  subdirs_id.push( kid );
1071  }
1072  }
1073 
1074  kid = m_TreeProject->GetNextChild( root_id, cookie );
1075  }
1076 #endif
1077 
1078 #if defined(DEBUG) && 1
1079  wxArrayString paths;
1080  m_watcher->GetWatchedPaths( &paths );
1081  wxLogDebug( "%s: watched paths:", __func__ );
1082 
1083  for( unsigned ii = 0; ii < paths.GetCount(); ii++ )
1084  wxLogDebug( " %s\n", TO_UTF8( paths[ii] ) );
1085 #endif
1086 }
Class TREEPROJECT_ITEM handles one item (a file or a directory name) for the tree file...
TREEPROJECTFILES * m_TreeProject
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
TreeFileType GetType() const
KICAD_MANAGER_FRAME * m_Parent
const wxString GetProjectFileName()
Definition: mainframe.cpp:144
TREEPROJECT_ITEM * GetItemIdData(wxTreeItemId aId)
Function GetItemIdData return the item data corresponding to a wxTreeItemId identifier.
wxFileSystemWatcher * m_watcher
const wxString & GetFileName() const
wxTreeItemId TREE_PROJECT_FRAME::findSubdirTreeItem ( const wxString &  aSubDir)
private

Function findSubdirTreeItem searches for the item in tree project which is the node of the subdirectory aSubDir.

Parameters
aSubDir= the directory to find in tree
Returns
the opaque reference to the tree item. if not found, return an invalid tree item. therefore wxTreeItemId::IsOk should be used to test the returned value

Definition at line 861 of file tree_project_frame.cpp.

References TREEPROJECT_ITEM::GetFileName(), GetItemIdData(), KICAD_MANAGER_FRAME::GetProjectFileName(), TREEPROJECT_ITEM::GetType(), TREEPROJECT_ITEM::IsPopulated(), m_Parent, m_root, m_TreeProject, and TREE_DIRECTORY.

Referenced by OnFileSystemEvent().

862 {
863  wxString prj_dir = wxPathOnly( m_Parent->GetProjectFileName() );
864 
865  // If the subdir is the current working directory, return m_root
866  // in main list:
867  if( prj_dir == aSubDir )
868  return m_root;
869 
870  // The subdir is in the main tree or in a subdir: Locate it
871  wxTreeItemIdValue cookie;
872  wxTreeItemId root_id = m_root;
873  std::stack < wxTreeItemId > subdirs_id;
874 
875  wxTreeItemId kid = m_TreeProject->GetFirstChild( root_id, cookie );
876 
877  while( 1 )
878  {
879  if( ! kid.IsOk() )
880  {
881  if( subdirs_id.empty() ) // all items were explored
882  {
883  root_id = kid; // Not found: return an invalid wxTreeItemId
884  break;
885  }
886  else
887  {
888  root_id = subdirs_id.top();
889  subdirs_id.pop();
890  kid = m_TreeProject->GetFirstChild( root_id, cookie );
891 
892  if( ! kid.IsOk() )
893  continue;
894  }
895  }
896 
897  TREEPROJECT_ITEM* itemData = GetItemIdData( kid );
898 
899  if( itemData && ( itemData->GetType() == TREE_DIRECTORY ) )
900  {
901  if( itemData->GetFileName() == aSubDir ) // Found!
902  {
903  root_id = kid;
904  break;
905  }
906 
907  // kid is a subdir, push in list to explore it later
908  if( itemData->IsPopulated() )
909  subdirs_id.push( kid );
910  }
911 
912  kid = m_TreeProject->GetNextChild( root_id, cookie );
913  }
914 
915  return root_id;
916 }
Class TREEPROJECT_ITEM handles one item (a file or a directory name) for the tree file...
TREEPROJECTFILES * m_TreeProject
TreeFileType GetType() const
KICAD_MANAGER_FRAME * m_Parent
const wxString GetProjectFileName()
Definition: mainframe.cpp:144
TREEPROJECT_ITEM * GetItemIdData(wxTreeItemId aId)
Function GetItemIdData return the item data corresponding to a wxTreeItemId identifier.
const wxString & GetFileName() const
wxString TREE_PROJECT_FRAME::GetFileExt ( TreeFileType  type)
staticprotected

Definition at line 235 of file tree_project_frame.cpp.

References ComponentFileExtension, DrillFileExtension, FootprintPlaceFileExtension, GerberFileExtension, HtmlFileExtension, KiCadFootprintFileExtension, KiCadPcbFileExtension, LegacyPcbFileExtension, NetlistFileExtension, PageLayoutDescrFileExtension, PdfFileExtension, ProjectFileExtension, ReportFileExtension, SchematicFileExtension, SchematicLibraryFileExtension, SVGFileExtension, TextFileExtension, TREE_CMP_LINK, TREE_DRILL, TREE_FOOTPRINT_FILE, TREE_FP_PLACE, TREE_GERBER, TREE_HTML, TREE_LEGACY_PCB, TREE_NET, TREE_PAGE_LAYOUT_DESCR, TREE_PDF, TREE_PROJECT, TREE_REPORT, TREE_SCHEMA, TREE_SCHEMATIC_LIBFILE, TREE_SEXP_PCB, TREE_SVG, and TREE_TXT.

Referenced by AddItemToTreeProject(), and TREEPROJECT_ITEM::Rename().

236 {
237  wxString ext;
238 
239  switch( type )
240  {
241  case TREE_PROJECT:
242  ext = ProjectFileExtension;
243  break;
244 
245  case TREE_SCHEMA:
247  break;
248 
249  case TREE_LEGACY_PCB:
251  break;
252 
253  case TREE_SEXP_PCB:
254  ext = KiCadPcbFileExtension;
255  break;
256 
257  case TREE_GERBER:
258  ext = GerberFileExtension;
259  break;
260 
261  case TREE_HTML:
262  ext = HtmlFileExtension;
263  break;
264 
265  case TREE_PDF:
266  ext = PdfFileExtension;
267  break;
268 
269  case TREE_TXT:
270  ext = TextFileExtension;
271  break;
272 
273  case TREE_NET:
274  ext = NetlistFileExtension;
275  break;
276 
277  case TREE_CMP_LINK:
279  break;
280 
281  case TREE_REPORT:
282  ext = ReportFileExtension;
283  break;
284 
285  case TREE_FP_PLACE:
287  break;
288 
289  case TREE_DRILL:
290  ext = DrillFileExtension;
291  break;
292 
293  case TREE_SVG:
294  ext = SVGFileExtension;
295  break;
296 
299  break;
300 
301  case TREE_FOOTPRINT_FILE:
303  break;
304 
307  break;
308 
309  default: // Eliminates unnecessary GCC warning.
310  break;
311  }
312 
313  return ext;
314 }
Definition: kicad.h:59
const wxString KiCadFootprintFileExtension
const wxString DrillFileExtension
const wxString ProjectFileExtension
const wxString NetlistFileExtension
Definition: kicad.h:61
const wxChar TextFileExtension[]
Definition: kicad.h:68
const wxString SVGFileExtension
const wxString PdfFileExtension
const wxString FootprintPlaceFileExtension
const wxString SchematicLibraryFileExtension
const wxString SchematicFileExtension
const wxString GerberFileExtension
const wxString ComponentFileExtension
const wxString LegacyPcbFileExtension
const wxString KiCadPcbFileExtension
const wxString ReportFileExtension
Definition: kicad.h:60
const wxString PageLayoutDescrFileExtension
const wxString HtmlFileExtension
wxString TREE_PROJECT_FRAME::GetFileWildcard ( TreeFileType  type)
staticprotected

Definition at line 320 of file tree_project_frame.cpp.

References ComponentFileWildcard, DrillFileWildcard, FootprintPlaceFileWildcard, GerberFileWildcard, HtmlFileWildcard, KiCadFootprintLibFileWildcard, NetlistFileWildcard, PageLayoutDescrFileWildcard, PcbFileWildcard, PdfFileWildcard, ProjectFileWildcard, ReportFileWildcard, SchematicFileWildcard, SchematicLibraryFileWildcard, SVGFileWildcard, TextFileWildcard, TREE_CMP_LINK, TREE_DRILL, TREE_FOOTPRINT_FILE, TREE_FP_PLACE, TREE_GERBER, TREE_HTML, TREE_LEGACY_PCB, TREE_NET, TREE_PAGE_LAYOUT_DESCR, TREE_PDF, TREE_PROJECT, TREE_REPORT, TREE_SCHEMA, TREE_SCHEMATIC_LIBFILE, TREE_SEXP_PCB, TREE_SVG, and TREE_TXT.

321 {
322  wxString ext;
323 
324  switch( type )
325  {
326  case TREE_PROJECT:
327  ext = ProjectFileWildcard;
328  break;
329 
330  case TREE_SCHEMA:
331  ext = SchematicFileWildcard;
332  break;
333 
334  case TREE_LEGACY_PCB:
335  case TREE_SEXP_PCB:
336  ext = PcbFileWildcard;
337  break;
338 
339  case TREE_GERBER:
340  ext = GerberFileWildcard;
341  break;
342 
343  case TREE_HTML:
344  ext = HtmlFileWildcard;
345  break;
346 
347  case TREE_PDF:
348  ext = PdfFileWildcard;
349  break;
350 
351  case TREE_TXT:
352  ext = TextFileWildcard;
353  break;
354 
355  case TREE_NET:
356  ext = NetlistFileWildcard;
357  break;
358 
359  case TREE_CMP_LINK:
360  ext = ComponentFileWildcard;
361  break;
362 
363  case TREE_REPORT:
364  ext = ReportFileWildcard;
365  break;
366 
367  case TREE_FP_PLACE:
369  break;
370 
371  case TREE_DRILL:
372  ext = DrillFileWildcard;
373  break;
374 
375  case TREE_SVG:
376  ext = SVGFileWildcard;
377  break;
378 
381  break;
382 
383  case TREE_FOOTPRINT_FILE:
385  break;
386 
389  break;
390 
391  default: // Eliminates unnecessary GCC warning.
392  break;
393  }
394 
395  return ext;
396 }
Definition: kicad.h:59
const wxString SchematicLibraryFileWildcard
const wxString PageLayoutDescrFileWildcard
const wxString ProjectFileWildcard
const wxString HtmlFileWildcard
const wxString KiCadFootprintLibFileWildcard
Definition: kicad.h:61
const wxString DrillFileWildcard
const wxString SVGFileWildcard
Definition: kicad.h:68
const wxString NetlistFileWildcard
const wxString PdfFileWildcard
const wxString SchematicFileWildcard
const wxString FootprintPlaceFileWildcard
const wxString ReportFileWildcard
Definition: kicad.h:60
const wxString ComponentFileWildcard
const wxString GerberFileWildcard
const wxString PcbFileWildcard
const wxChar TextFileWildcard[]
const std::vector<wxString>& TREE_PROJECT_FRAME::GetFilters ( )
inlineprivate

Definition at line 148 of file tree_project_frame.h.

References m_filters.

149  {
150  return m_filters;
151  }
std::vector< wxString > m_filters
TREEPROJECT_ITEM * TREE_PROJECT_FRAME::GetItemIdData ( wxTreeItemId  aId)
protected

Function GetItemIdData return the item data corresponding to a wxTreeItemId identifier.

Parameters
aId= the wxTreeItemId identifier.
Returns
a TREEPROJECT_ITEM pointer correspondinfg to item id aId

Definition at line 855 of file tree_project_frame.cpp.

References m_TreeProject.

Referenced by AddItemToTreeProject(), FileWatcherReset(), findSubdirTreeItem(), OnExpand(), and OnFileSystemEvent().

856 {
857  return dynamic_cast<TREEPROJECT_ITEM*>( m_TreeProject->GetItemData( aId ) );
858 }
Class TREEPROJECT_ITEM handles one item (a file or a directory name) for the tree file...
TREEPROJECTFILES * m_TreeProject
TREEPROJECT_ITEM * TREE_PROJECT_FRAME::GetSelectedData ( )
protected

Function GetSelectedData return the item data from item currently selected (highlighted) Note this is not necessary the "clicked" item, because when expanding, collapsing an item this item is not selected.

Definition at line 848 of file tree_project_frame.cpp.

References m_TreeProject.

Referenced by OnCreateNewDirectory(), OnDeleteFile(), OnOpenSelectedFileWithTextEditor(), OnRenameFile(), OnRight(), and OnSelect().

849 {
850  return dynamic_cast<TREEPROJECT_ITEM*>( m_TreeProject->GetItemData
851  ( m_TreeProject->GetSelection() ) );
852 }
Class TREEPROJECT_ITEM handles one item (a file or a directory name) for the tree file...
TREEPROJECTFILES * m_TreeProject
void TREE_PROJECT_FRAME::OnCreateNewDirectory ( wxCommandEvent &  event)
private

Function OnCreateNewDirectory Creates a new subdirectory inside the current kicad project directory the user is prompted to enter a directory name.

Definition at line 178 of file tree_project_frame.cpp.

References Format(), GetChars(), TREEPROJECT_ITEM::GetDir(), KICAD_MANAGER_FRAME::GetProjectFileName(), GetSelectedData(), TREEPROJECT_ITEM::GetType(), m_Parent, m_TreeProject, and TREE_DIRECTORY.

179 {
180  // Get the root directory name:
181  TREEPROJECT_ITEM* treeData = GetSelectedData();
182 
183  if( !treeData )
184  return;
185 
186  TreeFileType rootType = treeData->GetType();
187  wxTreeItemId root;
188 
189  if( TREE_DIRECTORY == rootType )
190  {
191  root = m_TreeProject->GetSelection();
192  }
193  else
194  {
195  root = m_TreeProject->GetItemParent( m_TreeProject->GetSelection() );
196 
197  if( !root.IsOk() )
198  root = m_TreeProject->GetSelection();
199  }
200 
201  wxString prj_dir = wxPathOnly( m_Parent->GetProjectFileName() );
202 
203  // Ask for the new sub directory name
204  wxString curr_dir = treeData->GetDir();
205 
206  if( !curr_dir.IsEmpty() ) // A subdir is selected
207  {
208  // Make this subdir name relative to the current path.
209  // It will be more easy to read by the user, in the next dialog
210  wxFileName fn;
211  fn.AssignDir( curr_dir );
212  fn.MakeRelativeTo( prj_dir );
213  curr_dir = fn.GetPath();
214 
215  if( !curr_dir.IsEmpty() )
216  curr_dir += wxFileName::GetPathSeparator();
217  }
218 
219  wxString msg = wxString::Format( _( "Current project directory:\n%s" ), GetChars( prj_dir ) );
220  wxString subdir = wxGetTextFromUser( msg, _( "Create New Directory" ), curr_dir );
221 
222  if( subdir.IsEmpty() )
223  return;
224 
225  wxString full_dirname = prj_dir + wxFileName::GetPathSeparator() + subdir;
226 
227  if( wxMkdir( full_dirname ) )
228  {
229  // the new itel will be added by the file watcher
230  // AddItemToTreeProject( subdir, root );
231  }
232 }
Class TREEPROJECT_ITEM handles one item (a file or a directory name) for the tree file...
TreeFileType
Definition: kicad.h:52
TREEPROJECTFILES * m_TreeProject
const wxString GetDir() const
TreeFileType GetType() const
KICAD_MANAGER_FRAME * m_Parent
TREEPROJECT_ITEM * GetSelectedData()
Function GetSelectedData return the item data from item currently selected (highlighted) Note this is...
const wxString GetProjectFileName()
Definition: mainframe.cpp:144
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void TREE_PROJECT_FRAME::OnDeleteFile ( wxCommandEvent &  event)
private

Function OnDeleteFile Called via the popup menu, when right clicking on a file name or a directory name to delete the selected file or directory in the tree project.

Definition at line 736 of file tree_project_frame.cpp.

References TREEPROJECT_ITEM::Delete(), and GetSelectedData().

737 {
738  TREEPROJECT_ITEM* tree_data = GetSelectedData();
739 
740  if( !tree_data )
741  return;
742 
743  tree_data->Delete();
744 }
Class TREEPROJECT_ITEM handles one item (a file or a directory name) for the tree file...
bool Delete(bool check=true)
TREEPROJECT_ITEM * GetSelectedData()
Function GetSelectedData return the item data from item currently selected (highlighted) Note this is...
void TREE_PROJECT_FRAME::OnExpand ( wxTreeEvent &  Event)
private

Called on a click on the + or - button of an item with children.

Definition at line 788 of file tree_project_frame.cpp.

References AddItemToTreeProject(), FileWatcherReset(), TREEPROJECT_ITEM::GetFileName(), GetItemIdData(), TREEPROJECT_ITEM::GetType(), TREEPROJECT_ITEM::IsPopulated(), m_TreeProject, name, TREEPROJECT_ITEM::SetPopulated(), and TREE_DIRECTORY.

789 {
790  wxTreeItemId itemId = Event.GetItem();
791  TREEPROJECT_ITEM* tree_data = GetItemIdData( itemId );
792 
793  if( !tree_data )
794  return;
795 
796  if( tree_data->GetType() != TREE_DIRECTORY )
797  return;
798 
799  // explore list of non populated subdirs, and populate them
800  wxTreeItemIdValue cookie;
801  wxTreeItemId kid = m_TreeProject->GetFirstChild( itemId, cookie );
802 
803  bool subdir_populated = false;
804 
805  for( ; kid.IsOk(); kid = m_TreeProject->GetNextChild( itemId, cookie ) )
806  {
807  TREEPROJECT_ITEM* itemData = GetItemIdData( kid );
808 
809  if( !itemData || itemData->GetType() != TREE_DIRECTORY )
810  continue;
811 
812  if( itemData->IsPopulated() )
813  continue;
814 
815  wxString fileName = itemData->GetFileName();
816  wxDir dir( fileName );
817 
818  if( dir.IsOpened() )
819  {
820  wxString dir_filename;
821 
822  if( dir.GetFirst( &dir_filename ) )
823  {
824  do // Add name to tree item, but do not recurse in subdirs:
825  {
826  wxString name = fileName + wxFileName::GetPathSeparator() + dir_filename;
827  AddItemToTreeProject( name, kid, false );
828  } while( dir.GetNext( &dir_filename ) );
829  }
830 
831  itemData->SetPopulated( true ); // set state to populated
832  subdir_populated = true;
833  }
834 
835  // Sort filenames by alphabetic order
836  m_TreeProject->SortChildren( kid );
837  }
838 
839  if( subdir_populated )
840  {
841  #ifndef __WINDOWS__
843  #endif
844  }
845 }
Class TREEPROJECT_ITEM handles one item (a file or a directory name) for the tree file...
TREEPROJECTFILES * m_TreeProject
TreeFileType GetType() const
void FileWatcherReset()
Reinit the watched paths Should be called after opening a new project to rebuild the list of watched ...
TREEPROJECT_ITEM * GetItemIdData(wxTreeItemId aId)
Function GetItemIdData return the item data corresponding to a wxTreeItemId identifier.
const char * name
const wxString & GetFileName() const
bool AddItemToTreeProject(const wxString &aName, wxTreeItemId &aRoot, bool aRecurse=true)
Function AddItemToTreeProject.
void SetPopulated(bool aValue)
void TREE_PROJECT_FRAME::OnFileSystemEvent ( wxFileSystemWatcherEvent &  event)
private

called when a file or directory is modified/created/deleted The tree project is modified when a file or directory is created/deleted/renamed to reflect the file change

Definition at line 919 of file tree_project_frame.cpp.

References AddItemToTreeProject(), findSubdirTreeItem(), TREEPROJECT_ITEM::GetFileName(), GetItemIdData(), and m_TreeProject.

Referenced by TREE_PROJECT_FRAME().

920 {
921  wxFileName pathModified = event.GetPath();
922  wxString subdir = pathModified.GetPath();
923  wxString fn = pathModified.GetFullPath();
924 
925  switch( event.GetChangeType() )
926  {
927  case wxFSW_EVENT_DELETE:
928  break;
929 
930  case wxFSW_EVENT_CREATE:
931  break;
932 
933  case wxFSW_EVENT_RENAME:
934  break;
935 
936  case wxFSW_EVENT_MODIFY:
937  case wxFSW_EVENT_ACCESS:
938  default:
939  return;
940  }
941 
942  wxTreeItemId root_id = findSubdirTreeItem( subdir );
943 
944  if( !root_id.IsOk() )
945  return;
946 
947  wxTreeItemIdValue cookie; // dummy variable needed by GetFirstChild()
948  wxTreeItemId kid = m_TreeProject->GetFirstChild( root_id, cookie );
949 
950  switch( event.GetChangeType() )
951  {
952  case wxFSW_EVENT_CREATE:
953  AddItemToTreeProject( pathModified.GetFullPath(), root_id, false );
954  break;
955 
956  case wxFSW_EVENT_DELETE:
957  while( kid.IsOk() )
958  {
959  TREEPROJECT_ITEM* itemData = GetItemIdData( kid );
960 
961  if( itemData && itemData->GetFileName() == fn )
962  {
963  m_TreeProject->Delete( kid );
964  return;
965  }
966  kid = m_TreeProject->GetNextChild( root_id, cookie );
967  }
968  break;
969 
970  case wxFSW_EVENT_RENAME :
971  {
972  wxFileName newpath = event.GetNewPath();
973  wxString newfn = newpath.GetFullPath();
974 
975  while( kid.IsOk() )
976  {
977  TREEPROJECT_ITEM* itemData = GetItemIdData( kid );
978 
979  if( itemData && itemData->GetFileName() == fn )
980  {
981  m_TreeProject->Delete( kid );
982  break;
983  }
984 
985  kid = m_TreeProject->GetNextChild( root_id, cookie );
986  }
987 
988  AddItemToTreeProject( newfn, root_id, false );
989  }
990  break;
991  }
992 
993  // Sort filenames by alphabetic order
994  m_TreeProject->SortChildren( root_id );
995 }
Class TREEPROJECT_ITEM handles one item (a file or a directory name) for the tree file...
TREEPROJECTFILES * m_TreeProject
wxTreeItemId findSubdirTreeItem(const wxString &aSubDir)
Function findSubdirTreeItem searches for the item in tree project which is the node of the subdirecto...
TREEPROJECT_ITEM * GetItemIdData(wxTreeItemId aId)
Function GetItemIdData return the item data corresponding to a wxTreeItemId identifier.
const wxString & GetFileName() const
bool AddItemToTreeProject(const wxString &aName, wxTreeItemId &aRoot, bool aRecurse=true)
Function AddItemToTreeProject.
void TREE_PROJECT_FRAME::OnOpenSelectedFileWithTextEditor ( wxCommandEvent &  event)
private

Function OnOpenSelectedFileWithTextEditor Called via the popup menu, when right clicking on a file name Call the text editor to open the selected file in the tree project.

Definition at line 717 of file tree_project_frame.cpp.

References AddDelimiterString(), ExecuteFile(), PGM_BASE::GetEditorName(), TREEPROJECT_ITEM::GetFileName(), GetSelectedData(), TREEPROJECT_ITEM::GetType(), Pgm(), and TREE_DIRECTORY.

718 {
719  TREEPROJECT_ITEM* tree_data = GetSelectedData();
720 
721  if( !tree_data )
722  return;
723 
724  if( tree_data->GetType() == TREE_DIRECTORY )
725  return;
726 
727  wxString fullFileName = tree_data->GetFileName();
728  AddDelimiterString( fullFileName );
729  wxString editorname = Pgm().GetEditorName();
730 
731  if( !editorname.IsEmpty() )
732  ExecuteFile( this, editorname, fullFileName );
733 }
Class TREEPROJECT_ITEM handles one item (a file or a directory name) for the tree file...
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
TreeFileType GetType() const
void AddDelimiterString(wxString &string)
Function AddDelimiterString Add un " to the start and the end of string (if not already done)...
Definition: gestfich.cpp:44
TREEPROJECT_ITEM * GetSelectedData()
Function GetSelectedData return the item data from item currently selected (highlighted) Note this is...
const wxString & GetFileName() const
VTBL_ENTRY const wxString & GetEditorName(bool aCanShowFileChooser=true)
Return the preferred editor name.
Definition: pgm_base.cpp:336
int ExecuteFile(wxWindow *frame, const wxString &ExecFile, const wxString &param, wxProcess *callback)
Function ExecuteFile calls the executable file ExecFile with the command line parameters param...
Definition: gestfich.cpp:208
void TREE_PROJECT_FRAME::OnRenameFile ( wxCommandEvent &  event)
private

Function OnRenameFile Called via the popup menu, when right clicking on a file name or a directory name to rename the selected file or directory in the tree project.

Definition at line 747 of file tree_project_frame.cpp.

References Format(), GetChars(), TREEPROJECT_ITEM::GetFileName(), GetSelectedData(), m_TreeProject, and TREEPROJECT_ITEM::Rename().

748 {
749  wxTreeItemId curr_item = m_TreeProject->GetSelection();
750  TREEPROJECT_ITEM* tree_data = GetSelectedData();
751 
752  if( !tree_data )
753  return;
754 
755  wxString buffer = m_TreeProject->GetItemText( curr_item );
756  wxString msg = wxString::Format(
757  _( "Change filename: '%s'" ),
758  GetChars( tree_data->GetFileName() ) );
759 
760  wxTextEntryDialog dlg( this, msg, _( "Change filename" ), buffer );
761 
762  if( dlg.ShowModal() != wxID_OK )
763  return; // canceled by user
764 
765  buffer = dlg.GetValue();
766  buffer.Trim( true );
767  buffer.Trim( false );
768 
769  if( buffer.IsEmpty() )
770  return; // empty file name not allowed
771 
772  if( tree_data->Rename( buffer, true ) )
773  m_TreeProject->SetItemText( curr_item, buffer );
774 }
Class TREEPROJECT_ITEM handles one item (a file or a directory name) for the tree file...
TREEPROJECTFILES * m_TreeProject
TREEPROJECT_ITEM * GetSelectedData()
Function GetSelectedData return the item data from item currently selected (highlighted) Note this is...
bool Rename(const wxString &name, bool check=true)
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
const wxString & GetFileName() const
void TREE_PROJECT_FRAME::OnRight ( wxTreeEvent &  Event)
private

Called on a right click on an item.

Definition at line 657 of file tree_project_frame.cpp.

References AddMenuItem(), TREEPROJECT_ITEM::GetFileName(), GetSelectedData(), TREEPROJECT_ITEM::GetType(), ID_PROJECT_DELETE, ID_PROJECT_NEWDIR, ID_PROJECT_RENAME, ID_PROJECT_TXTEDIT, KiBitmap(), m_TreeProject, TREE_DIRECTORY, and TREE_PROJECT.

658 {
659  int tree_id;
660  TREEPROJECT_ITEM* tree_data;
661  wxString fullFileName;
662  wxTreeItemId curr_item = Event.GetItem();
663 
664  // Ensure item is selected (Under Windows right click does not select the item)
665  m_TreeProject->SelectItem( curr_item );
666 
667  tree_data = GetSelectedData();
668 
669  if( !tree_data )
670  return;
671 
672  tree_id = tree_data->GetType();
673  fullFileName = tree_data->GetFileName();
674 
675  wxMenu popupMenu;
676 
677  switch( tree_id )
678  {
679  case TREE_PROJECT:
680  AddMenuItem( &popupMenu, ID_PROJECT_NEWDIR,
681  _( "New D&irectory" ),
682  _( "Create a New Directory" ),
683  KiBitmap( directory_xpm ) );
684  break;
685 
686  case TREE_DIRECTORY:
687  AddMenuItem( &popupMenu, ID_PROJECT_NEWDIR,
688  _( "New D&irectory" ),
689  _( "Create a New Directory" ),
690  KiBitmap( directory_xpm ) );
691  AddMenuItem( &popupMenu, ID_PROJECT_DELETE,
692  _( "&Delete Directory" ),
693  _( "Delete the Directory and its content" ),
694  KiBitmap( delete_xpm ) );
695  break;
696 
697  default:
698  AddMenuItem( &popupMenu, ID_PROJECT_TXTEDIT,
699  _( "&Edit in a text editor" ),
700  _( "Open the file in a Text Editor" ),
701  KiBitmap( editor_xpm ) );
702  AddMenuItem( &popupMenu, ID_PROJECT_RENAME,
703  _( "&Rename file" ),
704  _( "Rename file" ),
705  KiBitmap( right_xpm ) );
706  AddMenuItem( &popupMenu, ID_PROJECT_DELETE,
707  _( "&Delete File" ),
708  _( "Delete the Directory and its content" ),
709  KiBitmap( delete_xpm ) );
710  break;
711  }
712 
713  PopupMenu( &popupMenu );
714 }
Class TREEPROJECT_ITEM handles one item (a file or a directory name) for the tree file...
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Function AddMenuItem is an inline helper function to create and insert a menu item with an icon into ...
Definition: bitmap.cpp:55
TREEPROJECTFILES * m_TreeProject
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
TreeFileType GetType() const
TREEPROJECT_ITEM * GetSelectedData()
Function GetSelectedData return the item data from item currently selected (highlighted) Note this is...
const wxString & GetFileName() const
void TREE_PROJECT_FRAME::OnSelect ( wxTreeEvent &  Event)
private

Called on a double click on an item.

Definition at line 777 of file tree_project_frame.cpp.

References TREEPROJECT_ITEM::Activate(), and GetSelectedData().

778 {
779  TREEPROJECT_ITEM* tree_data = GetSelectedData();
780 
781  if( !tree_data )
782  return;
783 
784  tree_data->Activate( this );
785 }
Class TREEPROJECT_ITEM handles one item (a file or a directory name) for the tree file...
void Activate(TREE_PROJECT_FRAME *prjframe)
TREEPROJECT_ITEM * GetSelectedData()
Function GetSelectedData return the item data from item currently selected (highlighted) Note this is...
void TREE_PROJECT_FRAME::ReCreateTreePrj ( )

Create or modify the tree showing project file names.

Definition at line 584 of file tree_project_frame.cpp.

References AddItemToTreeProject(), KICAD_MANAGER_FRAME::GetProjectFileName(), m_Parent, m_root, m_TreeProject, name, NAMELESS_PROJECT, ProjectFileExtension, TREE_PROJECT, and TREEPROJECT_ITEM.

Referenced by KICAD_MANAGER_FRAME::OnLoadProject(), KICAD_MANAGER_FRAME::OnRefresh(), and KICAD_MANAGER_FRAME::ReCreateTreePrj().

585 {
586  wxTreeItemId rootcellule;
587  bool prjOpened = false;
588  wxString pro_dir = m_Parent->GetProjectFileName();
589 
590  if( !m_TreeProject )
591  m_TreeProject = new TREEPROJECTFILES( this );
592  else
593  m_TreeProject->DeleteAllItems();
594 
595  if( !pro_dir ) // This is empty from TREE_PROJECT_FRAME constructor
596  return;
597 
598  wxFileName fn = pro_dir;
599 
600  if( !fn.IsOk() )
601  {
602  fn.Clear();
603  fn.SetPath( wxStandardPaths::Get().GetDocumentsDir() );
604  fn.SetName( NAMELESS_PROJECT );
605  fn.SetExt( ProjectFileExtension );
606  }
607 
608  prjOpened = fn.FileExists();
609 
610  // root tree:
611  m_root = rootcellule = m_TreeProject->AddRoot( fn.GetFullName(),
612  TREE_PROJECT - 1,
613  TREE_PROJECT - 1 );
614 
615  m_TreeProject->SetItemBold( rootcellule, true );
616 
617  m_TreeProject->SetItemData( rootcellule,
619  fn.GetFullPath(),
620  m_TreeProject ) );
621 
622  // Now adding all current files if available
623  if( prjOpened )
624  {
625  pro_dir = wxPathOnly( m_Parent->GetProjectFileName() );
626  wxDir dir( pro_dir );
627 
628  if( dir.IsOpened() ) // protected dirs will not open, see "man opendir()"
629  {
630  wxString filename;
631  bool cont = dir.GetFirst( &filename );
632 
633  while( cont )
634  {
635  if( filename != fn.GetFullName() )
636  {
637  wxString name = dir.GetName() + wxFileName::GetPathSeparator() + filename;
638  AddItemToTreeProject( name, m_root );
639  }
640 
641  cont = dir.GetNext( &filename );
642  }
643  }
644  }
645  else
646  {
647  m_TreeProject->AppendItem( m_root, wxT( "Empty project" ) );
648  }
649 
650  m_TreeProject->Expand( rootcellule );
651 
652  // Sort filenames by alphabetic order
653  m_TreeProject->SortChildren( m_root );
654 }
const wxString ProjectFileExtension
Class TREEPROJECTFILES This is the class to show (as a tree) the files in the project directory...
TREEPROJECTFILES * m_TreeProject
friend class TREEPROJECT_ITEM
KICAD_MANAGER_FRAME * m_Parent
const wxString GetProjectFileName()
Definition: mainframe.cpp:144
const char * name
bool AddItemToTreeProject(const wxString &aName, wxTreeItemId &aRoot, bool aRecurse=true)
Function AddItemToTreeProject.
#define NAMELESS_PROJECT
default name for nameless projects
Definition: common.h:73
void TREE_PROJECT_FRAME::RemoveFilter ( const wxString &  filter)
private

Definition at line 165 of file tree_project_frame.cpp.

References m_filters.

166 {
167  for( unsigned int i = 0; i < m_filters.size(); i++ )
168  {
169  if( filter == m_filters[i] )
170  {
171  m_filters.erase( m_filters.begin() + i );
172  return;
173  }
174  }
175 }
std::vector< wxString > m_filters

Friends And Related Function Documentation

friend class TREEPROJECT_ITEM
friend

Definition at line 49 of file tree_project_frame.h.

Referenced by AddItemToTreeProject(), and ReCreateTreePrj().

Member Data Documentation

std::vector<wxString> TREE_PROJECT_FRAME::m_filters
private

Definition at line 56 of file tree_project_frame.h.

Referenced by AddItemToTreeProject(), GetFilters(), and RemoveFilter().

wxTreeItemId TREE_PROJECT_FRAME::m_root
private
wxFileSystemWatcher* TREE_PROJECT_FRAME::m_watcher
private

Definition at line 57 of file tree_project_frame.h.

Referenced by FileWatcherReset(), and ~TREE_PROJECT_FRAME().


The documentation for this class was generated from the following files: