Implement double-click for other filetypes in project tree.
Fixes: lp:1787207 * https://bugs.launchpad.net/kicad/+bug/1787207
This commit is contained in:
parent
45bc1b1aff
commit
f9412f0fd4
|
@ -176,6 +176,11 @@ void LIB_TREE::Unselect()
|
||||||
m_tree_ctrl->UnselectAll();
|
m_tree_ctrl->UnselectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LIB_TREE::ExpandLibId( const LIB_ID& aLibId )
|
||||||
|
{
|
||||||
|
expandIfValid( m_adapter->FindItem( aLibId ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void LIB_TREE::Regenerate()
|
void LIB_TREE::Regenerate()
|
||||||
{
|
{
|
||||||
|
@ -235,6 +240,12 @@ void LIB_TREE::centerIfValid( const wxDataViewItem& aTreeId )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LIB_TREE::expandIfValid( const wxDataViewItem& aTreeId )
|
||||||
|
{
|
||||||
|
if( aTreeId.IsOk() && !m_tree_ctrl->IsExpanded( aTreeId ) )
|
||||||
|
m_tree_ctrl->Expand( aTreeId );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void LIB_TREE::postPreselectEvent()
|
void LIB_TREE::postPreselectEvent()
|
||||||
{
|
{
|
||||||
|
|
|
@ -84,6 +84,11 @@ public:
|
||||||
*/
|
*/
|
||||||
void Unselect();
|
void Unselect();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expand and item i the tree widget.
|
||||||
|
*/
|
||||||
|
void ExpandLibId( const LIB_ID& aLibId );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Associates a right click context menu for a specific node type.
|
* Associates a right click context menu for a specific node type.
|
||||||
* @param aType is the node type to have a menu associated.
|
* @param aType is the node type to have a menu associated.
|
||||||
|
@ -123,6 +128,8 @@ protected:
|
||||||
|
|
||||||
void centerIfValid( const wxDataViewItem& aTreeId );
|
void centerIfValid( const wxDataViewItem& aTreeId );
|
||||||
|
|
||||||
|
void expandIfValid( const wxDataViewItem& aTreeId );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Post a wxEVT_DATAVIEW_SELECTION_CHANGED to notify the selection handler
|
* Post a wxEVT_DATAVIEW_SELECTION_CHANGED to notify the selection handler
|
||||||
* that a new part has been preselected.
|
* that a new part has been preselected.
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <fctsys.h>
|
#include <fctsys.h>
|
||||||
#include <pgm_base.h>
|
#include <pgm_base.h>
|
||||||
#include <kiface_i.h>
|
#include <kiface_i.h>
|
||||||
|
#include <kiway_express.h>
|
||||||
#include <class_drawpanel.h>
|
#include <class_drawpanel.h>
|
||||||
#include <base_screen.h>
|
#include <base_screen.h>
|
||||||
#include <confirm.h>
|
#include <confirm.h>
|
||||||
|
@ -1658,3 +1659,52 @@ void LIB_EDIT_FRAME::ShowChangedLanguage()
|
||||||
UpdateMsgPanel();
|
UpdateMsgPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LIB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
|
||||||
|
{
|
||||||
|
const std::string& payload = mail.GetPayload();
|
||||||
|
|
||||||
|
switch( mail.Command() )
|
||||||
|
{
|
||||||
|
case MAIL_LIB_EDIT:
|
||||||
|
if( !payload.empty() )
|
||||||
|
{
|
||||||
|
wxString libFileName( payload );
|
||||||
|
wxString libNickname;
|
||||||
|
wxString msg;
|
||||||
|
|
||||||
|
SYMBOL_LIB_TABLE* libTable = Prj().SchSymbolLibTable();
|
||||||
|
const LIB_TABLE_ROW* libTableRow = libTable->FindRowByURI( libFileName );
|
||||||
|
|
||||||
|
if( !libTableRow )
|
||||||
|
{
|
||||||
|
msg.Printf( _( "The current configuration does not include the symbol library\n"
|
||||||
|
"\"%s\".\nUse Manage Symbol Libraries to edit the configuration." ),
|
||||||
|
libFileName );
|
||||||
|
DisplayErrorMessage( this, _( "Library not found in symbol library table." ), msg );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
libNickname = libTableRow->GetNickName();
|
||||||
|
|
||||||
|
if( !libTable->HasLibrary( libNickname, true ) )
|
||||||
|
{
|
||||||
|
msg.Printf( _( "The library with the nickname \"%s\" is not enabled\n"
|
||||||
|
"in the current configuration. Use Manage Symbol Libraries to\n"
|
||||||
|
"edit the configuration." ), libNickname );
|
||||||
|
DisplayErrorMessage( this, _( "Symbol library not enabled." ), msg );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetCurLib( libNickname );
|
||||||
|
|
||||||
|
if( m_treePane )
|
||||||
|
m_treePane->GetLibTree()->ExpandLibId( LIB_ID( libNickname, wxEmptyString ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -703,6 +703,8 @@ public:
|
||||||
|
|
||||||
void ShowChangedLanguage() override;
|
void ShowChangedLanguage() override;
|
||||||
|
|
||||||
|
void KiwayMailIn( KIWAY_EXPRESS& mail ) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
///> Helper screen used when no part is loaded
|
///> Helper screen used when no part is loaded
|
||||||
SCH_SCREEN* m_dummyScreen;
|
SCH_SCREEN* m_dummyScreen;
|
||||||
|
|
|
@ -48,6 +48,9 @@ enum MAIL_T
|
||||||
MAIL_SCH_PCB_UPDATE_REQUEST,
|
MAIL_SCH_PCB_UPDATE_REQUEST,
|
||||||
MAIL_SCH_REFRESH, ///< The the schematic editor to refresh the display.
|
MAIL_SCH_REFRESH, ///< The the schematic editor to refresh the display.
|
||||||
|
|
||||||
|
MAIL_LIB_EDIT,
|
||||||
|
MAIL_FP_EDIT,
|
||||||
|
|
||||||
///< General-puspose messages
|
///< General-puspose messages
|
||||||
MAIL_STATUS
|
MAIL_STATUS
|
||||||
};
|
};
|
||||||
|
|
|
@ -283,32 +283,20 @@ void KICAD_MANAGER_FRAME::Execute( wxWindow* frame, const wxString& execFile,
|
||||||
|
|
||||||
void KICAD_MANAGER_FRAME::RunEeschema( const wxString& aProjectSchematicFileName )
|
void KICAD_MANAGER_FRAME::RunEeschema( const wxString& aProjectSchematicFileName )
|
||||||
{
|
{
|
||||||
KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, false );
|
KIWAY_PLAYER* frame;
|
||||||
|
|
||||||
// Please: note: DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers() calls
|
try
|
||||||
// Kiway.Player( FRAME_SCH, true )
|
|
||||||
// therefore, the schematic editor is sometimes running, but the schematic project
|
|
||||||
// is not loaded, if the library editor was called, and the dialog field editor was used.
|
|
||||||
// On linux, it happens the first time the schematic editor is launched, if
|
|
||||||
// library editor was running, and the dialog field editor was open
|
|
||||||
// On Windows, it happens always after the library editor was called,
|
|
||||||
// and the dialog field editor was used
|
|
||||||
if( !frame )
|
|
||||||
{
|
{
|
||||||
try
|
frame = Kiway().Player( FRAME_SCH, true );
|
||||||
{
|
}
|
||||||
frame = Kiway().Player( FRAME_SCH, true );
|
catch( const IO_ERROR& err )
|
||||||
}
|
{
|
||||||
catch( const IO_ERROR& err )
|
wxMessageBox( _( "Eeschema failed to load:\n" ) + err.What(),
|
||||||
{
|
_( "KiCad Error" ), wxOK | wxICON_ERROR, this );
|
||||||
wxMessageBox( _( "Eeschema failed to load:\n" ) + err.What(),
|
return;
|
||||||
_( "KiCad Error" ), wxOK | wxICON_ERROR, this );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !frame->IsShown() ) // the frame exists, (created by the dialog field editor)
|
if( !frame->IsShown() ) // A hidden frame might not have the project loaded.
|
||||||
// but no project loaded.
|
|
||||||
{
|
{
|
||||||
frame->OpenProjectFiles( std::vector<wxString>( 1, aProjectSchematicFileName ) );
|
frame->OpenProjectFiles( std::vector<wxString>( 1, aProjectSchematicFileName ) );
|
||||||
frame->Show( true );
|
frame->Show( true );
|
||||||
|
@ -338,23 +326,21 @@ void KICAD_MANAGER_FRAME::OnRunEeschema( wxCommandEvent& event )
|
||||||
|
|
||||||
void KICAD_MANAGER_FRAME::OnRunSchLibEditor( wxCommandEvent& event )
|
void KICAD_MANAGER_FRAME::OnRunSchLibEditor( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
|
KIWAY_PLAYER* frame;
|
||||||
|
|
||||||
if( !frame )
|
try
|
||||||
{
|
{
|
||||||
try
|
frame = Kiway().Player( FRAME_SCH_LIB_EDITOR, true );
|
||||||
{
|
|
||||||
frame = Kiway().Player( FRAME_SCH_LIB_EDITOR, true );
|
|
||||||
}
|
|
||||||
catch( const IO_ERROR& err )
|
|
||||||
{
|
|
||||||
wxMessageBox( _( "Component library editor failed to load:\n" ) + err.What(),
|
|
||||||
_( "KiCad Error" ), wxOK | wxICON_ERROR, this );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
frame->Show( true );
|
|
||||||
}
|
}
|
||||||
|
catch( const IO_ERROR& err )
|
||||||
|
{
|
||||||
|
wxMessageBox( _( "Component library editor failed to load:\n" ) + err.What(),
|
||||||
|
_( "KiCad Error" ), wxOK | wxICON_ERROR, this );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !frame->IsShown() )
|
||||||
|
frame->Show( true );
|
||||||
|
|
||||||
// On Windows, Raise() does not bring the window on screen, when iconized
|
// On Windows, Raise() does not bring the window on screen, when iconized
|
||||||
if( frame->IsIconized() )
|
if( frame->IsIconized() )
|
||||||
|
@ -379,10 +365,7 @@ void KICAD_MANAGER_FRAME::RunPcbNew( const wxString& aProjectBoardFileName )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// a pcb frame can be already existing, but not yet used.
|
if( !frame->IsVisible() ) // A hidden frame might not have the board loaded.
|
||||||
// this is the case when running the footprint editor, or the footprint viewer first
|
|
||||||
// if the frame is not visible, the board is not yet loaded
|
|
||||||
if( !frame->IsVisible() )
|
|
||||||
{
|
{
|
||||||
frame->OpenProjectFiles( std::vector<wxString>( 1, aProjectBoardFileName ) );
|
frame->OpenProjectFiles( std::vector<wxString>( 1, aProjectBoardFileName ) );
|
||||||
frame->Show( true );
|
frame->Show( true );
|
||||||
|
@ -410,23 +393,21 @@ void KICAD_MANAGER_FRAME::OnRunPcbNew( wxCommandEvent& event )
|
||||||
|
|
||||||
void KICAD_MANAGER_FRAME::OnRunPcbFpEditor( wxCommandEvent& event )
|
void KICAD_MANAGER_FRAME::OnRunPcbFpEditor( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_MODULE_EDITOR, false );
|
KIWAY_PLAYER* frame;
|
||||||
|
|
||||||
if( !frame )
|
try
|
||||||
{
|
{
|
||||||
try
|
frame = Kiway().Player( FRAME_PCB_MODULE_EDITOR, true );
|
||||||
{
|
|
||||||
frame = Kiway().Player( FRAME_PCB_MODULE_EDITOR, true );
|
|
||||||
}
|
|
||||||
catch( const IO_ERROR& err )
|
|
||||||
{
|
|
||||||
wxMessageBox( _( "Footprint library editor failed to load:\n" ) + err.What(),
|
|
||||||
_( "KiCad Error" ), wxOK | wxICON_ERROR, this );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
frame->Show( true );
|
|
||||||
}
|
}
|
||||||
|
catch( const IO_ERROR& err )
|
||||||
|
{
|
||||||
|
wxMessageBox( _( "Footprint library editor failed to load:\n" ) + err.What(),
|
||||||
|
_( "KiCad Error" ), wxOK | wxICON_ERROR, this );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !frame->IsShown() )
|
||||||
|
frame->Show( true );
|
||||||
|
|
||||||
// On Windows, Raise() does not bring the window on screen, when iconized
|
// On Windows, Raise() does not bring the window on screen, when iconized
|
||||||
if( frame->IsIconized() )
|
if( frame->IsIconized() )
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
#include <gestfich.h>
|
#include <gestfich.h>
|
||||||
#include <executable_names.h>
|
#include <executable_names.h>
|
||||||
|
#include <kiway.h>
|
||||||
#include "treeprojectfiles.h"
|
#include "treeprojectfiles.h"
|
||||||
#include "pgm_kicad.h"
|
#include "pgm_kicad.h"
|
||||||
#include "tree_project_frame.h"
|
#include "tree_project_frame.h"
|
||||||
|
@ -235,10 +235,9 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* aTreePrjFrame )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TREE_NET:
|
case TREE_NET:
|
||||||
// Nothing to do ( can be read only by Pcbnew, or by a text editor)
|
case TREE_DRILL:
|
||||||
break;
|
|
||||||
|
|
||||||
case TREE_TXT:
|
case TREE_TXT:
|
||||||
|
case TREE_REPORT:
|
||||||
{
|
{
|
||||||
wxString editorname = Pgm().GetEditorName();
|
wxString editorname = Pgm().GetEditorName();
|
||||||
|
|
||||||
|
@ -251,6 +250,22 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* aTreePrjFrame )
|
||||||
frame->Execute( m_parent, PL_EDITOR_EXE, fullFileName );
|
frame->Execute( m_parent, PL_EDITOR_EXE, fullFileName );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TREE_FOOTPRINT_FILE:
|
||||||
|
{
|
||||||
|
wxCommandEvent dummy;
|
||||||
|
frame->OnRunPcbFpEditor( dummy );
|
||||||
|
frame->Kiway().ExpressMail( FRAME_PCB_MODULE_EDITOR, MAIL_FP_EDIT, fullFileName );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TREE_SCHEMATIC_LIBFILE:
|
||||||
|
{
|
||||||
|
wxCommandEvent dummy;
|
||||||
|
frame->OnRunSchLibEditor( dummy );
|
||||||
|
frame->Kiway().ExpressMail( FRAME_SCH_LIB_EDITOR, MAIL_LIB_EDIT, fullFileName );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
AddDelimiterString( fullFileName );
|
AddDelimiterString( fullFileName );
|
||||||
OpenFile( fullFileName );
|
OpenFile( fullFileName );
|
||||||
|
|
|
@ -507,6 +507,7 @@ public:
|
||||||
*/
|
*/
|
||||||
void UpdateMsgPanel() override;
|
void UpdateMsgPanel() override;
|
||||||
|
|
||||||
|
void KiwayMailIn( KIWAY_EXPRESS& mail ) override;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <fctsys.h>
|
#include <fctsys.h>
|
||||||
#include <kiface_i.h>
|
#include <kiface_i.h>
|
||||||
#include <kiway.h>
|
#include <kiway.h>
|
||||||
|
#include <kiway_express.h>
|
||||||
#include <class_drawpanel.h>
|
#include <class_drawpanel.h>
|
||||||
#include <pcb_draw_panel_gal.h>
|
#include <pcb_draw_panel_gal.h>
|
||||||
#include <confirm.h>
|
#include <confirm.h>
|
||||||
|
@ -1105,3 +1106,57 @@ bool FOOTPRINT_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileS
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FOOTPRINT_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
|
||||||
|
{
|
||||||
|
const std::string& payload = mail.GetPayload();
|
||||||
|
|
||||||
|
switch( mail.Command() )
|
||||||
|
{
|
||||||
|
case MAIL_FP_EDIT:
|
||||||
|
if( !payload.empty() )
|
||||||
|
{
|
||||||
|
wxFileName fpFileName( payload );
|
||||||
|
wxString libNickname;
|
||||||
|
wxString msg;
|
||||||
|
|
||||||
|
FP_LIB_TABLE* libTable = Prj().PcbFootprintLibs();
|
||||||
|
const LIB_TABLE_ROW* libTableRow = libTable->FindRowByURI( fpFileName.GetPath() );
|
||||||
|
|
||||||
|
if( !libTableRow )
|
||||||
|
{
|
||||||
|
msg.Printf( _( "The current configuration does not include the footprint library\n"
|
||||||
|
"\"%s\".\nUse Manage Footprint Libraries to edit the configuration." ),
|
||||||
|
fpFileName.GetPath() );
|
||||||
|
DisplayErrorMessage( this, _( "Library not found in footprint library table." ), msg );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
libNickname = libTableRow->GetNickName();
|
||||||
|
|
||||||
|
if( !libTable->HasLibrary( libNickname, true ) )
|
||||||
|
{
|
||||||
|
msg.Printf( _( "The library with the nickname \"%s\" is not enabled\n"
|
||||||
|
"in the current configuration. Use Manage Footprint Libraries to\n"
|
||||||
|
"edit the configuration." ), libNickname );
|
||||||
|
DisplayErrorMessage( this, _( "Footprint library not enabled." ), msg );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
LIB_ID fpId( libNickname, fpFileName.GetName() );
|
||||||
|
|
||||||
|
if( m_treePane )
|
||||||
|
{
|
||||||
|
m_treePane->GetLibTree()->SelectLibId( fpId );
|
||||||
|
wxCommandEvent event( COMPONENT_SELECTED );
|
||||||
|
wxPostEvent( m_treePane, event );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue