Handle pin sorting properly for values.

The pin number sorter doesn't handle units at all, and seems to
stumble on negative numbers.

Fixes: lp:1796869
* https://bugs.launchpad.net/kicad/+bug/1796869
This commit is contained in:
Jeff Young 2018-10-09 14:53:55 +01:00
parent bc69330fe0
commit 55c1ca1191
1 changed files with 26 additions and 3 deletions

View File

@ -231,11 +231,34 @@ public:
if( lhStr == rhStr )
{
// Secondary sort key is always COL_NUMBER
lhStr = GetValue( lhs, COL_NUMBER, units );
rhStr = GetValue( rhs, COL_NUMBER, units );
sortCol = COL_NUMBER;
lhStr = GetValue( lhs, sortCol, units );
rhStr = GetValue( rhs, sortCol, units );
}
return ascending == ( PinNumbers::Compare( lhStr, rhStr ) < 0 );
bool cmp;
switch( sortCol )
{
case COL_NUMBER:
case COL_NAME:
cmp = PinNumbers::Compare( lhStr, rhStr ) < 0;
break;
case COL_NUMBER_SIZE:
case COL_NAME_SIZE:
cmp = ValueFromString( units, lhStr, true ) < ValueFromString( units, rhStr, true );
break;
case COL_LENGTH:
case COL_POSX:
case COL_POSY:
cmp = ValueFromString( units, lhStr ) < ValueFromString( units, rhStr );
break;
default:
cmp = StrNumCmp( lhStr, rhStr ) < 0;
break;
}
return ascending == cmp;
}
void RebuildRows( LIB_PINS& aPins, bool groupByName )