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 129 of file tree_project_frame.cpp.

References OnFileSystemEvent(), and s_allowedExtensionsToList.

129  :
130  wxSashLayoutWindow( parent, ID_LEFT_FRAME,
131  wxDefaultPosition, wxDefaultSize,
132  wxNO_BORDER | wxTAB_TRAVERSAL )
133 {
134  m_Parent = parent;
135  m_TreeProject = NULL;
136 
137  m_watcher = NULL;
138  Connect( wxEVT_FSWATCHER,
139  wxFileSystemWatcherEventHandler( TREE_PROJECT_FRAME::OnFileSystemEvent ) );
140 
141  /*
142  * Filtering is now inverted: the filters are actually used to _enable_ support
143  * for a given file type.
144  */
145 
146  // NOTE: sch filter must be first because of a test in AddFile() below
147  m_filters.push_back( wxT( "^.*\\.sch$" ) );
148 
149  for( int ii = 0; s_allowedExtensionsToList[ii] != NULL; ii++ )
150  m_filters.push_back( s_allowedExtensionsToList[ii] );
151 
152  m_filters.push_back( wxT( "^no KiCad files found" ) );
153 
154  ReCreateTreePrj();
155 }
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 158 of file tree_project_frame.cpp.

References m_watcher.

159 {
160  if( m_watcher )
161  {
162  m_watcher->RemoveAll();
163  m_watcher->SetOwner( NULL );
164  delete m_watcher;
165  }
166 }
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 403 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().

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

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

866 {
867  wxString prj_dir = wxPathOnly( m_Parent->GetProjectFileName() );
868 
869  // If the subdir is the current working directory, return m_root
870  // in main list:
871  if( prj_dir == aSubDir )
872  return m_root;
873 
874  // The subdir is in the main tree or in a subdir: Locate it
875  wxTreeItemIdValue cookie;
876  wxTreeItemId root_id = m_root;
877  std::stack < wxTreeItemId > subdirs_id;
878 
879  wxTreeItemId kid = m_TreeProject->GetFirstChild( root_id, cookie );
880 
881  while( 1 )
882  {
883  if( ! kid.IsOk() )
884  {
885  if( subdirs_id.empty() ) // all items were explored
886  {
887  root_id = kid; // Not found: return an invalid wxTreeItemId
888  break;
889  }
890  else
891  {
892  root_id = subdirs_id.top();
893  subdirs_id.pop();
894  kid = m_TreeProject->GetFirstChild( root_id, cookie );
895 
896  if( ! kid.IsOk() )
897  continue;
898  }
899  }
900 
901  TREEPROJECT_ITEM* itemData = GetItemIdData( kid );
902 
903  if( itemData && ( itemData->GetType() == TREE_DIRECTORY ) )
904  {
905  if( itemData->GetFileName() == aSubDir ) // Found!
906  {
907  root_id = kid;
908  break;
909  }
910 
911  // kid is a subdir, push in list to explore it later
912  if( itemData->IsPopulated() )
913  subdirs_id.push( kid );
914  }
915 
916  kid = m_TreeProject->GetNextChild( root_id, cookie );
917  }
918 
919  return root_id;
920 }
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:147
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 239 of file tree_project_frame.cpp.

References ComponentFileExtension, DrillFileExtension, FootprintPlaceFileExtension, GerberFileExtensionWildCard(), 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().

240 {
241  wxString ext;
242 
243  switch( type )
244  {
245  case TREE_PROJECT:
246  ext = ProjectFileExtension;
247  break;
248 
249  case TREE_SCHEMA:
251  break;
252 
253  case TREE_LEGACY_PCB:
255  break;
256 
257  case TREE_SEXP_PCB:
258  ext = KiCadPcbFileExtension;
259  break;
260 
261  case TREE_GERBER:
263  break;
264 
265  case TREE_HTML:
266  ext = HtmlFileExtension;
267  break;
268 
269  case TREE_PDF:
270  ext = PdfFileExtension;
271  break;
272 
273  case TREE_TXT:
274  ext = TextFileExtension;
275  break;
276 
277  case TREE_NET:
278  ext = NetlistFileExtension;
279  break;
280 
281  case TREE_CMP_LINK:
283  break;
284 
285  case TREE_REPORT:
286  ext = ReportFileExtension;
287  break;
288 
289  case TREE_FP_PLACE:
291  break;
292 
293  case TREE_DRILL:
294  ext = DrillFileExtension;
295  break;
296 
297  case TREE_SVG:
298  ext = SVGFileExtension;
299  break;
300 
303  break;
304 
305  case TREE_FOOTPRINT_FILE:
307  break;
308 
311  break;
312 
313  default: // Eliminates unnecessary GCC warning.
314  break;
315  }
316 
317  return ext;
318 }
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 GerberFileExtensionWildCard(".((gbr|gbrjob|(gb|gt)[alops])|pho)")
const wxString SVGFileExtension
const wxString PdfFileExtension
const wxString FootprintPlaceFileExtension
const wxString SchematicLibraryFileExtension
const wxString SchematicFileExtension
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 324 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.

325 {
326  wxString ext;
327 
328  switch( type )
329  {
330  case TREE_PROJECT:
331  ext = ProjectFileWildcard;
332  break;
333 
334  case TREE_SCHEMA:
335  ext = SchematicFileWildcard;
336  break;
337 
338  case TREE_LEGACY_PCB:
339  case TREE_SEXP_PCB:
340  ext = PcbFileWildcard;
341  break;
342 
343  case TREE_GERBER:
344  ext = GerberFileWildcard;
345  break;
346 
347  case TREE_HTML:
348  ext = HtmlFileWildcard;
349  break;
350 
351  case TREE_PDF:
352  ext = PdfFileWildcard;
353  break;
354 
355  case TREE_TXT:
356  ext = TextFileWildcard;
357  break;
358 
359  case TREE_NET:
360  ext = NetlistFileWildcard;
361  break;
362 
363  case TREE_CMP_LINK:
364  ext = ComponentFileWildcard;
365  break;
366 
367  case TREE_REPORT:
368  ext = ReportFileWildcard;
369  break;
370 
371  case TREE_FP_PLACE:
373  break;
374 
375  case TREE_DRILL:
376  ext = DrillFileWildcard;
377  break;
378 
379  case TREE_SVG:
380  ext = SVGFileWildcard;
381  break;
382 
385  break;
386 
387  case TREE_FOOTPRINT_FILE:
389  break;
390 
393  break;
394 
395  default: // Eliminates unnecessary GCC warning.
396  break;
397  }
398 
399  return ext;
400 }
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 859 of file tree_project_frame.cpp.

References m_TreeProject.

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

860 {
861  return dynamic_cast<TREEPROJECT_ITEM*>( m_TreeProject->GetItemData( aId ) );
862 }
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 852 of file tree_project_frame.cpp.

References m_TreeProject.

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

853 {
854  return dynamic_cast<TREEPROJECT_ITEM*>( m_TreeProject->GetItemData
855  ( m_TreeProject->GetSelection() ) );
856 }
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 182 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.

