Fix incorrect handling of the last component in the component list.
This commit is contained in:
parent
6b74f8ef48
commit
4d0d56fbd7
|
@ -95,6 +95,15 @@ private:
|
||||||
|
|
||||||
void initDlg();
|
void initDlg();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new row (new entry) in m_grid.
|
||||||
|
* @param aRowId is the row index
|
||||||
|
* @param aMarkRow = true to use bold/italic font in column COL_CURR_LIBID
|
||||||
|
* @param aReferences is the value of cell( aRowId, COL_REFS)
|
||||||
|
* @param aStrLibId is the value of cell( aRowId, COL_CURR_LIBID)
|
||||||
|
*/
|
||||||
|
void AddRowToGrid( int aRowId, bool aMarkRow, const wxString& aReferences, const wxString& aStrLibId );
|
||||||
|
|
||||||
// returns true if all new lib id are valid
|
// returns true if all new lib id are valid
|
||||||
bool validateLibIds();
|
bool validateLibIds();
|
||||||
|
|
||||||
|
@ -218,50 +227,21 @@ void DIALOG_EDIT_COMPONENTS_LIBID::initDlg()
|
||||||
int row = 0;
|
int row = 0;
|
||||||
wxString refs;
|
wxString refs;
|
||||||
bool mark_cell = false;
|
bool mark_cell = false;
|
||||||
|
CMP_CANDIDATE* cmp = nullptr;
|
||||||
|
|
||||||
for( unsigned ii = 0; ii < m_components.size(); ii++ )
|
for( unsigned ii = 0; ii < m_components.size(); ii++ )
|
||||||
{
|
{
|
||||||
CMP_CANDIDATE& cmp = m_components[ii];
|
cmp = &m_components[ii];
|
||||||
|
|
||||||
wxString str_libid = cmp.GetStringLibId();
|
wxString str_libid = cmp->GetStringLibId();
|
||||||
|
|
||||||
if( last_str_libid != str_libid || ii == m_components.size()-1 )
|
if( last_str_libid != str_libid )
|
||||||
{
|
{
|
||||||
|
// Add last group to grid
|
||||||
if( ii == m_components.size()-1 )
|
AddRowToGrid( row, mark_cell, refs, last_str_libid );
|
||||||
{
|
|
||||||
if( !refs.IsEmpty() )
|
|
||||||
refs += " ";
|
|
||||||
|
|
||||||
refs += cmp.GetSchematicReference();
|
|
||||||
cmp.m_Row = row;
|
|
||||||
mark_cell = cmp.m_IsOrphan;
|
|
||||||
|
|
||||||
last_str_libid = str_libid;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( m_grid->GetNumberRows() <= row )
|
|
||||||
m_grid->AppendRows();
|
|
||||||
|
|
||||||
m_grid->SetCellValue( row, COL_REFS, refs );
|
|
||||||
m_grid->SetReadOnly( row, COL_REFS );
|
|
||||||
|
|
||||||
m_grid->SetCellValue( row, COL_CURR_LIBID, last_str_libid );
|
|
||||||
m_grid->SetReadOnly( row, COL_CURR_LIBID );
|
|
||||||
|
|
||||||
if( mark_cell ) // A symbol is not existing in libraries: mark the cell
|
|
||||||
{
|
|
||||||
wxFont font = m_grid->GetDefaultCellFont();
|
|
||||||
font.MakeBold();
|
|
||||||
font.MakeItalic();
|
|
||||||
m_grid->SetCellFont( row, COL_CURR_LIBID, font );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_grid->SetCellRenderer( row, COL_REFS, new wxGridCellAutoWrapStringRenderer);
|
|
||||||
m_grid->AutoSizeRow( row, false );
|
|
||||||
|
|
||||||
// prepare next entry
|
// prepare next entry
|
||||||
mark_cell = cmp.m_IsOrphan;
|
mark_cell = cmp->m_IsOrphan;
|
||||||
last_str_libid = str_libid;
|
last_str_libid = str_libid;
|
||||||
refs.Empty();
|
refs.Empty();
|
||||||
row++;
|
row++;
|
||||||
|
@ -270,10 +250,13 @@ void DIALOG_EDIT_COMPONENTS_LIBID::initDlg()
|
||||||
if( !refs.IsEmpty() )
|
if( !refs.IsEmpty() )
|
||||||
refs += " ";
|
refs += " ";
|
||||||
|
|
||||||
refs += cmp.GetSchematicReference();
|
refs += cmp->GetSchematicReference();
|
||||||
cmp.m_Row = row;
|
cmp->m_Row = row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add last component group:
|
||||||
|
AddRowToGrid( row, mark_cell, refs, last_str_libid );
|
||||||
|
|
||||||
m_grid->AutoSizeColumn( COL_CURR_LIBID );
|
m_grid->AutoSizeColumn( COL_CURR_LIBID );
|
||||||
|
|
||||||
// Gives a similar width to COL_NEW_LIBID because it can conatains similar strings
|
// Gives a similar width to COL_NEW_LIBID because it can conatains similar strings
|
||||||
|
@ -282,6 +265,33 @@ void DIALOG_EDIT_COMPONENTS_LIBID::initDlg()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DIALOG_EDIT_COMPONENTS_LIBID::AddRowToGrid( int aRowId, bool aMarkRow,
|
||||||
|
const wxString& aReferences, const wxString& aStrLibId )
|
||||||
|
{
|
||||||
|
int row = aRowId;
|
||||||
|
|
||||||
|
if( m_grid->GetNumberRows() <= row )
|
||||||
|
m_grid->AppendRows();
|
||||||
|
|
||||||
|
m_grid->SetCellValue( row, COL_REFS, aReferences );
|
||||||
|
m_grid->SetReadOnly( row, COL_REFS );
|
||||||
|
|
||||||
|
m_grid->SetCellValue( row, COL_CURR_LIBID, aStrLibId );
|
||||||
|
m_grid->SetReadOnly( row, COL_CURR_LIBID );
|
||||||
|
|
||||||
|
if( aMarkRow ) // A symbol is not existing in libraries: mark the cell
|
||||||
|
{
|
||||||
|
wxFont font = m_grid->GetDefaultCellFont();
|
||||||
|
font.MakeBold();
|
||||||
|
font.MakeItalic();
|
||||||
|
m_grid->SetCellFont( row, COL_CURR_LIBID, font );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_grid->SetCellRenderer( row, COL_REFS, new wxGridCellAutoWrapStringRenderer);
|
||||||
|
m_grid->AutoSizeRow( row, false );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool DIALOG_EDIT_COMPONENTS_LIBID::validateLibIds()
|
bool DIALOG_EDIT_COMPONENTS_LIBID::validateLibIds()
|
||||||
{
|
{
|
||||||
int row_max = m_grid->GetNumberRows() - 1;
|
int row_max = m_grid->GetNumberRows() - 1;
|
||||||
|
|
Loading…
Reference in New Issue