Re-instate LibEdit cut/copy/paste of symbols.
Fixes: lp:1788975 * https://bugs.launchpad.net/kicad/+bug/1788975
This commit is contained in:
parent
2e8f2d2850
commit
12213d994a
|
@ -219,6 +219,9 @@ enum id_eeschema_frm
|
||||||
ID_LIBEDIT_IMPORT_PART,
|
ID_LIBEDIT_IMPORT_PART,
|
||||||
ID_LIBEDIT_EXPORT_PART,
|
ID_LIBEDIT_EXPORT_PART,
|
||||||
ID_LIBEDIT_REMOVE_PART,
|
ID_LIBEDIT_REMOVE_PART,
|
||||||
|
ID_LIBEDIT_CUT_PART,
|
||||||
|
ID_LIBEDIT_COPY_PART,
|
||||||
|
ID_LIBEDIT_PASTE_PART,
|
||||||
ID_LIBEDIT_DUPLICATE_PART,
|
ID_LIBEDIT_DUPLICATE_PART,
|
||||||
|
|
||||||
/* Library editor horizontal toolbar IDs. */
|
/* Library editor horizontal toolbar IDs. */
|
||||||
|
|
|
@ -103,7 +103,10 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
|
||||||
EVT_TOOL( ID_LIBEDIT_IMPORT_PART, LIB_EDIT_FRAME::OnImportPart )
|
EVT_TOOL( ID_LIBEDIT_IMPORT_PART, LIB_EDIT_FRAME::OnImportPart )
|
||||||
EVT_TOOL( ID_LIBEDIT_EXPORT_PART, LIB_EDIT_FRAME::OnExportPart )
|
EVT_TOOL( ID_LIBEDIT_EXPORT_PART, LIB_EDIT_FRAME::OnExportPart )
|
||||||
EVT_TOOL( ID_LIBEDIT_REMOVE_PART, LIB_EDIT_FRAME::OnRemovePart )
|
EVT_TOOL( ID_LIBEDIT_REMOVE_PART, LIB_EDIT_FRAME::OnRemovePart )
|
||||||
EVT_TOOL( ID_LIBEDIT_DUPLICATE_PART, LIB_EDIT_FRAME::OnDuplicatePart )
|
EVT_TOOL( ID_LIBEDIT_CUT_PART, LIB_EDIT_FRAME::OnCopyCutPart )
|
||||||
|
EVT_TOOL( ID_LIBEDIT_COPY_PART, LIB_EDIT_FRAME::OnCopyCutPart )
|
||||||
|
EVT_TOOL( ID_LIBEDIT_PASTE_PART, LIB_EDIT_FRAME::OnPasteDuplicatePart )
|
||||||
|
EVT_TOOL( ID_LIBEDIT_DUPLICATE_PART, LIB_EDIT_FRAME::OnPasteDuplicatePart )
|
||||||
|
|
||||||
// Main horizontal toolbar.
|
// Main horizontal toolbar.
|
||||||
EVT_TOOL( ID_TO_LIBVIEW, LIB_EDIT_FRAME::OnOpenLibraryViewer )
|
EVT_TOOL( ID_TO_LIBVIEW, LIB_EDIT_FRAME::OnOpenLibraryViewer )
|
||||||
|
|
|
@ -62,6 +62,9 @@ class LIB_EDIT_FRAME : public SCH_BASE_FRAME
|
||||||
SYMBOL_TREE_PANE* m_treePane; ///< component search tree widget
|
SYMBOL_TREE_PANE* m_treePane; ///< component search tree widget
|
||||||
LIB_MANAGER* m_libMgr; ///< manager taking care of temporary modificatoins
|
LIB_MANAGER* m_libMgr; ///< manager taking care of temporary modificatoins
|
||||||
|
|
||||||
|
// Copy/cut/paste buffer to move parts between libraries
|
||||||
|
std::unique_ptr<LIB_PART> m_copiedPart;
|
||||||
|
|
||||||
/** Convert of the item currently being drawn. */
|
/** Convert of the item currently being drawn. */
|
||||||
bool m_drawSpecificConvert;
|
bool m_drawSpecificConvert;
|
||||||
|
|
||||||
|
@ -293,6 +296,8 @@ public:
|
||||||
void OnRemovePart( wxCommandEvent& aEvent );
|
void OnRemovePart( wxCommandEvent& aEvent );
|
||||||
|
|
||||||
void OnDuplicatePart( wxCommandEvent& aEvent );
|
void OnDuplicatePart( wxCommandEvent& aEvent );
|
||||||
|
void OnCopyCutPart( wxCommandEvent& aEvent );
|
||||||
|
void OnPasteDuplicatePart( wxCommandEvent& aEvent );
|
||||||
|
|
||||||
void OnSelectPart( wxCommandEvent& event );
|
void OnSelectPart( wxCommandEvent& event );
|
||||||
|
|
||||||
|
|
|
@ -490,16 +490,39 @@ void LIB_EDIT_FRAME::OnRemovePart( wxCommandEvent& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LIB_EDIT_FRAME::OnDuplicatePart( wxCommandEvent& aEvent )
|
void LIB_EDIT_FRAME::OnCopyCutPart( wxCommandEvent& aEvent )
|
||||||
{
|
{
|
||||||
int unit = 0;
|
int dummyUnit;
|
||||||
LIB_ID libId = m_treePane->GetLibTree()->GetSelectedLibId( &unit );
|
LIB_ID libId = m_treePane->GetLibTree()->GetSelectedLibId( &dummyUnit );
|
||||||
|
LIB_PART* part = m_libMgr->GetBufferedPart( libId.GetLibItemName(), libId.GetLibNickname() );
|
||||||
|
|
||||||
|
if( !part )
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_copiedPart.reset( new LIB_PART( *part ) );
|
||||||
|
|
||||||
|
if( aEvent.GetId() == ID_LIBEDIT_CUT_PART )
|
||||||
|
OnRemovePart( aEvent );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LIB_EDIT_FRAME::OnPasteDuplicatePart( wxCommandEvent& aEvent )
|
||||||
|
{
|
||||||
|
int dummyUnit;
|
||||||
|
LIB_ID libId = m_treePane->GetLibTree()->GetSelectedLibId( &dummyUnit );
|
||||||
wxString lib = libId.GetLibNickname();
|
wxString lib = libId.GetLibNickname();
|
||||||
|
|
||||||
if( !m_libMgr->LibraryExists( lib ) )
|
if( !m_libMgr->LibraryExists( lib ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LIB_PART* srcPart = m_libMgr->GetBufferedPart( libId.GetLibItemName(), lib );
|
LIB_PART* srcPart = nullptr;
|
||||||
|
|
||||||
|
if( aEvent.GetId() == ID_LIBEDIT_DUPLICATE_PART )
|
||||||
|
srcPart = m_libMgr->GetBufferedPart( libId.GetLibItemName(), lib );
|
||||||
|
else if( aEvent.GetId() == ID_LIBEDIT_PASTE_PART )
|
||||||
|
srcPart = m_copiedPart.get();
|
||||||
|
else
|
||||||
|
wxFAIL;
|
||||||
|
|
||||||
if( !srcPart )
|
if( !srcPart )
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -65,6 +65,8 @@ SYMBOL_TREE_PANE::SYMBOL_TREE_PANE( LIB_EDIT_FRAME* aParent, LIB_MANAGER* aLibMg
|
||||||
KiBitmap( new_component_xpm ) );
|
KiBitmap( new_component_xpm ) );
|
||||||
AddMenuItem( menuLibrary.get(), ID_LIBEDIT_IMPORT_PART, _( "&Import Symbol..." ),
|
AddMenuItem( menuLibrary.get(), ID_LIBEDIT_IMPORT_PART, _( "&Import Symbol..." ),
|
||||||
KiBitmap( import_part_xpm ) );
|
KiBitmap( import_part_xpm ) );
|
||||||
|
AddMenuItem( menuLibrary.get(), ID_LIBEDIT_PASTE_PART, _( "Paste Symbol" ),
|
||||||
|
KiBitmap( paste_xpm ) );
|
||||||
|
|
||||||
std::unique_ptr<wxMenu> menuPart = std::make_unique<wxMenu>();
|
std::unique_ptr<wxMenu> menuPart = std::make_unique<wxMenu>();
|
||||||
AddMenuItem( menuPart.get(), ID_LIBEDIT_EDIT_PART, _( "&Edit Symbol" ),
|
AddMenuItem( menuPart.get(), ID_LIBEDIT_EDIT_PART, _( "&Edit Symbol" ),
|
||||||
|
@ -82,6 +84,12 @@ SYMBOL_TREE_PANE::SYMBOL_TREE_PANE( LIB_EDIT_FRAME* aParent, LIB_MANAGER* aLibMg
|
||||||
AddMenuItem( menuPart.get(), ID_LIBEDIT_REVERT, _( "Revert" ),
|
AddMenuItem( menuPart.get(), ID_LIBEDIT_REVERT, _( "Revert" ),
|
||||||
KiBitmap( undo_xpm ) );
|
KiBitmap( undo_xpm ) );
|
||||||
|
|
||||||
|
menuPart->AppendSeparator();
|
||||||
|
AddMenuItem( menuPart.get(), ID_LIBEDIT_CUT_PART, _( "Cut" ),
|
||||||
|
KiBitmap( cut_xpm ) );
|
||||||
|
AddMenuItem( menuPart.get(), ID_LIBEDIT_COPY_PART, _( "Copy" ),
|
||||||
|
KiBitmap( copy_xpm ) );
|
||||||
|
|
||||||
menuPart->AppendSeparator();
|
menuPart->AppendSeparator();
|
||||||
AddMenuItem( menuPart.get(), ID_LIBEDIT_EXPORT_PART, _( "E&xport Symbol..." ),
|
AddMenuItem( menuPart.get(), ID_LIBEDIT_EXPORT_PART, _( "E&xport Symbol..." ),
|
||||||
KiBitmap( export_part_xpm ) );
|
KiBitmap( export_part_xpm ) );
|
||||||
|
|
Loading…
Reference in New Issue