183 {
184  // Get the root directory name:
185  TREEPROJECT_ITEM* treeData = GetSelectedData();
186 
187  if( !treeData )
188  return;
189 
190  TreeFileType rootType = treeData->GetType();
191  wxTreeItemId root;
192 
193  if( TREE_DIRECTORY == rootType )
194  {
195  root = m_TreeProject->GetSelection();
196  }
197  else
198  {
199  root = m_TreeProject->GetItemParent( m_TreeProject->GetSelection() );
200 
201  if( !root.IsOk() )
202  root = m_TreeProject->GetSelection();
203  }
204 
205  wxString prj_dir = wxPathOnly( m_Parent->GetProjectFileName() );
206 
207  // Ask for the new sub directory name
208  wxString curr_dir = treeData->GetDir();
209 
210  if( !curr_dir.IsEmpty() ) // A subdir is selected
211  {
212  // Make this subdir name relative to the current path.
213  // It will be more easy to read by the user, in the next dialog
214  wxFileName fn;
215  fn.AssignDir( curr_dir );
216  fn.MakeRelativeTo( prj_dir );
217  curr_dir = fn.GetPath();
218 
219  if( !curr_dir.IsEmpty() )
220  curr_dir += wxFileName::GetPathSeparator();
221  }
222 
223  wxString msg = wxString::Format( _( "Current project directory:\n%s" ), GetChars( prj_dir ) );
224  wxString subdir = wxGetTextFromUser( msg, _( "Create New Directory" ), curr_dir );
225 
226  if( subdir.IsEmpty() )
227  return;
228 
229  wxString full_dirname = prj_dir + wxFileName::GetPathSeparator() + subdir;
230 
231  if( wxMkdir( full_dirname ) )
232  {
233  // the new itel will be added by the file watcher
234  // AddItemToTreeProject( subdir, root );
235  }
236 }
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:147
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 740 of file tree_project_frame.cpp.

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

741 {
742  TREEPROJECT_ITEM* tree_data = GetSelectedData();
743 
744  if( !tree_data )
745  return;
746 
747  tree_data->Delete();
748 }
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 792 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.

793 {
794  wxTreeItemId itemId = Event.GetItem();
795  TREEPROJECT_ITEM* tree_data = GetItemIdData( itemId );
796 
797  if( !tree_data )
798  return;
799 
800  if( tree_data->GetType() != TREE_DIRECTORY )
801  return;
802 
803  // explore list of non populated subdirs, and populate them
804  wxTreeItemIdValue cookie;
805  wxTreeItemId kid = m_TreeProject->GetFirstChild( itemId, cookie );
806 
807  bool subdir_populated = false;
808 
809  for( ; kid.IsOk(); kid = m_TreeProject->GetNextChild( itemId, cookie ) )
810  {
811  TREEPROJECT_ITEM* itemData = GetItemIdData( kid );
812 
813  if( !itemData || itemData->GetType() != TREE_DIRECTORY )
814  continue;
815 
816  if( itemData->IsPopulated() )
817  continue;
818 
819  wxString fileName = itemData->GetFileName();
820  wxDir dir( fileName );
821 
822  if( dir.IsOpened() )
823  {
824  wxString dir_filename;
825 
826  if( dir.GetFirst( &dir_filename ) )
827  {
828  do // Add name to tree item, but do not recurse in subdirs:
829  {
830  wxString name = fileName + wxFileName::GetPathSeparator() + dir_filename;
831  AddItemToTreeProject( name, kid, false );
832  } while( dir.GetNext( &dir_filename ) );
833  }
834 
835  itemData->SetPopulated( true ); // set state to populated
836  subdir_populated = true;
837  }
838 
839  // Sort filenames by alphabetic order
840  m_TreeProject->SortChildren( kid );
841  }
842 
843  if( subdir_populated )
844  {
845  #ifndef __WINDOWS__
847  #endif
848  }
849 }
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 923 of file tree_project_frame.cpp.

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

Referenced by TREE_PROJECT_FRAME().

