Update membership grid when a netclass name changes.

Fixes https://gitlab.com/kicad/code/kicad/issues/4596
This commit is contained in:
Jeff Young 2020-06-01 20:35:43 +01:00
parent 542f713678
commit a02ee3719c
5 changed files with 23 additions and 1 deletions

View File

@ -297,7 +297,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 );
@ -314,7 +314,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();
}
@ -399,6 +410,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

View File

@ -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 ); }

View File

@ -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 );
}

View File

@ -1327,6 +1327,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>

View File

@ -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(); }