Warn user before removing invalid rows from library table entries.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/8080
This commit is contained in:
parent
aaffd0c137
commit
6e017b475d
|
@ -311,6 +311,8 @@ PANEL_SYM_LIB_TABLE::~PANEL_SYM_LIB_TABLE()
|
||||||
|
|
||||||
bool PANEL_SYM_LIB_TABLE::verifyTables()
|
bool PANEL_SYM_LIB_TABLE::verifyTables()
|
||||||
{
|
{
|
||||||
|
wxString msg;
|
||||||
|
|
||||||
for( SYMBOL_LIB_TABLE_GRID* model : { global_model(), project_model() } )
|
for( SYMBOL_LIB_TABLE_GRID* model : { global_model(), project_model() } )
|
||||||
{
|
{
|
||||||
if( !model )
|
if( !model )
|
||||||
|
@ -324,6 +326,23 @@ bool PANEL_SYM_LIB_TABLE::verifyTables()
|
||||||
|
|
||||||
if( !nick || !uri )
|
if( !nick || !uri )
|
||||||
{
|
{
|
||||||
|
if( !nick && !uri )
|
||||||
|
msg = _( "A library table row nickname and path cells are empty." );
|
||||||
|
else if( !nick )
|
||||||
|
msg = _( "A library table row nickname cell is empty." );
|
||||||
|
else
|
||||||
|
msg = _( "A library table row path cell is empty." );
|
||||||
|
|
||||||
|
wxMessageDialog badCellDlg( this, msg, _( "Invalid Row Definition" ),
|
||||||
|
wxYES_NO | wxCENTER | wxICON_QUESTION | wxYES_DEFAULT );
|
||||||
|
badCellDlg.SetExtendedMessage( _( "Empty cells will result in all rows that are "
|
||||||
|
"invalid to be removed from the table." ) );
|
||||||
|
badCellDlg.SetYesNoLabels( wxMessageDialog::ButtonLabel( "Remove Invalid Cells" ),
|
||||||
|
wxMessageDialog::ButtonLabel( "Cancel Table Update" ) );
|
||||||
|
|
||||||
|
if( badCellDlg.ShowModal() == wxID_NO )
|
||||||
|
return false;
|
||||||
|
|
||||||
// Delete the "empty" row, where empty means missing nick or uri.
|
// Delete the "empty" row, where empty means missing nick or uri.
|
||||||
// This also updates the UI which could be slow, but there should only be a few
|
// This also updates the UI which could be slow, but there should only be a few
|
||||||
// rows to delete, unless the user fell asleep on the Add Row
|
// rows to delete, unless the user fell asleep on the Add Row
|
||||||
|
@ -332,7 +351,7 @@ bool PANEL_SYM_LIB_TABLE::verifyTables()
|
||||||
}
|
}
|
||||||
else if( ( illegalCh = LIB_ID::FindIllegalLibraryNameChar( nick ) ) )
|
else if( ( illegalCh = LIB_ID::FindIllegalLibraryNameChar( nick ) ) )
|
||||||
{
|
{
|
||||||
wxString msg = wxString::Format( _( "Illegal character '%c' in nickname '%s'" ),
|
msg = wxString::Format( _( "Illegal character '%c' in nickname '%s'" ),
|
||||||
illegalCh,
|
illegalCh,
|
||||||
nick );
|
nick );
|
||||||
|
|
||||||
|
@ -373,9 +392,8 @@ bool PANEL_SYM_LIB_TABLE::verifyTables()
|
||||||
|
|
||||||
if( nick1 == nick2 )
|
if( nick1 == nick2 )
|
||||||
{
|
{
|
||||||
wxString msg = wxString::Format( _( "Multiple libraries cannot share the same "
|
msg = wxString::Format( _( "Multiple libraries cannot share the same "
|
||||||
"nickname ('%s')." ),
|
"nickname ('%s')." ), nick1 );
|
||||||
nick1 );
|
|
||||||
|
|
||||||
// show the tabbed panel holding the grid we have flunked:
|
// show the tabbed panel holding the grid we have flunked:
|
||||||
if( model != cur_model() )
|
if( model != cur_model() )
|
||||||
|
@ -418,7 +436,7 @@ bool PANEL_SYM_LIB_TABLE::verifyTables()
|
||||||
}
|
}
|
||||||
catch( const IO_ERROR& ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
wxString msg = wxString::Format( _( "Symbol library \"%s\" failed to load.\n %s" ),
|
msg = wxString::Format( _( "Symbol library \"%s\" failed to load.\n %s" ),
|
||||||
row.GetNickName(),
|
row.GetNickName(),
|
||||||
ioe.What() );
|
ioe.What() );
|
||||||
|
|
||||||
|
|
|
@ -512,6 +512,8 @@ PANEL_FP_LIB_TABLE::~PANEL_FP_LIB_TABLE()
|
||||||
|
|
||||||
bool PANEL_FP_LIB_TABLE::verifyTables()
|
bool PANEL_FP_LIB_TABLE::verifyTables()
|
||||||
{
|
{
|
||||||
|
wxString msg;
|
||||||
|
|
||||||
for( FP_LIB_TABLE_GRID* model : { global_model(), project_model() } )
|
for( FP_LIB_TABLE_GRID* model : { global_model(), project_model() } )
|
||||||
{
|
{
|
||||||
if( !model )
|
if( !model )
|
||||||
|
@ -525,6 +527,23 @@ bool PANEL_FP_LIB_TABLE::verifyTables()
|
||||||
|
|
||||||
if( !nick || !uri )
|
if( !nick || !uri )
|
||||||
{
|
{
|
||||||
|
if( !nick && !uri )
|
||||||
|
msg = _( "A library table row nickname and path cells are empty." );
|
||||||
|
else if( !nick )
|
||||||
|
msg = _( "A library table row nickname cell is empty." );
|
||||||
|
else
|
||||||
|
msg = _( "A library table row path cell is empty." );
|
||||||
|
|
||||||
|
wxMessageDialog badCellDlg( this, msg, _( "Invalid Row Definition" ),
|
||||||
|
wxYES_NO | wxCENTER | wxICON_QUESTION | wxYES_DEFAULT );
|
||||||
|
badCellDlg.SetExtendedMessage( _( "Empty cells will result in all rows that are "
|
||||||
|
"invalid to be removed from the table." ) );
|
||||||
|
badCellDlg.SetYesNoLabels( wxMessageDialog::ButtonLabel( "Remove Invalid Cells" ),
|
||||||
|
wxMessageDialog::ButtonLabel( "Cancel Table Update" ) );
|
||||||
|
|
||||||
|
if( badCellDlg.ShowModal() == wxID_NO )
|
||||||
|
return false;
|
||||||
|
|
||||||
// Delete the "empty" row, where empty means missing nick or uri.
|
// Delete the "empty" row, where empty means missing nick or uri.
|
||||||
// This also updates the UI which could be slow, but there should only be a few
|
// This also updates the UI which could be slow, but there should only be a few
|
||||||
// rows to delete, unless the user fell asleep on the Add Row
|
// rows to delete, unless the user fell asleep on the Add Row
|
||||||
|
@ -533,7 +552,7 @@ bool PANEL_FP_LIB_TABLE::verifyTables()
|
||||||
}
|
}
|
||||||
else if( ( illegalCh = LIB_ID::FindIllegalLibraryNameChar( nick ) ) )
|
else if( ( illegalCh = LIB_ID::FindIllegalLibraryNameChar( nick ) ) )
|
||||||
{
|
{
|
||||||
wxString msg = wxString::Format( _( "Illegal character '%c' in nickname '%s'." ),
|
msg = wxString::Format( _( "Illegal character '%c' in nickname '%s'." ),
|
||||||
illegalCh,
|
illegalCh,
|
||||||
nick );
|
nick );
|
||||||
|
|
||||||
|
@ -574,7 +593,7 @@ bool PANEL_FP_LIB_TABLE::verifyTables()
|
||||||
|
|
||||||
if( nick1 == nick2 )
|
if( nick1 == nick2 )
|
||||||
{
|
{
|
||||||
wxString msg = wxString::Format( _( "Multiple libraries cannot share the same "
|
msg = wxString::Format( _( "Multiple libraries cannot share the same "
|
||||||
"nickname ('%s')." ),
|
"nickname ('%s')." ),
|
||||||
nick1 );
|
nick1 );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue