Convert cross-references in Table Properties dialogs.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19705
This commit is contained in:
Jeff Young 2025-01-22 00:16:03 +00:00
parent 5a57e5cfd4
commit dac7c9d4d7
4 changed files with 40 additions and 8 deletions

View File

@ -148,9 +148,18 @@ bool DIALOG_TABLE_PROPERTIES::TransferDataToWindow()
SCH_TABLECELL* tableCell = m_table->GetCell( row, col ); SCH_TABLECELL* tableCell = m_table->GetCell( row, col );
if( tableCell->GetColSpan() == 0 || tableCell->GetRowSpan() == 0 ) if( tableCell->GetColSpan() == 0 || tableCell->GetRowSpan() == 0 )
{
m_grid->SetCellValue( row, col, coveredColor.GetAsString() ); m_grid->SetCellValue( row, col, coveredColor.GetAsString() );
else continue;
m_grid->SetCellValue( row, col, tableCell->GetText() ); }
wxString text = tableCell->GetText();
// show text variable cross-references in a human-readable format
if( SCHEMATIC* schematic = tableCell->Schematic() )
text = schematic->ConvertKIIDsToRefs( text );
m_grid->SetCellValue( row, col, text );
} }
} }
@ -317,6 +326,10 @@ bool DIALOG_TABLE_PROPERTIES::TransferDataFromWindow()
SCH_TABLECELL* tableCell = m_table->GetCell( row, col ); SCH_TABLECELL* tableCell = m_table->GetCell( row, col );
wxString txt = m_grid->GetCellValue( row, col ); wxString txt = m_grid->GetCellValue( row, col );
// convert any text variable cross-references to their UUIDs
if( SCHEMATIC* schematic = tableCell->Schematic() )
txt = schematic->ConvertRefsToKIIDs( txt );
#ifdef __WXMAC__ #ifdef __WXMAC__
// On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting. // On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting.
// Replace it now. // Replace it now.

View File

@ -463,7 +463,7 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow()
// convert any text variable cross-references to their UUIDs // convert any text variable cross-references to their UUIDs
if( SCHEMATIC* schematic = m_currentItem->Schematic() ) if( SCHEMATIC* schematic = m_currentItem->Schematic() )
text = schematic->ConvertRefsToKIIDs( m_textCtrl->GetValue() ); text = schematic->ConvertRefsToKIIDs( text );
#ifdef __WXMAC__ #ifdef __WXMAC__
// On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting // On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting

View File

@ -140,6 +140,8 @@ DIALOG_TABLE_PROPERTIES::~DIALOG_TABLE_PROPERTIES()
bool DIALOG_TABLE_PROPERTIES::TransferDataToWindow() bool DIALOG_TABLE_PROPERTIES::TransferDataToWindow()
{ {
BOARD* board = m_frame->GetBoard();
if( !wxDialog::TransferDataToWindow() ) if( !wxDialog::TransferDataToWindow() )
return false; return false;
@ -166,9 +168,17 @@ bool DIALOG_TABLE_PROPERTIES::TransferDataToWindow()
tableCell = m_table->GetCell( row, col ); tableCell = m_table->GetCell( row, col );
if( tableCell->GetColSpan() == 0 || tableCell->GetRowSpan() == 0 ) if( tableCell->GetColSpan() == 0 || tableCell->GetRowSpan() == 0 )
{
m_grid->SetCellValue( row, col, coveredColor.GetAsString() ); m_grid->SetCellValue( row, col, coveredColor.GetAsString() );
else continue;
m_grid->SetCellValue( row, col, tableCell->GetText() ); }
wxString text = tableCell->GetText();
// show text variable cross-references in a human-readable format
text = board->ConvertKIIDsToCrossReferences( UnescapeString( text ) );
m_grid->SetCellValue( row, col, text );
} }
} }
@ -276,6 +286,7 @@ bool DIALOG_TABLE_PROPERTIES::TransferDataFromWindow()
if( !wxDialog::TransferDataFromWindow() ) if( !wxDialog::TransferDataFromWindow() )
return false; return false;
BOARD* board = m_frame->GetBoard();
BOARD_COMMIT commit( m_frame ); BOARD_COMMIT commit( m_frame );
commit.Modify( m_table ); commit.Modify( m_table );
@ -301,6 +312,9 @@ bool DIALOG_TABLE_PROPERTIES::TransferDataFromWindow()
wxString txt = m_grid->GetCellValue( row, col ); wxString txt = m_grid->GetCellValue( row, col );
// convert any text variable cross-references to their UUIDs
txt = board->ConvertCrossReferencesToKIIDs( txt );
#ifdef __WXMAC__ #ifdef __WXMAC__
// On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting. // On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting.
// Replace it now. // Replace it now.

View File

@ -284,11 +284,14 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow()
{ {
BOARD* board = m_frame->GetBoard(); BOARD* board = m_frame->GetBoard();
FOOTPRINT* parentFP = m_item->GetParentFootprint(); FOOTPRINT* parentFP = m_item->GetParentFootprint();
wxString msg = board->ConvertKIIDsToCrossReferences( UnescapeString( m_item->GetText() ) ); wxString text = m_item->GetText();
// show text variable cross-references in a human-readable format
text = board->ConvertKIIDsToCrossReferences( UnescapeString( text ) );
if( m_SingleLineText->IsShown() ) if( m_SingleLineText->IsShown() )
{ {
m_SingleLineText->SetValue( msg ); m_SingleLineText->SetValue( text );
if( m_item->Type() == PCB_FIELD_T && static_cast<PCB_FIELD*>( m_item )->IsReference() ) if( m_item->Type() == PCB_FIELD_T && static_cast<PCB_FIELD*>( m_item )->IsReference() )
KIUI::SelectReferenceNumber( static_cast<wxTextEntry*>( m_SingleLineText ) ); KIUI::SelectReferenceNumber( static_cast<wxTextEntry*>( m_SingleLineText ) );
@ -297,7 +300,7 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow()
} }
else if( m_MultiLineText->IsShown() ) else if( m_MultiLineText->IsShown() )
{ {
m_MultiLineText->SetValue( msg ); m_MultiLineText->SetValue( text );
m_MultiLineText->SetSelection( -1, -1 ); m_MultiLineText->SetSelection( -1, -1 );
m_MultiLineText->EmptyUndoBuffer(); m_MultiLineText->EmptyUndoBuffer();
} }
@ -470,6 +473,7 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow()
{ {
if( !m_SingleLineText->GetValue().IsEmpty() ) if( !m_SingleLineText->GetValue().IsEmpty() )
{ {
// convert any text variable cross-references to their UUIDs
wxString txt = board->ConvertCrossReferencesToKIIDs( m_SingleLineText->GetValue() ); wxString txt = board->ConvertCrossReferencesToKIIDs( m_SingleLineText->GetValue() );
m_item->SetText( txt ); m_item->SetText( txt );
@ -479,6 +483,7 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow()
{ {
if( !m_MultiLineText->GetValue().IsEmpty() ) if( !m_MultiLineText->GetValue().IsEmpty() )
{ {
// convert any text variable cross-references to their UUIDs
wxString txt = board->ConvertCrossReferencesToKIIDs( m_MultiLineText->GetValue() ); wxString txt = board->ConvertCrossReferencesToKIIDs( m_MultiLineText->GetValue() );
#ifdef __WXMAC__ #ifdef __WXMAC__