Symbol Library Editor: update node information on library sync
This commit is contained in:
parent
12041551a1
commit
c09cf252c6
|
@ -132,8 +132,22 @@ CMP_TREE_NODE_LIB_ID::CMP_TREE_NODE_LIB_ID( CMP_TREE_NODE* aParent, LIB_ALIAS* a
|
||||||
{
|
{
|
||||||
wxASSERT( aParent && aAlias );
|
wxASSERT( aParent && aAlias );
|
||||||
|
|
||||||
Type = LIBID;
|
Type = LIBID;
|
||||||
Parent = aParent;
|
Parent = aParent;
|
||||||
|
Update( aAlias );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CMP_TREE_NODE_UNIT& CMP_TREE_NODE_LIB_ID::AddUnit( int aUnit )
|
||||||
|
{
|
||||||
|
CMP_TREE_NODE_UNIT* unit = new CMP_TREE_NODE_UNIT( this, aUnit );
|
||||||
|
Children.push_back( std::unique_ptr<CMP_TREE_NODE>( unit ) );
|
||||||
|
return *unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CMP_TREE_NODE_LIB_ID::Update( LIB_ALIAS* aAlias )
|
||||||
|
{
|
||||||
Name = aAlias->GetName();
|
Name = aAlias->GetName();
|
||||||
Desc = aAlias->GetDescription();
|
Desc = aAlias->GetDescription();
|
||||||
|
|
||||||
|
@ -165,24 +179,16 @@ CMP_TREE_NODE_LIB_ID::CMP_TREE_NODE_LIB_ID( CMP_TREE_NODE* aParent, LIB_ALIAS* a
|
||||||
SearchText += footprint.Lower();
|
SearchText += footprint.Lower();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Children.clear();
|
||||||
|
|
||||||
if( part && part->IsMulti() )
|
if( part && part->IsMulti() )
|
||||||
{
|
{
|
||||||
for( int u = 1; u <= part->GetUnitCount(); ++u )
|
for( int u = 1; u <= part->GetUnitCount(); ++u )
|
||||||
{
|
|
||||||
AddUnit( u );
|
AddUnit( u );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CMP_TREE_NODE_UNIT& CMP_TREE_NODE_LIB_ID::AddUnit( int aUnit )
|
|
||||||
{
|
|
||||||
CMP_TREE_NODE_UNIT* unit = new CMP_TREE_NODE_UNIT( this, aUnit );
|
|
||||||
Children.push_back( std::unique_ptr<CMP_TREE_NODE>( unit ) );
|
|
||||||
return *unit;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CMP_TREE_NODE_LIB_ID::UpdateScore( EDA_COMBINED_MATCHER& aMatcher )
|
void CMP_TREE_NODE_LIB_ID::UpdateScore( EDA_COMBINED_MATCHER& aMatcher )
|
||||||
{
|
{
|
||||||
if( Score <= 0 )
|
if( Score <= 0 )
|
||||||
|
|
|
@ -202,6 +202,10 @@ public:
|
||||||
*/
|
*/
|
||||||
CMP_TREE_NODE_LIB_ID( CMP_TREE_NODE* aParent, LIB_ALIAS* aAlias );
|
CMP_TREE_NODE_LIB_ID( CMP_TREE_NODE* aParent, LIB_ALIAS* aAlias );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the node using data from a LIB_ALIAS object.
|
||||||
|
*/
|
||||||
|
void Update( LIB_ALIAS* aAlias );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform the actual search.
|
* Perform the actual search.
|
||||||
|
|
|
@ -318,7 +318,11 @@ LIB_PART* LIB_MANAGER::GetBufferedPart( const wxString& aAlias, const wxString&
|
||||||
wxCHECK( alias, nullptr );
|
wxCHECK( alias, nullptr );
|
||||||
bufferedPart = new LIB_PART( *alias->GetPart(), nullptr );
|
bufferedPart = new LIB_PART( *alias->GetPart(), nullptr );
|
||||||
libBuf.CreateBuffer( bufferedPart, new SCH_SCREEN( &m_frame.Kiway() ) );
|
libBuf.CreateBuffer( bufferedPart, new SCH_SCREEN( &m_frame.Kiway() ) );
|
||||||
} catch( IO_ERROR& e ) {}
|
}
|
||||||
|
catch( IO_ERROR& e )
|
||||||
|
{
|
||||||
|
bufferedPart = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return bufferedPart;
|
return bufferedPart;
|
||||||
|
@ -387,6 +391,7 @@ bool LIB_MANAGER::RevertPart( const wxString& aAlias, const wxString& aLibrary )
|
||||||
auto partBuf = it->second.GetBuffer( aAlias );
|
auto partBuf = it->second.GetBuffer( aAlias );
|
||||||
wxCHECK( partBuf, false );
|
wxCHECK( partBuf, false );
|
||||||
partBuf->SetPart( new LIB_PART( *partBuf->GetOriginal() ) );
|
partBuf->SetPart( new LIB_PART( *partBuf->GetOriginal() ) );
|
||||||
|
m_frame.SyncLibraries( false );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -587,6 +592,7 @@ LIB_MANAGER::LIB_BUFFER& LIB_MANAGER::getLibraryBuffer( const wxString& aLibrary
|
||||||
if( it != m_libs.end() )
|
if( it != m_libs.end() )
|
||||||
return it->second;
|
return it->second;
|
||||||
|
|
||||||
|
// The requested buffer does not exist yet, so create one
|
||||||
auto ret = m_libs.emplace( aLibrary, LIB_BUFFER( aLibrary ) );
|
auto ret = m_libs.emplace( aLibrary, LIB_BUFFER( aLibrary ) );
|
||||||
LIB_BUFFER& buf = ret.first->second;
|
LIB_BUFFER& buf = ret.first->second;
|
||||||
|
|
||||||
|
|
|
@ -113,13 +113,15 @@ int LIB_MANAGER_ADAPTER::GetLibrariesCount() const
|
||||||
|
|
||||||
void LIB_MANAGER_ADAPTER::updateLibrary( CMP_TREE_NODE_LIB& aLibNode )
|
void LIB_MANAGER_ADAPTER::updateLibrary( CMP_TREE_NODE_LIB& aLibNode )
|
||||||
{
|
{
|
||||||
if( m_libHashes.count( aLibNode.Name ) == 0 )
|
auto hashIt = m_libHashes.find( aLibNode.Name );
|
||||||
|
|
||||||
|
if( hashIt == m_libHashes.end() )
|
||||||
{
|
{
|
||||||
// add a new library
|
// add a new library
|
||||||
for( auto alias : m_libMgr->GetAliases( aLibNode.Name ) )
|
for( auto alias : m_libMgr->GetAliases( aLibNode.Name ) )
|
||||||
aLibNode.AddAlias( alias );
|
aLibNode.AddAlias( alias );
|
||||||
}
|
}
|
||||||
else
|
else if( hashIt->second != m_libMgr->GetLibraryHash( aLibNode.Name ) )
|
||||||
{
|
{
|
||||||
// update an existing libary
|
// update an existing libary
|
||||||
std::list<LIB_ALIAS*> aliases = m_libMgr->GetAliases( aLibNode.Name );
|
std::list<LIB_ALIAS*> aliases = m_libMgr->GetAliases( aLibNode.Name );
|
||||||
|
@ -135,7 +137,8 @@ void LIB_MANAGER_ADAPTER::updateLibrary( CMP_TREE_NODE_LIB& aLibNode )
|
||||||
if( aliasIt != aliases.end() )
|
if( aliasIt != aliases.end() )
|
||||||
{
|
{
|
||||||
// alias exists both in the component tree and the library manager,
|
// alias exists both in the component tree and the library manager,
|
||||||
// no need to update
|
// update only the node data
|
||||||
|
static_cast<CMP_TREE_NODE_LIB_ID*>( nodeIt->get() )->Update( *aliasIt );
|
||||||
aliases.erase( aliasIt );
|
aliases.erase( aliasIt );
|
||||||
++nodeIt;
|
++nodeIt;
|
||||||
}
|
}
|
||||||
|
@ -194,7 +197,7 @@ bool LIB_MANAGER_ADAPTER::GetAttr( wxDataViewItem const& aItem, unsigned int aCo
|
||||||
// mark modified libs with bold font
|
// mark modified libs with bold font
|
||||||
aAttr.SetBold( m_libMgr->IsLibraryModified( node->Name ) );
|
aAttr.SetBold( m_libMgr->IsLibraryModified( node->Name ) );
|
||||||
|
|
||||||
// mark current library with inverted colors
|
// mark the current library with inverted colors
|
||||||
if( node->Name == m_libMgr->GetCurrentLib() )
|
if( node->Name == m_libMgr->GetCurrentLib() )
|
||||||
aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
|
aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
|
||||||
|
|
||||||
|
@ -207,7 +210,7 @@ bool LIB_MANAGER_ADAPTER::GetAttr( wxDataViewItem const& aItem, unsigned int aCo
|
||||||
// mark aliases with italic font
|
// mark aliases with italic font
|
||||||
aAttr.SetItalic( !node->IsRoot );
|
aAttr.SetItalic( !node->IsRoot );
|
||||||
|
|
||||||
// mark current library with inverted colors
|
// mark the current part with inverted colors
|
||||||
if( node->LibId == m_libMgr->GetCurrentLibId() )
|
if( node->LibId == m_libMgr->GetCurrentLibId() )
|
||||||
aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
|
aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue