Add alt pin table to compare function for LIB_PIN.

Also fixes refresh issue when editing alt pins.

Fixes https://gitlab.com/kicad/code/kicad/issues/7204
This commit is contained in:
Jeff Young 2021-01-28 11:15:47 +00:00
parent ff7742c6b8
commit 69d58d39e5
2 changed files with 31 additions and 4 deletions

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -31,6 +31,7 @@
#include <kicad_string.h>
#include <menus_helpers.h>
#include <widgets/grid_icon_text_helpers.h>
#include <widgets/grid_combobox.h>
#include <widgets/wx_grid.h>
#include <settings/settings_manager.h>
#include <ee_collectors.h>
@ -109,7 +110,7 @@ public:
choices.push_back( alt.first );
attr = new wxGridCellAttr();
attr->SetEditor( new wxGridCellChoiceEditor( choices ) );
attr->SetEditor( new GRID_CELL_COMBOBOX( choices ) );
}
m_nameAttrs.push_back( attr );
@ -195,7 +196,7 @@ public:
switch( aCol )
{
case COL_ALT_NAME:
if( aValue == at( aRow ).GetName() )
if( aValue == at( aRow ).GetLibPin()->GetName() )
at( aRow ).SetAlt( wxEmptyString );
else
at( aRow ).SetAlt( aValue );

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -879,6 +879,32 @@ int LIB_PIN::compare( const LIB_ITEM& aOther, LIB_ITEM::COMPARE_FLAGS aCompareFl
if( m_nameTextSize != tmp->m_nameTextSize )
return m_nameTextSize - tmp->m_nameTextSize;
if( m_alternates.size() != tmp->m_alternates.size() )
return m_alternates.size() - tmp->m_alternates.size();
auto lhsItem = m_alternates.begin();
auto rhsItem = tmp->m_alternates.begin();
while( lhsItem != m_alternates.end() )
{
const ALT& lhsAlt = lhsItem->second;
const ALT& rhsAlt = rhsItem->second;
retv = lhsAlt.m_Name.Cmp( rhsAlt.m_Name );
if( retv )
return retv;
if( lhsAlt.m_Type != rhsAlt.m_Type )
return static_cast<int>( lhsAlt.m_Type ) - static_cast<int>( rhsAlt.m_Type );
if( lhsAlt.m_Shape != rhsAlt.m_Shape )
return static_cast<int>( lhsAlt.m_Shape ) - static_cast<int>( rhsAlt.m_Shape );
++lhsItem;
++rhsItem;
}
return 0;
}