Change all of the component tree helper objects to use LIB_IDs instead of
LIB_ALIAS pointers. LIB_ALIAS pointers are dangerous to use because they
can be deleted in the symbol library editor while the component chooser
dialog has copies of them. With LIB_IDs, the LIB_ALIAS pointer is found
on demand and can be guaranteed to be valid.
Update the chooser dialog to load the symbol library table instead of the
libraries defined in the project file and return a LIB_ID instead of a
LIB_ALIAS pointer.
Modify SCH_BASE_FRAME::SelectComponentFromLibrary() to handle the LIB_IDs
returned from the component chooser dialog.
- In the listing, display alias names in italics
- In the info panel, display per-alias description correctly, as well as
root description
Fixes: lp:1676190
* https://bugs.launchpad.net/kicad/+bug/1676190
- Stop wx from sorting the items. We've already sorted them, and
profiling shows our sort is faster than theirs.
- Go back to using strings as cache keys, because using pointers means
the cache doesn't survive from one invocation to the next. Switch to
wxHashMap because it can use wxString keys in an unordered (faster)
map.
This refactors COMPONENT_TREE_SEARCH_CONTAINER into a Model-View-Adapter
architecture comprising:
- eeschema/cmp_tree_model.h
- CMP_TREE_NODE: Base class representing a searchable library
set with scoring and sorting
- CMP_TREE_NODE_UNIT
- CMP_TREE_NODE_ALIAS
- CMP_TREE_NODE_LIB
- CMP_TREE_NODE_ROOT
- eeschema/cmp_tree_model_adapter.h
- CMP_TREE_MODEL_ADAPTER: mediator between wxDataViewCtrl (via
wxDataViewModel) and CMP_TREE_NODE*
+---+ +------------------+
+---+ Generates | A | | VIEW |
| M | from libs | D | wxDataViewModel |------------------|
| O | <---------- | A | <------------------> | wxDataViewCtrl |
| D | | P | |------------------|
| E | <---------> | T | <------------------- | wxTextCtrl |
| L | UpdateScore | E | UpdateSearchString() |------------------|
+---+ | R | | |
+---+ +------------------+
Representing the data with a proper model allows the wxDataViewCtrl to
be updated in bulk, which is significantly faster than the old method of
populating it one item at a time. This also adds flexibility if more
data is to be added in the future (which may come in handy with the
upcoming .sweet format, as that adds more ways components can be related
to each other).
Replacing the wxTreeListCtrl with a wxDataViewCtrl also significantly
reduces the general GUI quirkiness, as wxDataViewCtrl is much more well
behaved.