From dac7c9d4d7b5110028c1384f4e070d4aa091206b Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 22 Jan 2025 00:16:03 +0000 Subject: [PATCH] Convert cross-references in Table Properties dialogs. Fixes https://gitlab.com/kicad/code/kicad/-/issues/19705 --- eeschema/dialogs/dialog_table_properties.cpp | 17 +++++++++++++++-- eeschema/dialogs/dialog_text_properties.cpp | 2 +- pcbnew/dialogs/dialog_table_properties.cpp | 18 ++++++++++++++++-- pcbnew/dialogs/dialog_text_properties.cpp | 11 ++++++++--- 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/eeschema/dialogs/dialog_table_properties.cpp b/eeschema/dialogs/dialog_table_properties.cpp index f8582d3494..e327242085 100644 --- a/eeschema/dialogs/dialog_table_properties.cpp +++ b/eeschema/dialogs/dialog_table_properties.cpp @@ -148,9 +148,18 @@ bool DIALOG_TABLE_PROPERTIES::TransferDataToWindow() SCH_TABLECELL* tableCell = m_table->GetCell( row, col ); if( tableCell->GetColSpan() == 0 || tableCell->GetRowSpan() == 0 ) + { m_grid->SetCellValue( row, col, coveredColor.GetAsString() ); - else - m_grid->SetCellValue( row, col, tableCell->GetText() ); + continue; + } + + 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 ); 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__ // On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting. // Replace it now. diff --git a/eeschema/dialogs/dialog_text_properties.cpp b/eeschema/dialogs/dialog_text_properties.cpp index 939ae4ef4f..02461966bc 100644 --- a/eeschema/dialogs/dialog_text_properties.cpp +++ b/eeschema/dialogs/dialog_text_properties.cpp @@ -463,7 +463,7 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() // convert any text variable cross-references to their UUIDs if( SCHEMATIC* schematic = m_currentItem->Schematic() ) - text = schematic->ConvertRefsToKIIDs( m_textCtrl->GetValue() ); + text = schematic->ConvertRefsToKIIDs( text ); #ifdef __WXMAC__ // On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting diff --git a/pcbnew/dialogs/dialog_table_properties.cpp b/pcbnew/dialogs/dialog_table_properties.cpp index 405f24ea25..5eeb08a2b5 100644 --- a/pcbnew/dialogs/dialog_table_properties.cpp +++ b/pcbnew/dialogs/dialog_table_properties.cpp @@ -140,6 +140,8 @@ DIALOG_TABLE_PROPERTIES::~DIALOG_TABLE_PROPERTIES() bool DIALOG_TABLE_PROPERTIES::TransferDataToWindow() { + BOARD* board = m_frame->GetBoard(); + if( !wxDialog::TransferDataToWindow() ) return false; @@ -166,9 +168,17 @@ bool DIALOG_TABLE_PROPERTIES::TransferDataToWindow() tableCell = m_table->GetCell( row, col ); if( tableCell->GetColSpan() == 0 || tableCell->GetRowSpan() == 0 ) + { m_grid->SetCellValue( row, col, coveredColor.GetAsString() ); - else - m_grid->SetCellValue( row, col, tableCell->GetText() ); + continue; + } + + 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() ) return false; + BOARD* board = m_frame->GetBoard(); BOARD_COMMIT commit( m_frame ); commit.Modify( m_table ); @@ -301,6 +312,9 @@ bool DIALOG_TABLE_PROPERTIES::TransferDataFromWindow() wxString txt = m_grid->GetCellValue( row, col ); + // convert any text variable cross-references to their UUIDs + txt = board->ConvertCrossReferencesToKIIDs( txt ); + #ifdef __WXMAC__ // On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting. // Replace it now. diff --git a/pcbnew/dialogs/dialog_text_properties.cpp b/pcbnew/dialogs/dialog_text_properties.cpp index c740981d51..8f350fd749 100644 --- a/pcbnew/dialogs/dialog_text_properties.cpp +++ b/pcbnew/dialogs/dialog_text_properties.cpp @@ -284,11 +284,14 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow() { BOARD* board = m_frame->GetBoard(); 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() ) { - m_SingleLineText->SetValue( msg ); + m_SingleLineText->SetValue( text ); if( m_item->Type() == PCB_FIELD_T && static_cast( m_item )->IsReference() ) KIUI::SelectReferenceNumber( static_cast( m_SingleLineText ) ); @@ -297,7 +300,7 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow() } else if( m_MultiLineText->IsShown() ) { - m_MultiLineText->SetValue( msg ); + m_MultiLineText->SetValue( text ); m_MultiLineText->SetSelection( -1, -1 ); m_MultiLineText->EmptyUndoBuffer(); } @@ -470,6 +473,7 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() { if( !m_SingleLineText->GetValue().IsEmpty() ) { + // convert any text variable cross-references to their UUIDs wxString txt = board->ConvertCrossReferencesToKIIDs( m_SingleLineText->GetValue() ); m_item->SetText( txt ); @@ -479,6 +483,7 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() { if( !m_MultiLineText->GetValue().IsEmpty() ) { + // convert any text variable cross-references to their UUIDs wxString txt = board->ConvertCrossReferencesToKIIDs( m_MultiLineText->GetValue() ); #ifdef __WXMAC__