Deconflict some LIB_TREE_ITEM APIs so they can remain non-const.

(The non-const is required by FOOTPRINT_INFO, which must load
footrpints to get some of the data.)
This commit is contained in:
Jeff Young 2024-04-02 17:10:23 +01:00
parent 59142a10d7
commit bf2b3b0b0f
12 changed files with 39 additions and 30 deletions

View File

@ -83,7 +83,7 @@ std::vector<SEARCH_TERM> FOOTPRINT_INFO::GetSearchTerms()
// Also include keywords as one long string, just in case
terms.emplace_back( SEARCH_TERM( GetKeywords(), 1 ) );
terms.emplace_back( SEARCH_TERM( GetDescription(), 1 ) );
terms.emplace_back( SEARCH_TERM( GetDesc(), 1 ) );
return terms;
}

View File

@ -193,7 +193,7 @@ LIB_TREE_NODE_ITEM::LIB_TREE_NODE_ITEM( LIB_TREE_NODE* aParent, LIB_TREE_ITEM* a
m_LibId.SetLibItemName( aItem->GetName() );
m_Name = aItem->GetName();
m_Desc = aItem->GetDescription();
m_Desc = aItem->GetDesc();
m_Footprint = aItem->GetFootprint();
m_PinCount = aItem->GetPinCount();
@ -221,11 +221,11 @@ LIB_TREE_NODE_UNIT& LIB_TREE_NODE_ITEM::AddUnit( LIB_TREE_ITEM* aItem, int aUnit
void LIB_TREE_NODE_ITEM::Update( LIB_TREE_ITEM* aItem )
{
m_LibId.SetLibNickname( aItem->GetLibId().GetLibNickname() );
m_LibId.SetLibNickname( aItem->GetLIB_ID().GetLibNickname() );
m_LibId.SetLibItemName( aItem->GetName() );
m_Name = aItem->GetName();
m_Desc = aItem->GetDescription();
m_Desc = aItem->GetDesc();
aItem->GetChooserFields( m_Fields );

View File

@ -842,7 +842,7 @@ void CVPCB_MAINFRAME::DisplayStatus()
if( fp ) // can be NULL if no netlist loaded
{
msg = wxString::Format( _( "Description: %s; Keywords: %s" ),
fp->GetDescription(),
fp->GetDesc(),
fp->GetKeywords() );
}

View File

@ -126,7 +126,7 @@ protected:
if( parent )
{
root_name = parent->GetName();
root_desc = parent->GetDescription();
root_desc = parent->GetDesc();
}
m_html.Replace( wxS( "__ALIASOF__" ), wxString::Format( AliasOfFormat,

View File

@ -1349,7 +1349,7 @@ LIB_FIELD* LIB_SYMBOL::FindField( const wxString& aFieldName, bool aCaseInsensit
const LIB_FIELD* LIB_SYMBOL::FindField( const wxString& aFieldName,
const bool aCaseInsensitive ) const
bool aCaseInsensitive ) const
{
for( const LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
{
@ -1370,7 +1370,7 @@ const LIB_FIELD* LIB_SYMBOL::FindField( const wxString& aFieldName,
}
LIB_FIELD& LIB_SYMBOL::GetValueField()
LIB_FIELD& LIB_SYMBOL::GetValueField() const
{
LIB_FIELD* field = GetFieldById( VALUE_FIELD );
wxASSERT( field != nullptr );
@ -1378,7 +1378,7 @@ LIB_FIELD& LIB_SYMBOL::GetValueField()
}
LIB_FIELD& LIB_SYMBOL::GetReferenceField()
LIB_FIELD& LIB_SYMBOL::GetReferenceField() const
{
LIB_FIELD* field = GetFieldById( REFERENCE_FIELD );
wxASSERT( field != nullptr );
@ -1386,7 +1386,7 @@ LIB_FIELD& LIB_SYMBOL::GetReferenceField()
}
LIB_FIELD& LIB_SYMBOL::GetFootprintField()
LIB_FIELD& LIB_SYMBOL::GetFootprintField() const
{
LIB_FIELD* field = GetFieldById( FOOTPRINT_FIELD );
wxASSERT( field != nullptr );
@ -1394,7 +1394,7 @@ LIB_FIELD& LIB_SYMBOL::GetFootprintField()
}
LIB_FIELD& LIB_SYMBOL::GetDatasheetField()
LIB_FIELD& LIB_SYMBOL::GetDatasheetField() const
{
LIB_FIELD* field = GetFieldById( DATASHEET_FIELD );
wxASSERT( field != nullptr );
@ -1402,7 +1402,7 @@ LIB_FIELD& LIB_SYMBOL::GetDatasheetField()
}
LIB_FIELD& LIB_SYMBOL::GetDescriptionField()
LIB_FIELD& LIB_SYMBOL::GetDescriptionField() const
{
LIB_FIELD* field = GetFieldById( DESCRIPTION_FIELD );
wxASSERT( field != nullptr );

View File

@ -159,8 +159,10 @@ public:
virtual void SetName( const wxString& aName );
wxString GetName() const override { return m_name; }
LIB_ID& LibId() { return m_libId; }
LIB_ID GetLibId() const override { return m_libId; }
LIB_ID GetLIB_ID() const override { return m_libId; }
wxString GetDesc() override { return GetDescription(); }
const LIB_ID& GetLibId() const { return m_libId; }
void SetLibId( const LIB_ID& aLibId ) { m_libId = aLibId; }
LIB_ID GetSourceLibId() const { return m_sourceLibId; }
@ -175,7 +177,7 @@ public:
}
///< Gets the Description field text value */
wxString GetDescription() override
wxString GetDescription() const
{
if( GetDescriptionField().GetText().IsEmpty() && IsAlias() )
{
@ -318,7 +320,7 @@ public:
LIB_FIELD* FindField( const wxString& aFieldName, bool aCaseInsensitive = false );
const LIB_FIELD* FindField( const wxString& aFieldName,
const bool aCaseInsensitive = false ) const;
bool aCaseInsensitive = false ) const;
/**
* Return pointer to the requested field.
@ -329,19 +331,19 @@ public:
LIB_FIELD* GetFieldById( int aId ) const;
/** Return reference to the value field. */
LIB_FIELD& GetValueField();
LIB_FIELD& GetValueField() const;
/** Return reference to the reference designator field. */
LIB_FIELD& GetReferenceField();
LIB_FIELD& GetReferenceField() const;
/** Return reference to the footprint field */
LIB_FIELD& GetFootprintField();
LIB_FIELD& GetFootprintField() const;
/** Return reference to the datasheet field. */
LIB_FIELD& GetDatasheetField();
LIB_FIELD& GetDatasheetField() const;
/** Return reference to the description field. */
LIB_FIELD& GetDescriptionField();
LIB_FIELD& GetDescriptionField() const;
wxString GetPrefix();

View File

@ -462,7 +462,9 @@ std::unique_ptr<LIB_SYMBOL> SCH_IO_DATABASE::loadSymbolFromRow( const wxString&
symbol->SetName( aSymbolName );
}
symbol->LibId().SetSubLibraryName( aTable.name );
LIB_ID libId = symbol->GetLibId();
libId.SetSubLibraryName( aTable.name );;
symbol->SetLibId( libId );
if( aRow.count( aTable.footprints_col ) )
{

View File

@ -380,7 +380,9 @@ LIB_SYMBOL* SCH_IO_HTTP_LIB::loadSymbolFromPart( const wxString& aSymbo
symbol = originalSymbol->Duplicate();
symbol->SetSourceLibId( symbolId );
symbol->LibId().SetSubLibraryName( aCategory.name );
LIB_ID libId = symbol->GetLibId();
libId.SetSubLibraryName( aCategory.name );
symbol->SetLibId( libId );
}
else if( !symbolId.IsValid() )
{
@ -403,7 +405,10 @@ LIB_SYMBOL* SCH_IO_HTTP_LIB::loadSymbolFromPart( const wxString& aSymbo
// Actual symbol not found: return metadata only; error will be
// indicated in the symbol chooser
symbol = new LIB_SYMBOL( aSymbolName );
symbol->LibId().SetSubLibraryName( aCategory.name );
LIB_ID libId = symbol->GetLibId();
libId.SetSubLibraryName( aCategory.name );
symbol->SetLibId( libId );
}
symbol->SetExcludedFromBOM( aPart.exclude_from_bom );

View File

@ -74,12 +74,12 @@ public:
int GetPinCount() override { return GetUniquePadCount(); }
LIB_ID GetLibId() const override
LIB_ID GetLIB_ID() const override
{
return LIB_ID( m_nickname, m_fpname );
}
wxString GetDescription() override
wxString GetDesc() override
{
ensure_loaded();
return m_doc;

View File

@ -44,11 +44,11 @@ public:
{
}
virtual LIB_ID GetLibId() const = 0;
virtual LIB_ID GetLIB_ID() const = 0;
virtual wxString GetName() const = 0;
virtual wxString GetLibNickname() const = 0;
virtual wxString GetDescription() = 0;
virtual wxString GetDesc() = 0;
/**
* Retrieves a key/value map of the fields on this item that should be exposed to the library

View File

@ -323,7 +323,7 @@ void FOOTPRINT_LIST_IMPL::WriteCacheToFile( const wxString& aFilePath )
{
txtStream << fpinfo->GetLibNickname() << endl;
txtStream << fpinfo->GetName() << endl;
txtStream << EscapeString( fpinfo->GetDescription(), CTX_LINE ) << endl;
txtStream << EscapeString( fpinfo->GetDesc(), CTX_LINE ) << endl;
txtStream << EscapeString( fpinfo->GetKeywords(), CTX_LINE ) << endl;
txtStream << wxString::Format( wxT( "%d" ), fpinfo->GetOrderNum() ) << endl;
txtStream << wxString::Format( wxT( "%u" ), fpinfo->GetPadCount() ) << endl;

View File

@ -96,7 +96,7 @@ PANEL_FOOTPRINT_CHOOSER::PANEL_FOOTPRINT_CHOOSER( PCB_BASE_FRAME* aFrame, wxTopL
historyInfos, false, true );
if( historyInfos.size() )
adapter->SetPreselectNode( historyInfos[0]->GetLibId(), 0 );
adapter->SetPreselectNode( historyInfos[0]->GetLIB_ID(), 0 );
adapter->SetFilter( &m_filter );
adapter->AddLibraries( m_frame );