38wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>
43 return wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>( adapter );
66 return node ? node->
m_Type == LIB_TREE_NODE::TYPE::LIBRARY :
true;
70#define PROGRESS_INTERVAL_MILLIS 120
73 std::function<
void(
int,
int,
const wxString& )> aProgressCallback )
83 const wxString&
name = it->get()->m_Name;
85 if( wxGetUTCTimeMillis() > nextUpdate )
87 aProgressCallback( i, max,
name );
98 ||
name == aForceRefresh )
121 if( wxGetUTCTimeMillis() > nextUpdate )
123 aProgressCallback( i++, max, libName );
174 auto aliasIt = std::find_if( aliases.begin(), aliases.end(),
177 return a->GetName() == (*nodeIt)->m_LibId.GetLibItemName().wx_str();
180 if( aliasIt != aliases.end() )
185 aliases.erase( aliasIt );
205LIB_TREE_NODE::PTR_VECTOR::iterator
219 return wxDataViewItem();
224 unsigned int aCol )
const
228 aVariant = wxEmptyString;
247 if( node->
m_Type == LIB_TREE_NODE::TYPE::LIBRARY )
250 aVariant = aVariant.GetString() +
" *";
252 else if( node->
m_Type == LIB_TREE_NODE::TYPE::ITEM )
255 aVariant = aVariant.GetString() +
" *";
263 if( node->
m_Type == LIB_TREE_NODE::TYPE::LIBRARY )
272 aVariant =
_(
"(failed to load)" ) + wxS(
" " ) + aVariant.GetString();
274 aVariant =
_(
"(read-only)" ) + wxS(
" " ) + aVariant.GetString();
286 if( key == wxT(
"Description" ) )
288 else if( node->
m_Fields.count( key ) )
289 valueStr = node->
m_Fields.at( key );
291 valueStr = wxEmptyString;
293 valueStr.Replace( wxS(
"\n" ), wxS(
" " ) );
295 if( !aVariant.GetString().IsEmpty() )
297 if( !valueStr.IsEmpty() )
298 aVariant = valueStr + wxS(
" - " ) + aVariant.GetString();
311 wxDataViewItemAttr& aAttr )
const
317 wxCHECK( node,
false );
322 aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
334 case LIB_TREE_NODE::TYPE::LIBRARY:
343 aAttr.SetStrikethrough(
true );
349 case LIB_TREE_NODE::TYPE::ITEM:
359 aAttr.SetStrikethrough(
true );
375 wxCHECK( node,
false );
382 const wxDataViewItem& aItem )
384 static const wxString c_previewName = wxS(
"symHoverPreview" );
390 wxWindow::FindWindowByName( c_previewName, aParent ) );
394 wxBoxSizer* mainSizer =
new wxBoxSizer( wxVERTICAL );
395 aParent->SetSizer( mainSizer );
401 wxBoxSizer* panelSizer =
new wxBoxSizer( wxVERTICAL );
402 panel->SetSizer( panelSizer );
406 preview->SetName( c_previewName );
407 preview->SetLayoutDirection( wxLayout_LeftToRight );
409 panelSizer->Add( preview, 1, wxEXPAND | wxALL, 1 );
410 mainSizer->Add( panel, 1, wxEXPAND, 0 );
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
static const COLOR4D BLACK
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
const wxString GetUniStringLibItemName() const
Get strings for display messages in dialogs.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Symbol library management helper that is specific to the symbol library editor frame.
Define a library symbol object.
wxString GetDescription() const override
const LIB_ID & GetLibId() const override
const wxString & GetDescr() const
Return the description of the library referenced by this row.
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
LIB_TREE_NODE_ROOT m_tree
static LIB_TREE_NODE * ToNode(wxDataViewItem aItem)
Convert wxDataViewItem -> #SYM_TREE_NODE.
static wxDataViewItem ToItem(const LIB_TREE_NODE *aNode)
Convert #SYM_TREE_NODE -> wxDataViewItem.
static const wxString GetPinningSymbol()
@ NAME_COL
Library or library item name column.
std::map< unsigned, wxString > m_colIdxMap
virtual int GetLibrariesCount() const
Return the number of libraries loaded in the tree.
wxDataViewCtrl * m_widget
LIB_TREE_NODE_LIBRARY & DoAddLibraryNode(const wxString &aNodeName, const wxString &aDesc, bool pinned)
wxDataViewItem FindItem(const LIB_ID &aLibId)
Returns tree item corresponding to part.
LIB_TREE_NODE_ITEM & AddItem(LIB_TREE_ITEM *aItem)
Construct a new alias node, add it to this library, and return it.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
std::map< wxString, wxString > m_Fields
List of weighted search terms.
void AssignIntrinsicRanks(bool presorted=false)
Store intrinsic ranks on all children of this node.
virtual COMMON_SETTINGS * GetCommonSettings() const
The backing store for a PROJECT, in JSON format.
static SYMBOL_LIB_TABLE * SchSymbolLibTable(PROJECT *aProject)
Accessor for project symbol library table.
virtual PROJECT_FILE & GetProjectFile() const
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Handle actions for the various symbol editor and viewers.
The symbol library editor main window.
LIB_SYMBOL * GetCurSymbol() const
Return the current symbol being edited or NULL if none selected.
LIB_ID GetTargetLibId() const override
Return either the symbol selected in the symbol tree (if context menu is active) or the symbol on the...
LIB_SYMBOL_LIBRARY_MANAGER & GetLibManager()
Class to handle modifications to the symbol libraries.
bool IsLibraryReadOnly(const wxString &aLibrary) const
Return true if the library is stored in a read-only file.
bool LibraryExists(const wxString &aLibrary, bool aCheckEnabled=false) const
Return true if library exists.
bool IsLibraryModified(const wxString &aLibrary) const
Return true if library has unsaved modifications.
wxArrayString GetLibraryNames() const
Return the array of library names.
bool IsSymbolModified(const wxString &aAlias, const wxString &aLibrary) const
Return true if symbol has unsaved modifications.
bool IsLibraryLoaded(const wxString &aLibrary) const
Return true if the library was successfully loaded.
int GetLibraryHash(const wxString &aLibrary) const
Return a library hash value to determine if it has changed.
SYMBOL_LIB_TABLE_ROW * GetLibrary(const wxString &aLibrary) const
Find a single library within the (aggregate) library table.
std::list< LIB_SYMBOL * > GetAliases(const wxString &aLibrary) const
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_IO object i...
SYMBOL_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an SYMBOL_LIB_TABLE_ROW if aNickName is found in this table or in any chained fallBack table f...
LIB_TREE_NODE::PTR_VECTOR::iterator deleteLibrary(LIB_TREE_NODE::PTR_VECTOR::iterator &aLibNodeIt)
SYMBOL_LIBRARY_MANAGER * m_libMgr
Hashes to decide whether a library needs an update.
void GetValue(wxVariant &aVariant, wxDataViewItem const &aItem, unsigned int aCol) const override
SYMBOL_EDIT_FRAME * m_frame
bool GetAttr(wxDataViewItem const &aItem, unsigned int aCol, wxDataViewItemAttr &aAttr) const override
void updateLibrary(LIB_TREE_NODE_LIBRARY &aLibNode)
wxDataViewItem GetCurrentDataViewItem() override
static wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > Create(SYMBOL_EDIT_FRAME *aParent, SYMBOL_LIBRARY_MANAGER *aLibs)
virtual void ShowPreview(wxWindow *aParent, const wxDataViewItem &aItem) override
int GetLibrariesCount() const override
Return the number of libraries loaded in the tree.
void Sync(const wxString &aForceRefresh, std::function< void(int, int, const wxString &)> aProgressCallback)
TOOL_INTERACTIVE * GetContextMenuTool() override
bool IsContainer(const wxDataViewItem &aItem) const override
virtual bool HasPreview(const wxDataViewItem &aItem) override
std::map< wxString, int > m_libHashes
SYMBOL_LIBRARY_MANAGER hash value returned in the last synchronization.
SYMBOL_TREE_SYNCHRONIZING_ADAPTER(SYMBOL_EDIT_FRAME *aParent, SYMBOL_LIBRARY_MANAGER *aLibMgr)
void SetBorders(bool aLeft, bool aRight, bool aTop, bool aBottom)
void SetBorderColor(const KIGFX::COLOR4D &aColor)
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
PGM_BASE & Pgm()
The global Program "get" accessor.
wxString UnescapeString(const wxString &aSource)
std::vector< wxString > pinned_symbol_libs
#define PROGRESS_INTERVAL_MILLIS