2012-08-29 12:40:09 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2020-03-16 13:04:50 +00:00
|
|
|
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-08-29 12:40:09 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2016-02-24 21:36:52 +00:00
|
|
|
/**
|
|
|
|
* @file tree_project_frame.cpp
|
|
|
|
* @brief Function to build the tree of files in the current project directory
|
|
|
|
*/
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2016-02-24 21:36:52 +00:00
|
|
|
|
|
|
|
#include <stack>
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <wx/regex.h>
|
2015-09-25 19:38:09 +00:00
|
|
|
#include <wx/stdpaths.h>
|
2016-02-24 21:36:52 +00:00
|
|
|
#include <wx/string.h>
|
|
|
|
|
|
|
|
#include <bitmaps.h>
|
|
|
|
#include <gestfich.h>
|
2012-04-09 09:16:47 +00:00
|
|
|
#include <menus_helpers.h>
|
2018-10-17 19:03:33 +00:00
|
|
|
#include <trace_helpers.h>
|
2016-02-24 21:36:52 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
|
|
|
|
2018-02-07 13:16:05 +00:00
|
|
|
#include "treeproject_item.h"
|
|
|
|
#include "treeprojectfiles.h"
|
2016-02-24 21:36:52 +00:00
|
|
|
#include "pgm_kicad.h"
|
2019-05-25 19:39:42 +00:00
|
|
|
#include "kicad_id.h"
|
2016-02-24 21:36:52 +00:00
|
|
|
|
|
|
|
#include "tree_project_frame.h"
|
2007-05-28 18:09:49 +00:00
|
|
|
|
|
|
|
|
2010-02-20 13:20:55 +00:00
|
|
|
/* Note about the tree project build process:
|
2010-02-17 17:47:12 +00:00
|
|
|
* Building the tree project can be *very* long if there are a lot of subdirectories
|
|
|
|
* in the working directory.
|
2010-05-29 18:34:18 +00:00
|
|
|
* Unfortunately, this happens easily if the project file *.pro is in the home directory
|
2010-02-20 13:20:55 +00:00
|
|
|
* So the tree project is built "on demand":
|
|
|
|
* First the tree is built from the current directory and shows files and subdirs.
|
|
|
|
* > First level subdirs trees are built (i.e subdirs contents are not read)
|
|
|
|
* > When expanding a subdir, each subdir contains is read,
|
|
|
|
* and the corresponding sub tree is populated on the fly.
|
2010-02-17 17:47:12 +00:00
|
|
|
*/
|
|
|
|
|
2008-05-30 18:06:21 +00:00
|
|
|
// list of files extensions listed in the tree project window
|
|
|
|
// Add extensions in a compatible regex format to see others files types
|
2019-12-05 19:35:37 +00:00
|
|
|
static const wxChar* s_allowedExtensionsToList[] = {
|
2008-05-30 18:06:21 +00:00
|
|
|
wxT( "^.*\\.pro$" ),
|
2020-07-07 00:14:27 +00:00
|
|
|
wxT( "^.*\\.kicad_pro$" ),
|
2008-05-30 18:06:21 +00:00
|
|
|
wxT( "^.*\\.pdf$" ),
|
2020-04-07 14:00:16 +00:00
|
|
|
wxT( "^.*\\.sch$" ), // Legacy Eeschema files
|
|
|
|
wxT( "^.*\\.kicad_sch$" ), // S-expr Eeschema files
|
2019-12-05 19:35:37 +00:00
|
|
|
wxT( "^[^$].*\\.brd$" ), // Legacy Pcbnew files
|
|
|
|
wxT( "^[^$].*\\.kicad_pcb$" ), // S format Pcbnew board files
|
|
|
|
wxT( "^[^$].*\\.kicad_wks$" ), // S format kicad page layout help_textr files
|
|
|
|
wxT( "^[^$].*\\.kicad_mod$" ), // S format kicad footprint files, currently not listed
|
|
|
|
wxT( "^.*\\.net$" ), // pcbnew netlist file
|
|
|
|
wxT( "^.*\\.cir$" ), // Spice netlist file
|
2020-04-07 14:00:16 +00:00
|
|
|
wxT( "^.*\\.lib$" ), // Legacy schematic library file
|
|
|
|
wxT( "^.*\\.kicad_sym$" ), // S-expr symbol libraries
|
2008-05-30 18:06:21 +00:00
|
|
|
wxT( "^.*\\.txt$" ),
|
2019-12-05 19:35:37 +00:00
|
|
|
wxT( "^.*\\.pho$" ), // Gerber file (Old Kicad extension)
|
|
|
|
wxT( "^.*\\.gbr$" ), // Gerber file
|
|
|
|
wxT( "^.*\\.gbrjob$" ), // Gerber job file
|
|
|
|
wxT( "^.*\\.gb[alops]$" ), // Gerber back (or bottom) layer file (deprecated Protel ext)
|
|
|
|
wxT( "^.*\\.gt[alops]$" ), // Gerber front (or top) layer file (deprecated Protel ext)
|
|
|
|
wxT( "^.*\\.g[0-9]{1,2}$" ), // Gerber inner layer file (deprecated Protel ext)
|
2008-05-30 18:06:21 +00:00
|
|
|
wxT( "^.*\\.odt$" ),
|
|
|
|
wxT( "^.*\\.htm$" ),
|
|
|
|
wxT( "^.*\\.html$" ),
|
2019-12-05 19:35:37 +00:00
|
|
|
wxT( "^.*\\.rpt$" ), // Report files
|
|
|
|
wxT( "^.*\\.csv$" ), // Report files in comma separated format
|
|
|
|
wxT( "^.*\\.pos$" ), // Footprint position files
|
2020-06-03 20:13:01 +00:00
|
|
|
wxT( "^.*\\.cmp$" ), // CvPcb cmp/footprint link files
|
2019-12-05 19:35:37 +00:00
|
|
|
wxT( "^.*\\.drl$" ), // Excellon drill files
|
|
|
|
wxT( "^.*\\.nc$" ), // Excellon NC drill files (alternate file ext)
|
|
|
|
wxT( "^.*\\.xnc$" ), // Excellon NC drill files (alternate file ext)
|
|
|
|
wxT( "^.*\\.svg$" ), // SVG print/plot files
|
|
|
|
wxT( "^.*\\.ps$" ), // Postscript plot files
|
|
|
|
NULL // end of list
|
2008-05-30 18:06:21 +00:00
|
|
|
};
|
|
|
|
|
2008-11-02 14:54:53 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
/* TODO: Check if these file extension and wildcard definitions are used
|
2011-09-30 18:15:37 +00:00
|
|
|
* in any of the other KiCad programs and move them into the common
|
2012-08-29 12:40:09 +00:00
|
|
|
* library as required.
|
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2014-07-07 19:49:14 +00:00
|
|
|
// File extension definitions.
|
2014-04-14 18:49:52 +00:00
|
|
|
const wxChar TextFileExtension[] = wxT( "txt" );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2017-08-19 16:28:11 +00:00
|
|
|
// Gerber file extension wildcard.
|
2017-09-08 18:32:32 +00:00
|
|
|
const wxString GerberFileExtensionWildCard( ".((gbr|gbrjob|(gb|gt)[alops])|pho)" );
|
2017-08-19 16:28:11 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2008-11-02 14:54:53 +00:00
|
|
|
/**
|
2019-07-17 10:57:12 +00:00
|
|
|
* @brief 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
|
2010-02-20 13:20:55 +00:00
|
|
|
* only useful files are shown.
|
2008-11-02 14:54:53 +00:00
|
|
|
*/
|
2010-02-20 13:20:55 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
2010-02-20 13:20:55 +00:00
|
|
|
BEGIN_EVENT_TABLE( TREE_PROJECT_FRAME, wxSashLayoutWindow )
|
2015-02-28 19:00:48 +00:00
|
|
|
EVT_TREE_ITEM_ACTIVATED( ID_PROJECT_TREE, TREE_PROJECT_FRAME::OnSelect )
|
|
|
|
EVT_TREE_ITEM_EXPANDED( ID_PROJECT_TREE, TREE_PROJECT_FRAME::OnExpand )
|
|
|
|
EVT_TREE_ITEM_RIGHT_CLICK( ID_PROJECT_TREE, TREE_PROJECT_FRAME::OnRight )
|
|
|
|
EVT_MENU( ID_PROJECT_TXTEDIT, TREE_PROJECT_FRAME::OnOpenSelectedFileWithTextEditor )
|
2018-06-21 15:05:08 +00:00
|
|
|
EVT_MENU( ID_PROJECT_SWITCH_TO_OTHER, TREE_PROJECT_FRAME::OnSwitchToSelectedProject )
|
2015-02-28 19:00:48 +00:00
|
|
|
EVT_MENU( ID_PROJECT_NEWDIR, TREE_PROJECT_FRAME::OnCreateNewDirectory )
|
2019-06-17 13:25:49 +00:00
|
|
|
EVT_MENU( ID_PROJECT_OPEN_DIR, TREE_PROJECT_FRAME::OnOpenDirectory )
|
2015-02-28 19:00:48 +00:00
|
|
|
EVT_MENU( ID_PROJECT_DELETE, TREE_PROJECT_FRAME::OnDeleteFile )
|
2019-08-28 16:01:06 +00:00
|
|
|
EVT_MENU( ID_PROJECT_PRINT, TREE_PROJECT_FRAME::OnPrintFile )
|
2015-02-28 19:00:48 +00:00
|
|
|
EVT_MENU( ID_PROJECT_RENAME, TREE_PROJECT_FRAME::OnRenameFile )
|
2010-02-20 13:20:55 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
2011-04-17 13:54:17 +00:00
|
|
|
TREE_PROJECT_FRAME::TREE_PROJECT_FRAME( KICAD_MANAGER_FRAME* parent ) :
|
2019-07-17 10:57:12 +00:00
|
|
|
wxSashLayoutWindow( parent, ID_LEFT_FRAME, wxDefaultPosition, wxDefaultSize,
|
2017-02-20 11:41:23 +00:00
|
|
|
wxNO_BORDER | wxTAB_TRAVERSAL )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2009-02-04 15:25:03 +00:00
|
|
|
m_Parent = parent;
|
|
|
|
m_TreeProject = NULL;
|
2019-11-17 00:52:43 +00:00
|
|
|
m_isRenaming = false;
|
2014-07-07 19:49:14 +00:00
|
|
|
|
2013-01-01 14:06:49 +00:00
|
|
|
m_watcher = NULL;
|
2012-12-31 08:12:29 +00:00
|
|
|
Connect( wxEVT_FSWATCHER,
|
|
|
|
wxFileSystemWatcherEventHandler( TREE_PROJECT_FRAME::OnFileSystemEvent ) );
|
2014-07-07 19:49:14 +00:00
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
/*
|
|
|
|
* Filtering is now inverted: the filters are actually used to _enable_ support
|
|
|
|
* for a given file type.
|
|
|
|
*/
|
2012-08-29 12:40:09 +00:00
|
|
|
for( int ii = 0; s_allowedExtensionsToList[ii] != NULL; ii++ )
|
2019-07-17 10:57:12 +00:00
|
|
|
m_filters.emplace_back( s_allowedExtensionsToList[ii] );
|
2008-11-02 14:54:53 +00:00
|
|
|
|
2019-07-17 10:57:12 +00:00
|
|
|
m_filters.emplace_back( wxT( "^no KiCad files found" ) );
|
2008-11-02 14:54:53 +00:00
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
ReCreateTreePrj();
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
|
|
|
|
2011-09-08 05:58:45 +00:00
|
|
|
|
2010-02-19 15:01:32 +00:00
|
|
|
TREE_PROJECT_FRAME::~TREE_PROJECT_FRAME()
|
2009-05-21 17:42:42 +00:00
|
|
|
{
|
2016-06-16 12:38:31 +00:00
|
|
|
if( m_watcher )
|
|
|
|
{
|
|
|
|
m_watcher->RemoveAll();
|
|
|
|
m_watcher->SetOwner( NULL );
|
|
|
|
delete m_watcher;
|
|
|
|
}
|
2009-05-21 17:42:42 +00:00
|
|
|
}
|
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2018-06-21 15:05:08 +00:00
|
|
|
void TREE_PROJECT_FRAME::OnSwitchToSelectedProject( wxCommandEvent& event )
|
|
|
|
{
|
2019-12-05 19:35:37 +00:00
|
|
|
std::vector<TREEPROJECT_ITEM*> tree_data = GetSelectedData();
|
2018-06-21 15:05:08 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
if( tree_data.size() != 1 )
|
2018-06-21 15:05:08 +00:00
|
|
|
return;
|
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
wxString prj_filename = tree_data[0]->GetFileName();
|
2018-06-21 15:05:08 +00:00
|
|
|
|
|
|
|
m_Parent->LoadProject( prj_filename );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-17 13:25:49 +00:00
|
|
|
void TREE_PROJECT_FRAME::OnOpenDirectory( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
// Get the root directory name:
|
2019-12-05 19:35:37 +00:00
|
|
|
std::vector<TREEPROJECT_ITEM*> tree_data = GetSelectedData();
|
2019-06-17 13:25:49 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
for( TREEPROJECT_ITEM* item_data : tree_data )
|
2019-06-17 13:25:49 +00:00
|
|
|
{
|
2019-12-05 19:35:37 +00:00
|
|
|
// Ask for the new sub directory name
|
|
|
|
wxString curr_dir = item_data->GetDir();
|
|
|
|
|
|
|
|
if( curr_dir.IsEmpty() )
|
|
|
|
{
|
|
|
|
// Use project path if the tree view path was empty.
|
|
|
|
curr_dir = wxPathOnly( m_Parent->GetProjectFileName() );
|
2019-06-20 19:18:43 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
// As a last resort use the user's documents folder.
|
|
|
|
if( curr_dir.IsEmpty() || !wxFileName::DirExists( curr_dir ) )
|
|
|
|
curr_dir = wxStandardPaths::Get().GetDocumentsDir();
|
2019-06-17 13:25:49 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
if( !curr_dir.IsEmpty() )
|
|
|
|
curr_dir += wxFileName::GetPathSeparator();
|
|
|
|
}
|
2019-06-17 13:25:49 +00:00
|
|
|
|
2019-07-17 10:57:12 +00:00
|
|
|
#ifdef __WXMAC__
|
2019-12-05 19:35:37 +00:00
|
|
|
wxString msg;
|
2019-07-17 10:57:12 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
// Quote in case there are spaces in the path.
|
|
|
|
msg.Printf( "open \"%s\"", curr_dir );
|
2019-07-17 10:57:12 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
system( msg.c_str() );
|
2019-07-17 10:57:12 +00:00
|
|
|
#else
|
2019-12-05 19:35:37 +00:00
|
|
|
// Quote in case there are spaces in the path.
|
|
|
|
AddDelimiterString( curr_dir );
|
2019-06-17 13:25:49 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
wxLaunchDefaultApplication( curr_dir );
|
2019-07-17 10:57:12 +00:00
|
|
|
#endif
|
2019-12-05 19:35:37 +00:00
|
|
|
}
|
2019-06-17 13:25:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-16 12:56:01 +00:00
|
|
|
void TREE_PROJECT_FRAME::OnCreateNewDirectory( wxCommandEvent& event )
|
2007-09-13 11:55:46 +00:00
|
|
|
{
|
2012-04-16 12:56:01 +00:00
|
|
|
// Get the root directory name:
|
2019-12-05 19:35:37 +00:00
|
|
|
std::vector<TREEPROJECT_ITEM*> tree_data = GetSelectedData();
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
for( TREEPROJECT_ITEM* item_data : tree_data )
|
|
|
|
{
|
|
|
|
wxString prj_dir = wxPathOnly( m_Parent->GetProjectFileName() );
|
2014-10-21 16:34:51 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
// Ask for the new sub directory name
|
|
|
|
wxString curr_dir = item_data->GetDir();
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
if( !curr_dir.IsEmpty() ) // A subdir is selected
|
|
|
|
{
|
|
|
|
// Make this subdir name relative to the current path.
|
|
|
|
// It will be more easy to read by the user, in the next dialog
|
|
|
|
wxFileName fn;
|
|
|
|
fn.AssignDir( curr_dir );
|
|
|
|
fn.MakeRelativeTo( prj_dir );
|
|
|
|
curr_dir = fn.GetPath();
|
|
|
|
|
|
|
|
if( !curr_dir.IsEmpty() )
|
|
|
|
curr_dir += wxFileName::GetPathSeparator();
|
|
|
|
}
|
2012-12-31 08:12:29 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
wxString msg =
|
|
|
|
wxString::Format( _( "Current project directory:\n%s" ), GetChars( prj_dir ) );
|
|
|
|
wxString subdir = wxGetTextFromUser( msg, _( "Create New Directory" ), curr_dir );
|
2008-11-02 14:54:53 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
if( subdir.IsEmpty() )
|
|
|
|
return;
|
2012-04-16 12:56:01 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
wxString full_dirname = prj_dir + wxFileName::GetPathSeparator() + subdir;
|
2014-10-21 16:34:51 +00:00
|
|
|
|
2019-11-17 01:01:12 +00:00
|
|
|
// Make the new item and let the file watcher add it to the tree
|
|
|
|
wxMkdir( full_dirname );
|
2019-12-05 19:35:37 +00:00
|
|
|
}
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2010-02-19 15:01:32 +00:00
|
|
|
wxString TREE_PROJECT_FRAME::GetFileExt( TreeFileType type )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
switch( type )
|
|
|
|
{
|
2020-07-07 00:14:27 +00:00
|
|
|
case TREE_LEGACY_PROJECT: return LegacyProjectFileExtension;
|
|
|
|
case TREE_JSON_PROJECT: return ProjectFileExtension;
|
2020-06-03 20:13:01 +00:00
|
|
|
case TREE_LEGACY_SCHEMATIC: return LegacySchematicFileExtension;
|
|
|
|
case TREE_SEXPR_SCHEMATIC: return KiCadSchematicFileExtension;
|
|
|
|
case TREE_LEGACY_PCB: return LegacyPcbFileExtension;
|
|
|
|
case TREE_SEXPR_PCB: return KiCadPcbFileExtension;
|
|
|
|
case TREE_GERBER: return GerberFileExtensionWildCard;
|
|
|
|
case TREE_HTML: return HtmlFileExtension;
|
|
|
|
case TREE_PDF: return PdfFileExtension;
|
|
|
|
case TREE_TXT: return TextFileExtension;
|
|
|
|
case TREE_NET: return NetlistFileExtension;
|
|
|
|
case TREE_CMP_LINK: return ComponentFileExtension;
|
|
|
|
case TREE_REPORT: return ReportFileExtension;
|
|
|
|
case TREE_FP_PLACE: return FootprintPlaceFileExtension;
|
|
|
|
case TREE_DRILL: return DrillFileExtension;
|
|
|
|
case TREE_DRILL_NC: return "nc";
|
|
|
|
case TREE_DRILL_XNC: return "xnc";
|
|
|
|
case TREE_SVG: return SVGFileExtension;
|
|
|
|
case TREE_PAGE_LAYOUT_DESCR: return PageLayoutDescrFileExtension;
|
|
|
|
case TREE_FOOTPRINT_FILE: return KiCadFootprintFileExtension;
|
|
|
|
case TREE_SCHEMATIC_LIBFILE: return LegacySymbolLibFileExtension;
|
|
|
|
case TREE_SEXPR_SYMBOL_LIB_FILE: return KiCadSymbolLibFileExtension;
|
|
|
|
default: return wxEmptyString;
|
2007-09-13 11:55:46 +00:00
|
|
|
}
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2019-12-20 00:34:43 +00:00
|
|
|
wxTreeItemId TREE_PROJECT_FRAME::AddItemToTreeProject(
|
|
|
|
const wxString& aName, wxTreeItemId& aRoot, bool aCanResetFileWatcher, bool aRecurse )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2019-11-17 00:52:43 +00:00
|
|
|
wxTreeItemId newItemId;
|
2020-07-07 00:14:27 +00:00
|
|
|
TreeFileType type = TREE_UNKNOWN;
|
|
|
|
wxFileName fn( aName );
|
2012-12-31 08:12:29 +00:00
|
|
|
|
2010-02-17 17:47:12 +00:00
|
|
|
// Files/dirs names starting by "." are not visible files under unices.
|
|
|
|
// Skip them also under Windows
|
2012-12-31 08:12:29 +00:00
|
|
|
if( fn.GetName().StartsWith( wxT( "." ) ) )
|
2019-11-17 00:52:43 +00:00
|
|
|
return newItemId;
|
2010-02-17 17:47:12 +00:00
|
|
|
|
2010-02-20 13:20:55 +00:00
|
|
|
if( wxDirExists( aName ) )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2009-02-04 15:25:03 +00:00
|
|
|
type = TREE_DIRECTORY;
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-09-13 11:55:46 +00:00
|
|
|
// Filter
|
2009-02-04 15:25:03 +00:00
|
|
|
wxRegEx reg;
|
2020-05-12 11:53:45 +00:00
|
|
|
bool addFile = false;
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2020-05-12 11:53:45 +00:00
|
|
|
for( const wxString& m_filter : m_filters )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2020-05-12 11:53:45 +00:00
|
|
|
wxCHECK2_MSG( reg.Compile( m_filter, wxRE_ICASE ), continue,
|
|
|
|
wxString::Format( "Regex %s failed to compile.", m_filter ) );
|
2012-06-09 17:00:13 +00:00
|
|
|
|
2010-02-20 13:20:55 +00:00
|
|
|
if( reg.Matches( aName ) )
|
2007-09-13 11:55:46 +00:00
|
|
|
{
|
2009-02-04 15:25:03 +00:00
|
|
|
addFile = true;
|
2009-10-26 21:25:23 +00:00
|
|
|
break;
|
2007-09-13 11:55:46 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
if( !addFile )
|
2019-11-17 00:52:43 +00:00
|
|
|
return newItemId;
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
// only show the schematic if it is a top level schematic. Eeschema
|
2007-09-13 11:55:46 +00:00
|
|
|
// cannot open a schematic and display it properly unless it starts
|
|
|
|
// at the top of the hierarchy. The schematic is top level only if
|
|
|
|
// there is a line in the header saying:
|
|
|
|
// "Sheet 1 "
|
2013-01-03 19:25:12 +00:00
|
|
|
// However if the file has the same name as the project, it is always
|
|
|
|
// shown, because it is expected the root sheet.
|
|
|
|
// (and to fix an issue (under XP but could exist under other OS),
|
|
|
|
// when a .sch file is created, the file
|
|
|
|
// create is sent to the wxFileSystemWatcher, but the file still has 0 byte
|
|
|
|
// so it cannot detected as root sheet
|
|
|
|
// This is an ugly fix.
|
2020-05-12 11:53:45 +00:00
|
|
|
if( fn.GetExt() == "sch" || fn.GetExt() == "kicad_sch" )
|
2007-09-13 11:55:46 +00:00
|
|
|
{
|
2019-07-17 10:57:12 +00:00
|
|
|
wxString fullFileName = aName.BeforeLast( '.' );
|
|
|
|
wxString rootName;
|
2013-01-03 19:25:12 +00:00
|
|
|
TREEPROJECT_ITEM* itemData = GetItemIdData( m_root );
|
2018-10-17 19:03:33 +00:00
|
|
|
|
2013-01-03 19:25:12 +00:00
|
|
|
if( itemData )
|
2014-07-07 19:49:14 +00:00
|
|
|
rootName = itemData->GetFileName().BeforeLast( '.' );
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2013-01-03 19:25:12 +00:00
|
|
|
if( fullFileName != rootName )
|
2007-09-13 11:55:46 +00:00
|
|
|
{
|
2013-01-03 19:25:12 +00:00
|
|
|
char line[128]; // small because we just need a few bytes from the start of a line
|
|
|
|
FILE* fp;
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2013-01-03 19:25:12 +00:00
|
|
|
fullFileName = aName;
|
|
|
|
fp = wxFopen( fullFileName, wxT( "rt" ) );
|
2009-10-26 21:25:23 +00:00
|
|
|
|
2013-01-03 19:25:12 +00:00
|
|
|
if( fp == NULL )
|
2019-11-17 00:52:43 +00:00
|
|
|
return newItemId;
|
2013-01-03 19:25:12 +00:00
|
|
|
|
|
|
|
addFile = false;
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2020-05-12 11:53:45 +00:00
|
|
|
// check the first 100 lines for the "Sheet 1" or "(page 1" string
|
2013-01-03 19:25:12 +00:00
|
|
|
for( int i = 0; i<100; ++i )
|
2007-09-13 11:55:46 +00:00
|
|
|
{
|
2013-01-03 19:25:12 +00:00
|
|
|
if( !fgets( line, sizeof(line), fp ) )
|
|
|
|
break;
|
|
|
|
|
2020-05-12 11:53:45 +00:00
|
|
|
if( fn.GetExt() == "sch" )
|
2013-01-03 19:25:12 +00:00
|
|
|
{
|
2020-05-12 11:53:45 +00:00
|
|
|
if( strncmp( line, "Sheet 1 ", 8 ) == 0 )
|
|
|
|
{
|
|
|
|
addFile = true;
|
|
|
|
break;
|
|
|
|
}
|
2020-07-07 00:14:27 +00:00
|
|
|
}
|
|
|
|
else if( fn.GetExt() == "kicad_sch" )
|
2020-05-12 11:53:45 +00:00
|
|
|
{
|
|
|
|
char* start = line;
|
|
|
|
|
|
|
|
while( *start == ' ' )
|
|
|
|
start++;
|
|
|
|
|
|
|
|
if( strncmp( start, "(page 1 ", 8 ) == 0 )
|
|
|
|
{
|
|
|
|
addFile = true;
|
|
|
|
break;
|
|
|
|
}
|
2013-01-03 19:25:12 +00:00
|
|
|
}
|
2007-09-13 11:55:46 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 19:25:12 +00:00
|
|
|
fclose( fp );
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2013-01-03 19:25:12 +00:00
|
|
|
if( !addFile )
|
2019-11-17 00:52:43 +00:00
|
|
|
return newItemId; // it is a non-top-level schematic
|
2013-01-03 19:25:12 +00:00
|
|
|
}
|
2007-09-13 11:55:46 +00:00
|
|
|
}
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2020-07-07 00:14:27 +00:00
|
|
|
for( int i = TREE_LEGACY_PROJECT; i < TREE_MAX; i++ )
|
2007-09-13 11:55:46 +00:00
|
|
|
{
|
|
|
|
wxString ext = GetFileExt( (TreeFileType) i );
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
if( ext == wxT( "" ) )
|
|
|
|
continue;
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2020-07-07 00:14:27 +00:00
|
|
|
reg.Compile( wxString::FromAscii( "^.*\\." ) + ext +
|
2009-02-04 15:25:03 +00:00
|
|
|
wxString::FromAscii( "$" ), wxRE_ICASE );
|
|
|
|
|
2010-02-20 13:20:55 +00:00
|
|
|
if( reg.Matches( aName ) )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2007-09-13 11:55:46 +00:00
|
|
|
type = (TreeFileType) i;
|
2007-05-28 18:09:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2020-07-07 00:14:27 +00:00
|
|
|
wxString file = wxFileNameFromPath( aName );
|
|
|
|
wxFileName currfile( file );
|
|
|
|
wxFileName project( m_Parent->GetProjectFileName() );
|
|
|
|
|
|
|
|
// Ignore legacy projects with the same name as the current project
|
|
|
|
if( ( type == TREE_LEGACY_PROJECT ) && ( currfile.GetName().CmpNoCase( project.GetName() ) == 0 ) )
|
|
|
|
return newItemId;
|
|
|
|
|
2012-12-31 08:12:29 +00:00
|
|
|
// also check to see if it is already there.
|
2020-07-07 00:14:27 +00:00
|
|
|
wxTreeItemIdValue cookie;
|
|
|
|
wxTreeItemId kid = m_TreeProject->GetFirstChild( aRoot, cookie );
|
2012-12-31 08:12:29 +00:00
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
while( kid.IsOk() )
|
|
|
|
{
|
2010-02-20 13:20:55 +00:00
|
|
|
TREEPROJECT_ITEM* itemData = GetItemIdData( kid );
|
2012-12-31 08:12:29 +00:00
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
if( itemData )
|
|
|
|
{
|
2014-07-07 19:49:14 +00:00
|
|
|
if( itemData->GetFileName() == aName )
|
2019-11-17 00:52:43 +00:00
|
|
|
return itemData->GetId(); // well, we would have added it, but it is already here!
|
2009-02-04 15:25:03 +00:00
|
|
|
}
|
2012-12-31 08:12:29 +00:00
|
|
|
|
2010-02-20 13:20:55 +00:00
|
|
|
kid = m_TreeProject->GetNextChild( aRoot, cookie );
|
2009-02-04 15:25:03 +00:00
|
|
|
}
|
2012-12-31 08:12:29 +00:00
|
|
|
|
2020-07-07 00:14:27 +00:00
|
|
|
// Only show the JSON project files if both legacy and JSON files are present
|
|
|
|
if( ( type == TREE_LEGACY_PROJECT ) || ( type == TREE_JSON_PROJECT ) )
|
|
|
|
{
|
|
|
|
kid = m_TreeProject->GetFirstChild( aRoot, cookie );
|
|
|
|
|
|
|
|
while( kid.IsOk() )
|
|
|
|
{
|
|
|
|
TREEPROJECT_ITEM* itemData = GetItemIdData( kid );
|
|
|
|
|
|
|
|
if( itemData )
|
|
|
|
{
|
|
|
|
wxFileName fname( itemData->GetFileName() );
|
|
|
|
|
|
|
|
if( fname.GetName().CmpNoCase( currfile.GetName() ) == 0 )
|
|
|
|
{
|
|
|
|
// If the tree item is the legacy project remove it.
|
|
|
|
if( itemData->GetType() == TREE_LEGACY_PROJECT )
|
|
|
|
{
|
|
|
|
m_TreeProject->Delete( kid );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// If we are the legacy project and the tree was the JSON project, ignore this file
|
|
|
|
else if( ( itemData->GetType() == TREE_JSON_PROJECT )
|
|
|
|
&& ( type == TREE_LEGACY_PROJECT ) )
|
|
|
|
{
|
|
|
|
return newItemId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
kid = m_TreeProject->GetNextChild( aRoot, cookie );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-02 14:54:53 +00:00
|
|
|
// Append the item (only appending the filename not the full path):
|
2019-11-17 00:52:43 +00:00
|
|
|
newItemId = m_TreeProject->AppendItem( aRoot, file );
|
2012-12-31 08:12:29 +00:00
|
|
|
TREEPROJECT_ITEM* data = new TREEPROJECT_ITEM( type, aName, m_TreeProject );
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2019-11-17 00:52:43 +00:00
|
|
|
m_TreeProject->SetItemData( newItemId, data );
|
2007-09-13 11:55:46 +00:00
|
|
|
data->SetState( 0 );
|
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
// Mark root files (files which have the same aName as the project)
|
2007-09-13 11:55:46 +00:00
|
|
|
if( currfile.GetName().CmpNoCase( project.GetName() ) == 0 )
|
2014-07-07 19:49:14 +00:00
|
|
|
data->SetRootFile( true );
|
2007-09-13 11:55:46 +00:00
|
|
|
else
|
2014-07-07 19:49:14 +00:00
|
|
|
data->SetRootFile( false );
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2019-12-20 00:34:43 +00:00
|
|
|
#ifndef __WINDOWS__
|
|
|
|
bool subdir_populated = false;
|
|
|
|
#endif
|
|
|
|
|
2010-02-20 13:20:55 +00:00
|
|
|
// This section adds dirs and files found in the subdirs
|
|
|
|
// in this case AddFile is recursive, but for the first level only.
|
|
|
|
if( TREE_DIRECTORY == type && aRecurse )
|
2009-02-04 15:25:03 +00:00
|
|
|
{
|
2020-07-07 00:14:27 +00:00
|
|
|
wxDir dir( aName );
|
2012-12-31 08:12:29 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
if( dir.IsOpened() ) // protected dirs will not open properly.
|
2008-05-16 11:38:35 +00:00
|
|
|
{
|
2020-07-07 00:14:27 +00:00
|
|
|
wxString dir_filename;
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
|
|
|
data->SetPopulated( true );
|
2019-12-20 00:34:43 +00:00
|
|
|
#ifndef __WINDOWS__
|
|
|
|
subdir_populated = aCanResetFileWatcher;
|
|
|
|
#endif
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
|
|
|
if( dir.GetFirst( &dir_filename ) )
|
2009-02-04 15:25:03 +00:00
|
|
|
{
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
do // Add name in tree, but do not recurse
|
|
|
|
{
|
2014-10-21 16:34:51 +00:00
|
|
|
wxString path = aName + wxFileName::GetPathSeparator() + dir_filename;
|
2019-12-20 00:34:43 +00:00
|
|
|
AddItemToTreeProject( path, newItemId, false, false );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
} while( dir.GetNext( &dir_filename ) );
|
|
|
|
}
|
2008-05-16 11:38:35 +00:00
|
|
|
}
|
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
// Sort filenames by alphabetic order
|
2019-11-17 00:52:43 +00:00
|
|
|
m_TreeProject->SortChildren( newItemId );
|
2009-02-04 15:25:03 +00:00
|
|
|
}
|
2008-11-02 14:54:53 +00:00
|
|
|
|
2019-12-20 00:34:43 +00:00
|
|
|
#ifndef __WINDOWS__
|
|
|
|
if( subdir_populated )
|
|
|
|
FileWatcherReset();
|
|
|
|
#endif
|
|
|
|
|
2019-11-17 00:52:43 +00:00
|
|
|
return newItemId;
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2010-02-19 15:01:32 +00:00
|
|
|
void TREE_PROJECT_FRAME::ReCreateTreePrj()
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2019-07-17 10:57:12 +00:00
|
|
|
wxString pro_dir = m_Parent->GetProjectFileName();
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
if( !m_TreeProject )
|
2010-02-19 15:01:32 +00:00
|
|
|
m_TreeProject = new TREEPROJECTFILES( this );
|
2007-09-13 11:55:46 +00:00
|
|
|
else
|
|
|
|
m_TreeProject->DeleteAllItems();
|
2007-05-28 18:09:49 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
if( !pro_dir ) // This is empty from TREE_PROJECT_FRAME constructor
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxFileName fn = pro_dir;
|
2014-07-07 19:49:14 +00:00
|
|
|
|
|
|
|
if( !fn.IsOk() )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
|
|
|
fn.Clear();
|
2015-09-25 19:38:09 +00:00
|
|
|
fn.SetPath( wxStandardPaths::Get().GetDocumentsDir() );
|
2010-02-24 15:33:03 +00:00
|
|
|
fn.SetName( NAMELESS_PROJECT );
|
2020-06-19 03:23:03 +00:00
|
|
|
fn.SetExt( ProjectFileExtension );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2019-07-17 10:57:12 +00:00
|
|
|
bool prjOpened = fn.FileExists();
|
2007-09-13 11:55:46 +00:00
|
|
|
|
|
|
|
// root tree:
|
2019-07-17 10:57:12 +00:00
|
|
|
m_root = m_TreeProject->AddRoot( fn.GetFullName(), TREE_ROOT, TREE_ROOT );
|
|
|
|
m_TreeProject->SetItemBold( m_root, true );
|
2020-07-07 00:14:27 +00:00
|
|
|
|
|
|
|
// The main project file is now a JSON file
|
|
|
|
m_TreeProject->SetItemData( m_root, new TREEPROJECT_ITEM( TREE_JSON_PROJECT, fn.GetFullPath(),
|
2019-07-17 10:57:12 +00:00
|
|
|
m_TreeProject ) );
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
// Now adding all current files if available
|
|
|
|
if( prjOpened )
|
|
|
|
{
|
2016-04-12 15:50:42 +00:00
|
|
|
pro_dir = wxPathOnly( m_Parent->GetProjectFileName() );
|
|
|
|
wxDir dir( pro_dir );
|
2009-02-04 15:25:03 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
if( dir.IsOpened() ) // protected dirs will not open, see "man opendir()"
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
wxString filename;
|
|
|
|
bool cont = dir.GetFirst( &filename );
|
|
|
|
|
|
|
|
while( cont )
|
|
|
|
{
|
|
|
|
if( filename != fn.GetFullName() )
|
|
|
|
{
|
2014-10-21 16:34:51 +00:00
|
|
|
wxString name = dir.GetName() + wxFileName::GetPathSeparator() + filename;
|
2019-12-20 00:34:43 +00:00
|
|
|
AddItemToTreeProject( name, m_root, false );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
}
|
2009-10-26 21:25:23 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
cont = dir.GetNext( &filename );
|
|
|
|
}
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
2012-12-31 08:12:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_TreeProject->AppendItem( m_root, wxT( "Empty project" ) );
|
|
|
|
}
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2019-07-17 10:57:12 +00:00
|
|
|
m_TreeProject->Expand( m_root );
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2014-07-07 19:49:14 +00:00
|
|
|
// Sort filenames by alphabetic order
|
2007-09-13 11:55:46 +00:00
|
|
|
m_TreeProject->SortChildren( m_root );
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2010-02-19 15:01:32 +00:00
|
|
|
void TREE_PROJECT_FRAME::OnRight( wxTreeEvent& Event )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2012-12-31 08:12:29 +00:00
|
|
|
wxTreeItemId curr_item = Event.GetItem();
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2014-07-07 19:49:14 +00:00
|
|
|
// Ensure item is selected (Under Windows right click does not select the item)
|
2007-09-13 11:55:46 +00:00
|
|
|
m_TreeProject->SelectItem( curr_item );
|
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
std::vector<TREEPROJECT_ITEM*> tree_data = GetSelectedData();
|
2012-12-31 08:12:29 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
bool can_switch_to_project = true;
|
|
|
|
bool can_create_new_directory = true;
|
|
|
|
bool can_open_this_directory = true;
|
|
|
|
bool can_edit = true;
|
|
|
|
bool can_rename = true;
|
|
|
|
bool can_delete = true;
|
|
|
|
bool can_print = true;
|
|
|
|
|
|
|
|
if( tree_data.size() == 0 )
|
2007-09-13 11:55:46 +00:00
|
|
|
return;
|
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
if( tree_data.size() != 1 )
|
|
|
|
{
|
|
|
|
can_switch_to_project = false;
|
|
|
|
can_create_new_directory = false;
|
|
|
|
can_rename = false;
|
|
|
|
can_print = false;
|
|
|
|
}
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
if( curr_item == m_TreeProject->GetRootItem() )
|
|
|
|
can_switch_to_project = false;
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
for( TREEPROJECT_ITEM* item_data : tree_data )
|
2007-09-13 11:55:46 +00:00
|
|
|
{
|
2019-12-05 19:35:37 +00:00
|
|
|
int tree_id = item_data->GetType();
|
|
|
|
wxString full_file_name = item_data->GetFileName();
|
|
|
|
|
|
|
|
switch( tree_id )
|
2018-10-17 19:03:33 +00:00
|
|
|
{
|
2020-07-07 00:14:27 +00:00
|
|
|
case TREE_LEGACY_PROJECT:
|
|
|
|
case TREE_JSON_PROJECT:
|
2019-12-05 19:35:37 +00:00
|
|
|
can_edit = false;
|
|
|
|
can_rename = false;
|
|
|
|
can_delete = false;
|
|
|
|
can_print = false;
|
|
|
|
break;
|
2019-12-06 08:34:29 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
case TREE_DIRECTORY:
|
|
|
|
can_switch_to_project = false;
|
|
|
|
can_edit = false;
|
|
|
|
can_rename = false;
|
|
|
|
can_print = false;
|
|
|
|
break;
|
2019-12-06 08:34:29 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
default:
|
|
|
|
can_switch_to_project = false;
|
|
|
|
can_create_new_directory = false;
|
|
|
|
can_open_this_directory = false;
|
2019-12-06 08:34:29 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
if( !CanPrintFile( full_file_name ) )
|
|
|
|
can_print = false;
|
2019-12-06 08:34:29 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
break;
|
2018-10-17 19:03:33 +00:00
|
|
|
}
|
2019-12-05 19:35:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wxMenu popup_menu;
|
|
|
|
wxString text;
|
|
|
|
wxString help_text;
|
|
|
|
|
|
|
|
if( can_switch_to_project )
|
|
|
|
{
|
2019-12-06 08:34:29 +00:00
|
|
|
AddMenuItem( &popup_menu, ID_PROJECT_SWITCH_TO_OTHER,
|
|
|
|
_( "Switch to this Project" ),
|
|
|
|
_( "Close all editors, and switch to the selected project" ),
|
|
|
|
KiBitmap( open_project_xpm ) );
|
2019-12-05 19:35:37 +00:00
|
|
|
popup_menu.AppendSeparator();
|
|
|
|
}
|
2018-10-17 19:03:33 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
if( can_create_new_directory )
|
|
|
|
{
|
2019-12-06 08:34:29 +00:00
|
|
|
AddMenuItem( &popup_menu, ID_PROJECT_NEWDIR, _( "New Directory..." ),
|
|
|
|
_( "Create a New Directory" ), KiBitmap( directory_xpm ) );
|
2019-12-05 19:35:37 +00:00
|
|
|
}
|
2019-06-17 13:25:49 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
if( can_open_this_directory )
|
|
|
|
{
|
|
|
|
if( tree_data.size() == 1 )
|
|
|
|
{
|
2019-07-17 10:57:12 +00:00
|
|
|
#ifdef __APPLE__
|
2019-12-05 19:35:37 +00:00
|
|
|
text = _( "Reveal in Finder" );
|
|
|
|
help_text = _( "Reveals the directory in a Finder window" );
|
2019-07-17 10:57:12 +00:00
|
|
|
#else
|
2019-12-06 08:34:29 +00:00
|
|
|
text = _( "Open Directory in File Explorer" );
|
2019-12-05 19:35:37 +00:00
|
|
|
help_text = _( "Opens the directory in the default system file manager" );
|
2019-07-17 10:57:12 +00:00
|
|
|
#endif
|
2019-12-05 19:35:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-07-17 10:57:12 +00:00
|
|
|
#ifdef __APPLE__
|
2019-12-05 19:35:37 +00:00
|
|
|
text = _( "Reveal in Finder" );
|
|
|
|
help_text = _( "Reveals the directories in a Finder window" );
|
2019-07-17 10:57:12 +00:00
|
|
|
#else
|
2019-12-06 08:34:29 +00:00
|
|
|
text = _( "Open Directories in File Explorer" );
|
2019-12-05 19:35:37 +00:00
|
|
|
help_text = _( "Opens the directories in the default system file manager" );
|
2019-07-17 10:57:12 +00:00
|
|
|
#endif
|
2019-12-05 19:35:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AddMenuItem( &popup_menu, ID_PROJECT_OPEN_DIR, text, help_text,
|
|
|
|
KiBitmap( directory_browser_xpm ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( can_edit )
|
|
|
|
{
|
|
|
|
if( tree_data.size() == 1 )
|
|
|
|
help_text = _( "Open the file in a Text Editor" );
|
|
|
|
else
|
2019-12-06 08:34:29 +00:00
|
|
|
help_text = _( "Open files in a Text Editor" );
|
2019-12-05 19:35:37 +00:00
|
|
|
|
2019-12-06 08:34:29 +00:00
|
|
|
AddMenuItem( &popup_menu, ID_PROJECT_TXTEDIT, _( "Edit in a Text Editor" ),
|
|
|
|
help_text, KiBitmap( editor_xpm ) );
|
2019-12-05 19:35:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( can_rename )
|
|
|
|
{
|
|
|
|
if( tree_data.size() == 1 )
|
|
|
|
{
|
2019-12-06 08:34:29 +00:00
|
|
|
text = _( "Rename File..." );
|
2019-12-05 19:35:37 +00:00
|
|
|
help_text = _( "Rename file" );
|
|
|
|
}
|
|
|
|
else
|
2019-08-29 20:59:49 +00:00
|
|
|
{
|
2019-12-06 08:34:29 +00:00
|
|
|
text = _( "Rename Files..." );
|
2019-12-05 19:35:37 +00:00
|
|
|
help_text = _( "Rename files" );
|
|
|
|
}
|
|
|
|
|
|
|
|
AddMenuItem( &popup_menu, ID_PROJECT_RENAME, text, help_text, KiBitmap( right_xpm ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( can_delete )
|
|
|
|
{
|
|
|
|
if( tree_data.size() == 1 )
|
|
|
|
help_text = _( "Delete the file and its content" );
|
|
|
|
else
|
|
|
|
help_text = _( "Delete the files and their contents" );
|
|
|
|
|
|
|
|
if( can_switch_to_project || can_create_new_directory || can_open_this_directory || can_edit
|
|
|
|
|| can_rename )
|
|
|
|
popup_menu.AppendSeparator();
|
2019-12-06 08:34:29 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
AddMenuItem(
|
2019-12-06 08:34:29 +00:00
|
|
|
&popup_menu, ID_PROJECT_DELETE, _( "Delete" ), help_text, KiBitmap( delete_xpm ) );
|
2019-12-05 19:35:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( can_print )
|
|
|
|
{
|
|
|
|
popup_menu.AppendSeparator();
|
|
|
|
AddMenuItem( &popup_menu, ID_PROJECT_PRINT,
|
2019-08-29 20:59:49 +00:00
|
|
|
#ifdef __APPLE__
|
2019-12-05 19:35:37 +00:00
|
|
|
_( "Print..." ),
|
2019-08-29 20:59:49 +00:00
|
|
|
#else
|
2019-12-06 08:34:29 +00:00
|
|
|
_( "Print" ),
|
2019-08-29 20:59:49 +00:00
|
|
|
#endif
|
2019-12-05 19:35:37 +00:00
|
|
|
_( "Print the contents of the file" ), KiBitmap( print_button_xpm ) );
|
2007-09-13 11:55:46 +00:00
|
|
|
}
|
|
|
|
|
2020-04-09 16:54:04 +00:00
|
|
|
if( popup_menu.GetMenuItemCount() > 0 )
|
|
|
|
PopupMenu( &popup_menu );
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
|
|
|
|
2014-07-07 19:49:14 +00:00
|
|
|
|
2012-12-31 08:12:29 +00:00
|
|
|
void TREE_PROJECT_FRAME::OnOpenSelectedFileWithTextEditor( wxCommandEvent& event )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2019-12-06 08:34:29 +00:00
|
|
|
wxString editorname = Pgm().GetEditorName();
|
|
|
|
|
|
|
|
if( editorname.IsEmpty() )
|
|
|
|
return;
|
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
std::vector<TREEPROJECT_ITEM*> tree_data = GetSelectedData();
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2019-12-06 08:34:29 +00:00
|
|
|
wxString files;
|
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
for( TREEPROJECT_ITEM* item_data : tree_data )
|
|
|
|
{
|
|
|
|
wxString fullFileName = item_data->GetFileName();
|
|
|
|
AddDelimiterString( fullFileName );
|
2008-11-02 14:54:53 +00:00
|
|
|
|
2019-12-06 08:34:29 +00:00
|
|
|
if( !files.IsEmpty() )
|
|
|
|
files += " ";
|
|
|
|
|
|
|
|
files += fullFileName;
|
2019-12-05 19:35:37 +00:00
|
|
|
}
|
2019-12-06 08:34:29 +00:00
|
|
|
|
|
|
|
ExecuteFile( this, editorname, files );
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2010-02-19 15:01:32 +00:00
|
|
|
void TREE_PROJECT_FRAME::OnDeleteFile( wxCommandEvent& )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2019-12-05 19:35:37 +00:00
|
|
|
std::vector<TREEPROJECT_ITEM*> tree_data = GetSelectedData();
|
2020-04-09 16:54:04 +00:00
|
|
|
wxString msg, caption;
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2020-04-09 16:54:04 +00:00
|
|
|
if( tree_data.size() == 1 )
|
|
|
|
{
|
|
|
|
bool is_directory = wxDirExists( tree_data[0]->GetFileName() );
|
|
|
|
msg = wxString::Format(
|
|
|
|
_( "Are you sure you want to delete '%s'?" ), tree_data[0]->GetFileName() );
|
|
|
|
caption = is_directory ? _( "Delete Directory" ) : _( "Delete File" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
msg = wxString::Format(
|
|
|
|
_( "Are you sure you want to delete %lu items?" ), tree_data.size() );
|
|
|
|
caption = _( "Delete Multiple Items" );
|
|
|
|
}
|
|
|
|
|
|
|
|
wxMessageDialog dialog( m_parent, msg, caption, wxYES_NO | wxICON_QUESTION );
|
|
|
|
|
|
|
|
if( dialog.ShowModal() == wxID_YES )
|
|
|
|
{
|
|
|
|
for( TREEPROJECT_ITEM* item_data : tree_data )
|
|
|
|
item_data->Delete();
|
|
|
|
}
|
2019-08-28 16:01:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TREE_PROJECT_FRAME::OnPrintFile( wxCommandEvent& )
|
|
|
|
{
|
2019-12-05 19:35:37 +00:00
|
|
|
std::vector<TREEPROJECT_ITEM*> tree_data = GetSelectedData();
|
2012-12-31 08:12:29 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
for( TREEPROJECT_ITEM* item_data : tree_data )
|
|
|
|
item_data->Print();
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2010-02-19 15:01:32 +00:00
|
|
|
void TREE_PROJECT_FRAME::OnRenameFile( wxCommandEvent& )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2019-12-05 19:35:37 +00:00
|
|
|
wxTreeItemId curr_item = m_TreeProject->GetFocusedItem();
|
|
|
|
std::vector<TREEPROJECT_ITEM*> tree_data = GetSelectedData();
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
// XXX: Unnecessary?
|
|
|
|
if( tree_data.size() != 1 )
|
2009-02-04 15:25:03 +00:00
|
|
|
return;
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2014-07-07 19:49:14 +00:00
|
|
|
wxString buffer = m_TreeProject->GetItemText( curr_item );
|
2019-12-06 08:34:29 +00:00
|
|
|
wxString msg = wxString::Format( _( "Change filename: \"%s\"" ),
|
|
|
|
tree_data[0]->GetFileName() );
|
2019-07-17 10:57:12 +00:00
|
|
|
wxTextEntryDialog dlg( this, msg, _( "Change filename" ), buffer );
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2010-07-20 10:30:40 +00:00
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
2015-02-28 19:00:48 +00:00
|
|
|
return; // canceled by user
|
2010-07-20 10:30:40 +00:00
|
|
|
|
2012-12-31 08:12:29 +00:00
|
|
|
buffer = dlg.GetValue();
|
2010-07-21 08:15:54 +00:00
|
|
|
buffer.Trim( true );
|
|
|
|
buffer.Trim( false );
|
2012-12-31 08:12:29 +00:00
|
|
|
|
2010-07-20 10:30:40 +00:00
|
|
|
if( buffer.IsEmpty() )
|
2012-12-31 08:12:29 +00:00
|
|
|
return; // empty file name not allowed
|
2008-11-02 14:54:53 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
tree_data[0]->Rename( buffer, true );
|
2019-11-17 00:52:43 +00:00
|
|
|
m_isRenaming = true;
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-19 15:01:32 +00:00
|
|
|
void TREE_PROJECT_FRAME::OnSelect( wxTreeEvent& Event )
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2019-12-05 19:35:37 +00:00
|
|
|
std::vector<TREEPROJECT_ITEM*> tree_data = GetSelectedData();
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
if( tree_data.size() != 1 )
|
2009-02-04 15:25:03 +00:00
|
|
|
return;
|
2012-12-31 08:12:29 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
tree_data[0]->Activate( this );
|
2007-09-13 11:55:46 +00:00
|
|
|
}
|
2010-02-20 13:20:55 +00:00
|
|
|
|
2012-12-31 08:12:29 +00:00
|
|
|
|
2010-02-20 13:20:55 +00:00
|
|
|
void TREE_PROJECT_FRAME::OnExpand( wxTreeEvent& Event )
|
|
|
|
{
|
2012-12-31 08:12:29 +00:00
|
|
|
wxTreeItemId itemId = Event.GetItem();
|
|
|
|
TREEPROJECT_ITEM* tree_data = GetItemIdData( itemId );
|
2010-02-20 13:20:55 +00:00
|
|
|
|
|
|
|
if( !tree_data )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( tree_data->GetType() != TREE_DIRECTORY )
|
|
|
|
return;
|
|
|
|
|
2012-12-31 08:12:29 +00:00
|
|
|
// explore list of non populated subdirs, and populate them
|
|
|
|
wxTreeItemIdValue cookie;
|
|
|
|
wxTreeItemId kid = m_TreeProject->GetFirstChild( itemId, cookie );
|
|
|
|
|
2019-09-05 16:57:30 +00:00
|
|
|
#ifndef __WINDOWS__
|
|
|
|
bool subdir_populated = false;
|
|
|
|
#endif
|
|
|
|
|
2010-02-20 13:20:55 +00:00
|
|
|
for( ; kid.IsOk(); kid = m_TreeProject->GetNextChild( itemId, cookie ) )
|
|
|
|
{
|
|
|
|
TREEPROJECT_ITEM* itemData = GetItemIdData( kid );
|
2012-12-31 08:12:29 +00:00
|
|
|
|
2010-02-20 13:20:55 +00:00
|
|
|
if( !itemData || itemData->GetType() != TREE_DIRECTORY )
|
|
|
|
continue;
|
2012-12-31 08:12:29 +00:00
|
|
|
|
2014-07-07 19:49:14 +00:00
|
|
|
if( itemData->IsPopulated() )
|
2010-02-20 13:20:55 +00:00
|
|
|
continue;
|
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
wxString fileName = itemData->GetFileName();
|
|
|
|
wxDir dir( fileName );
|
2012-12-31 08:12:29 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
if( dir.IsOpened() )
|
2010-02-20 13:20:55 +00:00
|
|
|
{
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
wxString dir_filename;
|
|
|
|
|
|
|
|
if( dir.GetFirst( &dir_filename ) )
|
2010-02-20 13:20:55 +00:00
|
|
|
{
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
do // Add name to tree item, but do not recurse in subdirs:
|
|
|
|
{
|
2014-10-21 16:34:51 +00:00
|
|
|
wxString name = fileName + wxFileName::GetPathSeparator() + dir_filename;
|
|
|
|
AddItemToTreeProject( name, kid, false );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
} while( dir.GetNext( &dir_filename ) );
|
|
|
|
}
|
2012-12-31 08:12:29 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
itemData->SetPopulated( true ); // set state to populated
|
2019-09-05 16:57:30 +00:00
|
|
|
#ifndef __WINDOWS__
|
|
|
|
subdir_populated = true;
|
|
|
|
#endif
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
}
|
2010-02-20 13:20:55 +00:00
|
|
|
|
2014-07-07 19:49:14 +00:00
|
|
|
// Sort filenames by alphabetic order
|
2010-02-20 13:20:55 +00:00
|
|
|
m_TreeProject->SortChildren( kid );
|
|
|
|
}
|
2013-01-01 14:06:49 +00:00
|
|
|
|
2019-07-17 10:57:12 +00:00
|
|
|
#ifndef __WINDOWS__
|
2013-01-01 14:06:49 +00:00
|
|
|
if( subdir_populated )
|
2013-01-02 21:49:56 +00:00
|
|
|
FileWatcherReset();
|
2019-07-17 10:57:12 +00:00
|
|
|
#endif
|
2010-02-20 13:20:55 +00:00
|
|
|
}
|
|
|
|
|
2012-12-31 08:12:29 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
std::vector<TREEPROJECT_ITEM*> TREE_PROJECT_FRAME::GetSelectedData()
|
2010-02-20 13:20:55 +00:00
|
|
|
{
|
2019-12-05 19:35:37 +00:00
|
|
|
wxArrayTreeItemIds selection;
|
|
|
|
std::vector<TREEPROJECT_ITEM*> data;
|
|
|
|
|
|
|
|
m_TreeProject->GetSelections( selection );
|
|
|
|
|
|
|
|
for( auto it = selection.begin(); it != selection.end(); it++ )
|
|
|
|
data.push_back( GetItemIdData( *it ) );
|
|
|
|
|
|
|
|
return data;
|
2010-02-20 13:20:55 +00:00
|
|
|
}
|
|
|
|
|
2012-12-31 08:12:29 +00:00
|
|
|
|
|
|
|
TREEPROJECT_ITEM* TREE_PROJECT_FRAME::GetItemIdData( wxTreeItemId aId )
|
2010-02-20 13:20:55 +00:00
|
|
|
{
|
|
|
|
return dynamic_cast<TREEPROJECT_ITEM*>( m_TreeProject->GetItemData( aId ) );
|
|
|
|
}
|
|
|
|
|
2014-07-07 19:49:14 +00:00
|
|
|
|
2012-12-31 08:12:29 +00:00
|
|
|
wxTreeItemId TREE_PROJECT_FRAME::findSubdirTreeItem( const wxString& aSubDir )
|
|
|
|
{
|
2014-10-21 16:34:51 +00:00
|
|
|
wxString prj_dir = wxPathOnly( m_Parent->GetProjectFileName() );
|
|
|
|
|
2012-12-31 08:12:29 +00:00
|
|
|
// If the subdir is the current working directory, return m_root
|
|
|
|
// in main list:
|
2014-10-21 16:34:51 +00:00
|
|
|
if( prj_dir == aSubDir )
|
2012-12-31 08:12:29 +00:00
|
|
|
return m_root;
|
|
|
|
|
|
|
|
// The subdir is in the main tree or in a subdir: Locate it
|
|
|
|
wxTreeItemIdValue cookie;
|
|
|
|
wxTreeItemId root_id = m_root;
|
|
|
|
std::stack < wxTreeItemId > subdirs_id;
|
|
|
|
|
|
|
|
wxTreeItemId kid = m_TreeProject->GetFirstChild( root_id, cookie );
|
2015-02-28 19:00:48 +00:00
|
|
|
|
2019-07-17 10:57:12 +00:00
|
|
|
while( true )
|
2012-12-31 08:12:29 +00:00
|
|
|
{
|
|
|
|
if( ! kid.IsOk() )
|
|
|
|
{
|
|
|
|
if( subdirs_id.empty() ) // all items were explored
|
|
|
|
{
|
|
|
|
root_id = kid; // Not found: return an invalid wxTreeItemId
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
root_id = subdirs_id.top();
|
|
|
|
subdirs_id.pop();
|
|
|
|
kid = m_TreeProject->GetFirstChild( root_id, cookie );
|
2016-06-16 12:38:31 +00:00
|
|
|
|
2019-12-05 19:35:37 +00:00
|
|
|
if( ! kid.IsOk() )
|
2012-12-31 08:12:29 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TREEPROJECT_ITEM* itemData = GetItemIdData( kid );
|
|
|
|
|
2013-01-01 14:06:49 +00:00
|
|
|
if( itemData && ( itemData->GetType() == TREE_DIRECTORY ) )
|
2012-12-31 08:12:29 +00:00
|
|
|
{
|
2014-07-07 19:49:14 +00:00
|
|
|
if( itemData->GetFileName() == aSubDir ) // Found!
|
2012-12-31 08:12:29 +00:00
|
|
|
{
|
|
|
|
root_id = kid;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-01-01 14:06:49 +00:00
|
|
|
// kid is a subdir, push in list to explore it later
|
2014-07-07 19:49:14 +00:00
|
|
|
if( itemData->IsPopulated() )
|
2012-12-31 08:12:29 +00:00
|
|
|
subdirs_id.push( kid );
|
|
|
|
}
|
2016-06-16 12:38:31 +00:00
|
|
|
|
2012-12-31 08:12:29 +00:00
|
|
|
kid = m_TreeProject->GetNextChild( root_id, cookie );
|
|
|
|
}
|
|
|
|
|
|
|
|
return root_id;
|
|
|
|
}
|
|
|
|
|
2014-07-07 19:49:14 +00:00
|
|
|
|
|
|
|
void TREE_PROJECT_FRAME::OnFileSystemEvent( wxFileSystemWatcherEvent& event )
|
2012-12-31 08:12:29 +00:00
|
|
|
{
|
2017-09-22 17:11:11 +00:00
|
|
|
const wxFileName& pathModified = event.GetPath();
|
2013-01-02 21:49:56 +00:00
|
|
|
wxString subdir = pathModified.GetPath();
|
|
|
|
wxString fn = pathModified.GetFullPath();
|
2012-12-31 08:12:29 +00:00
|
|
|
|
|
|
|
switch( event.GetChangeType() )
|
|
|
|
{
|
|
|
|
case wxFSW_EVENT_DELETE:
|
|
|
|
case wxFSW_EVENT_CREATE:
|
|
|
|
case wxFSW_EVENT_RENAME:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wxFSW_EVENT_MODIFY:
|
|
|
|
case wxFSW_EVENT_ACCESS:
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxTreeItemId root_id = findSubdirTreeItem( subdir );
|
2014-10-21 16:34:51 +00:00
|
|
|
|
2012-12-31 08:12:29 +00:00
|
|
|
if( !root_id.IsOk() )
|
|
|
|
return;
|
2010-02-20 13:20:55 +00:00
|
|
|
|
2013-01-02 21:49:56 +00:00
|
|
|
wxTreeItemIdValue cookie; // dummy variable needed by GetFirstChild()
|
|
|
|
wxTreeItemId kid = m_TreeProject->GetFirstChild( root_id, cookie );
|
2012-12-31 08:12:29 +00:00
|
|
|
|
2013-01-02 21:49:56 +00:00
|
|
|
switch( event.GetChangeType() )
|
2012-12-31 08:12:29 +00:00
|
|
|
{
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
case wxFSW_EVENT_CREATE:
|
2019-11-17 00:52:43 +00:00
|
|
|
{
|
2019-12-20 00:34:43 +00:00
|
|
|
wxTreeItemId newitem = AddItemToTreeProject( pathModified.GetFullPath(), root_id );
|
2019-11-17 00:52:43 +00:00
|
|
|
|
|
|
|
// If we are in the process of renaming a file, select the new one
|
2019-11-17 01:51:54 +00:00
|
|
|
// This is needed for MSW and OSX, since we don't get RENAME events from them, just a
|
|
|
|
// pair of DELETE and CREATE events.
|
2019-11-17 00:52:43 +00:00
|
|
|
if( m_isRenaming && newitem.IsOk() )
|
|
|
|
{
|
|
|
|
m_TreeProject->SelectItem( newitem );
|
|
|
|
m_isRenaming = false;
|
|
|
|
}
|
|
|
|
}
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case wxFSW_EVENT_DELETE:
|
|
|
|
while( kid.IsOk() )
|
|
|
|
{
|
|
|
|
TREEPROJECT_ITEM* itemData = GetItemIdData( kid );
|
|
|
|
|
2020-05-16 11:05:53 +00:00
|
|
|
if( itemData && itemData->GetFileName() == fn )
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
{
|
|
|
|
m_TreeProject->Delete( kid );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
kid = m_TreeProject->GetNextChild( root_id, cookie );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wxFSW_EVENT_RENAME :
|
|
|
|
{
|
2017-09-22 17:11:11 +00:00
|
|
|
const wxFileName& newpath = event.GetNewPath();
|
2019-11-16 01:35:48 +00:00
|
|
|
wxString newdir = newpath.GetPath();
|
2017-09-22 17:11:11 +00:00
|
|
|
wxString newfn = newpath.GetFullPath();
|
2012-12-31 08:12:29 +00:00
|
|
|
|
2013-01-02 21:49:56 +00:00
|
|
|
while( kid.IsOk() )
|
2012-12-31 08:12:29 +00:00
|
|
|
{
|
2013-01-02 21:49:56 +00:00
|
|
|
TREEPROJECT_ITEM* itemData = GetItemIdData( kid );
|
|
|
|
|
2020-05-16 11:05:53 +00:00
|
|
|
if( itemData && itemData->GetFileName() == fn )
|
2012-12-31 08:12:29 +00:00
|
|
|
{
|
2013-01-02 21:49:56 +00:00
|
|
|
m_TreeProject->Delete( kid );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
break;
|
2012-12-31 08:12:29 +00:00
|
|
|
}
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
2013-01-02 21:49:56 +00:00
|
|
|
kid = m_TreeProject->GetNextChild( root_id, cookie );
|
2012-12-31 08:12:29 +00:00
|
|
|
}
|
2013-01-02 21:49:56 +00:00
|
|
|
|
2020-05-16 11:05:53 +00:00
|
|
|
// Add the new item only if it is not the current project file (root item).
|
|
|
|
// Remember: this code is called by a wxFileSystemWatcherEvent event, and not always
|
|
|
|
// called after an actual file rename, and the cleanup code does not explore the
|
|
|
|
// root item, because it cannot be renamed by the user.
|
|
|
|
TREEPROJECT_ITEM* rootData = GetItemIdData( root_id );
|
2019-11-17 00:52:43 +00:00
|
|
|
|
2020-05-16 11:05:53 +00:00
|
|
|
if( newfn != rootData->GetFileName() )
|
|
|
|
{
|
|
|
|
wxTreeItemId newroot_id = findSubdirTreeItem( newdir );
|
|
|
|
wxTreeItemId newitem = AddItemToTreeProject( newfn, newroot_id );
|
|
|
|
|
|
|
|
// If the item exists, select it
|
|
|
|
if( newitem.IsOk() )
|
|
|
|
m_TreeProject->SelectItem( newitem );
|
|
|
|
}
|
2019-11-17 01:51:54 +00:00
|
|
|
|
|
|
|
m_isRenaming = false;
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
}
|
|
|
|
break;
|
2012-12-31 08:12:29 +00:00
|
|
|
}
|
|
|
|
|
2014-07-07 19:49:14 +00:00
|
|
|
// Sort filenames by alphabetic order
|
2012-12-31 08:12:29 +00:00
|
|
|
m_TreeProject->SortChildren( root_id );
|
|
|
|
}
|
|
|
|
|
2014-07-07 19:49:14 +00:00
|
|
|
|
2012-12-31 08:12:29 +00:00
|
|
|
void TREE_PROJECT_FRAME::FileWatcherReset()
|
|
|
|
{
|
|
|
|
// Prepare file watcher:
|
2016-06-16 12:38:31 +00:00
|
|
|
if( m_watcher )
|
|
|
|
{
|
|
|
|
m_watcher->RemoveAll();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_watcher = new wxFileSystemWatcher();
|
|
|
|
m_watcher->SetOwner( this );
|
|
|
|
}
|
2012-12-31 08:12:29 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
// We can see wxString under a debugger, not a wxFileName
|
2014-10-21 16:34:51 +00:00
|
|
|
wxString prj_dir = wxPathOnly( m_Parent->GetProjectFileName() );
|
|
|
|
wxFileName fn;
|
|
|
|
fn.AssignDir( prj_dir );
|
|
|
|
fn.DontFollowLink();
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
2019-07-17 10:57:12 +00:00
|
|
|
// Add directories which should be monitored.
|
|
|
|
// under windows, we add the curr dir and all subdirs
|
|
|
|
// under unix, we add only the curr dir and the populated subdirs
|
|
|
|
// see http://docs.wxwidgets.org/trunk/classwx_file_system_watcher.htm
|
|
|
|
// under unix, the file watcher needs more work to be efficient
|
|
|
|
// moreover, under wxWidgets 2.9.4, AddTree does not work properly.
|
2012-12-31 08:12:29 +00:00
|
|
|
#ifdef __WINDOWS__
|
2014-10-21 16:34:51 +00:00
|
|
|
m_watcher->AddTree( fn );
|
2012-12-31 08:12:29 +00:00
|
|
|
#else
|
2014-10-21 16:34:51 +00:00
|
|
|
m_watcher->Add( fn );
|
2013-01-01 14:06:49 +00:00
|
|
|
|
|
|
|
// Add subdirs
|
|
|
|
wxTreeItemIdValue cookie;
|
|
|
|
wxTreeItemId root_id = m_root;
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
2013-01-01 14:06:49 +00:00
|
|
|
std::stack < wxTreeItemId > subdirs_id;
|
|
|
|
|
|
|
|
wxTreeItemId kid = m_TreeProject->GetFirstChild( root_id, cookie );
|
2015-02-28 19:00:48 +00:00
|
|
|
|
2019-07-17 10:57:12 +00:00
|
|
|
while( true )
|
2013-01-01 14:06:49 +00:00
|
|
|
{
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
if( !kid.IsOk() )
|
2013-01-01 14:06:49 +00:00
|
|
|
{
|
|
|
|
if( subdirs_id.empty() ) // all items were explored
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
root_id = subdirs_id.top();
|
|
|
|
subdirs_id.pop();
|
|
|
|
kid = m_TreeProject->GetFirstChild( root_id, cookie );
|
2016-06-16 12:38:31 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
if( !kid.IsOk() )
|
2013-01-01 14:06:49 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TREEPROJECT_ITEM* itemData = GetItemIdData( kid );
|
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
if( itemData && itemData->GetType() == TREE_DIRECTORY )
|
2013-01-01 14:06:49 +00:00
|
|
|
{
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
// we can see wxString under a debugger, not a wxFileName
|
2017-09-22 17:11:11 +00:00
|
|
|
const wxString& path = itemData->GetFileName();
|
2013-01-01 14:06:49 +00:00
|
|
|
|
2018-10-17 19:34:46 +00:00
|
|
|
wxLogTrace( tracePathsAndFiles, "%s: add '%s'\n", __func__, TO_UTF8( path ) );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
|
|
|
if( wxFileName::IsDirReadable( path ) ) // linux whines about watching protected dir
|
|
|
|
{
|
2014-10-21 16:34:51 +00:00
|
|
|
fn.AssignDir( path );
|
|
|
|
m_watcher->Add( fn );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
|
|
|
// if kid is a subdir, push in list to explore it later
|
|
|
|
if( itemData->IsPopulated() && m_TreeProject->GetChildrenCount( kid ) )
|
|
|
|
subdirs_id.push( kid );
|
|
|
|
}
|
2013-01-01 14:06:49 +00:00
|
|
|
}
|
2014-07-07 19:49:14 +00:00
|
|
|
|
2013-01-01 14:06:49 +00:00
|
|
|
kid = m_TreeProject->GetNextChild( root_id, cookie );
|
|
|
|
}
|
2012-12-31 08:12:29 +00:00
|
|
|
#endif
|
2013-01-01 14:06:49 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
#if defined(DEBUG) && 1
|
2013-01-01 14:06:49 +00:00
|
|
|
wxArrayString paths;
|
|
|
|
m_watcher->GetWatchedPaths( &paths );
|
2018-10-17 19:03:33 +00:00
|
|
|
wxLogTrace( tracePathsAndFiles, "%s: watched paths:", __func__ );
|
2016-06-16 12:38:31 +00:00
|
|
|
|
2013-01-01 14:06:49 +00:00
|
|
|
for( unsigned ii = 0; ii < paths.GetCount(); ii++ )
|
2018-10-17 19:03:33 +00:00
|
|
|
wxLogTrace( tracePathsAndFiles, " %s\n", TO_UTF8( paths[ii] ) );
|
2013-01-01 14:06:49 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-06-16 12:38:31 +00:00
|
|
|
|
|
|
|
void KICAD_MANAGER_FRAME::OnChangeWatchedPaths( wxCommandEvent& aEvent )
|
2013-01-01 14:06:49 +00:00
|
|
|
{
|
2019-06-10 14:23:37 +00:00
|
|
|
m_leftWin->FileWatcherReset();
|
2012-12-31 08:12:29 +00:00
|
|
|
}
|