Add library descriptions to component tree.

Fixes: lp:1747547
* https://bugs.launchpad.net/kicad/+bug/1747547
This commit is contained in:
Jeff Young 2018-02-06 15:14:01 +00:00 committed by Maciej Suminski
parent a35cc44bd1
commit 17ce87a7a5
9 changed files with 32 additions and 13 deletions

View File

@ -256,11 +256,13 @@ void CMP_TREE_NODE_LIB_ID::UpdateScore( EDA_COMBINED_MATCHER& aMatcher )
}
CMP_TREE_NODE_LIB::CMP_TREE_NODE_LIB( CMP_TREE_NODE* aParent, wxString const& aName )
CMP_TREE_NODE_LIB::CMP_TREE_NODE_LIB( CMP_TREE_NODE* aParent,
wxString const& aName, wxString const& aDesc )
{
Type = LIB;
Name = aName;
MatchName = aName.Lower();
Desc = aDesc;
Parent = aParent;
LibId.SetLibNickname( aName );
}
@ -292,9 +294,9 @@ CMP_TREE_NODE_ROOT::CMP_TREE_NODE_ROOT()
}
CMP_TREE_NODE_LIB& CMP_TREE_NODE_ROOT::AddLib( wxString const& aName )
CMP_TREE_NODE_LIB& CMP_TREE_NODE_ROOT::AddLib( wxString const& aName, wxString const& aDesc )
{
CMP_TREE_NODE_LIB* lib = new CMP_TREE_NODE_LIB( this, aName );
CMP_TREE_NODE_LIB* lib = new CMP_TREE_NODE_LIB( this, aName, aDesc );
Children.push_back( std::unique_ptr<CMP_TREE_NODE>( lib ) );
return *lib;
}

View File

@ -243,8 +243,9 @@ public:
*
* @param aParent parent node, should be a CMP_TREE_NODE_ROOT
* @param aName display name of the library
* @param aDesc a description of the library
*/
CMP_TREE_NODE_LIB( CMP_TREE_NODE* aParent, wxString const& aName );
CMP_TREE_NODE_LIB( CMP_TREE_NODE* aParent, wxString const& aName, wxString const& aDesc );
/**
* Construct a new alias node, add it to this library, and return it.
@ -278,7 +279,7 @@ public:
/**
* Construct an empty library node, add it to the root, and return it.
*/
CMP_TREE_NODE_LIB& AddLib( wxString const& aName );
CMP_TREE_NODE_LIB& AddLib( wxString const& aName, wxString const& aDesc );
virtual void UpdateScore( EDA_COMBINED_MATCHER& aMatcher ) override;
};

View File

@ -62,7 +62,7 @@ void CMP_TREE_MODEL_ADAPTER::AddLibrary( wxString const& aLibNickname )
if( alias_list.size() > 0 )
{
AddAliasList( aLibNickname, alias_list );
AddAliasList( aLibNickname, m_libs->GetDescription( aLibNickname ), alias_list );
m_tree.AssignIntrinsicRanks();
}
}
@ -94,5 +94,5 @@ void CMP_TREE_MODEL_ADAPTER::AddAliasList(
}
if( alias_list.size() > 0 )
AddAliasList( aNodeName, alias_list );
AddAliasList( aNodeName, m_libs->GetDescription( aNodeName ), alias_list );
}

View File

@ -143,11 +143,10 @@ void CMP_TREE_MODEL_ADAPTER_BASE::AddLibrariesWithProgress(
}
void CMP_TREE_MODEL_ADAPTER_BASE::AddAliasList(
wxString const& aNodeName,
std::vector<LIB_ALIAS*> const& aAliasList )
void CMP_TREE_MODEL_ADAPTER_BASE::AddAliasList( wxString const& aNodeName, wxString const& aDesc,
std::vector<LIB_ALIAS*> const& aAliasList )
{
auto& lib_node = m_tree.AddLib( aNodeName );
auto& lib_node = m_tree.AddLib( aNodeName, aDesc );
for( auto a: aAliasList )
{

View File

@ -176,10 +176,12 @@ public:
* phase.
*
* @param aNodeName the parent node the components will appear under
* @param aDesc the description field of the parent node
* @param aAliasList list of aliases
*/
void AddAliasList(
wxString const& aNodeName,
wxString const& aDesc,
std::vector<LIB_ALIAS*> const& aAliasList );
/**

View File

@ -145,7 +145,7 @@ SCH_BASE_FRAME::COMPONENT_SELECTION SCH_BASE_FRAME::SelectComponentFromLibrary(
history_list.push_back( alias );
}
adapter->AddAliasList( "-- " + _( "History" ) + " --", history_list );
adapter->AddAliasList( "-- " + _( "History" ) + " --", _( "Recently used items" ), history_list );
adapter->SetPreselectNode( aHistoryList[0].LibId, aHistoryList[0].Unit );
}

View File

@ -90,6 +90,12 @@ wxArrayString LIB_MANAGER::GetLibraryNames() const
}
SYMBOL_LIB_TABLE_ROW* LIB_MANAGER::GetLibrary( const wxString& aLibrary )
{
return symTable()->FindRow( aLibrary );
}
bool LIB_MANAGER::FlushAll()
{
bool result = true;

View File

@ -41,6 +41,7 @@ class PART_LIB;
class SCH_PLUGIN;
class LIB_EDIT_FRAME;
class SYMBOL_LIB_TABLE;
class SYMBOL_LIB_TABLE_ROW;
/**
* Class to handle modifications to the symbol libraries.
@ -72,6 +73,11 @@ public:
*/
wxArrayString GetLibraryNames() const;
/**
* Finds a single library within the (aggregate) library table.
*/
SYMBOL_LIB_TABLE_ROW* GetLibrary( const wxString& aLibrary );
/**
* Returns a set containing all part names for a specific library.
*/

View File

@ -24,6 +24,7 @@
#include <lib_manager_adapter.h>
#include <lib_manager.h>
#include <symbol_lib_table.h>
#include <class_libentry.h>
@ -104,7 +105,9 @@ void LIB_MANAGER_ADAPTER::Sync( bool aForce, std::function<void(int, int, const
nextUpdate = wxGetUTCTimeMillis() + PROGRESS_INTERVAL_MILLIS;
}
auto& lib_node = m_tree.AddLib( libName );
SYMBOL_LIB_TABLE_ROW* library = m_libMgr->GetLibrary( libName );
auto& lib_node = m_tree.AddLib( libName, library->GetDescr() );
updateLibrary( lib_node );
m_tree.AssignIntrinsicRanks();
}