924 {
925  wxFileName pathModified = event.GetPath();
926  wxString subdir = pathModified.GetPath();
927  wxString fn = pathModified.GetFullPath();
928 
929  switch( event.GetChangeType() )
930  {
931  case wxFSW_EVENT_DELETE:
932  break;
933 
934  case wxFSW_EVENT_CREATE:
935  break;
936 
937  case wxFSW_EVENT_RENAME:
938  break;
939 
940  case wxFSW_EVENT_MODIFY:
941  case wxFSW_EVENT_ACCESS:
942  default:
943  return;
944  }
945 
946  wxTreeItemId root_id = findSubdirTreeItem( subdir );
947 
948  if( !root_id.IsOk() )
949  return;
950 
951  wxTreeItemIdValue cookie; // dummy variable needed by GetFirstChild()
952  wxTreeItemId kid = m_TreeProject->GetFirstChild( root_id, cookie );
953 
954  switch( event.GetChangeType() )
955  {
956  case wxFSW_EVENT_CREATE:
957  AddItemToTreeProject( pathModified.GetFullPath(), root_id, false );
958  break;
959 
960  case wxFSW_EVENT_DELETE:
961  while( kid.IsOk() )
962  {
963  TREEPROJECT_ITEM* itemData = GetItemIdData( kid );
964 
965  if( itemData && itemData->GetFileName() == fn )
966  {
967  m_TreeProject->Delete( kid );
968  return;
969  }
970  kid = m_TreeProject->GetNextChild( root_id, cookie );
971  }
972  break;
973 
974  case wxFSW_EVENT_RENAME :
975  {
976  wxFileName newpath = event.GetNewPath();
977  wxString newfn = newpath.GetFullPath();
978 
979  while( kid.IsOk() )
980  {
981  TREEPROJECT_ITEM* itemData = GetItemIdData( kid );
982 
983  if( itemData && itemData->GetFileName() == fn )
984  {
985  m_TreeProject->Delete( kid );
986  break;
987  }
988 
989  kid = m_TreeProject->GetNextChild( root_id, cookie );
990  }
991 
992  AddItemToTreeProject( newfn, root_id, false );
993  }
994  break;
995  }
996 
997  // Sort filenames by alphabetic order
998  m_TreeProject->SortChildren( root_id );
999 }
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 721 of file tree_project_frame.cpp.

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

722 {
723  TREEPROJECT_ITEM* tree_data = GetSelectedData();
724 
725  if( !tree_data )
726  return;
727 
728  if( tree_data->GetType() == TREE_DIRECTORY )
729  return;
730 
731  wxString fullFileName = tree_data->GetFileName();
732  AddDelimiterString( fullFileName );
733  wxString editorname = Pgm().GetEditorName();
734 
735  if( !editorname.IsEmpty() )
736  ExecuteFile( this, editorname, fullFileName );
737 }
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:338
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 751 of file tree_project_frame.cpp.

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

752 {
753  wxTreeItemId curr_item = m_TreeProject->GetSelection();
754  TREEPROJECT_ITEM* tree_data = GetSelectedData();
755 
756  if( !tree_data )
757  return;
758 
759  wxString buffer = m_TreeProject->GetItemText( curr_item );
760  wxString msg = wxString::Format(
761  _( "Change filename: '%s'" ),
762  GetChars( tree_data->GetFileName() ) );
763 
764  wxTextEntryDialog dlg( this, msg, _( "Change filename" ), buffer );
765 
766  if( dlg.ShowModal() != wxID_OK )
767  return; // canceled by user
768 
769  buffer = dlg.GetValue();
770  buffer.Trim( true );
771  buffer.Trim( false );
772 
773  if( buffer.IsEmpty() )
774  return; // empty file name not allowed
775 
776  if( tree_data->Rename( buffer, true ) )
777  m_TreeProject->SetItemText( curr_item, buffer );
778 }
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 661 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.

