mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-13 17:53:11 +02:00
Update properties to show units
The function duplicated our built-in funcitonality and did not properly handly outputs Fixes https://gitlab.com/kicad/code/kicad/issues/21685
This commit is contained in:
parent
0acc659676
commit
3f8abe3744
@ -165,28 +165,6 @@ SCH_ITEM* SCH_ITEM::Duplicate( bool addToParentGroup, SCH_COMMIT* aCommit, bool
|
||||
}
|
||||
|
||||
|
||||
void SCH_ITEM::SetUnitProp( const wxString& aUnit )
|
||||
{
|
||||
if( aUnit == _HKI( "All units" ) )
|
||||
{
|
||||
m_unit = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if( SYMBOL* symbol = GetParentSymbol() )
|
||||
{
|
||||
for( int unit = 1; unit <= symbol->GetUnitCount(); unit++ )
|
||||
{
|
||||
if( symbol->GetUnitDisplayName( unit, false ) == aUnit )
|
||||
{
|
||||
m_unit = unit;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
wxString SCH_ITEM::GetUnitDisplayName( int aUnit, bool aLabel ) const
|
||||
{
|
||||
if( aUnit == 0 )
|
||||
@ -208,13 +186,6 @@ wxString SCH_ITEM::GetBodyStyleDescription( int aBodyStyle, bool aLabel ) const
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
|
||||
wxString SCH_ITEM::GetUnitProp() const
|
||||
{
|
||||
return GetUnitDisplayName( m_unit, false );
|
||||
}
|
||||
|
||||
|
||||
void SCH_ITEM::SetBodyStyleProp( const wxString& aBodyStyle )
|
||||
{
|
||||
if( aBodyStyle == _HKI( "All body styles" ) )
|
||||
@ -734,21 +705,21 @@ static struct SCH_ITEM_DESC
|
||||
return false;
|
||||
};
|
||||
|
||||
propMgr.AddProperty( new PROPERTY<SCH_ITEM, wxString>( _HKI( "Unit" ),
|
||||
&SCH_ITEM::SetUnitProp, &SCH_ITEM::GetUnitProp ) )
|
||||
propMgr.AddProperty( new PROPERTY<SCH_ITEM, int>( _HKI( "Unit" ),
|
||||
&SCH_ITEM::SetUnit, &SCH_ITEM::GetUnit ) )
|
||||
.SetAvailableFunc( multiUnit )
|
||||
.SetIsHiddenFromDesignEditors()
|
||||
.SetChoicesFunc( []( INSPECTABLE* aItem )
|
||||
{
|
||||
wxPGChoices choices;
|
||||
choices.Add( _HKI( "All units" ) );
|
||||
choices.Add( _HKI( "All units" ), 0 );
|
||||
|
||||
if( SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem ) )
|
||||
{
|
||||
if( SYMBOL* symbol = item->GetParentSymbol() )
|
||||
{
|
||||
for( int ii = 1; ii <= symbol->GetUnitCount(); ii++ )
|
||||
choices.Add( symbol->GetUnitDisplayName( ii, false ) );
|
||||
choices.Add( symbol->GetUnitDisplayName( ii, false ), ii );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -240,9 +240,6 @@ public:
|
||||
virtual wxString GetUnitDisplayName( int aUnit, bool aLabel ) const;
|
||||
virtual wxString GetBodyStyleDescription( int aBodyStyle, bool aLabel ) const;
|
||||
|
||||
virtual void SetUnitProp( const wxString& aUnit );
|
||||
virtual wxString GetUnitProp() const;
|
||||
|
||||
virtual void SetBodyStyle( int aBodyStyle ) { m_bodyStyle = aBodyStyle; }
|
||||
int GetBodyStyle() const { return m_bodyStyle; }
|
||||
|
||||
|
@ -2986,7 +2986,7 @@ static struct SCH_SYMBOL_DESC
|
||||
return false;
|
||||
};
|
||||
|
||||
propMgr.AddProperty( new PROPERTY<SCH_SYMBOL, wxString>( _HKI( "Unit" ),
|
||||
propMgr.AddProperty( new PROPERTY<SCH_SYMBOL, int>( _HKI( "Unit" ),
|
||||
&SCH_SYMBOL::SetUnitProp, &SCH_SYMBOL::GetUnitProp ) )
|
||||
.SetAvailableFunc( multiUnit )
|
||||
.SetChoicesFunc( []( INSPECTABLE* aItem )
|
||||
@ -2996,7 +2996,7 @@ static struct SCH_SYMBOL_DESC
|
||||
if( SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( aItem ) )
|
||||
{
|
||||
for( int ii = 1; ii <= symbol->GetUnitCount(); ii++ )
|
||||
choices.Add( symbol->GetUnitDisplayName( ii, false ) );
|
||||
choices.Add( symbol->GetUnitDisplayName( ii, false ), ii );
|
||||
}
|
||||
|
||||
return choices;
|
||||
|
@ -497,24 +497,15 @@ public:
|
||||
SetValueFieldText( aRef );
|
||||
}
|
||||
|
||||
wxString GetUnitProp() const override
|
||||
int GetUnitProp() const
|
||||
{
|
||||
int unit = GetUnitSelection( &Schematic()->CurrentSheet() );
|
||||
|
||||
return GetUnitDisplayName( unit, false );
|
||||
return GetUnitSelection( &Schematic()->CurrentSheet() );
|
||||
}
|
||||
|
||||
void SetUnitProp( const wxString& aUnit ) override
|
||||
void SetUnitProp( int aUnit )
|
||||
{
|
||||
for( int unit = 1; unit <= GetUnitCount(); unit++ )
|
||||
{
|
||||
if( GetUnitDisplayName( unit, false ) == aUnit )
|
||||
{
|
||||
SetUnitSelection( &Schematic()->CurrentSheet(), unit );
|
||||
SetUnit( unit );
|
||||
return;
|
||||
}
|
||||
}
|
||||
SetUnitSelection( &Schematic()->CurrentSheet(), aUnit );
|
||||
SetUnit( aUnit );
|
||||
}
|
||||
|
||||
wxString GetBodyStyleProp() const override
|
||||
|
Loading…
x
Reference in New Issue
Block a user