Allow column auto-sizing in RC trees.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16727
This commit is contained in:
Alex Shvartzkop 2024-01-25 20:30:22 +03:00
parent 2e760483b0
commit 6a69396070
2 changed files with 4 additions and 19 deletions

View File

@ -78,7 +78,7 @@ void RC_ITEM::SetItems( const EDA_ITEM* aItem, const EDA_ITEM* bItem,
}
wxString getSeverityString( SEVERITY aSeverity )
wxString RC_ITEM::getSeverityString( SEVERITY aSeverity )
{
wxString severity;
@ -244,8 +244,6 @@ RC_TREE_MODEL::RC_TREE_MODEL( EDA_DRAW_FRAME* aParentFrame, wxDataViewCtrl* aVie
m_severities( 0 ),
m_rcItemsProvider( nullptr )
{
m_view->GetMainWindow()->Connect( wxEVT_SIZE, wxSizeEventHandler( RC_TREE_MODEL::onSizeView ),
nullptr, this );
}
@ -327,8 +325,7 @@ void RC_TREE_MODEL::rebuildModel( std::shared_ptr<RC_ITEMS_PROVIDER> aProvider,
#endif
m_view->ClearColumns();
int width = m_view->GetMainWindow()->GetRect().GetWidth() - WX_DATAVIEW_WINDOW_PADDING;
m_view->AppendTextColumn( wxEmptyString, 0, wxDATAVIEW_CELL_INERT, width );
m_view->AppendTextColumn( wxEmptyString, 0, wxDATAVIEW_CELL_INERT, wxCOL_WIDTH_AUTOSIZE );
ExpandAll();
@ -709,15 +706,3 @@ void RC_TREE_MODEL::CenterMarker( const MARKER_BASE* aMarker )
}
}
}
void RC_TREE_MODEL::onSizeView( wxSizeEvent& aEvent )
{
int width = m_view->GetMainWindow()->GetRect().GetWidth() - WX_DATAVIEW_WINDOW_PADDING;
if( m_view->GetColumnCount() > 0 )
m_view->GetColumn( 0 )->SetWidth( width );
// Pass size event to other widgets
aEvent.Skip();
}

View File

@ -179,6 +179,8 @@ public:
}
protected:
static wxString getSeverityString( SEVERITY aSeverity );
int m_errorCode; ///< The error code's numeric value
wxString m_errorMessage; ///< A message describing the details of this specific error
wxString m_errorTitle; ///< The string describing the type of error
@ -290,8 +292,6 @@ public:
protected:
void rebuildModel( std::shared_ptr<RC_ITEMS_PROVIDER> aProvider, int aSeverities );
void onSizeView( wxSizeEvent& aEvent );
wxString getSeverityString( SEVERITY aSeverity );
EDA_DRAW_FRAME* m_editFrame;
wxDataViewCtrl* m_view;