662 {
663  int tree_id;
664  TREEPROJECT_ITEM* tree_data;
665  wxString fullFileName;
666  wxTreeItemId curr_item = Event.GetItem();
667 
668  // Ensure item is selected (Under Windows right click does not select the item)
669  m_TreeProject->SelectItem( curr_item );
670 
671  tree_data = GetSelectedData();
672 
673  if( !tree_data )
674  return;
675 
676  tree_id = tree_data->GetType();
677  fullFileName = tree_data->GetFileName();
678 
679  wxMenu popupMenu;
680 
681  switch( tree_id )
682  {
683  case TREE_PROJECT:
684  AddMenuItem( &popupMenu, ID_PROJECT_NEWDIR,
685  _( "New D&irectory" ),
686  _( "Create a New Directory" ),
687  KiBitmap( directory_xpm ) );
688  break;
689 
690  case TREE_DIRECTORY:
691  AddMenuItem( &popupMenu, ID_PROJECT_NEWDIR,
692  _( "New D&irectory" ),
693  _( "Create a New Directory" ),
694  KiBitmap( directory_xpm ) );
695  AddMenuItem( &popupMenu, ID_PROJECT_DELETE,
696  _( "&Delete Directory" ),
697  _( "Delete the Directory and its content" ),
698  KiBitmap( delete_xpm ) );
699  break;
700 
701  default:
702  AddMenuItem( &popupMenu, ID_PROJECT_TXTEDIT,
703  _( "&Edit in a text editor" ),
704  _( "Open the file in a Text Editor" ),
705  KiBitmap( editor_xpm ) );
706  AddMenuItem( &popupMenu, ID_PROJECT_RENAME,
707  _( "&Rename file" ),
708  _( "Rename file" ),
709  KiBitmap( right_xpm ) );
710  AddMenuItem( &popupMenu, ID_PROJECT_DELETE,
711  _( "&Delete File" ),
712  _( "Delete the Directory and its content" ),
713  KiBitmap( delete_xpm ) );
714  break;
715  }
716 
717  PopupMenu( &popupMenu );
718 }
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 781 of file tree_project_frame.cpp.

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

782 {
783  TREEPROJECT_ITEM* tree_data = GetSelectedData();
784 
785  if( !tree_data )
786  return;
787 
788  tree_data->Activate( this );
789 }
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 588 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::LoadProject(), KICAD_MANAGER_FRAME::OnRefresh(), and KICAD_MANAGER_FRAME::ReCreateTreePrj().

589 {
590  wxTreeItemId rootcellule;
591  bool prjOpened = false;
592  wxString pro_dir = m_Parent->GetProjectFileName();
593 
594  if( !m_TreeProject )
595  m_TreeProject = new TREEPROJECTFILES( this );
596  else
597  m_TreeProject->DeleteAllItems();
598 
599  if( !pro_dir ) // This is empty from TREE_PROJECT_FRAME constructor
600  return;
601 
602  wxFileName fn = pro_dir;
603 
604  if( !fn.IsOk() )
605  {
606  fn.Clear();
607  fn.SetPath( wxStandardPaths::Get().GetDocumentsDir() );
608  fn.SetName( NAMELESS_PROJECT );
609  fn.SetExt( ProjectFileExtension );
610  }
611 
612  prjOpened = fn.FileExists();
613 
614  // root tree:
615  m_root = rootcellule = m_TreeProject->AddRoot( fn.GetFullName(),
616  TREE_PROJECT - 1,
617  TREE_PROJECT - 1 );
618 
619  m_TreeProject->SetItemBold( rootcellule, true );
620 
621  m_TreeProject->SetItemData( rootcellule,
623  fn.GetFullPath(),
624  m_TreeProject ) );
625 
626  // Now adding all current files if available
627  if( prjOpened )
628  {
629  pro_dir = wxPathOnly( m_Parent->GetProjectFileName() );
630  wxDir dir( pro_dir );
631 
632  if( dir.IsOpened() ) // protected dirs will not open, see "man opendir()"
633  {
634  wxString filename;
635  bool cont = dir.GetFirst( &filename );
636 
637  while( cont )
638  {
639  if( filename != fn.GetFullName() )
640  {
641  wxString name = dir.GetName() + wxFileName::GetPathSeparator() + filename;
642  AddItemToTreeProject( name, m_root );
643  }
644 
645  cont = dir.GetNext( &filename );
646  }
647  }
648  }
649  else
650  {
651  m_TreeProject->AppendItem( m_root, wxT( "Empty project" ) );
652  }
653 
654  m_TreeProject->Expand( rootcellule );
655 
656  // Sort filenames by alphabetic order
657  m_TreeProject->SortChildren( m_root );
658 }
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:147
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 169 of file tree_project_frame.cpp.

References m_filters.

170 {
171  for( unsigned int i = 0; i < m_filters.size(); i++ )
172  {
173  if( filter == m_filters[i] )
174  {
175  m_filters.erase( m_filters.begin() + i );
176  return;
177  }
178  }
179 }
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: