31 std::vector<FIELD_CASE_CONFLICT> conflicts ) :
37 m_grid->SetSelectionMode( wxGrid::wxGridSelectRows );
39 m_headerLabel->SetLabel( wxString::Format(
_(
"%zu symbols have user fields whose names differ only in case. "
40 "Choose how to resolve each before opening the table." ),
44 m_grid->SetupColumnAutosizer( 3 );
49 { wxID_CANCEL,
_(
"Cancel" ) } } );
58 m_grid->PopEventHandler(
true );
69 [](
const wxString& aValue )
71 return aValue.IsEmpty() ? wxString(
_(
"(empty)" ) ) : aValue;
81 wxString fieldsLabel = c.
variants[0].first;
82 wxString valuesLabel = formatValue( c.
variants[0].second );
84 for(
size_t ii = 1; ii < c.
variants.size(); ++ii )
86 fieldsLabel +=
'\n' + c.
variants[ii].first;
87 valuesLabel +=
'\n' + formatValue( c.
variants[ii].second );
90 m_grid->SetCellValue( i, 2, fieldsLabel );
91 m_grid->SetCellValue( i, 3, valuesLabel );
93 wxArrayString choices;
94 choices.Add( wxString::Format(
_(
"Keep '%s'" ), c.
variants[0].first ) );
96 for(
size_t ii = 1; ii < c.
variants.size(); ++ii )
97 choices.Add( wxString::Format(
_(
"Keep '%s'" ), c.
variants[ii].first ) );
99 choices.Add(
_(
"Join values" ) );
101 m_grid->SetCellEditor( i, 4,
new wxGridCellChoiceEditor( choices,
false ) );
102 m_grid->SetCellValue( i, 4, choices[0] );
113 std::vector<int> siblings;
115 if( aRow < 0 ||
static_cast<size_t>( aRow ) >=
m_conflicts.size() )
118 const wxString& key =
m_conflicts[aRow].caseFoldedKey;
122 if(
static_cast<int>( i ) != aRow &&
m_conflicts[i].caseFoldedKey.IsSameAs( key,
false ) )
123 siblings.push_back(
static_cast<int>( i ) );
132 int row =
event.GetRow();
133 int col =
event.GetCol();
135 if( col != 4 || row < 0 ||
static_cast<size_t>( row ) >=
m_conflicts.size() )
143 for(
int ii = 0; ii < (int)
m_conflicts[row].variants.size(); ++ii )
145 if(
m_grid->GetCellValue( row, 4 ).Contains(
m_conflicts[row].variants[ii].first ) )
157 m_grid->SetCellValue( sibling, 4,
m_grid->GetCellValue( row, 4 ) );
177 for(
size_t row = 0; row <
m_conflicts.size(); ++row )
191 for(
const auto& [fieldName, fieldValue] : c.
variants )
193 if( !value.IsEmpty() && !fieldValue.IsEmpty() )
203 if( action < (
int) c.
variants.size() )
206 for(
const auto& [fieldName, fieldValue] : c.
variants )
208 if( value.IsEmpty() )
213 for(
int jj = 0; jj < (int) c.
variants.size(); ++jj )
218 field->SetText( value );
227 commit.
Push(
_(
"Resolve Duplicate Field Names" ) );
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
wxStaticText * m_headerLabel
DIALOG_RESOLVE_FIELD_CASE_CONFLICTS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Resolve Field Name Conflicts"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
wxTextCtrl * m_separatorCtrl
wxCheckBox * m_bulkApplyCheckbox
void onActionCellChanged(wxGridEvent &event) override
DIALOG_RESOLVE_FIELD_CASE_CONFLICTS(wxWindow *aParent, SCH_EDIT_FRAME *aFrame, std::vector< FIELD_CASE_CONFLICT > conflicts)
std::vector< FIELD_CASE_CONFLICT > m_conflicts
std::vector< int > m_rowAction
void onApplyAndContinue(wxCommandEvent &event) override
~DIALOG_RESOLVE_FIELD_CASE_CONFLICTS() override
std::vector< int > findSiblingRows(int aRow) const
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Commit for the schematic and symbol editors.
void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
Schematic editor (Eeschema) main window.
SCH_SCREEN * LastScreen()
wxString PathHumanReadable(bool aUseShortRootName=true, bool aStripTrailingSeparator=false, bool aEscapeSheetNames=false) const
Return the sheet path in a human readable form made from the sheet names.
void RemoveField(const wxString &aFieldName)
Remove a user field from the symbol.
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
std::vector< std::pair< wxString, wxString > > variants