Component chooser: display correct unit in reference field

This commit is contained in:
Chris Pavlina 2017-02-19 15:11:35 -05:00
parent 2e07d83461
commit 70301a6244
3 changed files with 19 additions and 14 deletions

View File

@ -246,7 +246,7 @@ bool DIALOG_CHOOSE_COMPONENT::updateSelection()
return false; return false;
} }
m_componentDetails->SetPage( GenerateAliasInfo( selection ) ); m_componentDetails->SetPage( GenerateAliasInfo( selection, unit ) );
updateFootprint(); updateFootprint();

View File

@ -46,11 +46,13 @@ class ALIAS_INFO_GENERATOR
{ {
wxString m_html; wxString m_html;
LIB_ALIAS const * m_part; LIB_ALIAS const * m_part;
int m_unit;
public: public:
ALIAS_INFO_GENERATOR( LIB_ALIAS const * aAlias ) ALIAS_INFO_GENERATOR( LIB_ALIAS const * aAlias, int aUnit )
: m_html( DescriptionFormat ), : m_html( DescriptionFormat ),
m_part( aAlias ) m_part( aAlias ),
m_unit( aUnit )
{ } { }
/** /**
@ -139,19 +141,22 @@ protected:
wxString GetHtmlFieldRow( LIB_FIELD const & aField ) wxString GetHtmlFieldRow( LIB_FIELD const & aField )
{ {
wxString name = aField.GetName(); wxString name = aField.GetName();
wxString text = aField.GetFullText(); wxString text = aField.GetFullText( m_unit > 0 ? m_unit : 1 );
wxString fieldhtml = FieldFormat; wxString fieldhtml = FieldFormat;
fieldhtml.Replace( "__NAME__", EscapedHTML( name ) ); fieldhtml.Replace( "__NAME__", EscapedHTML( name ) );
if( aField.GetId() == DATASHEET ) switch( aField.GetId() )
{
wxString datasheetlink = DatasheetLinkFormat;
datasheetlink.Replace( "__VALUE__", EscapedHTML( text ) );
fieldhtml.Replace( "__VALUE__", datasheetlink );
}
else
{ {
case DATASHEET:
{
wxString datasheetlink = DatasheetLinkFormat;
datasheetlink.Replace( "__VALUE__", EscapedHTML( text ) );
fieldhtml.Replace( "__VALUE__", datasheetlink );
}
break;
default:
fieldhtml.Replace( "__VALUE__", EscapedHTML( text ) ); fieldhtml.Replace( "__VALUE__", EscapedHTML( text ) );
} }
@ -175,9 +180,9 @@ protected:
}; };
wxString GenerateAliasInfo( LIB_ALIAS const * aAlias ) wxString GenerateAliasInfo( LIB_ALIAS const * aAlias, int aUnit )
{ {
ALIAS_INFO_GENERATOR gen( aAlias ); ALIAS_INFO_GENERATOR gen( aAlias, aUnit );
gen.GenerateHtml(); gen.GenerateHtml();
return gen.GetHtml(); return gen.GetHtml();
} }

View File

@ -27,6 +27,6 @@
* Return an HTML page describing a LIB_ALIAS. This is suitable for inclusion * Return an HTML page describing a LIB_ALIAS. This is suitable for inclusion
* in a wxHtmlWindow. * in a wxHtmlWindow.
*/ */
wxString GenerateAliasInfo( LIB_ALIAS const * aAlias ); wxString GenerateAliasInfo( LIB_ALIAS const * aAlias, int aUnit );
#endif // GENERATE_ALIAS_INFO_H #endif // GENERATE_ALIAS_INFO_H