7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 09:31:42 +00:00

Switch to using unit names in property inspector.

This commit is contained in:
Jeff Young 2025-02-14 23:02:27 +00:00
parent 56b8fec74b
commit d921a4e916
3 changed files with 29 additions and 12 deletions

View File

@ -3032,7 +3032,7 @@ static struct SCH_SYMBOL_DESC
return false;
};
propMgr.AddProperty( new PROPERTY<SCH_SYMBOL, int>( _HKI( "Unit" ),
propMgr.AddProperty( new PROPERTY<SCH_SYMBOL, wxString>( _HKI( "Unit" ),
&SCH_SYMBOL::SetUnitProp, &SCH_SYMBOL::GetUnitProp ) )
.SetAvailableFunc( multiUnit );

View File

@ -522,21 +522,37 @@ public:
SetValueFieldText( aRef );
}
int GetUnitProp() const
wxString GetUnitProp() const
{
return GetUnitSelection( &Schematic()->CurrentSheet() );
int unit = GetUnitSelection( &Schematic()->CurrentSheet() );
if( HasUnitDisplayName( unit ) )
return GetUnitDisplayName( unit );
else
return SubReference( unit, false );
}
void SetUnitProp( int aUnit )
void SetUnitProp( const wxString& aUnit )
{
if( aUnit < 1 )
return;
for( int unit = 1; unit <= GetUnitCount(); unit++ )
{
if( HasUnitDisplayName( unit ) && GetUnitDisplayName( unit ) == aUnit )
{
SetUnitSelection( &Schematic()->CurrentSheet(), unit );
SetUnit( unit );
return;
}
}
if( aUnit > GetUnitCount() )
aUnit = GetUnitCount();
SetUnitSelection( &Schematic()->CurrentSheet(), aUnit );
SetUnit( aUnit );
for( int unit = 1; unit <= GetUnitCount(); unit++ )
{
if( SubReference( unit, false ) == aUnit )
{
SetUnitSelection( &Schematic()->CurrentSheet(), unit );
SetUnit( unit );
return;
}
}
}
int GetBodyStyleProp() const

View File

@ -602,7 +602,8 @@ int SCH_DRAWING_TOOLS::PlaceNextSymbolUnit( const TOOL_EVENT& aEvent )
std::unique_ptr<SCH_SYMBOL> newSymbol = std::make_unique<SCH_SYMBOL>( *symbol );
const SCH_SHEET_PATH& sheetPath = m_frame->GetCurrentSheet();
newSymbol->SetUnitProp( nextMissing );
newSymbol->SetUnitSelection( &sheetPath, nextMissing );
newSymbol->SetUnit( nextMissing );
newSymbol->SetRefProp( symbol->GetRef( &sheetPath, false ) );
// Post the new symbol - don't reannotate it - we set the reference ourselves