diff --git a/eeschema/sch_item.cpp b/eeschema/sch_item.cpp index efe1f65516..7a73bd4147 100644 --- a/eeschema/sch_item.cpp +++ b/eeschema/sch_item.cpp @@ -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( _HKI( "Unit" ), - &SCH_ITEM::SetUnitProp, &SCH_ITEM::GetUnitProp ) ) + propMgr.AddProperty( new PROPERTY( _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( 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 ); } } diff --git a/eeschema/sch_item.h b/eeschema/sch_item.h index a4896e4012..9818dd7f85 100644 --- a/eeschema/sch_item.h +++ b/eeschema/sch_item.h @@ -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; } diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 86d4eff8a9..c172184640 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -2986,7 +2986,7 @@ static struct SCH_SYMBOL_DESC return false; }; - propMgr.AddProperty( new PROPERTY( _HKI( "Unit" ), + propMgr.AddProperty( new PROPERTY( _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( aItem ) ) { for( int ii = 1; ii <= symbol->GetUnitCount(); ii++ ) - choices.Add( symbol->GetUnitDisplayName( ii, false ) ); + choices.Add( symbol->GetUnitDisplayName( ii, false ), ii ); } return choices; diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h index 2a7414b22c..a544543705 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -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