Save pinned libraries in project.
Fixes https://gitlab.com/kicad/code/kicad/issues/2288
This commit is contained in:
parent
0aa6e43783
commit
3ec360f15c
|
@ -19,8 +19,10 @@
|
||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <eda_base_frame.h>
|
||||||
#include <eda_pattern_match.h>
|
#include <eda_pattern_match.h>
|
||||||
#include <kiface_i.h>
|
#include <kiface_i.h>
|
||||||
|
#include <config_params.h>
|
||||||
#include <lib_tree_model_adapter.h>
|
#include <lib_tree_model_adapter.h>
|
||||||
#include <wx/tokenzr.h>
|
#include <wx/tokenzr.h>
|
||||||
#include <wx/wupdlock.h>
|
#include <wx/wupdlock.h>
|
||||||
|
@ -71,8 +73,9 @@ unsigned int LIB_TREE_MODEL_ADAPTER::IntoArray( LIB_TREE_NODE const& aNode,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LIB_TREE_MODEL_ADAPTER::LIB_TREE_MODEL_ADAPTER()
|
LIB_TREE_MODEL_ADAPTER::LIB_TREE_MODEL_ADAPTER( EDA_BASE_FRAME* aParent ) :
|
||||||
:m_filter( CMP_FILTER_NONE ),
|
m_parent( aParent ),
|
||||||
|
m_filter( CMP_FILTER_NONE ),
|
||||||
m_show_units( true ),
|
m_show_units( true ),
|
||||||
m_preselect_unit( 0 ),
|
m_preselect_unit( 0 ),
|
||||||
m_freeze( 0 ),
|
m_freeze( 0 ),
|
||||||
|
@ -87,15 +90,15 @@ LIB_TREE_MODEL_ADAPTER::LIB_TREE_MODEL_ADAPTER()
|
||||||
m_config = Kiface().KifaceSettings();
|
m_config = Kiface().KifaceSettings();
|
||||||
m_configPrefix = typeid( this ).name();
|
m_configPrefix = typeid( this ).name();
|
||||||
|
|
||||||
// Read the column width from the config
|
// Read the column width from the global config
|
||||||
int colWidth = 0;
|
int colWidth = 0;
|
||||||
|
|
||||||
if( m_config->Read( m_configPrefix + LIST_COLUMN_WIDTH_KEY, &colWidth ) )
|
if( m_config->Read( m_configPrefix + LIST_COLUMN_WIDTH_KEY, &colWidth ) )
|
||||||
m_colWidths[PART_COL] = colWidth;
|
m_colWidths[PART_COL] = colWidth;
|
||||||
|
|
||||||
// JEY TODO NEW SETTINGS ARCH: read pinned items array....
|
// Read the pinned entries from the project config
|
||||||
//for( UFT8 pinnedItem : pinnedItems )
|
m_parent->Kiway().Prj().ConfigLoad( Kiface().KifaceSearch(), m_parent->GetName(),
|
||||||
// m_pinnedLibIDs.insert( pinnedItem );
|
GetProjectFileParameters() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -116,18 +119,30 @@ void LIB_TREE_MODEL_ADAPTER::SaveColWidths()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<PARAM_CFG*>& LIB_TREE_MODEL_ADAPTER::GetProjectFileParameters()
|
||||||
|
{
|
||||||
|
if( !m_projectFileParams.empty() )
|
||||||
|
return m_projectFileParams;
|
||||||
|
|
||||||
|
m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( PINNED_ITEMS_KEY, &m_pinnedLibs ) );
|
||||||
|
|
||||||
|
return m_projectFileParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void LIB_TREE_MODEL_ADAPTER::SavePinnedItems()
|
void LIB_TREE_MODEL_ADAPTER::SavePinnedItems()
|
||||||
{
|
{
|
||||||
// JEY TODO NEW SETTINGS ARCH: clear pinned items array in settings....
|
m_pinnedLibs.clear();
|
||||||
|
|
||||||
for( auto& child: m_tree.m_Children )
|
for( auto& child: m_tree.m_Children )
|
||||||
{
|
{
|
||||||
if( child->m_Pinned )
|
if( child->m_Pinned )
|
||||||
{
|
m_pinnedLibs.push_back( child->m_LibId.GetLibNickname() );
|
||||||
UTF8 pinnedItem = child->m_LibId.Format();
|
|
||||||
// JEY TODO NEW SETTINGS ARCH: add pinned entry to settings array....
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_parent->Kiway().Prj().ConfigSave( Kiface().KifaceSearch(), m_parent->GetName(),
|
||||||
|
GetProjectFileParameters() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -150,13 +165,22 @@ void LIB_TREE_MODEL_ADAPTER::SetPreselectNode( LIB_ID const& aLibId, int aUnit )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LIB_TREE_NODE_LIB& LIB_TREE_MODEL_ADAPTER::DoAddLibraryNode( wxString const& aNodeName,
|
||||||
|
wxString const& aDesc )
|
||||||
|
{
|
||||||
|
LIB_TREE_NODE_LIB& lib_node = m_tree.AddLib( aNodeName, aDesc );
|
||||||
|
|
||||||
|
lib_node.m_Pinned = m_pinnedLibs.Index( lib_node.m_LibId.GetLibNickname() ) != wxNOT_FOUND;
|
||||||
|
|
||||||
|
return lib_node;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void LIB_TREE_MODEL_ADAPTER::DoAddLibrary( wxString const& aNodeName, wxString const& aDesc,
|
void LIB_TREE_MODEL_ADAPTER::DoAddLibrary( wxString const& aNodeName, wxString const& aDesc,
|
||||||
std::vector<LIB_TREE_ITEM*> const& aItemList,
|
std::vector<LIB_TREE_ITEM*> const& aItemList,
|
||||||
bool presorted )
|
bool presorted )
|
||||||
{
|
{
|
||||||
LIB_TREE_NODE_LIB& lib_node = m_tree.AddLib( aNodeName, aDesc );
|
LIB_TREE_NODE_LIB& lib_node = DoAddLibraryNode( aNodeName, aDesc );
|
||||||
|
|
||||||
lib_node.m_Pinned = m_pinnedLibIDs.count( lib_node.m_LibId.Format() ) > 0;
|
|
||||||
|
|
||||||
for( LIB_TREE_ITEM* item: aItemList )
|
for( LIB_TREE_ITEM* item: aItemList )
|
||||||
lib_node.AddItem( item );
|
lib_node.AddItem( item );
|
||||||
|
|
|
@ -90,6 +90,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class TOOL_INTERACTIVE;
|
class TOOL_INTERACTIVE;
|
||||||
|
class PARAM_CFG;
|
||||||
|
|
||||||
class LIB_TREE_MODEL_ADAPTER: public wxDataViewModel
|
class LIB_TREE_MODEL_ADAPTER: public wxDataViewModel
|
||||||
{
|
{
|
||||||
|
@ -132,6 +133,8 @@ public:
|
||||||
void SaveColWidths();
|
void SaveColWidths();
|
||||||
void SavePinnedItems();
|
void SavePinnedItems();
|
||||||
|
|
||||||
|
std::vector<PARAM_CFG*>& GetProjectFileParameters();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the component filter type. Must be set before adding libraries
|
* Set the component filter type. Must be set before adding libraries
|
||||||
*
|
*
|
||||||
|
@ -274,7 +277,9 @@ protected:
|
||||||
|
|
||||||
LIB_TREE_NODE_ROOT m_tree;
|
LIB_TREE_NODE_ROOT m_tree;
|
||||||
|
|
||||||
LIB_TREE_MODEL_ADAPTER();
|
LIB_TREE_MODEL_ADAPTER( EDA_BASE_FRAME* aParent );
|
||||||
|
|
||||||
|
LIB_TREE_NODE_LIB& DoAddLibraryNode( wxString const& aNodeName, wxString const& aDesc );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether a container has columns too
|
* Check whether a container has columns too
|
||||||
|
@ -332,6 +337,8 @@ protected:
|
||||||
wxDataViewItemAttr& aAttr ) const override;
|
wxDataViewItemAttr& aAttr ) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
EDA_BASE_FRAME* m_parent;
|
||||||
|
|
||||||
CMP_FILTER_TYPE m_filter;
|
CMP_FILTER_TYPE m_filter;
|
||||||
bool m_show_units;
|
bool m_show_units;
|
||||||
LIB_ID m_preselect_lib_id;
|
LIB_ID m_preselect_lib_id;
|
||||||
|
@ -342,20 +349,18 @@ private:
|
||||||
wxDataViewColumn* m_col_desc;
|
wxDataViewColumn* m_col_desc;
|
||||||
wxDataViewCtrl* m_widget;
|
wxDataViewCtrl* m_widget;
|
||||||
|
|
||||||
int m_colWidths[NUM_COLS];
|
|
||||||
|
|
||||||
wxConfigBase* m_config;
|
wxConfigBase* m_config;
|
||||||
wxString m_configPrefix;
|
wxString m_configPrefix;
|
||||||
|
std::vector<PARAM_CFG*> m_projectFileParams;
|
||||||
|
|
||||||
std::set<UTF8> m_pinnedLibIDs;
|
int m_colWidths[NUM_COLS];
|
||||||
|
wxArrayString m_pinnedLibs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find any results worth highlighting and expand them, according to given
|
* Find any results worth highlighting and expand them, according to given criteria
|
||||||
* criteria (f(CMP_TREE_NODE const*) -> bool)
|
|
||||||
* The highest-scoring node is written to aHighScore
|
* The highest-scoring node is written to aHighScore
|
||||||
*/
|
*/
|
||||||
void FindAndExpand( LIB_TREE_NODE& aNode,
|
void FindAndExpand( LIB_TREE_NODE& aNode, std::function<bool( LIB_TREE_NODE const* )> aFunc,
|
||||||
std::function<bool( LIB_TREE_NODE const* )> aFunc,
|
|
||||||
LIB_TREE_NODE** aHighScore );
|
LIB_TREE_NODE** aHighScore );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -103,7 +103,7 @@ COMPONENT_SELECTION SCH_BASE_FRAME::SelectCompFromLibTree( const SCHLIB_FILTER*
|
||||||
if( !dialogLock.try_lock() )
|
if( !dialogLock.try_lock() )
|
||||||
return COMPONENT_SELECTION();
|
return COMPONENT_SELECTION();
|
||||||
|
|
||||||
auto adapterPtr( SYMBOL_TREE_MODEL_ADAPTER::Create( libs ) );
|
auto adapterPtr( SYMBOL_TREE_MODEL_ADAPTER::Create( this, libs ) );
|
||||||
auto adapter = static_cast<SYMBOL_TREE_MODEL_ADAPTER*>( adapterPtr.get() );
|
auto adapter = static_cast<SYMBOL_TREE_MODEL_ADAPTER*>( adapterPtr.get() );
|
||||||
bool loaded = false;
|
bool loaded = false;
|
||||||
|
|
||||||
|
|
|
@ -747,7 +747,7 @@ void LIB_VIEW_FRAME::OnSelectSymbol( wxCommandEvent& aEvent )
|
||||||
|
|
||||||
// Container doing search-as-you-type.
|
// Container doing search-as-you-type.
|
||||||
SYMBOL_LIB_TABLE* libs = Prj().SchSymbolLibTable();
|
SYMBOL_LIB_TABLE* libs = Prj().SchSymbolLibTable();
|
||||||
auto adapterPtr( SYMBOL_TREE_MODEL_ADAPTER::Create( libs ) );
|
auto adapterPtr( SYMBOL_TREE_MODEL_ADAPTER::Create( this, libs ) );
|
||||||
auto adapter = static_cast<SYMBOL_TREE_MODEL_ADAPTER*>( adapterPtr.get() );
|
auto adapter = static_cast<SYMBOL_TREE_MODEL_ADAPTER*>( adapterPtr.get() );
|
||||||
|
|
||||||
const auto libNicknames = libs->GetLogicalLibs();
|
const auto libNicknames = libs->GetLogicalLibs();
|
||||||
|
|
|
@ -35,14 +35,16 @@ bool SYMBOL_TREE_MODEL_ADAPTER::m_show_progress = true;
|
||||||
#define PROGRESS_INTERVAL_MILLIS 66
|
#define PROGRESS_INTERVAL_MILLIS 66
|
||||||
|
|
||||||
|
|
||||||
SYMBOL_TREE_MODEL_ADAPTER::PTR SYMBOL_TREE_MODEL_ADAPTER::Create( LIB_TABLE* aLibs )
|
SYMBOL_TREE_MODEL_ADAPTER::PTR SYMBOL_TREE_MODEL_ADAPTER::Create( EDA_BASE_FRAME* aParent,
|
||||||
|
LIB_TABLE* aLibs )
|
||||||
{
|
{
|
||||||
return PTR( new SYMBOL_TREE_MODEL_ADAPTER( aLibs ) );
|
return PTR( new SYMBOL_TREE_MODEL_ADAPTER( aParent, aLibs ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SYMBOL_TREE_MODEL_ADAPTER::SYMBOL_TREE_MODEL_ADAPTER( LIB_TABLE* aLibs )
|
SYMBOL_TREE_MODEL_ADAPTER::SYMBOL_TREE_MODEL_ADAPTER( EDA_BASE_FRAME* aParent, LIB_TABLE* aLibs ) :
|
||||||
: m_libs( (SYMBOL_LIB_TABLE*) aLibs )
|
LIB_TREE_MODEL_ADAPTER( aParent ),
|
||||||
|
m_libs( (SYMBOL_LIB_TABLE*) aLibs )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param aLibs library set from which parts will be loaded
|
* @param aLibs library set from which parts will be loaded
|
||||||
*/
|
*/
|
||||||
static PTR Create( LIB_TABLE* aLibs );
|
static PTR Create( EDA_BASE_FRAME* aParent, LIB_TABLE* aLibs );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add all the libraries in a SYMBOL_LIB_TABLE to the model.
|
* Add all the libraries in a SYMBOL_LIB_TABLE to the model.
|
||||||
|
@ -59,7 +59,7 @@ protected:
|
||||||
/**
|
/**
|
||||||
* Constructor; takes a set of libraries to be included in the search.
|
* Constructor; takes a set of libraries to be included in the search.
|
||||||
*/
|
*/
|
||||||
SYMBOL_TREE_MODEL_ADAPTER( LIB_TABLE* aLibs );
|
SYMBOL_TREE_MODEL_ADAPTER( EDA_BASE_FRAME* aParent, LIB_TABLE* aLibs );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include <lib_manager.h>
|
#include <lib_manager.h>
|
||||||
#include <symbol_lib_table.h>
|
#include <symbol_lib_table.h>
|
||||||
#include <class_libentry.h>
|
#include <class_libentry.h>
|
||||||
#include <tool/tool_manager.h>
|
|
||||||
#include <tools/lib_control.h>
|
#include <tools/lib_control.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,6 +39,7 @@ LIB_TREE_MODEL_ADAPTER::PTR SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Create( LIB_EDIT_
|
||||||
|
|
||||||
SYMBOL_TREE_SYNCHRONIZING_ADAPTER::SYMBOL_TREE_SYNCHRONIZING_ADAPTER( LIB_EDIT_FRAME* aParent,
|
SYMBOL_TREE_SYNCHRONIZING_ADAPTER::SYMBOL_TREE_SYNCHRONIZING_ADAPTER( LIB_EDIT_FRAME* aParent,
|
||||||
LIB_MANAGER* aLibMgr ) :
|
LIB_MANAGER* aLibMgr ) :
|
||||||
|
LIB_TREE_MODEL_ADAPTER( aParent ),
|
||||||
m_frame( aParent ),
|
m_frame( aParent ),
|
||||||
m_libMgr( aLibMgr ),
|
m_libMgr( aLibMgr ),
|
||||||
m_lastSyncHash( -1 )
|
m_lastSyncHash( -1 )
|
||||||
|
@ -117,7 +117,7 @@ void SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Sync( bool aForce,
|
||||||
|
|
||||||
SYMBOL_LIB_TABLE_ROW* library = m_libMgr->GetLibrary( libName );
|
SYMBOL_LIB_TABLE_ROW* library = m_libMgr->GetLibrary( libName );
|
||||||
|
|
||||||
auto& lib_node = m_tree.AddLib( libName, library->GetDescr() );
|
auto& lib_node = DoAddLibraryNode( libName, library->GetDescr() );
|
||||||
updateLibrary( lib_node );
|
updateLibrary( lib_node );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,14 +26,16 @@
|
||||||
|
|
||||||
#include "fp_tree_model_adapter.h"
|
#include "fp_tree_model_adapter.h"
|
||||||
|
|
||||||
FP_TREE_MODEL_ADAPTER::PTR FP_TREE_MODEL_ADAPTER::Create( LIB_TABLE* aLibs )
|
FP_TREE_MODEL_ADAPTER::PTR FP_TREE_MODEL_ADAPTER::Create( EDA_BASE_FRAME* aParent,
|
||||||
|
LIB_TABLE* aLibs )
|
||||||
{
|
{
|
||||||
return PTR( new FP_TREE_MODEL_ADAPTER( aLibs ) );
|
return PTR( new FP_TREE_MODEL_ADAPTER( aParent, aLibs ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FP_TREE_MODEL_ADAPTER::FP_TREE_MODEL_ADAPTER( LIB_TABLE* aLibs )
|
FP_TREE_MODEL_ADAPTER::FP_TREE_MODEL_ADAPTER( EDA_BASE_FRAME* aParent, LIB_TABLE* aLibs ) :
|
||||||
: m_libs( (FP_LIB_TABLE*) aLibs )
|
LIB_TREE_MODEL_ADAPTER( aParent ),
|
||||||
|
m_libs( (FP_LIB_TABLE*) aLibs )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param aLibs library set from which parts will be loaded
|
* @param aLibs library set from which parts will be loaded
|
||||||
*/
|
*/
|
||||||
static PTR Create( LIB_TABLE* aLibs );
|
static PTR Create( EDA_BASE_FRAME* aParent, LIB_TABLE* aLibs );
|
||||||
|
|
||||||
void AddLibraries();
|
void AddLibraries();
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ protected:
|
||||||
/**
|
/**
|
||||||
* Constructor; takes a set of libraries to be included in the search.
|
* Constructor; takes a set of libraries to be included in the search.
|
||||||
*/
|
*/
|
||||||
FP_TREE_MODEL_ADAPTER( LIB_TABLE* aLibs );
|
FP_TREE_MODEL_ADAPTER( EDA_BASE_FRAME* aParent, LIB_TABLE* aLibs );
|
||||||
|
|
||||||
std::vector<LIB_TREE_ITEM*> getFootprints( const wxString& aLibName );
|
std::vector<LIB_TREE_ITEM*> getFootprints( const wxString& aLibName );
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ LIB_TREE_MODEL_ADAPTER::PTR FP_TREE_SYNCHRONIZING_ADAPTER::Create( FOOTPRINT_EDI
|
||||||
|
|
||||||
FP_TREE_SYNCHRONIZING_ADAPTER::FP_TREE_SYNCHRONIZING_ADAPTER( FOOTPRINT_EDIT_FRAME* aFrame,
|
FP_TREE_SYNCHRONIZING_ADAPTER::FP_TREE_SYNCHRONIZING_ADAPTER( FOOTPRINT_EDIT_FRAME* aFrame,
|
||||||
FP_LIB_TABLE* aLibs ) :
|
FP_LIB_TABLE* aLibs ) :
|
||||||
FP_TREE_MODEL_ADAPTER( aLibs ),
|
FP_TREE_MODEL_ADAPTER( aFrame, aLibs ),
|
||||||
m_frame( aFrame )
|
m_frame( aFrame )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,7 +216,7 @@ MODULE* PCB_BASE_FRAME::SelectFootprintFromLibTree( LIB_ID aPreselect )
|
||||||
if( GFootprintList.GetErrorCount() )
|
if( GFootprintList.GetErrorCount() )
|
||||||
GFootprintList.DisplayErrors( this );
|
GFootprintList.DisplayErrors( this );
|
||||||
|
|
||||||
auto adapterPtr( FP_TREE_MODEL_ADAPTER::Create( fpTable ) );
|
auto adapterPtr( FP_TREE_MODEL_ADAPTER::Create( this, fpTable ) );
|
||||||
auto adapter = static_cast<FP_TREE_MODEL_ADAPTER*>( adapterPtr.get() );
|
auto adapter = static_cast<FP_TREE_MODEL_ADAPTER*>( adapterPtr.get() );
|
||||||
|
|
||||||
std::vector<LIB_TREE_ITEM*> historyInfos;
|
std::vector<LIB_TREE_ITEM*> historyInfos;
|
||||||
|
|
Loading…
Reference in New Issue