2017-10-28 18:28:14 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2017 Chris Pavlina <pavlina.chris@gmail.com>
|
|
|
|
* Copyright (C) 2014 Henner Zeller <h.zeller@acm.org>
|
2023-05-01 20:26:29 +00:00
|
|
|
* Copyright (C) 2014-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2017-10-28 18:28:14 +00:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2018-07-27 20:47:51 +00:00
|
|
|
#ifndef LIB_TREE_MODEL_ADAPTER_H
|
|
|
|
#define LIB_TREE_MODEL_ADAPTER_H
|
2017-10-28 18:28:14 +00:00
|
|
|
|
|
|
|
#include <lib_id.h>
|
2018-07-27 20:47:51 +00:00
|
|
|
#include <lib_tree_model.h>
|
2017-10-28 18:28:14 +00:00
|
|
|
#include <wx/hashmap.h>
|
|
|
|
#include <wx/dataview.h>
|
2019-02-10 00:57:53 +00:00
|
|
|
#include <wx/headerctrl.h>
|
2017-10-28 18:28:14 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <functional>
|
2020-02-07 17:06:24 +00:00
|
|
|
#include <set>
|
2022-08-28 23:02:12 +00:00
|
|
|
#include <map>
|
2017-10-28 18:28:14 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-10 14:10:55 +00:00
|
|
|
* Adapter class in the symbol selector Model-View-Adapter (mediated MVC)
|
2017-10-28 18:28:14 +00:00
|
|
|
* architecture. The other pieces are in:
|
|
|
|
*
|
2021-06-10 14:10:55 +00:00
|
|
|
* - Model: SYM_TREE_NODE and descendants in eeschema/cmp_tree_model.h
|
2017-10-28 18:28:14 +00:00
|
|
|
* - View:
|
|
|
|
* - DIALOG_CHOOSE_COMPONENT in eeschema/dialogs/dialog_choose_component.h
|
|
|
|
* - wxDataViewCtrl
|
|
|
|
*
|
|
|
|
* This adapter presents the interface specified by wxDataViewModel to the
|
|
|
|
* wxDataViewCtrl:
|
|
|
|
*
|
|
|
|
* +---+ +------------------+
|
|
|
|
* +---+ Generates | A | | VIEW |
|
|
|
|
* | M | from libs | D | wxDataViewModel |------------------|
|
|
|
|
* | O | <---------- | A | <------------------> | wxDataViewCtrl |
|
|
|
|
* | D | | P | |------------------|
|
|
|
|
* | E | <---------> | T | <------------------- | wxTextCtrl |
|
|
|
|
* | L | UpdateScore | E | UpdateSearchString() |------------------|
|
|
|
|
* +---+ | R | | |
|
|
|
|
* +---+ +------------------+
|
|
|
|
*
|
|
|
|
* Because this adapter is a wxDataViewModel, it is reference-counted by
|
|
|
|
* wxObject. To ensure this interface is used correctly, the constructor
|
2018-07-27 20:47:51 +00:00
|
|
|
* is private; LIB_TREE_MODEL_ADAPTER should be created by the static
|
|
|
|
* factory method LIB_TREE_MODEL_ADAPTER::Create().
|
2017-10-28 18:28:14 +00:00
|
|
|
*
|
|
|
|
* Quick summary of methods used to drive this class:
|
|
|
|
*
|
|
|
|
* - `SetFilter()` - set whether the view is restricted to power parts
|
|
|
|
* - `ShowUnits()` - set whether units are displayed
|
|
|
|
* - `SetPreselectNode()` - set a node to highlight when not searching
|
|
|
|
* - `AddLibrary()` - populate the model with all aliases in a library
|
|
|
|
* - `AddAliasList()` - populate the model with a specific list of aliases
|
|
|
|
*
|
|
|
|
* Quick summary of methods used by the View:
|
|
|
|
*
|
|
|
|
* - `UpdateSearchString()` - pass in the user's search text
|
|
|
|
* - `AttachTo()` - pass in the wxDataViewCtrl
|
|
|
|
* - `GetAliasFor()` - get the LIB_ALIAS* for a selected item
|
|
|
|
* - `GetUnitFor()` - get the unit for a selected item
|
|
|
|
* - `GetComponentsCount()` - count the aliases loaded
|
|
|
|
*
|
|
|
|
* Methods implemented as part of wxDataViewModel:
|
|
|
|
*
|
|
|
|
* - `HasContainerColumns()` - whether a parent item has more than one column
|
|
|
|
* - `IsContainer()` - whether an item is a parent
|
|
|
|
* - `GetParent()` - return the parent of an item, or invalid if root
|
|
|
|
* - `GetChildren()` - get the children of an item
|
|
|
|
* - `GetColumnCount()` - get the number of columns in the view
|
|
|
|
* - `GetColumnType()` - get the data type shown in each column
|
|
|
|
* - `GetValue()` - get the data shown in a cell
|
|
|
|
* - `SetValue()` - edit the data in a cell (does nothing)
|
|
|
|
* - `GetAttr()` - get any per-item formatting
|
|
|
|
* - `Compare()` - compare two rows, for sorting
|
|
|
|
* - `HasDefaultCompare()` - whether sorted by default
|
|
|
|
*/
|
2019-09-18 23:00:48 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
class APP_SETTINGS_BASE;
|
2019-06-05 19:15:57 +00:00
|
|
|
class TOOL_INTERACTIVE;
|
2020-03-24 01:01:23 +00:00
|
|
|
class EDA_BASE_FRAME;
|
|
|
|
|
2019-06-05 19:15:57 +00:00
|
|
|
|
2018-07-27 20:47:51 +00:00
|
|
|
class LIB_TREE_MODEL_ADAPTER: public wxDataViewModel
|
2017-10-28 18:28:14 +00:00
|
|
|
{
|
2022-07-09 18:41:03 +00:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* @return a unicode string to mark a node name like a pinned library name.
|
|
|
|
* This is not an ASCII7 char, but a unicode char.
|
|
|
|
*/
|
|
|
|
static const wxString GetPinningSymbol()
|
|
|
|
{
|
|
|
|
return wxString::FromUTF8( "☆ " );
|
|
|
|
}
|
|
|
|
|
2017-10-28 18:28:14 +00:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Destructor. Do NOT delete this class manually; it is reference-counted
|
|
|
|
* by wxObject.
|
|
|
|
*/
|
2018-07-27 20:47:51 +00:00
|
|
|
~LIB_TREE_MODEL_ADAPTER();
|
2017-10-28 18:28:14 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-10 14:10:55 +00:00
|
|
|
* This enum allows a selective filtering of symbols to list
|
2017-10-28 18:28:14 +00:00
|
|
|
*/
|
2021-06-10 14:10:55 +00:00
|
|
|
enum SYM_FILTER_TYPE
|
2017-10-28 18:28:14 +00:00
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
SYM_FILTER_NONE, ///< no filtering
|
|
|
|
SYM_FILTER_POWER, ///< list symbols flagged PWR
|
2017-10-28 18:28:14 +00:00
|
|
|
};
|
|
|
|
|
2019-09-18 23:00:48 +00:00
|
|
|
/**
|
2022-08-28 23:02:12 +00:00
|
|
|
* This enum defines the order of the default columns in the tree view
|
2019-09-18 23:00:48 +00:00
|
|
|
*/
|
|
|
|
enum TREE_COLS
|
|
|
|
{
|
2022-07-28 13:51:13 +00:00
|
|
|
NAME_COL = 0, ///< Library or library item name column
|
|
|
|
DESC_COL, ///< Library or library description column
|
2022-08-28 23:02:12 +00:00
|
|
|
NUM_COLS ///< The number of default tree columns
|
2019-09-18 23:00:48 +00:00
|
|
|
};
|
|
|
|
|
2023-05-01 20:26:29 +00:00
|
|
|
enum SORT_MODE
|
|
|
|
{
|
|
|
|
BEST_MATCH = 0,
|
|
|
|
ALPHABETIC
|
|
|
|
};
|
2022-08-28 23:02:12 +00:00
|
|
|
|
2019-09-18 23:00:48 +00:00
|
|
|
/**
|
|
|
|
* Save the column widths to the config file. This requires the tree view to still be
|
|
|
|
* valid.
|
|
|
|
*/
|
2022-09-24 03:45:00 +00:00
|
|
|
void SaveSettings();
|
2019-09-18 23:00:48 +00:00
|
|
|
|
2017-10-28 18:28:14 +00:00
|
|
|
/**
|
2021-06-10 14:10:55 +00:00
|
|
|
* Set the symbol filter type. Must be set before adding libraries
|
2017-10-28 18:28:14 +00:00
|
|
|
*
|
2021-06-10 14:10:55 +00:00
|
|
|
* @param aFilter if SYM_FILTER_POWER, only power parts are loaded
|
2017-10-28 18:28:14 +00:00
|
|
|
*/
|
2021-06-10 14:10:55 +00:00
|
|
|
void SetFilter( SYM_FILTER_TYPE aFilter );
|
2017-10-28 18:28:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the active filter.
|
|
|
|
*/
|
2021-06-10 14:10:55 +00:00
|
|
|
SYM_FILTER_TYPE GetFilter() const { return m_filter; }
|
2017-10-28 18:28:14 +00:00
|
|
|
|
2023-05-01 20:26:29 +00:00
|
|
|
void SetSortMode( SORT_MODE aMode ) { m_sort_mode = aMode; }
|
|
|
|
SORT_MODE GetSortMode() const { return m_sort_mode; }
|
|
|
|
|
2017-10-28 18:28:14 +00:00
|
|
|
/**
|
|
|
|
* Whether or not to show units. May be set at any time; updates at the next
|
|
|
|
* UpdateSearchString()
|
|
|
|
*
|
|
|
|
* @param aShow if true, units are displayed
|
|
|
|
*/
|
|
|
|
void ShowUnits( bool aShow );
|
|
|
|
|
|
|
|
/**
|
2021-06-10 14:10:55 +00:00
|
|
|
* Set the symbol name to be selected if there are no search results.
|
2017-10-28 18:28:14 +00:00
|
|
|
* May be set at any time; updates at the next UpdateSearchString().
|
|
|
|
*
|
|
|
|
* @param aLibId symbol #LIB_ID to be selected
|
|
|
|
* @param aUnit unit to be selected, if > 0 (0 selects the alias itself)
|
|
|
|
*/
|
2021-07-27 12:22:27 +00:00
|
|
|
void SetPreselectNode( const LIB_ID& aLibId, int aUnit );
|
2017-10-28 18:28:14 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-10 14:10:55 +00:00
|
|
|
* Add the given list of symbols by alias. To be called in the setup
|
2017-10-28 18:28:14 +00:00
|
|
|
* phase.
|
|
|
|
*
|
2021-06-10 14:10:55 +00:00
|
|
|
* @param aNodeName the parent node the symbols will appear under
|
2018-07-27 20:47:51 +00:00
|
|
|
* @param aDesc the description field of the parent node
|
2021-06-10 14:10:55 +00:00
|
|
|
* @param aItemList list of symbols
|
2017-10-28 18:28:14 +00:00
|
|
|
*/
|
2021-07-27 12:22:27 +00:00
|
|
|
void DoAddLibrary( const wxString& aNodeName, const wxString& aDesc,
|
2022-07-22 08:26:49 +00:00
|
|
|
const std::vector<LIB_TREE_ITEM*>& aItemList,
|
|
|
|
bool pinned, bool presorted );
|
2018-08-05 11:56:02 +00:00
|
|
|
|
2022-09-24 03:45:00 +00:00
|
|
|
std::vector<wxString> GetAvailableColumns() const { return m_availableColumns; }
|
|
|
|
|
|
|
|
std::vector<wxString> GetShownColumns() const { return m_shownColumns; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets which columns are shown in the widget. Invalid column names are discarded.
|
|
|
|
* @param aColumnNames is an ordered list of column names to show
|
|
|
|
*/
|
|
|
|
void SetShownColumns( const std::vector<wxString>& aColumnNames );
|
|
|
|
|
2018-08-05 11:56:02 +00:00
|
|
|
/**
|
|
|
|
* Sort the tree and assign ranks after adding libraries.
|
|
|
|
*/
|
|
|
|
void AssignIntrinsicRanks() { m_tree.AssignIntrinsicRanks(); }
|
2017-10-28 18:28:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the search string provided by the user.
|
|
|
|
*
|
|
|
|
* @param aSearch full, unprocessed search text
|
2021-01-04 17:12:18 +00:00
|
|
|
* @param aState if true, we are keeping the state and so we shouldn't collapse the tree
|
2017-10-28 18:28:14 +00:00
|
|
|
*/
|
2021-07-27 12:22:27 +00:00
|
|
|
void UpdateSearchString( const wxString& aSearch, bool aState );
|
2017-10-28 18:28:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Attach to a wxDataViewCtrl and initialize it. This will set up columns
|
|
|
|
* and associate the model via the adapter.
|
|
|
|
*
|
2021-06-10 14:10:55 +00:00
|
|
|
* @param aDataViewCtrl the view symbol in the dialog
|
2017-10-28 18:28:14 +00:00
|
|
|
*/
|
|
|
|
void AttachTo( wxDataViewCtrl* aDataViewCtrl );
|
|
|
|
|
2021-04-01 09:49:05 +00:00
|
|
|
/**
|
|
|
|
* A final-stage initialization to be called after the window hierarchy has been realized
|
|
|
|
* and the window sizes set.
|
|
|
|
*/
|
|
|
|
void FinishTreeInitialization();
|
|
|
|
|
2022-07-28 13:51:13 +00:00
|
|
|
void OnSize( wxSizeEvent& aEvent );
|
2017-10-28 18:28:14 +00:00
|
|
|
/**
|
|
|
|
* Return the alias for the given item.
|
|
|
|
*
|
|
|
|
* @param aSelection item from the wxDataViewCtrl
|
|
|
|
* (see wxDataViewCtrl::GetSelection())
|
|
|
|
*
|
|
|
|
* @return alias, or nullptr if none is selected
|
|
|
|
*/
|
|
|
|
LIB_ID GetAliasFor( const wxDataViewItem& aSelection ) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the unit for the given item.
|
|
|
|
*
|
|
|
|
* @param aSelection item from the wxDataViewCtrl
|
|
|
|
* (see wxDataViewCtrl::GetSelection())
|
|
|
|
*
|
|
|
|
* @return Unit, or zero if the alias itself is selected. Return valid is
|
|
|
|
* invalid if GetAliasFor() returns nullptr.
|
|
|
|
*/
|
|
|
|
int GetUnitFor( const wxDataViewItem& aSelection ) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return node type for the given item.
|
|
|
|
*
|
|
|
|
* @param aSelection item from the wxDataViewCtrl
|
|
|
|
* (see wxDataViewCtrl::GetSelection())
|
|
|
|
*
|
|
|
|
* @return Type of the selected node, might be INVALID.
|
|
|
|
*/
|
2018-07-27 20:47:51 +00:00
|
|
|
LIB_TREE_NODE::TYPE GetTypeFor( const wxDataViewItem& aSelection ) const;
|
|
|
|
|
2020-02-07 17:06:24 +00:00
|
|
|
LIB_TREE_NODE* GetTreeNodeFor( const wxDataViewItem& aSelection ) const;
|
|
|
|
|
2021-07-27 12:22:27 +00:00
|
|
|
virtual wxString GenerateInfo( const LIB_ID& aLibId, int aUnit ) { return wxEmptyString; };
|
2017-10-28 18:28:14 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-10 14:10:55 +00:00
|
|
|
* Return the number of symbols loaded in the tree.
|
2017-10-28 18:28:14 +00:00
|
|
|
*/
|
2018-07-27 20:47:51 +00:00
|
|
|
int GetItemCount() const;
|
2017-10-28 18:28:14 +00:00
|
|
|
|
2017-11-22 11:06:17 +00:00
|
|
|
/**
|
|
|
|
* Return the number of libraries loaded in the tree.
|
|
|
|
*/
|
|
|
|
virtual int GetLibrariesCount() const
|
|
|
|
{
|
2020-02-07 17:06:24 +00:00
|
|
|
return m_tree.m_Children.size();
|
2017-11-22 11:06:17 +00:00
|
|
|
}
|
|
|
|
|
2017-11-14 11:03:19 +00:00
|
|
|
/**
|
|
|
|
* Returns tree item corresponding to part.
|
|
|
|
*
|
|
|
|
* @param aLibId specifies the part and library name to be searched for.
|
|
|
|
* @return Tree data item representing the part. Might be invalid if nothings was found.
|
|
|
|
*/
|
|
|
|
wxDataViewItem FindItem( const LIB_ID& aLibId );
|
|
|
|
|
2017-11-21 13:54:30 +00:00
|
|
|
/**
|
|
|
|
* Populate a list of all the children of an item
|
|
|
|
*
|
|
|
|
* @return number of children
|
|
|
|
*/
|
2021-07-27 12:22:27 +00:00
|
|
|
unsigned int GetChildren( const wxDataViewItem& aItem,
|
2018-07-27 20:47:51 +00:00
|
|
|
wxDataViewItemArray& aChildren ) const override;
|
2017-11-21 13:54:30 +00:00
|
|
|
|
2018-04-28 09:43:41 +00:00
|
|
|
// Freezing/Thawing. Used when updating the table model so that we don't try and fetch
|
|
|
|
// values during updating. Primarily a problem on OSX which doesn't pay attention to the
|
|
|
|
// wxDataViewCtrl's freeze count when updating the keyWindow.
|
|
|
|
void Freeze() { m_freeze++; }
|
|
|
|
void Thaw() { m_freeze--; }
|
|
|
|
bool IsFrozen() const { return m_freeze; }
|
|
|
|
|
2020-03-31 01:09:01 +00:00
|
|
|
void RefreshTree();
|
2020-03-08 15:14:22 +00:00
|
|
|
|
2019-06-05 19:15:57 +00:00
|
|
|
// Allows subclasses to nominate a context menu handler.
|
|
|
|
virtual TOOL_INTERACTIVE* GetContextMenuTool() { return nullptr; }
|
|
|
|
|
2022-09-21 13:44:13 +00:00
|
|
|
void PinLibrary( LIB_TREE_NODE* aTreeNode );
|
|
|
|
void UnpinLibrary( LIB_TREE_NODE* aTreeNode );
|
|
|
|
|
2023-04-11 22:51:27 +00:00
|
|
|
void ShowChangedLanguage()
|
|
|
|
{
|
|
|
|
recreateColumns();
|
|
|
|
}
|
|
|
|
|
2017-10-28 18:28:14 +00:00
|
|
|
protected:
|
2021-06-10 14:10:55 +00:00
|
|
|
/**
|
|
|
|
* Convert #SYM_TREE_NODE -> wxDataViewItem.
|
|
|
|
*/
|
2021-07-27 12:22:27 +00:00
|
|
|
static wxDataViewItem ToItem( const LIB_TREE_NODE* aNode );
|
2021-06-10 14:10:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert wxDataViewItem -> #SYM_TREE_NODE.
|
|
|
|
*/
|
2020-02-07 17:06:24 +00:00
|
|
|
static LIB_TREE_NODE* ToNode( wxDataViewItem aItem );
|
2021-06-10 14:10:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert SYM_TREE_NODE's children to wxDataViewItemArray.
|
|
|
|
*/
|
2021-07-27 12:22:27 +00:00
|
|
|
static unsigned int IntoArray( const LIB_TREE_NODE& aNode, wxDataViewItemArray& aChildren );
|
2017-10-28 18:28:14 +00:00
|
|
|
|
2020-05-31 21:42:04 +00:00
|
|
|
/**
|
2021-06-10 14:10:55 +00:00
|
|
|
* Create the adapter.
|
|
|
|
*
|
2020-05-31 21:42:04 +00:00
|
|
|
* @param aParent is the parent frame
|
|
|
|
* @param aPinnedKey is the key to load the pinned libraries list from the project file
|
|
|
|
*/
|
2021-07-27 12:22:27 +00:00
|
|
|
LIB_TREE_MODEL_ADAPTER( EDA_BASE_FRAME* aParent, const wxString& aPinnedKey );
|
2020-02-14 14:22:21 +00:00
|
|
|
|
2022-07-22 08:26:49 +00:00
|
|
|
LIB_TREE_NODE_LIB& DoAddLibraryNode( const wxString& aNodeName, const wxString& aDesc,
|
|
|
|
bool pinned );
|
2017-10-28 18:28:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check whether a container has columns too
|
|
|
|
*/
|
2021-07-27 12:22:27 +00:00
|
|
|
bool HasContainerColumns( const wxDataViewItem& aItem ) const override;
|
2017-10-28 18:28:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check whether an item can have children.
|
|
|
|
*/
|
2021-07-27 12:22:27 +00:00
|
|
|
bool IsContainer( const wxDataViewItem& aItem ) const override;
|
2017-10-28 18:28:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the parent of an item.
|
|
|
|
*
|
|
|
|
* @return parent of aItem, or an invalid wxDataViewItem if parent is root
|
|
|
|
*/
|
2021-07-27 12:22:27 +00:00
|
|
|
wxDataViewItem GetParent( const wxDataViewItem& aItem ) const override;
|
2017-10-28 18:28:14 +00:00
|
|
|
|
2022-08-28 23:02:12 +00:00
|
|
|
unsigned int GetColumnCount() const override { return m_columns.size(); }
|
2017-10-28 18:28:14 +00:00
|
|
|
|
|
|
|
/**
|
2019-06-05 19:15:57 +00:00
|
|
|
* Return the type of data stored in the column as indicated by wxVariant::GetType()
|
2017-10-28 18:28:14 +00:00
|
|
|
*/
|
2019-06-05 19:15:57 +00:00
|
|
|
wxString GetColumnType( unsigned int aCol ) const override { return "string"; }
|
2017-10-28 18:28:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the value of an item.
|
|
|
|
*
|
|
|
|
* @param aVariant wxVariant to receive the data
|
|
|
|
* @param aItem item whose data will be placed into aVariant
|
|
|
|
* @param aCol column number of the data
|
|
|
|
*/
|
2019-06-05 19:15:57 +00:00
|
|
|
void GetValue( wxVariant& aVariant,
|
2021-07-27 12:22:27 +00:00
|
|
|
const wxDataViewItem& aItem,
|
2019-06-05 19:15:57 +00:00
|
|
|
unsigned int aCol ) const override;
|
2017-10-28 18:28:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the value of an item. Does nothing - this model doesn't support
|
|
|
|
* editing.
|
|
|
|
*/
|
2021-07-27 12:22:27 +00:00
|
|
|
bool SetValue( const wxVariant& aVariant,
|
|
|
|
const wxDataViewItem& aItem,
|
2019-06-05 19:15:57 +00:00
|
|
|
unsigned int aCol ) override { return false; }
|
2017-10-28 18:28:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get any formatting for an item.
|
|
|
|
*
|
|
|
|
* @param aItem item to get formatting for
|
|
|
|
* @param aCol column number of interest
|
|
|
|
* @param aAttr receiver for attributes
|
2020-12-19 23:29:10 +00:00
|
|
|
* @return true if the item has non-default attributes
|
2017-10-28 18:28:14 +00:00
|
|
|
*/
|
2021-07-27 12:22:27 +00:00
|
|
|
bool GetAttr( const wxDataViewItem& aItem,
|
2019-06-05 19:15:57 +00:00
|
|
|
unsigned int aCol,
|
|
|
|
wxDataViewItemAttr& aAttr ) const override;
|
2017-10-28 18:28:14 +00:00
|
|
|
|
2022-09-21 13:44:13 +00:00
|
|
|
virtual bool isSymbolModel() = 0;
|
|
|
|
|
|
|
|
void resortTree();
|
|
|
|
|
2017-10-28 18:28:14 +00:00
|
|
|
private:
|
|
|
|
/**
|
2023-04-14 22:34:14 +00:00
|
|
|
* Find any results worth highlighting and expand them.
|
2017-10-28 18:28:14 +00:00
|
|
|
*/
|
2023-04-14 22:34:14 +00:00
|
|
|
void Find( LIB_TREE_NODE& aNode, std::function<bool( const LIB_TREE_NODE* )> aFunc );
|
2017-10-28 18:28:14 +00:00
|
|
|
|
|
|
|
/**
|
2018-06-10 22:20:06 +00:00
|
|
|
* Find and expand successful search results. Return the best match (if any).
|
2017-10-28 18:28:14 +00:00
|
|
|
*/
|
2023-04-14 22:34:14 +00:00
|
|
|
const LIB_TREE_NODE* ShowResults();
|
2020-12-19 23:29:10 +00:00
|
|
|
|
2022-08-28 23:02:12 +00:00
|
|
|
wxDataViewColumn* doAddColumn( const wxString& aHeader, bool aTranslate = true );
|
|
|
|
|
2020-12-19 23:29:10 +00:00
|
|
|
protected:
|
2022-08-28 23:02:12 +00:00
|
|
|
void addColumnIfNecessary( const wxString& aHeader );
|
|
|
|
|
2022-09-24 03:45:00 +00:00
|
|
|
void recreateColumns();
|
|
|
|
|
2022-08-28 23:02:12 +00:00
|
|
|
LIB_TREE_NODE_ROOT m_tree;
|
|
|
|
std::map<unsigned, wxString> m_colIdxMap;
|
2023-01-20 03:14:10 +00:00
|
|
|
std::vector<wxString> m_availableColumns;
|
2020-12-19 23:29:10 +00:00
|
|
|
|
|
|
|
private:
|
2022-09-21 13:44:13 +00:00
|
|
|
EDA_BASE_FRAME* m_parent;
|
2020-12-19 23:29:10 +00:00
|
|
|
|
2021-06-10 14:10:55 +00:00
|
|
|
SYM_FILTER_TYPE m_filter;
|
2023-05-01 20:26:29 +00:00
|
|
|
SORT_MODE m_sort_mode;
|
2020-12-19 23:29:10 +00:00
|
|
|
bool m_show_units;
|
|
|
|
LIB_ID m_preselect_lib_id;
|
|
|
|
int m_preselect_unit;
|
|
|
|
int m_freeze;
|
|
|
|
|
|
|
|
wxDataViewCtrl* m_widget;
|
|
|
|
|
2022-08-28 23:02:12 +00:00
|
|
|
std::vector<wxDataViewColumn*> m_columns;
|
|
|
|
std::map<wxString, wxDataViewColumn*> m_colNameMap;
|
|
|
|
std::map<wxString, int> m_colWidths;
|
2022-09-24 03:45:00 +00:00
|
|
|
std::vector<wxString> m_shownColumns; // Stored in display order
|
2017-10-28 18:28:14 +00:00
|
|
|
};
|
|
|
|
|
2018-07-27 20:47:51 +00:00
|
|
|
#endif // LIB_TREE_MODEL_ADAPTER_H
|
2017-10-28 18:28:14 +00:00
|
|
|
|