Allow overwriting existing symbols

This allows the workflow:
1) Edit symbol in schematic
2) Save As to original library

Also allows the user to quickly overwrite a symbol they don't want,
either by importing over the existing symbol or creating a new one.
This commit is contained in:
Seth Hillbrand 2021-07-28 09:30:25 -07:00
parent 8c69a856fc
commit d5abbd0d14
2 changed files with 21 additions and 6 deletions

View File

@ -421,8 +421,13 @@ void SYMBOL_EDIT_FRAME::CreateNewSymbol()
wxString msg = wxString::Format( _( "Symbol '%s' already exists in library '%s'." ),
name,
lib );
DisplayError( this, msg );
return;
KIDIALOG errorDlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
errorDlg.SetOKLabel( _( "Overwrite" ) );
errorDlg.DoNotShowCheckbox( __FILE__, __LINE__ );
if( errorDlg.ShowModal() == wxID_CANCEL )
return;
}
LIB_SYMBOL new_symbol( name ); // do not create symbol on the heap, it will be buffered soon
@ -673,8 +678,13 @@ void SYMBOL_EDIT_FRAME::saveSymbolAs()
wxString msg = wxString::Format( _( "Symbol '%s' already exists in library '%s'" ),
new_name,
new_lib );
DisplayError( this, msg );
return;
KIDIALOG errorDlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
errorDlg.SetOKLabel( _( "Overwrite" ) );
errorDlg.DoNotShowCheckbox( __FILE__, __LINE__ );
if( errorDlg.ShowModal() == wxID_CANCEL )
return;
}
LIB_SYMBOL new_symbol( *symbol );

View File

@ -94,8 +94,13 @@ void SYMBOL_EDIT_FRAME::ImportSymbol()
if( m_libMgr->SymbolExists( symbols[0], libName ) )
{
msg.Printf( _( "Symbol %s already exists in library '%s'." ), symbolName, libName );
DisplayError( this, msg );
return;
KIDIALOG errorDlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
errorDlg.SetOKLabel( _( "Overwrite" ) );
errorDlg.DoNotShowCheckbox( __FILE__, __LINE__ );
if( errorDlg.ShowModal() == wxID_CANCEL )
return;
}
m_libMgr->UpdateSymbol( entry, libName );