From d72b9861f7901fa51f05ffe4d16ea9501d61c369 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 30 Apr 2022 00:08:30 +0100 Subject: [PATCH] Translate net inspector column names on the fly. Fixes https://gitlab.com/kicad/code/kicad/issues/11467 --- pcbnew/dialogs/dialog_net_inspector.cpp | 34 ++++++++++++------------- pcbnew/dialogs/dialog_net_inspector.h | 16 ++++++------ 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pcbnew/dialogs/dialog_net_inspector.cpp b/pcbnew/dialogs/dialog_net_inspector.cpp index d7e69181fa..7dfdae6488 100644 --- a/pcbnew/dialogs/dialog_net_inspector.cpp +++ b/pcbnew/dialogs/dialog_net_inspector.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -69,22 +68,14 @@ struct DIALOG_NET_INSPECTOR::COLUMN_DESC }; -#define def_col( c, num, name, csv_name, csv_flags ) \ - const DIALOG_NET_INSPECTOR::COLUMN_DESC DIALOG_NET_INSPECTOR::c = { num, \ - name, \ - csv_name, \ - COLUMN_DESC::csv_flags } - -def_col( COLUMN_NET, 0, _( "Net" ), _( "Net Code" ), CSV_NONE ); -def_col( COLUMN_NAME, 1, _( "Name" ), _( "Net Name" ), CSV_QUOTE ); -def_col( COLUMN_PAD_COUNT, 2, _( "Pad Count" ), _( "Pad Count" ), CSV_NONE ); -def_col( COLUMN_VIA_COUNT, 3, _( "Via Count" ), _( "Via Count" ), CSV_NONE ); -def_col( COLUMN_VIA_LENGTH, 4, _( "Via Length" ), _( "Via Length" ), CSV_NONE ); -def_col( COLUMN_BOARD_LENGTH, 5, _( "Track Length" ), _( "Track Length" ), CSV_NONE ); -def_col( COLUMN_CHIP_LENGTH, 6, _( "Die Length" ), _( "Die Length" ), CSV_NONE ); -def_col( COLUMN_TOTAL_LENGTH, 7, _( "Total Length" ), _( "Net Length" ), CSV_NONE ); - -#undef def_col +DIALOG_NET_INSPECTOR::COLUMN_DESC DIALOG_NET_INSPECTOR::COLUMN_NET; +DIALOG_NET_INSPECTOR::COLUMN_DESC DIALOG_NET_INSPECTOR::COLUMN_NAME; +DIALOG_NET_INSPECTOR::COLUMN_DESC DIALOG_NET_INSPECTOR::COLUMN_PAD_COUNT; +DIALOG_NET_INSPECTOR::COLUMN_DESC DIALOG_NET_INSPECTOR::COLUMN_VIA_COUNT; +DIALOG_NET_INSPECTOR::COLUMN_DESC DIALOG_NET_INSPECTOR::COLUMN_VIA_LENGTH; +DIALOG_NET_INSPECTOR::COLUMN_DESC DIALOG_NET_INSPECTOR::COLUMN_BOARD_LENGTH; +DIALOG_NET_INSPECTOR::COLUMN_DESC DIALOG_NET_INSPECTOR::COLUMN_CHIP_LENGTH; +DIALOG_NET_INSPECTOR::COLUMN_DESC DIALOG_NET_INSPECTOR::COLUMN_TOTAL_LENGTH; class DIALOG_NET_INSPECTOR::LIST_ITEM @@ -797,6 +788,15 @@ DIALOG_NET_INSPECTOR::DIALOG_NET_INSPECTOR( PCB_EDIT_FRAME* aParent, m_data_model = new DATA_MODEL( *this ); m_netsList->AssociateModel( &*m_data_model ); + COLUMN_NET = { 0, _( "Net" ), _( "Net Code" ), COLUMN_DESC::CSV_NONE }; + COLUMN_NAME = { 1, _( "Name" ), _( "Net Name" ), COLUMN_DESC::CSV_QUOTE }; + COLUMN_PAD_COUNT = { 2, _( "Pad Count" ), _( "Pad Count" ), COLUMN_DESC::CSV_NONE }; + COLUMN_VIA_COUNT = { 3, _( "Via Count" ), _( "Via Count" ), COLUMN_DESC::CSV_NONE }; + COLUMN_VIA_LENGTH = { 4, _( "Via Length" ), _( "Via Length" ), COLUMN_DESC::CSV_NONE }; + COLUMN_BOARD_LENGTH = { 5, _( "Track Length" ), _( "Track Length" ), COLUMN_DESC::CSV_NONE }; + COLUMN_CHIP_LENGTH = { 6, _( "Die Length" ), _( "Die Length" ), COLUMN_DESC::CSV_NONE }; + COLUMN_TOTAL_LENGTH = { 7, _( "Total Length" ), _( "Net Length" ), COLUMN_DESC::CSV_NONE }; + std::array, 8> add_col = { [&]() { diff --git a/pcbnew/dialogs/dialog_net_inspector.h b/pcbnew/dialogs/dialog_net_inspector.h index b88bf92107..df2afe0d9f 100644 --- a/pcbnew/dialogs/dialog_net_inspector.h +++ b/pcbnew/dialogs/dialog_net_inspector.h @@ -72,14 +72,14 @@ private: using LIST_ITEM_ITER = std::vector>::iterator; using LIST_ITEM_CONST_ITER = std::vector>::const_iterator; - static const COLUMN_DESC COLUMN_NET; - static const COLUMN_DESC COLUMN_NAME; - static const COLUMN_DESC COLUMN_PAD_COUNT; - static const COLUMN_DESC COLUMN_VIA_COUNT; - static const COLUMN_DESC COLUMN_VIA_LENGTH; - static const COLUMN_DESC COLUMN_BOARD_LENGTH; - static const COLUMN_DESC COLUMN_CHIP_LENGTH; - static const COLUMN_DESC COLUMN_TOTAL_LENGTH; + static COLUMN_DESC COLUMN_NET; + static COLUMN_DESC COLUMN_NAME; + static COLUMN_DESC COLUMN_PAD_COUNT; + static COLUMN_DESC COLUMN_VIA_COUNT; + static COLUMN_DESC COLUMN_VIA_LENGTH; + static COLUMN_DESC COLUMN_BOARD_LENGTH; + static COLUMN_DESC COLUMN_CHIP_LENGTH; + static COLUMN_DESC COLUMN_TOTAL_LENGTH; wxString formatNetCode( const NETINFO_ITEM* aNet ) const; wxString formatNetName( const NETINFO_ITEM* aNet ) const;