Commit acbe6290 authored by Dick Hollenbeck's avatar Dick Hollenbeck

switch back to original sexpr usage of PTREE, add new DSNLEXER constructor,...

switch back to original sexpr usage of PTREE, add new DSNLEXER constructor, enforce accessors in kicad.exe
parent 0304598a
......@@ -36,6 +36,8 @@
//#define STANDALONE 1 // enable this for stand alone testing.
#define FMT_CLIPBOARD _( "clipboard" )
//-----<DSNLEXER>-------------------------------------------------------------
......@@ -89,7 +91,7 @@ DSNLEXER::DSNLEXER( const KEYWORD* aKeywordTable, unsigned aKeywordCount,
keywordCount( aKeywordCount )
{
STRING_LINE_READER* stringReader = new STRING_LINE_READER( aClipboardTxt, aSource.IsEmpty() ?
wxString( _( "clipboard" ) ) : aSource );
wxString( FMT_CLIPBOARD ) : aSource );
PushReader( stringReader );
init();
}
......@@ -107,6 +109,20 @@ DSNLEXER::DSNLEXER( const KEYWORD* aKeywordTable, unsigned aKeywordCount,
}
static const KEYWORD empty_keywords[1] = {};
DSNLEXER::DSNLEXER( const std::string& aSExpression, const wxString& aSource ) :
iOwnReaders( true ),
keywords( empty_keywords ),
keywordCount( 0 )
{
STRING_LINE_READER* stringReader = new STRING_LINE_READER( aSExpression, aSource.IsEmpty() ?
wxString( FMT_CLIPBOARD ) : aSource );
PushReader( stringReader );
init();
}
DSNLEXER::~DSNLEXER()
{
if( iOwnReaders )
......
......@@ -83,11 +83,7 @@ inline void scanAtom( PTREE* aTree, DSNLEXER* aLexer )
//D(printf( "%s: '%s'\n", __func__, key );)
#if 0
aTree->push_back( PTREE::value_type( key, PTREE() ) );
#else
aTree->put_value( key );
#endif
}
......@@ -194,7 +190,7 @@ static void formatNode( OUTPUTFORMATTER* out, int aNestLevel, int aCtl,
out->Print( aNestLevel, "(%s%s", out->Quotes( aKey ).c_str(), ctl & CTL_OMIT_NL ? "" : "\n" );
if( aTree.data().size() )
if( aTree.data().size() ) // sexpr format does not use data()
{
out->Print( 0, " %s%s",
out->Quotes( aTree.data() ).c_str(),
......
......@@ -56,55 +56,61 @@ void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfRef
sheets.GetComponents( refs, false );
static const KEYWORD empty_keywords[1] = {};
DSNLEXER lexer( empty_keywords, 0, aChangedSetOfReferences, FROM_UTF8( __func__ ) );
DSNLEXER lexer( aChangedSetOfReferences, FROM_UTF8( __func__ ) );
PTREE doc;
Scan( &doc, &lexer );
try
{
Scan( &doc, &lexer );
#if defined(DEBUG) && 0
STRING_FORMATTER sf;
Format( &sf, 0, 0, doc );
printf( "%s: '%s'\n", __func__, sf.GetString().c_str() );
STRING_FORMATTER sf;
Format( &sf, 0, 0, doc );
printf( "%s: '%s'\n", __func__, sf.GetString().c_str() );
#endif
CPTREE& back_anno = doc.get_child( "back_annotation" );
CPTREE& back_anno = doc.get_child( "back_annotation" );
for( PTREE::const_iterator ref = back_anno.begin(); ref != back_anno.end(); ++ref )
{
wxASSERT( ref->first == "ref" );
for( PTREE::const_iterator ref = back_anno.begin(); ref != back_anno.end(); ++ref )
{
wxASSERT( ref->first == "ref" );
wxString reference = (UTF8&) ref->second.data();
wxString footprint = (UTF8) ref->second.get<std::string>( "fpid" );
wxString reference = (UTF8&) ref->second.front().first;
wxString footprint = (UTF8&) ref->second.get_child( "fpid" ).front().first;
// DBG( printf( "%s: ref:%s fpid:%s\n", __func__, TO_UTF8( reference ), TO_UTF8( footprint ) ); )
DBG( printf( "%s: ref:%s fpid:%s\n", __func__, TO_UTF8( reference ), TO_UTF8( footprint ) ); )
// Search the component in the flat list
for( unsigned ii = 0; ii < refs.GetCount(); ++ii )
{
if( Cmp_KEEPCASE( reference, refs[ii].GetRef() ) == 0 )
// Search the component in the flat list
for( unsigned ii = 0; ii < refs.GetCount(); ++ii )
{
// We have found a candidate.
// Note: it can be not unique (multiple parts per package)
// So we *do not* stop the search here
SCH_COMPONENT* component = refs[ii].GetComponent();
SCH_FIELD* fpfield = component->GetField( FOOTPRINT );
const wxString& oldfp = fpfield->GetText();
if( !oldfp && fpfield->IsVisible() )
if( Cmp_KEEPCASE( reference, refs[ii].GetRef() ) == 0 )
{
fpfield->SetVisible( false );
// We have found a candidate.
// Note: it can be not unique (multiple parts per package)
// So we *do not* stop the search here
SCH_COMPONENT* component = refs[ii].GetComponent();
SCH_FIELD* fpfield = component->GetField( FOOTPRINT );
const wxString& oldfp = fpfield->GetText();
if( !oldfp && fpfield->IsVisible() )
{
fpfield->SetVisible( false );
}
// DBG( printf("%s: ref:%s fpid:%s\n", __func__, TO_UTF8( refs[ii].GetRef() ), TO_UTF8( footprint ) );)
if( oldfp != footprint )
isChanged = true;
fpfield->SetText( footprint );
}
// DBG( printf("%s: ref:%s fpid:%s\n", __func__, TO_UTF8( refs[ii].GetRef() ), TO_UTF8( footprint ) );)
if( oldfp != footprint )
isChanged = true;
fpfield->SetText( footprint );
}
}
}
catch( const PTREE_ERROR& ex )
{
// remap the exception to something the caller is likely to understand.
THROW_IO_ERROR( ex.what() );
}
if( isChanged )
OnModify();
......
......@@ -174,7 +174,7 @@ public:
FILE* aFile, const wxString& aFileName );
/**
* Constructor ( std::string&*, const wxString& )
* Constructor ( const KEYWORD*, unsigned, const std::string&, const wxString& )
* intializes a DSN lexer and prepares to read from @a aSExpression.
*
* @param aKeywordTable is an array of KEYWORDS holding \a aKeywordCount. This
......@@ -186,6 +186,16 @@ public:
DSNLEXER( const KEYWORD* aKeywordTable, unsigned aKeywordCount,
const std::string& aSExpression, const wxString& aSource = wxEmptyString );
/**
* Constructor ( const std::string&, const wxString& )
* intializes a DSN lexer and prepares to read from @a aSExpression. Use this
* one without a keyword table with the DOM parser in ptree.h.
*
* @param aSExpression is text to feed through a STRING_LINE_READER
* @param aSource is a description of aSExpression, used for error reporting.
*/
DSNLEXER( const std::string& aSExpression, const wxString& aSource = wxEmptyString );
/**
* Constructor ( LINE_READER* )
* intializes a DSN lexer and prepares to read from @a aLineReader which
......
......@@ -52,9 +52,9 @@ makes it easy to extract a subset of a ptree.
#include <richio.h>
#include <dsnlexer.h>
typedef boost::property_tree::ptree PTREE;
typedef const PTREE CPTREE;
typedef boost::property_tree::ptree PTREE;
typedef const PTREE CPTREE;
typedef boost::property_tree::ptree_error PTREE_ERROR;
/**
* Function Scan
......
......@@ -51,12 +51,11 @@ TREEPROJECT_ITEM::TREEPROJECT_ITEM( enum TreeFileType type, const wxString& data
m_Type = type;
m_parent = parent;
m_FileName = data;
m_IsRootFile = false; // true only for the root item of the tree (the project name)
m_WasPopulated = false;
m_IsRootFile = false; // true only for the root item of the tree (the project name)
m_IsPopulated = false;
}
// Set the state used in the icon list
void TREEPROJECT_ITEM::SetState( int state )
{
wxImageList* imglist = m_parent->GetImageList();
......@@ -71,8 +70,7 @@ void TREEPROJECT_ITEM::SetState( int state )
}
/* Get the directory containing the file */
wxString TREEPROJECT_ITEM::GetDir() const
const wxString TREEPROJECT_ITEM::GetDir() const
{
if( TREE_DIRECTORY == m_Type )
return m_FileName;
......@@ -84,7 +82,6 @@ wxString TREEPROJECT_ITEM::GetDir() const
}
/* rename the file checking if extension change occurs */
bool TREEPROJECT_ITEM::Rename( const wxString& name, bool check )
{
// this is broken & unsafe to use on linux.
......@@ -145,14 +142,13 @@ type.\n Do you want to continue ?"
}
/*******************************************/
bool TREEPROJECT_ITEM::Delete( bool check )
/*******************************************/
/* delete a file */
{
wxString msg;
wxString msg = wxString::Format( _(
"Do you really want to delete '%s'" ),
GetChars( GetFileName() )
);
msg.Printf( _( "Do you really want to delete <%s>" ), GetChars( GetFileName() ) );
wxMessageDialog dialog( m_parent, msg,
_( "Delete File" ), wxYES_NO | wxICON_QUESTION );
......@@ -184,16 +180,15 @@ bool TREEPROJECT_ITEM::Delete( bool check )
}
// Called under item activation
void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe )
{
wxString sep = wxFileName().GetPathSeparator();
wxString FullFileName = GetFileName();
wxString fullFileName = GetFileName();
wxTreeItemId id = GetId();
KICAD_MANAGER_FRAME* mainFrame = (KICAD_MANAGER_FRAME*) Pgm().App().GetTopWindow();
AddDelimiterString( FullFileName );
AddDelimiterString( fullFileName );
switch( GetType() )
{
......@@ -205,24 +200,29 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe )
break;
case TREE_SCHEMA:
mainFrame->Execute( m_parent, EESCHEMA_EXE, FullFileName );
mainFrame->Execute( m_parent, EESCHEMA_EXE, fullFileName );
break;
case TREE_LEGACY_PCB:
case TREE_SEXP_PCB:
mainFrame->Execute( m_parent, PCBNEW_EXE, FullFileName );
{
DBG( printf( "%s: %s\n", __func__, TO_UTF8( fullFileName ) ); )
mainFrame->Execute( m_parent, PCBNEW_EXE, fullFileName );
}
break;
case TREE_GERBER:
mainFrame->Execute( m_parent, GERBVIEW_EXE, FullFileName );
mainFrame->Execute( m_parent, GERBVIEW_EXE, fullFileName );
break;
case TREE_PDF:
OpenPDF( FullFileName );
OpenPDF( fullFileName );
break;
case TREE_NET:
mainFrame->Execute( m_parent, CVPCB_EXE, FullFileName );
mainFrame->Execute( m_parent, CVPCB_EXE, fullFileName );
break;
case TREE_TXT:
......@@ -230,18 +230,16 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe )
wxString editorname = Pgm().GetEditorName();
if( !editorname.IsEmpty() )
mainFrame->Execute( m_parent, editorname, FullFileName );
break;
mainFrame->Execute( m_parent, editorname, fullFileName );
}
break;
case TREE_PAGE_LAYOUT_DESCR:
mainFrame->Execute( m_parent, PL_EDITOR_EXE, FullFileName );
mainFrame->Execute( m_parent, PL_EDITOR_EXE, fullFileName );
break;
default:
OpenFile( FullFileName );
OpenFile( fullFileName );
break;
}
}
/*
* class_treeproject_item.h
*/
#ifndef TREEPROJECT_ITEM_H_
#define TREEPROJECT_ITEM_H_
/** class TREEPROJECT_ITEM
* Handle one item (a file or a directory name) for the tree file
/**
* Class TREEPROJECT_ITEM
* handles one item (a file or a directory name) for the tree file
*/
class TREEPROJECT_ITEM : public wxTreeItemData
{
public:
TreeFileType m_Type; // = TREE_PROJECT, TREE_DIRECTORY ...
wxString m_FileName; // Filename for a file, or directory name
bool m_IsRootFile; // True if m_Filename is a root schematic (same name as project)
bool m_WasPopulated; // True the name is a directory, and its content was read
private:
wxTreeCtrl* m_parent;
int m_state;
friend class KICAD_MANAGER_FRAME;
public:
TREEPROJECT_ITEM( TreeFileType type, const wxString& data,
wxTreeCtrl* parent );
TREEPROJECT_ITEM() : m_parent( NULL ) { }
TREEPROJECT_ITEM( const TREEPROJECT_ITEM& src ) :
m_Type( src.m_Type ), m_FileName( src.m_FileName ), m_parent( src.m_parent )
{
SetState( src.m_state );
m_WasPopulated = false;
m_IsPopulated = false;
}
TreeFileType GetType() const
{
return m_Type;
}
TreeFileType GetType() const { return m_Type; }
void SetType( TreeFileType aType ) { m_Type = aType; }
void SetType( TreeFileType aType )
{
m_Type = aType;
}
const wxString& GetFileName() const { return m_FileName; }
void SetFileName( const wxString& name ) { m_FileName = name; }
wxString GetFileName() const
{
return m_FileName;
}
bool IsRootFile() const { return m_IsRootFile; }
void SetRootFile( bool aValue ) { m_IsRootFile = aValue; }
void SetFileName( const wxString& name )
{
m_FileName = name;
}
bool IsPopulated() const { return m_IsPopulated; }
void SetPopulated( bool aValue ) { m_IsPopulated = aValue; }
/**
* @return the path of an item.
* if this item is a directory, returns the stored filename
* if this is a file, returns its path
*/
wxString GetDir() const;
const wxString GetDir() const;
bool Rename( const wxString& name, bool check = true );
bool Delete( bool check = true );
void Activate( TREE_PROJECT_FRAME* prjframe );
bool Rename( const wxString& name, bool check = true );
bool Delete( bool check = true );
void Activate( TREE_PROJECT_FRAME* prjframe );
void SetState( int state );
private:
TreeFileType m_Type; // = TREE_PROJECT, TREE_DIRECTORY ...
wxString m_FileName; // Filename for a file, or directory name
bool m_IsRootFile; // True if m_Filename is a root schematic (same name as project)
bool m_IsPopulated; // True if the name is a directory, and its content was read
wxTreeCtrl* m_parent;
int m_state;
};
#endif // TREEPROJECT_ITEM_H_
......@@ -83,8 +83,7 @@ TREEPROJECTFILES::TREEPROJECTFILES( TREE_PROJECT_FRAME* parent ) :
TREEPROJECTFILES::~TREEPROJECTFILES()
{
if( m_ImageList )
delete m_ImageList;
delete m_ImageList;
}
......@@ -93,16 +92,18 @@ int TREEPROJECTFILES::OnCompareItems( const wxTreeItemId& item1, const wxTreeIte
TREEPROJECT_ITEM* myitem1 = (TREEPROJECT_ITEM*) GetItemData( item1 );
TREEPROJECT_ITEM* myitem2 = (TREEPROJECT_ITEM*) GetItemData( item2 );
if( (myitem1->m_Type == TREE_DIRECTORY) && ( myitem2->m_Type != TREE_DIRECTORY ) )
if( myitem1->GetType() == TREE_DIRECTORY && myitem2->GetType() != TREE_DIRECTORY )
return -1;
if( (myitem2->m_Type == TREE_DIRECTORY) && ( myitem1->m_Type != TREE_DIRECTORY ) )
if( myitem2->GetType() == TREE_DIRECTORY && myitem1->GetType() != TREE_DIRECTORY )
return 1;
if( myitem1->m_IsRootFile && !myitem2->m_IsRootFile )
if( myitem1->IsRootFile() && !myitem2->IsRootFile() )
return -1;
if( myitem2->m_IsRootFile && !myitem1->m_IsRootFile )
if( myitem2->IsRootFile() && !myitem1->IsRootFile() )
return 1;
return myitem1->m_FileName.CmpNoCase( myitem2->m_FileName );
return myitem1->GetFileName().CmpNoCase( myitem2->GetFileName() );
}
......@@ -41,8 +41,8 @@
#include <kicad.h>
static const wxString ZipFileExtension( wxT( "zip" ) );
static const wxString ZipFileWildcard( wxT( "Zip file (*.zip) | *.zip" ) );
#define ZipFileExtension wxT( "zip" )
#define ZipFileWildcard wxT( "Zip file (*.zip) | *.zip" )
void KICAD_MANAGER_FRAME::OnFileHistory( wxCommandEvent& event )
......@@ -53,14 +53,17 @@ void KICAD_MANAGER_FRAME::OnFileHistory( wxCommandEvent& event )
if( fn != wxEmptyString )
{
wxCommandEvent cmd( 0, wxID_ANY );
m_ProjectFileName = fn;
SetProjectFileName( fn );
OnLoadProject( cmd );
}
}
void KICAD_MANAGER_FRAME::OnUnarchiveFiles( wxCommandEvent& event )
{
wxFileName fn = m_ProjectFileName;
wxFileName fn = GetProjectFileName();
fn.SetExt( ZipFileExtension );
wxFileDialog dlg( this, _( "Unzip Project" ), fn.GetPath(),
......@@ -70,8 +73,7 @@ void KICAD_MANAGER_FRAME::OnUnarchiveFiles( wxCommandEvent& event )
if( dlg.ShowModal() == wxID_CANCEL )
return;
wxString msg;
msg.Printf( _("\nOpen <%s>\n" ), GetChars( dlg.GetPath() ) );
wxString msg = wxString::Format( _("\nOpen <%s>\n" ), GetChars( dlg.GetPath() ) );
PrintMsg( msg );
wxDirDialog dirDlg( this, _( "Target Directory" ), fn.GetPath(),
......@@ -85,6 +87,7 @@ void KICAD_MANAGER_FRAME::OnUnarchiveFiles( wxCommandEvent& event )
PrintMsg( msg );
wxFileSystem zipfilesys;
zipfilesys.AddHandler( new wxZipFSHandler );
zipfilesys.ChangePathTo( dlg.GetPath() + wxT( "#zip:" ) );
......@@ -94,7 +97,7 @@ void KICAD_MANAGER_FRAME::OnUnarchiveFiles( wxCommandEvent& event )
while( !localfilename.IsEmpty() )
{
zipfile = zipfilesys.OpenFile( localfilename );
if( zipfile == NULL )
if( !zipfile )
{
DisplayError( this, wxT( "Zip file read error" ) );
break;
......@@ -139,7 +142,7 @@ void KICAD_MANAGER_FRAME::OnArchiveFiles( wxCommandEvent& event )
};
wxString msg;
wxFileName fileName = m_ProjectFileName;
wxFileName fileName = GetProjectFileName();
wxString oldPath = wxGetCwd();
fileName.SetExt( wxT( "zip" ) );
......
......@@ -158,15 +158,15 @@ bool PGM_KICAD::OnPgmInit( wxApp* aWxApp )
bool prjloaded = false; // true when the project is loaded
if( App().argc > 1 )
frame->m_ProjectFileName = App().argv[1];
frame->SetProjectFileName( App().argv[1] );
else if( GetFileHistory().GetCount() )
{
// Try to open the last opened project,
// if a project name is not given when starting Kicad
frame->m_ProjectFileName = GetFileHistory().GetHistoryFile( 0 );
frame->SetProjectFileName( GetFileHistory().GetHistoryFile( 0 ) );
if( !frame->m_ProjectFileName.FileExists() )
if( !wxFileExists( frame->GetProjectFileName() ) )
GetFileHistory().RemoveFileFromHistory( 0 );
else
{
......@@ -177,12 +177,12 @@ bool PGM_KICAD::OnPgmInit( wxApp* aWxApp )
}
}
if( !frame->m_ProjectFileName.FileExists() )
if( !wxFileExists( frame->GetProjectFileName() ) )
{
wxFileName namelessProject( wxGetCwd(), NAMELESS_PROJECT,
ProjectFileExtension );
frame->m_ProjectFileName = namelessProject;
frame->SetProjectFileName( namelessProject.GetFullPath() );
}
if( !prjloaded )
......@@ -218,23 +218,24 @@ void PGM_KICAD::MacOpenFile( const wxString& aFileName )
KICAD_MANAGER_FRAME* frame = (KICAD_MANAGER_FRAME*) GetTopWindow();
wxFileName fn = aFileName;
frame->SetProjectFile( aFileName );
frame->m_ProjectFileName = fn;
wxFileName fn = aFileName;
if( !frame->m_ProjectFileName.FileExists() && m_fileHistory.GetCount() )
if( !fn.FileExists() && m_fileHistory.GetCount() )
{
m_fileHistory.RemoveFileFromHistory( 0 );
return;
}
wxCommandEvent loadEvent;
loadEvent.SetId( wxID_ANY );
frame->OnLoadProject( loadEvent );
wxString title = GetTitle() + wxT( " " ) + GetBuildVersion() +
wxT( " " ) + frame->m_ProjectFileName.GetFullPath();
wxT( " " ) + frame->GetProjectFileName();
if( !fn.IsDirWritable() )
title += _( " [Read Only]" );
......
......@@ -120,28 +120,6 @@ enum id_kicad_frm {
*/
class KICAD_MANAGER_FRAME : public EDA_BASE_FRAME
{
protected:
wxConfigBase* config(); // override EDA_BASE_FRAME virtual
const SEARCH_STACK& sys_search(); // override EDA_BASE_FRAME virtual
wxString help_name(); // override EDA_BASE_FRAME virtual
public:
TREE_PROJECT_FRAME* m_LeftWin;
LAUNCHER_PANEL* m_Launcher;
wxTextCtrl* m_MessagesBox;
wxAuiToolBar* m_VToolBar; // Vertical toolbar (not used)
wxString m_BoardFileName;
wxString m_SchematicRootFileName;
wxFileName m_ProjectFileName;
private:
int m_leftWinWidth;
void language_change( wxCommandEvent& event );
public:
KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
const wxPoint& pos, const wxSize& size );
......@@ -211,7 +189,7 @@ public:
void OnUpdateDefaultPdfBrowser( wxUpdateUIEvent& event );
void OnUpdatePreferredPdfBrowser( wxUpdateUIEvent& event );
void CreateNewProject( const wxString aPrjFullFileName, bool aTemplateSelector );
void CreateNewProject( const wxString& aPrjFullFileName, bool aTemplateSelector );
void LoadSettings( wxConfigBase* aCfg );
......@@ -249,7 +227,32 @@ public:
void OnChangeWatchedPaths(wxCommandEvent& aEvent );
#endif
void SetProjectFileName( const wxString& aFullProjectProFileName );
const wxString GetProjectFileName();
// read only accessors
const wxString SchFileName();
const wxString PcbFileName();
DECLARE_EVENT_TABLE()
private:
wxConfigBase* config(); // override EDA_BASE_FRAME virtual
const SEARCH_STACK& sys_search(); // override EDA_BASE_FRAME virtual
wxString help_name(); // override EDA_BASE_FRAME virtual
TREE_PROJECT_FRAME* m_LeftWin;
LAUNCHER_PANEL* m_Launcher;
wxTextCtrl* m_MessagesBox;
wxAuiToolBar* m_VToolBar; // Vertical toolbar (not used)
wxFileName m_project_file_name;
int m_leftWinWidth;
void language_change( wxCommandEvent& event );
};
......
......@@ -41,7 +41,6 @@
#include <wildcards_and_files_ext.h>
#include <menus_helpers.h>
#define USE_KIFACE 1
#define TreeFrameWidthEntry wxT( "LeftWinWidth" )
......@@ -125,6 +124,35 @@ wxConfigBase* KICAD_MANAGER_FRAME::config()
return ret;
}
void KICAD_MANAGER_FRAME::SetProjectFileName( const wxString& aFullProjectProFileName )
{
m_project_file_name = aFullProjectProFileName;
wxASSERT( m_project_file_name.IsAbsolute() );
}
const wxString KICAD_MANAGER_FRAME::GetProjectFileName()
{
return m_project_file_name.GetFullPath();
}
const wxString KICAD_MANAGER_FRAME::SchFileName()
{
wxFileName fn( GetProjectFileName(), SchematicFileExtension );
return fn.GetFullName();
}
const wxString KICAD_MANAGER_FRAME::PcbFileName()
{
wxFileName fn( GetProjectFileName(), PcbFileExtension );
return fn.GetFullName();
}
const SEARCH_STACK& KICAD_MANAGER_FRAME::sys_search()
{
......@@ -159,7 +187,7 @@ void KICAD_MANAGER_FRAME::OnCloseWindow( wxCloseEvent& Event )
{
int px, py;
UpdateFileHistory( m_ProjectFileName.GetFullPath(), &Pgm().GetFileHistory() );
UpdateFileHistory( GetProjectFileName(), &Pgm().GetFileHistory() );
if( !IsIconized() ) // save main frame position and size
{
......@@ -238,16 +266,14 @@ void KICAD_MANAGER_FRAME::OnRunPageLayoutEditor( wxCommandEvent& event )
void KICAD_MANAGER_FRAME::OnRunPcbNew( wxCommandEvent& event )
{
wxFileName legacy_board( m_ProjectFileName );
wxFileName kicad_board( m_ProjectFileName );
wxFileName kicad_board( PcbFileName() );
wxFileName legacy_board( GetProjectFileName() );
legacy_board.SetExt( LegacyPcbFileExtension );
kicad_board.SetExt( KiCadPcbFileExtension );
wxFileName& board = ( !legacy_board.FileExists() || kicad_board.FileExists() ) ?
kicad_board : legacy_board;
#if USE_KIFACE
KIWAY_PLAYER* frame = Kiway.Player( FRAME_PCB, false );
if( !frame )
{
......@@ -256,19 +282,15 @@ void KICAD_MANAGER_FRAME::OnRunPcbNew( wxCommandEvent& event )
frame->Show( true );
}
frame->Raise();
#else
Execute( this, PCBNEW_EXE, QuoteFullPath( board ) );
#endif
}
void KICAD_MANAGER_FRAME::OnRunCvpcb( wxCommandEvent& event )
{
wxFileName fn( m_ProjectFileName );
wxFileName fn( m_project_file_name );
fn.SetExt( NetlistFileExtension );
#if USE_KIFACE
KIWAY_PLAYER* frame = Kiway.Player( FRAME_CVPCB, false );
if( !frame )
{
......@@ -277,19 +299,15 @@ void KICAD_MANAGER_FRAME::OnRunCvpcb( wxCommandEvent& event )
frame->Show( true );
}
frame->Raise();
#else
Execute( this, CVPCB_EXE, QuoteFullPath( fn ) );
#endif
}
void KICAD_MANAGER_FRAME::OnRunEeschema( wxCommandEvent& event )
{
wxFileName fn( m_ProjectFileName );
wxFileName fn( m_project_file_name );
fn.SetExt( SchematicFileExtension );
#if USE_KIFACE
KIWAY_PLAYER* frame = Kiway.Player( FRAME_SCH, false );
if( !frame )
{
......@@ -298,20 +316,14 @@ void KICAD_MANAGER_FRAME::OnRunEeschema( wxCommandEvent& event )
frame->Show( true );
}
frame->Raise();
#else
Execute( this, EESCHEMA_EXE, QuoteFullPath( fn ) );
#endif
}
void KICAD_MANAGER_FRAME::OnRunGerbview( wxCommandEvent& event )
{
// Gerbview is called without any file to open, because we do not know
// the list and the name of files to open (if any...).
#if USE_KIFACE && 0
#else
Execute( this, GERBVIEW_EXE, wxEmptyString );
#endif
}
......@@ -392,7 +404,7 @@ void KICAD_MANAGER_FRAME::PrintPrjInfo()
wxString msg = wxString::Format( _(
"Working dir: %s\nProject: %s\n" ),
GetChars( wxGetCwd() ),
GetChars( m_ProjectFileName.GetFullPath() )
GetChars( GetProjectFileName() )
);
PrintMsg( msg );
}
......
......@@ -57,8 +57,8 @@
PARAM_CFG_ARRAY s_KicadManagerParams;
void KICAD_MANAGER_FRAME::CreateNewProject( const wxString aPrjFullFileName,
bool aTemplateSelector = false )
void KICAD_MANAGER_FRAME::CreateNewProject( const wxString& aPrjFullFileName,
bool aTemplateSelector = false )
{
wxString filename;
wxFileName newProjectName = aPrjFullFileName;
......@@ -169,15 +169,8 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString aPrjFullFileName,
}
}
// Init schematic filename
m_SchematicRootFileName = wxFileName( newProjectName.GetName(),
SchematicFileExtension ).GetFullName();
// Init pcb board filename
m_BoardFileName = wxFileName( newProjectName.GetName(), PcbFileExtension ).GetFullName();
// Init project filename
m_ProjectFileName = newProjectName;
SetProjectFileName( newProjectName.GetFullPath() );
// Write settings to project file
// was: wxGetApp().WriteProjectConfig( aPrjFullFileName, GeneralGroupName, s_KicadManagerParams );
......@@ -187,15 +180,19 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString aPrjFullFileName,
void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
{
int style;
wxString title;
bool newProject = ( event.GetId() == ID_NEW_PROJECT ) ||
( event.GetId() == ID_NEW_PROJECT_FROM_TEMPLATE );
wxString title;
// this is still a mess, will work on it tomorrow.
ClearMsg();
if( event.GetId() != wxID_ANY )
{
int style;
bool newProject = ( event.GetId() == ID_NEW_PROJECT ) ||
( event.GetId() == ID_NEW_PROJECT_FROM_TEMPLATE );
if( newProject )
{
title = _( "Create New Project" );
......@@ -207,21 +204,20 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
style = wxFD_OPEN | wxFD_FILE_MUST_EXIST;
}
wxString default_dir = wxGetCwd();
wxFileDialog dlg( this, title, default_dir, wxEmptyString,
ProjectFileWildcard, style );
wxString default_dir = wxGetCwd();
wxFileDialog dlg( this, title, default_dir, wxEmptyString,
ProjectFileWildcard, style );
if( dlg.ShowModal() == wxID_CANCEL )
return;
m_ProjectFileName = dlg.GetPath();
wxFileName pro( dlg.GetPath() );
pro.SetExt( ProjectFileExtension );
if( newProject )
{
m_ProjectFileName.SetExt( ProjectFileExtension );
// Check if the project directory is empty
wxDir directory ( m_ProjectFileName.GetPath() );
wxDir directory( pro.GetPath() );
if( directory.HasFiles() )
{
......@@ -233,57 +229,59 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
{
// Append a new directory with the same name of the project file
// and try to create it
m_ProjectFileName.AppendDir( m_ProjectFileName.GetName() );
pro.AppendDir( pro.GetName() );
if( !wxMkdir( m_ProjectFileName.GetPath() ) )
if( !wxMkdir( pro.GetPath() ) )
// There was a problem, undo
m_ProjectFileName.RemoveLastDir();
pro.RemoveLastDir();
}
}
if( event.GetId() == ID_NEW_PROJECT )
{
CreateNewProject( m_ProjectFileName.GetFullPath() );
CreateNewProject( pro.GetFullPath() );
}
else if( event.GetId() == ID_NEW_PROJECT_FROM_TEMPLATE )
{
// Launch the template selector dialog
CreateNewProject( m_ProjectFileName.GetFullPath(), true );
CreateNewProject( pro.GetFullPath(), true );
}
}
SetProjectFileName( pro.GetFullName() );
}
wxLogDebug( wxT( "Loading KiCad project file: " ) + m_ProjectFileName.GetFullPath() );
wxLogDebug( wxT( "Loading KiCad project file: " ) + GetProjectFileName() );
/* Check if project file exists and if it is not noname.pro */
wxString filename = m_ProjectFileName.GetFullName();
// Check if project file exists and if it is not noname.pro
wxString filename = GetProjectFileName();
wxString nameless_prj = NAMELESS_PROJECT wxT( ".pro" );
if( !m_ProjectFileName.FileExists() && !filename.IsSameAs( nameless_prj ) )
if( !wxFileExists( GetProjectFileName() ) && !filename.IsSameAs( nameless_prj ) )
{
wxString msg = wxString::Format(
_( "KiCad project file '%s' not found" ),
GetChars( m_ProjectFileName.GetFullPath() ) );
GetChars( GetProjectFileName() ) );
DisplayError( this, msg );
return;
}
wxSetWorkingDirectory( m_ProjectFileName.GetPath() );
wxSetWorkingDirectory( wxFileName( GetProjectFileName() ).GetPath() );
// was wxGetApp().ReadProjectConfig( m_ProjectFileName.GetFullPath(),
// GeneralGroupName, s_KicadManagerParams, false );
Prj().ConfigLoad( Pgm().SysSearch(), m_ProjectFileName.GetFullPath(),
Prj().ConfigLoad( Pgm().SysSearch(), GetProjectFileName(),
GeneralGroupName, s_KicadManagerParams, false );
title = wxT( "KiCad " ) + GetBuildVersion() + wxT( ' ' ) + m_ProjectFileName.GetFullPath();
title = wxT( "KiCad " ) + GetBuildVersion() + wxT( ' ' ) + GetProjectFileName();
if( !m_ProjectFileName.IsDirWritable() )
if( !wxIsWritable( GetProjectFileName() ) )
title += _( " [Read Only]" );
SetTitle( title );
UpdateFileHistory( m_ProjectFileName.GetFullPath(), &Pgm().GetFileHistory() );
UpdateFileHistory( GetProjectFileName(), &Pgm().GetFileHistory() );
m_LeftWin->ReCreateTreePrj();
......@@ -292,7 +290,8 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
// however this is possible only when the main loop event handler is running,
// so we use it to run the rebuild function.
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_INIT_WATCHED_PATHS );
wxPostEvent( this, cmd);
wxPostEvent( this, cmd );
#endif
PrintPrjInfo();
......@@ -301,12 +300,11 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
void KICAD_MANAGER_FRAME::OnSaveProject( wxCommandEvent& event )
{
if( !IsWritable( m_ProjectFileName ) )
if( !wxIsWritable( GetProjectFileName() ) )
return;
// was: wxGetApp().WriteProjectConfig( m_ProjectFileName.GetFullPath(),
// GeneralGroupName, s_KicadManagerParams );
Prj().ConfigSave( Pgm().SysSearch(), m_ProjectFileName.GetFullPath(),
Prj().ConfigSave( Pgm().SysSearch(), GetProjectFileName(),
GeneralGroupName, s_KicadManagerParams );
}
......@@ -93,10 +93,10 @@ static const wxChar* s_allowedExtensionsToList[] =
* library as required.
*/
/* File extension definitions. */
// File extension definitions.
const wxChar TextFileExtension[] = wxT( "txt" );
/* File wildcard definitions. */
// File wildcard definitions.
const wxChar TextFileWildcard[] = wxT( "Text files (*.txt)|*.txt" );
......@@ -132,11 +132,13 @@ TREE_PROJECT_FRAME::TREE_PROJECT_FRAME( KICAD_MANAGER_FRAME* parent ) :
{
m_Parent = parent;
m_TreeProject = NULL;
#ifdef KICAD_USE_FILES_WATCHER
m_watcher = NULL;
Connect( wxEVT_FSWATCHER,
wxFileSystemWatcherEventHandler( TREE_PROJECT_FRAME::OnFileSystemEvent ) );
#endif
/*
* Filtering is now inverted: the filters are actually used to _enable_ support
* for a given file type.
......@@ -162,9 +164,7 @@ TREE_PROJECT_FRAME::~TREE_PROJECT_FRAME()
}
/*****************************************************************************/
void TREE_PROJECT_FRAME::RemoveFilter( const wxString& filter )
/*****************************************************************************/
{
for( unsigned int i = 0; i < m_filters.size(); i++ )
{
......@@ -177,11 +177,6 @@ void TREE_PROJECT_FRAME::RemoveFilter( const wxString& filter )
}
/**
* Called by the popup menu in the tree frame
* Creates a new subdirectory inside the current kicad project directory
* the user is prompted to enter a directory name
*/
void TREE_PROJECT_FRAME::OnCreateNewDirectory( wxCommandEvent& event )
{
// Get the root directory name:
......@@ -374,16 +369,6 @@ wxString TREE_PROJECT_FRAME::GetFileWildcard( TreeFileType type )
}
/**
* Function AddItemToTreeProject
* @brief Add filename "name" to the tree \n
* if name is a directory, add the sub directory file names
* @param aName = the filename or the dirctory name to add
* @param aRoot = the wxTreeItemId item where to add sub tree items
* @param aRecurse = true to add file or subdir names to the current tree item
* false to stop file add.
* @return true if the file (or directory) is added.
*/
bool TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName,
wxTreeItemId& aRoot, bool aRecurse )
{
......@@ -450,7 +435,7 @@ bool TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName,
wxString rootName;
TREEPROJECT_ITEM* itemData = GetItemIdData( m_root );
if( itemData )
rootName = itemData->m_FileName.BeforeLast( '.' );
rootName = itemData->GetFileName().BeforeLast( '.' );
if( fullFileName != rootName )
{
......@@ -513,7 +498,7 @@ bool TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName,
if( itemData )
{
if( itemData->m_FileName == aName )
if( itemData->GetFileName() == aName )
{
return true; // well, we would have added it, but it is already here!
}
......@@ -531,13 +516,13 @@ bool TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName,
data->SetState( 0 );
/* Mark root files (files which have the same aName as the project) */
wxFileName project( m_Parent->m_ProjectFileName );
wxFileName project( m_Parent->GetProjectFileName() );
wxFileName currfile( file );
if( currfile.GetName().CmpNoCase( project.GetName() ) == 0 )
data->m_IsRootFile = true;
data->SetRootFile( true );
else
data->m_IsRootFile = false;
data->SetRootFile( false );
// This section adds dirs and files found in the subdirs
// in this case AddFile is recursive, but for the first level only.
......@@ -546,7 +531,8 @@ bool TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName,
const wxString sep = wxFileName().GetPathSeparator();
wxDir dir( aName );
wxString dir_filename;
data->m_WasPopulated = true; // set state to populated
data->SetPopulated( true );
if( dir.GetFirst( &dir_filename ) )
{
......@@ -564,13 +550,9 @@ bool TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName,
}
/**
* @brief Create or modify the tree showing project file names
*/
void TREE_PROJECT_FRAME::ReCreateTreePrj()
{
wxTreeItemId rootcellule;
wxFileName fn;
bool prjOpened = false;
if( !m_TreeProject )
......@@ -578,15 +560,15 @@ void TREE_PROJECT_FRAME::ReCreateTreePrj()
else
m_TreeProject->DeleteAllItems();
if( !m_Parent->m_ProjectFileName.IsOk() )
wxFileName fn = m_Parent->GetProjectFileName();
if( !fn.IsOk() )
{
fn.Clear();
fn.SetPath( ::wxGetCwd() );
fn.SetName( NAMELESS_PROJECT );
fn.SetExt( ProjectFileExtension );
}
else
fn = m_Parent->m_ProjectFileName;
prjOpened = fn.FileExists();
......@@ -625,26 +607,21 @@ void TREE_PROJECT_FRAME::ReCreateTreePrj()
m_TreeProject->Expand( rootcellule );
/* Sort filenames by alphabetic order */
// Sort filenames by alphabetic order
m_TreeProject->SortChildren( m_root );
m_Parent->m_ProjectFileName = fn;
m_Parent->SetProjectFileName( fn.GetFullPath() );
}
/**
* @brief Opens *popup* the context menu
*/
/*****************************************************************************/
void TREE_PROJECT_FRAME::OnRight( wxTreeEvent& Event )
/*****************************************************************************/
{
int tree_id;
TREEPROJECT_ITEM* tree_data;
wxString FullFileName;
wxTreeItemId curr_item = Event.GetItem();
/* Ensure item is selected (Under Windows right click does not select the item) */
// Ensure item is selected (Under Windows right click does not select the item)
m_TreeProject->SelectItem( curr_item );
tree_data = GetSelectedData();
......@@ -696,10 +673,7 @@ void TREE_PROJECT_FRAME::OnRight( wxTreeEvent& Event )
PopupMenu( &popupMenu );
}
/*
* Called by the popup menu, when right clicking on a file name
* Launch the text editor to open the selected file
*/
void TREE_PROJECT_FRAME::OnOpenSelectedFileWithTextEditor( wxCommandEvent& event )
{
TREEPROJECT_ITEM* tree_data = GetSelectedData();
......@@ -719,10 +693,6 @@ void TREE_PROJECT_FRAME::OnOpenSelectedFileWithTextEditor( wxCommandEvent& event
}
/* Called via the popup menu, when right clicking on a file name
* or a directory name to delete the selected file or directory
* in the tree project
*/
void TREE_PROJECT_FRAME::OnDeleteFile( wxCommandEvent& )
{
TREEPROJECT_ITEM* tree_data = GetSelectedData();
......@@ -734,10 +704,6 @@ void TREE_PROJECT_FRAME::OnDeleteFile( wxCommandEvent& )
}
/* Called via the popup menu, when right clicking on a file name
* or a directory name to rename the selected file or directory
* in the tree project
*/
void TREE_PROJECT_FRAME::OnRenameFile( wxCommandEvent& )
{
wxTreeItemId curr_item = m_TreeProject->GetSelection();
......@@ -746,9 +712,10 @@ void TREE_PROJECT_FRAME::OnRenameFile( wxCommandEvent& )
if( !tree_data )
return;
wxString buffer = m_TreeProject->GetItemText( curr_item );
wxString msg;
msg.Printf( _( "Change filename: <%s>" ), GetChars( tree_data->m_FileName ) );
wxString buffer = m_TreeProject->GetItemText( curr_item );
wxString msg = wxString::Format(
_( "Change filename: <%s>" ),
GetChars( tree_data->GetFileName() ) );
wxTextEntryDialog dlg( this, msg, _( "Change filename" ), buffer );
......@@ -767,12 +734,7 @@ void TREE_PROJECT_FRAME::OnRenameFile( wxCommandEvent& )
}
/*
* called on a double click on an item
*/
/*****************************************************************************/
void TREE_PROJECT_FRAME::OnSelect( wxTreeEvent& Event )
/*****************************************************************************/
{
wxString FullFileName;
......@@ -785,13 +747,7 @@ void TREE_PROJECT_FRAME::OnSelect( wxTreeEvent& Event )
}
/**
* @brief Called when expanding an item of the tree
* populate tree items corresponding to subdirectories not already populated
*/
/*****************************************************************************/
void TREE_PROJECT_FRAME::OnExpand( wxTreeEvent& Event )
/*****************************************************************************/
{
wxString FullFileName;
......@@ -816,7 +772,7 @@ void TREE_PROJECT_FRAME::OnExpand( wxTreeEvent& Event )
if( !itemData || itemData->GetType() != TREE_DIRECTORY )
continue;
if( itemData->m_WasPopulated )
if( itemData->IsPopulated() )
continue;
wxString fileName = itemData->GetFileName();
......@@ -832,10 +788,10 @@ void TREE_PROJECT_FRAME::OnExpand( wxTreeEvent& Event )
} while( dir.GetNext( &dir_filename ) );
}
itemData->m_WasPopulated = true; // set state to populated
itemData->SetPopulated( true ); // set state to populated
subdir_populated = true;
/* Sort filenames by alphabetic order */
// Sort filenames by alphabetic order
m_TreeProject->SortChildren( kid );
}
......@@ -850,12 +806,6 @@ void TREE_PROJECT_FRAME::OnExpand( wxTreeEvent& Event )
}
/**
* Function GetSelectedData
* return the item data from item currently selected (highlighted)
* Note this is not necessary the "clicked" item,
* because when expanding, collapsing an item this item is not selected
*/
TREEPROJECT_ITEM* TREE_PROJECT_FRAME::GetSelectedData()
{
return dynamic_cast<TREEPROJECT_ITEM*>( m_TreeProject->GetItemData
......@@ -863,25 +813,12 @@ TREEPROJECT_ITEM* TREE_PROJECT_FRAME::GetSelectedData()
}
/**
* Function GetItemIdData
* return the item data corresponding to a wxTreeItemId identifier
* @param aId = the wxTreeItemId identifier.
* @return a TREEPROJECT_ITEM pointer correspondinfg to item id aId
*/
TREEPROJECT_ITEM* TREE_PROJECT_FRAME::GetItemIdData( wxTreeItemId aId )
{
return dynamic_cast<TREEPROJECT_ITEM*>( m_TreeProject->GetItemData( aId ) );
}
/* Search for the item in tree project which is the
* node of the subdirectory aSubDir
* param aSubDir = the directory to find in tree
* return the opaque reference to the tree item.
* if not found, return an invalid tree item.
* therefore wxTreeItemId::IsOk should be used to test
* the returned value
*/
wxTreeItemId TREE_PROJECT_FRAME::findSubdirTreeItem( const wxString& aSubDir )
{
// If the subdir is the current working directory, return m_root
......@@ -918,14 +855,14 @@ wxTreeItemId TREE_PROJECT_FRAME::findSubdirTreeItem( const wxString& aSubDir )
if( itemData && ( itemData->GetType() == TREE_DIRECTORY ) )
{
if( itemData->m_FileName == aSubDir ) // Found!
if( itemData->GetFileName() == aSubDir ) // Found!
{
root_id = kid;
break;
}
// kid is a subdir, push in list to explore it later
if( itemData->m_WasPopulated )
if( itemData->IsPopulated() )
subdirs_id.push( kid );
}
kid = m_TreeProject->GetNextChild( root_id, cookie );
......@@ -934,12 +871,9 @@ wxTreeItemId TREE_PROJECT_FRAME::findSubdirTreeItem( const wxString& aSubDir )
return root_id;
}
#ifdef KICAD_USE_FILES_WATCHER
/* called when a file or directory is modified/created/deleted
* The tree project is modified when a file or directory
* is created/deleted/renamed to reflect the file change
*/
void TREE_PROJECT_FRAME::OnFileSystemEvent( wxFileSystemWatcherEvent& event )
void TREE_PROJECT_FRAME::OnFileSystemEvent( wxFileSystemWatcherEvent& event )
{
wxFileName pathModified = event.GetPath();
wxString subdir = pathModified.GetPath();
......@@ -981,7 +915,7 @@ wxTreeItemId TREE_PROJECT_FRAME::findSubdirTreeItem( const wxString& aSubDir )
{
TREEPROJECT_ITEM* itemData = GetItemIdData( kid );
if( itemData && ( itemData->m_FileName == fn ) )
if( itemData && itemData->GetFileName() == fn )
{
m_TreeProject->Delete( kid );
return;
......@@ -991,35 +925,33 @@ wxTreeItemId TREE_PROJECT_FRAME::findSubdirTreeItem( const wxString& aSubDir )
break;
case wxFSW_EVENT_RENAME :
{
wxFileName newpath = event.GetNewPath();
wxString newfn = newpath.GetFullPath();
while( kid.IsOk() )
{
TREEPROJECT_ITEM* itemData = GetItemIdData( kid );
wxFileName newpath = event.GetNewPath();
wxString newfn = newpath.GetFullPath();
if( itemData && ( itemData->m_FileName == fn ) )
while( kid.IsOk() )
{
m_TreeProject->Delete( kid );
break;
TREEPROJECT_ITEM* itemData = GetItemIdData( kid );
if( itemData && itemData->GetFileName() == fn )
{
m_TreeProject->Delete( kid );
break;
}
kid = m_TreeProject->GetNextChild( root_id, cookie );
}
kid = m_TreeProject->GetNextChild( root_id, cookie );
AddItemToTreeProject( newfn, root_id, false );
}
AddItemToTreeProject( newfn, root_id, false );
}
break;
}
/* Sort filenames by alphabetic order */
// Sort filenames by alphabetic order
m_TreeProject->SortChildren( root_id );
}
/* Reinit the watched paths
* Should be called after opening a new project to
* rebuild the list of watched paths.
* Should be called after the main loop event handler is started
*/
void TREE_PROJECT_FRAME::FileWatcherReset()
{
// Prepare file watcher:
......@@ -1065,13 +997,14 @@ void TREE_PROJECT_FRAME::FileWatcherReset()
if( itemData && ( itemData->GetType() == TREE_DIRECTORY ) )
{
watched_path = wxFileName::DirName( itemData->m_FileName );
watched_path = wxFileName::DirName( itemData->GetFileName() );
m_watcher->Add( watched_path );
// if kid is a subdir, push in list to explore it later
if( itemData->m_WasPopulated && m_TreeProject->GetChildrenCount( kid ) )
if( itemData->IsPopulated() && m_TreeProject->GetChildrenCount( kid ) )
subdirs_id.push( kid );
}
kid = m_TreeProject->GetNextChild( root_id, cookie );
}
#endif
......@@ -1084,14 +1017,6 @@ void TREE_PROJECT_FRAME::FileWatcherReset()
#endif
}
/* Called by sending a event with id = ID_INIT_WATCHED_PATHS
* rebuild the list of whatched paths
* We are using an event called function to install or reinit a file system watcher
* because a file watcher *needs* a running loop event handler.
* this is noticeable under Linux.
* therefore the safe way to do that is to use the main event loop
* to call m_LeftWin->FileWatcherReset()
*/
void KICAD_MANAGER_FRAME::OnChangeWatchedPaths(wxCommandEvent& aEvent )
{
m_LeftWin->FileWatcherReset();
......
......@@ -58,7 +58,12 @@ private:
public:
TREE_PROJECT_FRAME( KICAD_MANAGER_FRAME* parent );
~TREE_PROJECT_FRAME();
/**
* Create or modify the tree showing project file names
*/
void ReCreateTreePrj();
#ifdef KICAD_USE_FILES_WATCHER
/**
* Reinit the watched paths
......@@ -162,8 +167,8 @@ private:
bool aRecurse = true );
/**
* function findSubdirTreeItem
* Search for the item in tree project which is the
* Function findSubdirTreeItem
* searches for the item in tree project which is the
* node of the subdirectory aSubDir
* @param aSubDir = the directory to find in tree
* @return the opaque reference to the tree item.
......
......@@ -45,6 +45,7 @@ endif()
include_directories(
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/pcbnew
${BOOST_INCLUDE}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_BINARY_DIR}
)
......
......@@ -58,7 +58,7 @@ int main( int argc, char** argv )
static const KEYWORD empty_keywords[1] = {};
DSNLEXER lexer( empty_keywords, 0, fp, wxString( FROM_UTF8( argv[1] ) ) );
DSNLEXER lexer( empty_keywords, 0, fp, FROM_UTF8( argv[1] ) );
try
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment