Cleanup some includes and enum in kicad
This commit is contained in:
parent
8c4197db2a
commit
9db12be714
|
@ -31,14 +31,12 @@
|
|||
#include <wx/filename.h>
|
||||
#include <wx/log.h>
|
||||
#include <wx/stdpaths.h>
|
||||
#include <wx/string.h>
|
||||
|
||||
#include <filehistory.h>
|
||||
#include <hotkeys_basic.h>
|
||||
#include <kiway.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <systemdirsappend.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
|
|
|
@ -28,9 +28,7 @@
|
|||
#include "tree_project_frame.h"
|
||||
#include <bitmaps.h>
|
||||
#include <build_version.h>
|
||||
#include <executable_names.h>
|
||||
#include <filehistory.h>
|
||||
#include <gestfich.h>
|
||||
#include <kiplatform/app.h>
|
||||
#include <kiway.h>
|
||||
#include <kiway_express.h>
|
||||
|
|
|
@ -35,42 +35,6 @@ class TREE_PROJECT_FRAME;
|
|||
class ACTION_TOOLBAR;
|
||||
class KICAD_SETTINGS;
|
||||
|
||||
// Identify the type of files handled by KiCad manager
|
||||
//
|
||||
// When changing this enum please verify (and perhaps update)
|
||||
// TREE_PROJECT_FRAME::GetFileExt(),
|
||||
// s_AllowedExtensionsToList[]
|
||||
|
||||
enum TreeFileType {
|
||||
TREE_ROOT = 0,
|
||||
TREE_LEGACY_PROJECT, // Legacy project file (.pro)
|
||||
TREE_JSON_PROJECT, // JSON formatted project file (.kicad_pro)
|
||||
TREE_LEGACY_SCHEMATIC, // Schematic file (.sch)
|
||||
TREE_SEXPR_SCHEMATIC, // Schematic file (.kicad_sch)
|
||||
TREE_LEGACY_PCB, // board file (.brd) legacy format
|
||||
TREE_SEXPR_PCB, // board file (.kicad_brd) new s expression format
|
||||
TREE_GERBER, // Gerber file (.pho, .g*)
|
||||
TREE_GERBER_JOB_FILE, // Gerber file (.gbrjob)
|
||||
TREE_HTML, // HTML file (.htm, *.html)
|
||||
TREE_PDF, // PDF file (.pdf)
|
||||
TREE_TXT, // ascii text file (.txt)
|
||||
TREE_NET, // netlist file (.net)
|
||||
TREE_UNKNOWN,
|
||||
TREE_DIRECTORY,
|
||||
TREE_CMP_LINK, // cmp/footprint link file (.cmp)
|
||||
TREE_REPORT, // report file (.rpt)
|
||||
TREE_FP_PLACE, // footprints position (place) file (.pos)
|
||||
TREE_DRILL, // Excellon drill file (.drl)
|
||||
TREE_DRILL_NC, // Similar Excellon drill file (.nc)
|
||||
TREE_DRILL_XNC, // Similar Excellon drill file (.xnc)
|
||||
TREE_SVG, // SVG file (.svg)
|
||||
TREE_PAGE_LAYOUT_DESCR, // Page layout and title block descr file (.kicad_wks)
|
||||
TREE_FOOTPRINT_FILE, // footprint file (.kicad_mod)
|
||||
TREE_SCHEMATIC_LIBFILE, // schematic library file (.lib)
|
||||
TREE_SEXPR_SYMBOL_LIB_FILE, // s-expression symbol library file (.kicad_sym)
|
||||
TREE_MAX
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* The main KiCad project manager frame. It is not a KIWAY_PLAYER.
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
#include <pgm_base.h>
|
||||
#include <bin_mod.h>
|
||||
#include "kicad_settings.h"
|
||||
|
||||
/**
|
||||
* PGM_KICAD
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include <bitmaps.h>
|
||||
#include <tool/selection.h>
|
||||
#include <tool/tool_event.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/kicad_manager_actions.h>
|
||||
#include <tools/kicad_manager_control.h>
|
||||
#include <dialogs/dialog_template_selector.h>
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file tree_file_types.h
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TREE_FILE_TYPE_H
|
||||
#define TREE_FILE_TYPE_H
|
||||
|
||||
// Identify the type of files handled by KiCad manager
|
||||
//
|
||||
// When changing this enum please verify (and perhaps update)
|
||||
// TREE_PROJECT_FRAME::GetFileExt(),
|
||||
// s_AllowedExtensionsToList[]
|
||||
enum class TREE_FILE_TYPE
|
||||
{
|
||||
ROOT = 0,
|
||||
LEGACY_PROJECT, // Legacy project file (.pro)
|
||||
JSON_PROJECT, // JSON formatted project file (.kicad_pro)
|
||||
LEGACY_SCHEMATIC, // Schematic file (.sch)
|
||||
SEXPR_SCHEMATIC, // Schematic file (.kicad_sch)
|
||||
LEGACY_PCB, // board file (.brd) legacy format
|
||||
SEXPR_PCB, // board file (.kicad_brd) new s expression format
|
||||
GERBER, // Gerber file (.pho, .g*)
|
||||
GERBER_JOB_FILE, // Gerber file (.gbrjob)
|
||||
HTML, // HTML file (.htm, *.html)
|
||||
PDF, // PDF file (.pdf)
|
||||
TXT, // ascii text file (.txt)
|
||||
NET, // netlist file (.net)
|
||||
UNKNOWN,
|
||||
DIRECTORY,
|
||||
CMP_LINK, // cmp/footprint link file (.cmp)
|
||||
REPORT, // report file (.rpt)
|
||||
FP_PLACE, // footprints position (place) file (.pos)
|
||||
DRILL, // Excellon drill file (.drl)
|
||||
DRILL_NC, // Similar Excellon drill file (.nc)
|
||||
DRILL_XNC, // Similar Excellon drill file (.xnc)
|
||||
SVG, // SVG file (.svg)
|
||||
PAGE_LAYOUT_DESCR, // Page layout and title block descr file (.kicad_wks)
|
||||
FOOTPRINT_FILE, // footprint file (.kicad_mod)
|
||||
SCHEMATIC_LIBFILE, // schematic library file (.lib)
|
||||
SEXPR_SYMBOL_LIB_FILE, // s-expression symbol library file (.kicad_sym)
|
||||
MAX
|
||||
};
|
||||
|
||||
#endif // TREE_FILE_TYPE_H
|
|
@ -45,6 +45,7 @@
|
|||
#include "treeprojectfiles.h"
|
||||
#include "pgm_kicad.h"
|
||||
#include "kicad_id.h"
|
||||
#include "kicad_manager_frame.h"
|
||||
|
||||
#include "tree_project_frame.h"
|
||||
|
||||
|
@ -262,33 +263,33 @@ void TREE_PROJECT_FRAME::OnCreateNewDirectory( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
|
||||
wxString TREE_PROJECT_FRAME::GetFileExt( TreeFileType type )
|
||||
wxString TREE_PROJECT_FRAME::GetFileExt( TREE_FILE_TYPE type )
|
||||
{
|
||||
switch( type )
|
||||
{
|
||||
case TREE_LEGACY_PROJECT: return LegacyProjectFileExtension;
|
||||
case TREE_JSON_PROJECT: return ProjectFileExtension;
|
||||
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_GERBER_JOB_FILE: return GerberJobFileExtension;
|
||||
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;
|
||||
case TREE_FILE_TYPE::LEGACY_PROJECT: return LegacyProjectFileExtension;
|
||||
case TREE_FILE_TYPE::JSON_PROJECT: return ProjectFileExtension;
|
||||
case TREE_FILE_TYPE::LEGACY_SCHEMATIC: return LegacySchematicFileExtension;
|
||||
case TREE_FILE_TYPE::SEXPR_SCHEMATIC: return KiCadSchematicFileExtension;
|
||||
case TREE_FILE_TYPE::LEGACY_PCB: return LegacyPcbFileExtension;
|
||||
case TREE_FILE_TYPE::SEXPR_PCB: return KiCadPcbFileExtension;
|
||||
case TREE_FILE_TYPE::GERBER: return GerberFileExtensionWildCard;
|
||||
case TREE_FILE_TYPE::GERBER_JOB_FILE: return GerberJobFileExtension;
|
||||
case TREE_FILE_TYPE::HTML: return HtmlFileExtension;
|
||||
case TREE_FILE_TYPE::PDF: return PdfFileExtension;
|
||||
case TREE_FILE_TYPE::TXT: return TextFileExtension;
|
||||
case TREE_FILE_TYPE::NET: return NetlistFileExtension;
|
||||
case TREE_FILE_TYPE::CMP_LINK: return ComponentFileExtension;
|
||||
case TREE_FILE_TYPE::REPORT: return ReportFileExtension;
|
||||
case TREE_FILE_TYPE::FP_PLACE: return FootprintPlaceFileExtension;
|
||||
case TREE_FILE_TYPE::DRILL: return DrillFileExtension;
|
||||
case TREE_FILE_TYPE::DRILL_NC: return "nc";
|
||||
case TREE_FILE_TYPE::DRILL_XNC: return "xnc";
|
||||
case TREE_FILE_TYPE::SVG: return SVGFileExtension;
|
||||
case TREE_FILE_TYPE::PAGE_LAYOUT_DESCR: return PageLayoutDescrFileExtension;
|
||||
case TREE_FILE_TYPE::FOOTPRINT_FILE: return KiCadFootprintFileExtension;
|
||||
case TREE_FILE_TYPE::SCHEMATIC_LIBFILE: return LegacySymbolLibFileExtension;
|
||||
case TREE_FILE_TYPE::SEXPR_SYMBOL_LIB_FILE: return KiCadSymbolLibFileExtension;
|
||||
default: return wxEmptyString;
|
||||
}
|
||||
}
|
||||
|
@ -298,7 +299,7 @@ wxTreeItemId TREE_PROJECT_FRAME::AddItemToTreeProject(
|
|||
const wxString& aName, wxTreeItemId& aRoot, bool aCanResetFileWatcher, bool aRecurse )
|
||||
{
|
||||
wxTreeItemId newItemId;
|
||||
TreeFileType type = TREE_UNKNOWN;
|
||||
TREE_FILE_TYPE type = TREE_FILE_TYPE::UNKNOWN;
|
||||
wxFileName fn( aName );
|
||||
|
||||
// Files/dirs names starting by "." are not visible files under unices.
|
||||
|
@ -308,7 +309,7 @@ wxTreeItemId TREE_PROJECT_FRAME::AddItemToTreeProject(
|
|||
|
||||
if( wxDirExists( aName ) )
|
||||
{
|
||||
type = TREE_DIRECTORY;
|
||||
type = TREE_FILE_TYPE::DIRECTORY;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -401,14 +402,15 @@ wxTreeItemId TREE_PROJECT_FRAME::AddItemToTreeProject(
|
|||
}
|
||||
}
|
||||
|
||||
for( int i = TREE_LEGACY_PROJECT; i < TREE_MAX; i++ )
|
||||
for( int i = static_cast<int>( TREE_FILE_TYPE::LEGACY_PROJECT );
|
||||
i < static_cast<int>( TREE_FILE_TYPE::MAX ); i++ )
|
||||
{
|
||||
wxString ext = GetFileExt( (TreeFileType) i );
|
||||
wxString ext = GetFileExt( (TREE_FILE_TYPE) i );
|
||||
|
||||
if( ext == wxT( "" ) )
|
||||
continue;
|
||||
|
||||
if( i == TREE_GERBER ) // For gerber files, the official ext is gbr
|
||||
if( i == static_cast<int>( TREE_FILE_TYPE::GERBER ) ) // For gerber files, the official ext is gbr
|
||||
ext = "gbr";
|
||||
|
||||
reg.Compile( wxString::FromAscii( "^.*\\." ) + ext +
|
||||
|
@ -416,7 +418,7 @@ wxTreeItemId TREE_PROJECT_FRAME::AddItemToTreeProject(
|
|||
|
||||
if( reg.Matches( aName ) )
|
||||
{
|
||||
type = (TreeFileType) i;
|
||||
type = (TREE_FILE_TYPE) i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -427,7 +429,8 @@ wxTreeItemId TREE_PROJECT_FRAME::AddItemToTreeProject(
|
|||
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 ) )
|
||||
if( ( type == TREE_FILE_TYPE::LEGACY_PROJECT )
|
||||
&& ( currfile.GetName().CmpNoCase( project.GetName() ) == 0 ) )
|
||||
return newItemId;
|
||||
|
||||
// also check to see if it is already there.
|
||||
|
@ -448,7 +451,7 @@ wxTreeItemId TREE_PROJECT_FRAME::AddItemToTreeProject(
|
|||
}
|
||||
|
||||
// Only show the JSON project files if both legacy and JSON files are present
|
||||
if( ( type == TREE_LEGACY_PROJECT ) || ( type == TREE_JSON_PROJECT ) )
|
||||
if( ( type == TREE_FILE_TYPE::LEGACY_PROJECT ) || ( type == TREE_FILE_TYPE::JSON_PROJECT ) )
|
||||
{
|
||||
kid = m_TreeProject->GetFirstChild( aRoot, cookie );
|
||||
|
||||
|
@ -463,14 +466,14 @@ wxTreeItemId TREE_PROJECT_FRAME::AddItemToTreeProject(
|
|||
if( fname.GetName().CmpNoCase( currfile.GetName() ) == 0 )
|
||||
{
|
||||
// If the tree item is the legacy project remove it.
|
||||
if( itemData->GetType() == TREE_LEGACY_PROJECT )
|
||||
if( itemData->GetType() == TREE_FILE_TYPE::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 ) )
|
||||
else if( ( itemData->GetType() == TREE_FILE_TYPE::JSON_PROJECT )
|
||||
&& ( type == TREE_FILE_TYPE::LEGACY_PROJECT ) )
|
||||
{
|
||||
return newItemId;
|
||||
}
|
||||
|
@ -499,7 +502,7 @@ wxTreeItemId TREE_PROJECT_FRAME::AddItemToTreeProject(
|
|||
|
||||
// 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 )
|
||||
if( TREE_FILE_TYPE::DIRECTORY == type && aRecurse )
|
||||
{
|
||||
wxDir dir( aName );
|
||||
|
||||
|
@ -573,12 +576,13 @@ void TREE_PROJECT_FRAME::ReCreateTreePrj()
|
|||
}
|
||||
|
||||
// root tree:
|
||||
m_root = m_TreeProject->AddRoot( fn.GetFullName(), TREE_ROOT, TREE_ROOT );
|
||||
m_root = m_TreeProject->AddRoot( fn.GetFullName(), static_cast<int>( TREE_FILE_TYPE::ROOT ),
|
||||
static_cast<int>( TREE_FILE_TYPE::ROOT ) );
|
||||
m_TreeProject->SetItemBold( m_root, true );
|
||||
|
||||
// The main project file is now a JSON file
|
||||
m_TreeProject->SetItemData( m_root, new TREEPROJECT_ITEM( TREE_JSON_PROJECT, fn.GetFullPath(),
|
||||
m_TreeProject ) );
|
||||
m_TreeProject->SetItemData( m_root,
|
||||
new TREEPROJECT_ITEM( TREE_FILE_TYPE::JSON_PROJECT, fn.GetFullPath(), m_TreeProject ) );
|
||||
|
||||
// Now adding all current files if available
|
||||
if( prjOpened )
|
||||
|
@ -657,13 +661,12 @@ void TREE_PROJECT_FRAME::OnRight( wxTreeEvent& Event )
|
|||
continue;
|
||||
}
|
||||
|
||||
int tree_id = item->GetType();
|
||||
wxString full_file_name = item->GetFileName();
|
||||
|
||||
switch( tree_id )
|
||||
switch( item->GetType() )
|
||||
{
|
||||
case TREE_LEGACY_PROJECT:
|
||||
case TREE_JSON_PROJECT:
|
||||
case TREE_FILE_TYPE::LEGACY_PROJECT:
|
||||
case TREE_FILE_TYPE::JSON_PROJECT:
|
||||
can_rename = false;
|
||||
can_print = false;
|
||||
|
||||
|
@ -679,7 +682,7 @@ void TREE_PROJECT_FRAME::OnRight( wxTreeEvent& Event )
|
|||
}
|
||||
break;
|
||||
|
||||
case TREE_DIRECTORY:
|
||||
case TREE_FILE_TYPE::DIRECTORY:
|
||||
can_switch_to_project = false;
|
||||
can_edit = false;
|
||||
can_rename = false;
|
||||
|
@ -915,7 +918,7 @@ void TREE_PROJECT_FRAME::OnExpand( wxTreeEvent& Event )
|
|||
if( !tree_data )
|
||||
return;
|
||||
|
||||
if( tree_data->GetType() != TREE_DIRECTORY )
|
||||
if( tree_data->GetType() != TREE_FILE_TYPE::DIRECTORY )
|
||||
return;
|
||||
|
||||
// explore list of non populated subdirs, and populate them
|
||||
|
@ -930,7 +933,7 @@ void TREE_PROJECT_FRAME::OnExpand( wxTreeEvent& Event )
|
|||
{
|
||||
TREEPROJECT_ITEM* itemData = GetItemIdData( kid );
|
||||
|
||||
if( !itemData || itemData->GetType() != TREE_DIRECTORY )
|
||||
if( !itemData || itemData->GetType() != TREE_FILE_TYPE::DIRECTORY )
|
||||
continue;
|
||||
|
||||
if( itemData->IsPopulated() )
|
||||
|
@ -1027,7 +1030,7 @@ wxTreeItemId TREE_PROJECT_FRAME::findSubdirTreeItem( const wxString& aSubDir )
|
|||
|
||||
TREEPROJECT_ITEM* itemData = GetItemIdData( kid );
|
||||
|
||||
if( itemData && ( itemData->GetType() == TREE_DIRECTORY ) )
|
||||
if( itemData && ( itemData->GetType() == TREE_FILE_TYPE::DIRECTORY ) )
|
||||
{
|
||||
if( itemData->GetFileName() == aSubDir ) // Found!
|
||||
{
|
||||
|
|
|
@ -30,11 +30,12 @@
|
|||
#ifndef TREEPRJ_FRAME_H
|
||||
#define TREEPRJ_FRAME_H
|
||||
|
||||
#include <vector>
|
||||
#include <wx/fswatcher.h>
|
||||
#include <wx/laywin.h>
|
||||
#include <wx/treebase.h>
|
||||
|
||||
#include "kicad_manager_frame.h"
|
||||
#include "tree_file_type.h"
|
||||
|
||||
|
||||
class KICAD_MANAGER_FRAME;
|
||||
|
@ -80,7 +81,7 @@ public:
|
|||
void EmptyTreePrj();
|
||||
|
||||
protected:
|
||||
static wxString GetFileExt( TreeFileType type );
|
||||
static wxString GetFileExt( TREE_FILE_TYPE type );
|
||||
|
||||
/**
|
||||
* Function GetSelectedData
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <tool/tool_manager.h>
|
||||
#include <tools/kicad_manager_actions.h>
|
||||
|
||||
#include "kicad_manager_frame.h"
|
||||
#include "treeprojectfiles.h"
|
||||
#include "pgm_kicad.h"
|
||||
#include "tree_project_frame.h"
|
||||
|
@ -45,7 +46,7 @@
|
|||
#include "kicad_id.h"
|
||||
|
||||
|
||||
TREEPROJECT_ITEM::TREEPROJECT_ITEM( enum TreeFileType type, const wxString& data,
|
||||
TREEPROJECT_ITEM::TREEPROJECT_ITEM( TREE_FILE_TYPE type, const wxString& data,
|
||||
wxTreeCtrl* parent ) :
|
||||
wxTreeItemData()
|
||||
{
|
||||
|
@ -60,13 +61,14 @@ TREEPROJECT_ITEM::TREEPROJECT_ITEM( enum TreeFileType type, const wxString& data
|
|||
|
||||
void TREEPROJECT_ITEM::SetState( int state )
|
||||
{
|
||||
wxImageList* imglist = m_parent->GetImageList();
|
||||
wxImageList* imglist = m_parent->GetImageList();
|
||||
int treeEnumMax = static_cast<int>( TREE_FILE_TYPE::MAX );
|
||||
|
||||
if( !imglist || state < 0 || state >= imglist->GetImageCount() / ( TREE_MAX - 2 ) )
|
||||
if( !imglist || state < 0 || state >= imglist->GetImageCount() / ( treeEnumMax - 2 ) )
|
||||
return;
|
||||
|
||||
m_state = state;
|
||||
int imgid = m_Type - 1 + state * ( TREE_MAX - 1 );
|
||||
m_state = state;
|
||||
int imgid = static_cast<int>( m_Type ) - 1 + state * ( treeEnumMax - 1 );
|
||||
m_parent->SetItemImage( GetId(), imgid );
|
||||
m_parent->SetItemImage( GetId(), imgid, wxTreeItemIcon_Selected );
|
||||
}
|
||||
|
@ -74,7 +76,7 @@ void TREEPROJECT_ITEM::SetState( int state )
|
|||
|
||||
const wxString TREEPROJECT_ITEM::GetDir() const
|
||||
{
|
||||
if( TREE_DIRECTORY == m_Type )
|
||||
if( TREE_FILE_TYPE::DIRECTORY == m_Type )
|
||||
return GetFileName();
|
||||
|
||||
return wxFileName( GetFileName() ).GetPath();
|
||||
|
@ -84,7 +86,7 @@ const wxString TREEPROJECT_ITEM::GetDir() const
|
|||
bool TREEPROJECT_ITEM::Rename( const wxString& name, bool check )
|
||||
{
|
||||
// this is broken & unsafe to use on linux.
|
||||
if( m_Type == TREE_DIRECTORY )
|
||||
if( m_Type == TREE_FILE_TYPE::DIRECTORY )
|
||||
return false;
|
||||
|
||||
if( name.IsEmpty() )
|
||||
|
@ -94,7 +96,7 @@ bool TREEPROJECT_ITEM::Rename( const wxString& name, bool check )
|
|||
wxString newFile;
|
||||
wxString dirs = GetDir();
|
||||
|
||||
if( !dirs.IsEmpty() && GetType() != TREE_DIRECTORY )
|
||||
if( !dirs.IsEmpty() && GetType() != TREE_FILE_TYPE::DIRECTORY )
|
||||
newFile = dirs + sep + name;
|
||||
else
|
||||
newFile = name;
|
||||
|
@ -161,20 +163,20 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* aTreePrjFrame )
|
|||
|
||||
switch( GetType() )
|
||||
{
|
||||
case TREE_LEGACY_PROJECT:
|
||||
case TREE_JSON_PROJECT:
|
||||
case TREE_FILE_TYPE::LEGACY_PROJECT:
|
||||
case TREE_FILE_TYPE::JSON_PROJECT:
|
||||
// Select a new project if this is not the current project:
|
||||
if( id != aTreePrjFrame->m_TreeProject->GetRootItem() )
|
||||
frame->LoadProject( fullFileName );
|
||||
|
||||
break;
|
||||
|
||||
case TREE_DIRECTORY:
|
||||
case TREE_FILE_TYPE::DIRECTORY:
|
||||
m_parent->Toggle( id );
|
||||
break;
|
||||
|
||||
case TREE_LEGACY_SCHEMATIC:
|
||||
case TREE_SEXPR_SCHEMATIC:
|
||||
case TREE_FILE_TYPE::LEGACY_SCHEMATIC:
|
||||
case TREE_FILE_TYPE::SEXPR_SCHEMATIC:
|
||||
// Schematics not part of the project are opened in a separate process.
|
||||
if( fullFileName == frame->SchFileName() || fullFileName == frame->SchLegacyFileName() )
|
||||
toolMgr->RunAction( KICAD_MANAGER_ACTIONS::editSchematic, true );
|
||||
|
@ -183,8 +185,8 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* aTreePrjFrame )
|
|||
|
||||
break;
|
||||
|
||||
case TREE_LEGACY_PCB:
|
||||
case TREE_SEXPR_PCB:
|
||||
case TREE_FILE_TYPE::LEGACY_PCB:
|
||||
case TREE_FILE_TYPE::SEXPR_PCB:
|
||||
// Boards not part of the project are opened in a separate process.
|
||||
if( fullFileName == frame->PcbFileName() || fullFileName == frame->PcbLegacyFileName() )
|
||||
toolMgr->RunAction( KICAD_MANAGER_ACTIONS::editPCB, true );
|
||||
|
@ -193,40 +195,40 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* aTreePrjFrame )
|
|||
|
||||
break;
|
||||
|
||||
case TREE_GERBER:
|
||||
case TREE_GERBER_JOB_FILE:
|
||||
case TREE_DRILL:
|
||||
case TREE_DRILL_NC:
|
||||
case TREE_DRILL_XNC:
|
||||
case TREE_FILE_TYPE::GERBER:
|
||||
case TREE_FILE_TYPE::GERBER_JOB_FILE:
|
||||
case TREE_FILE_TYPE::DRILL:
|
||||
case TREE_FILE_TYPE::DRILL_NC:
|
||||
case TREE_FILE_TYPE::DRILL_XNC:
|
||||
toolMgr->RunAction( KICAD_MANAGER_ACTIONS::viewGerbers, true, &fullFileName );
|
||||
break;
|
||||
|
||||
case TREE_HTML:
|
||||
case TREE_FILE_TYPE::HTML:
|
||||
wxLaunchDefaultBrowser( fullFileName );
|
||||
break;
|
||||
|
||||
case TREE_PDF:
|
||||
case TREE_FILE_TYPE::PDF:
|
||||
OpenPDF( fullFileName );
|
||||
break;
|
||||
|
||||
case TREE_NET:
|
||||
case TREE_TXT:
|
||||
case TREE_REPORT:
|
||||
case TREE_FILE_TYPE::NET:
|
||||
case TREE_FILE_TYPE::TXT:
|
||||
case TREE_FILE_TYPE::REPORT:
|
||||
toolMgr->RunAction( KICAD_MANAGER_ACTIONS::openTextEditor, true, &fullFileName );
|
||||
break;
|
||||
|
||||
case TREE_PAGE_LAYOUT_DESCR:
|
||||
case TREE_FILE_TYPE::PAGE_LAYOUT_DESCR:
|
||||
toolMgr->RunAction( KICAD_MANAGER_ACTIONS::editWorksheet, true, &fullFileName );
|
||||
break;
|
||||
|
||||
case TREE_FOOTPRINT_FILE:
|
||||
case TREE_FILE_TYPE::FOOTPRINT_FILE:
|
||||
toolMgr->RunAction( KICAD_MANAGER_ACTIONS::editFootprints, true );
|
||||
packet = fullFileName.ToStdString();
|
||||
kiway.ExpressMail( FRAME_FOOTPRINT_EDITOR, MAIL_FP_EDIT, packet );
|
||||
break;
|
||||
|
||||
case TREE_SCHEMATIC_LIBFILE:
|
||||
case TREE_SEXPR_SYMBOL_LIB_FILE:
|
||||
case TREE_FILE_TYPE::SCHEMATIC_LIBFILE:
|
||||
case TREE_FILE_TYPE::SEXPR_SYMBOL_LIB_FILE:
|
||||
toolMgr->RunAction( KICAD_MANAGER_ACTIONS::editSymbols, true );
|
||||
packet = fullFileName.ToStdString();
|
||||
kiway.ExpressMail( FRAME_SCH_LIB_EDITOR, MAIL_LIB_EDIT, packet );
|
||||
|
|
|
@ -28,8 +28,10 @@
|
|||
|
||||
#include <wx/treebase.h>
|
||||
|
||||
#include "kicad_manager_frame.h"
|
||||
#include "tree_file_type.h"
|
||||
|
||||
class TREE_PROJECT_FRAME;
|
||||
class wxTreeCtrl;
|
||||
|
||||
/**
|
||||
* TREEPROJECT_ITEM
|
||||
|
@ -39,7 +41,7 @@ class TREEPROJECT_ITEM : public wxTreeItemData
|
|||
{
|
||||
public:
|
||||
|
||||
TREEPROJECT_ITEM( TreeFileType type, const wxString& data,
|
||||
TREEPROJECT_ITEM( TREE_FILE_TYPE type, const wxString& data,
|
||||
wxTreeCtrl* parent );
|
||||
|
||||
TREEPROJECT_ITEM() : m_parent( NULL ) { }
|
||||
|
@ -51,8 +53,8 @@ public:
|
|||
m_IsPopulated = false;
|
||||
}
|
||||
|
||||
TreeFileType GetType() const { return m_Type; }
|
||||
void SetType( TreeFileType aType ) { m_Type = aType; }
|
||||
TREE_FILE_TYPE GetType() const { return m_Type; }
|
||||
void SetType( TREE_FILE_TYPE aType ) { m_Type = aType; }
|
||||
|
||||
const wxString& GetFileName() const { return m_file_name; }
|
||||
void SetFileName( const wxString& name ) { m_file_name = name; }
|
||||
|
@ -78,7 +80,7 @@ public:
|
|||
|
||||
|
||||
private:
|
||||
TreeFileType m_Type; // = TREE_PROJECT, TREE_DIRECTORY ...
|
||||
TREE_FILE_TYPE m_Type; // = TREE_PROJECT, TREE_DIRECTORY ...
|
||||
wxString m_file_name; // 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
|
||||
|
|
|
@ -53,7 +53,7 @@ TREEPROJECTFILES::TREEPROJECTFILES( TREE_PROJECT_FRAME* parent )
|
|||
iconsize.y = dummy.GetHeight();
|
||||
|
||||
// Make an image list containing small icons
|
||||
m_ImageList = new wxImageList( iconsize.x, iconsize.y, true, TREE_MAX );
|
||||
m_ImageList = new wxImageList( iconsize.x, iconsize.y, true, static_cast<int>( TREE_FILE_TYPE::MAX ) );
|
||||
|
||||
m_ImageList->Add( KiBitmap( new_project_xpm ) ); // TREE_LEGACY_PROJECT
|
||||
m_ImageList->Add( KiBitmap( new_project_xpm ) ); // TREE_JSON_PROJECT
|
||||
|
@ -99,10 +99,12 @@ int TREEPROJECTFILES::OnCompareItems( const wxTreeItemId& item1, const wxTreeIte
|
|||
if( !myitem1 || !myitem2 )
|
||||
return 0;
|
||||
|
||||
if( myitem1->GetType() == TREE_DIRECTORY && myitem2->GetType() != TREE_DIRECTORY )
|
||||
if( myitem1->GetType() == TREE_FILE_TYPE::DIRECTORY
|
||||
&& myitem2->GetType() != TREE_FILE_TYPE::DIRECTORY )
|
||||
return -1;
|
||||
|
||||
if( myitem2->GetType() == TREE_DIRECTORY && myitem1->GetType() != TREE_DIRECTORY )
|
||||
if( myitem2->GetType() == TREE_FILE_TYPE::DIRECTORY
|
||||
&& myitem1->GetType() != TREE_FILE_TYPE::DIRECTORY )
|
||||
return 1;
|
||||
|
||||
if( myitem1->IsRootFile() && !myitem2->IsRootFile() )
|
||||
|
|
|
@ -32,8 +32,9 @@
|
|||
|
||||
#include <wx/treectrl.h>
|
||||
|
||||
#include "kicad_manager_frame.h"
|
||||
#include "tree_file_type.h"
|
||||
|
||||
class TREE_PROJECT_FRAME;
|
||||
|
||||
/** TREEPROJECTFILES
|
||||
* This is the class to show (as a tree) the files in the project directory
|
||||
|
|
Loading…
Reference in New Issue