Update membership grid when a netclass name changes.
Fixes https://gitlab.com/kicad/code/kicad/issues/4596
This commit is contained in:
parent
59523efc1a
commit
a76a1aefaa
|
@ -300,7 +300,7 @@ bool PANEL_SETUP_NETCLASSES::validateNetclassName( int aRow, wxString aName, boo
|
|||
|
||||
for( int ii = 0; ii < m_netclassGrid->GetNumberRows(); ii++ )
|
||||
{
|
||||
if( ii != aRow && m_netclassGrid->GetRowLabelValue( ii ).CmpNoCase( aName ) == 0 )
|
||||
if( ii != aRow && m_netclassGrid->GetCellValue( ii, GRID_NAME ).CmpNoCase( aName ) == 0 )
|
||||
{
|
||||
wxString msg = _( "Netclass name already in use." );
|
||||
m_Parent->SetError( msg, this, m_netclassGrid, focusFirst ? aRow : ii, GRID_NAME );
|
||||
|
@ -317,7 +317,18 @@ void PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging( wxGridEvent& event )
|
|||
if( event.GetCol() == GRID_NAME )
|
||||
{
|
||||
if( validateNetclassName( event.GetRow(), event.GetString() ) )
|
||||
{
|
||||
wxString oldName = m_netclassGrid->GetCellValue( event.GetRow(), GRID_NAME );
|
||||
wxString newName = event.GetString();
|
||||
|
||||
for( int row = 0; row < m_membershipGrid->GetNumberRows(); ++row )
|
||||
{
|
||||
if( m_membershipGrid->GetCellValue( row, 1 ) == oldName )
|
||||
m_membershipGrid->SetCellValue( row, 1, newName );
|
||||
}
|
||||
|
||||
m_netclassesDirty = true;
|
||||
}
|
||||
else
|
||||
event.Veto();
|
||||
}
|
||||
|
@ -402,6 +413,12 @@ void PANEL_SETUP_NETCLASSES::OnSizeNetclassGrid( wxSizeEvent& event )
|
|||
}
|
||||
|
||||
|
||||
void PANEL_SETUP_NETCLASSES::OnMembershipKillFocus( wxFocusEvent& event )
|
||||
{
|
||||
m_membershipGrid->CommitPendingChanges();
|
||||
}
|
||||
|
||||
|
||||
void PANEL_SETUP_NETCLASSES::AdjustMembershipGridColumns( int aWidth )
|
||||
{
|
||||
// Account for scroll bars
|
||||
|
|
|
@ -60,6 +60,7 @@ private:
|
|||
void OnSizeMembershipGrid( wxSizeEvent& event ) override;
|
||||
void OnUpdateUI( wxUpdateUIEvent &event ) override;
|
||||
void OnNetclassGridCellChanging( wxGridEvent& event );
|
||||
void OnMembershipKillFocus( wxFocusEvent& event ) override;
|
||||
void OnShowAll( wxCommandEvent& event ) override { doApplyFilters( true ); }
|
||||
void OnApplyFilters( wxCommandEvent& event ) override { doApplyFilters( false ); }
|
||||
void OnAssignAll( wxCommandEvent& event ) override { doAssignments( true ); }
|
||||
|
|
|
@ -256,6 +256,7 @@ PANEL_SETUP_NETCLASSES_BASE::PANEL_SETUP_NETCLASSES_BASE( wxWindow* parent, wxWi
|
|||
m_filterNetsButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnApplyFilters ), NULL, this );
|
||||
m_assignAllButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnAssignAll ), NULL, this );
|
||||
m_assignSelectedButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnAssignSelected ), NULL, this );
|
||||
m_membershipGrid->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnMembershipKillFocus ), NULL, this );
|
||||
m_membershipGrid->Connect( wxEVT_SIZE, wxSizeEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnSizeMembershipGrid ), NULL, this );
|
||||
}
|
||||
|
||||
|
@ -270,6 +271,7 @@ PANEL_SETUP_NETCLASSES_BASE::~PANEL_SETUP_NETCLASSES_BASE()
|
|||
m_filterNetsButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnApplyFilters ), NULL, this );
|
||||
m_assignAllButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnAssignAll ), NULL, this );
|
||||
m_assignSelectedButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnAssignSelected ), NULL, this );
|
||||
m_membershipGrid->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnMembershipKillFocus ), NULL, this );
|
||||
m_membershipGrid->Disconnect( wxEVT_SIZE, wxSizeEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnSizeMembershipGrid ), NULL, this );
|
||||
|
||||
}
|
||||
|
|
|
@ -1325,6 +1325,7 @@
|
|||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style">wxBORDER_DEFAULT</property>
|
||||
<event name="OnKillFocus">OnMembershipKillFocus</event>
|
||||
<event name="OnSize">OnSizeMembershipGrid</event>
|
||||
</object>
|
||||
</object>
|
||||
|
|
|
@ -66,6 +66,7 @@ class PANEL_SETUP_NETCLASSES_BASE : public wxPanel
|
|||
virtual void OnApplyFilters( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnAssignAll( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnAssignSelected( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnMembershipKillFocus( wxFocusEvent& event ) { event.Skip(); }
|
||||
virtual void OnSizeMembershipGrid( wxSizeEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue