Browse Source

Clean up lib table cherry-pick and hide

For now, we place this behind the advanced config flag for v9 testing
9.0
Seth Hillbrand 2 months ago
parent
commit
f787c01b47
  1. 5
      common/advanced_config.cpp
  2. 32
      eeschema/dialogs/dialog_lib_fields.cpp
  3. 32
      eeschema/lib_fields_data_model.cpp
  4. 5
      eeschema/tools/symbol_editor_control.cpp
  5. 9
      include/advanced_config.h
  6. 1
      include/widgets/grid_text_button_helpers.h
  7. 2
      pcbnew/generate_footprint_info.cpp

5
common/advanced_config.cpp

@ -102,6 +102,7 @@ static const wxChar EnableDesignBlocks[] = wxT( "EnableDesignBlocks" );
static const wxChar EnableGenerators[] = wxT( "EnableGenerators" );
static const wxChar EnableLibWithText[] = wxT( "EnableLibWithText" );
static const wxChar EnableLibDir[] = wxT( "EnableLibDir" );
static const wxChar LibraryTableEditor[] = wxT( "LibraryTableEditor" );
static const wxChar EnableEeschemaPrintCairo[] = wxT( "EnableEeschemaPrintCairo" );
static const wxChar EnableEeschemaExportClipboardCairo[] = wxT( "EnableEeschemaExportClipboardCairo" );
static const wxChar DisambiguationTime[] = wxT( "DisambiguationTime" );
@ -262,6 +263,7 @@ ADVANCED_CFG::ADVANCED_CFG()
m_EnableGenerators = false;
m_EnableLibWithText = false;
m_EnableLibDir = false;
m_LibraryTableEditor = false;
m_EnableEeschemaPrintCairo = true;
m_EnableEeschemaExportClipboardCairo = true;
@ -512,6 +514,9 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::EnableLibDir,
&m_EnableLibDir, m_EnableLibDir ) );
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::LibraryTableEditor,
&m_LibraryTableEditor, m_LibraryTableEditor ) );
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::EnableEeschemaPrintCairo,
&m_EnableEeschemaPrintCairo,
m_EnableEeschemaPrintCairo ) );

32
eeschema/dialogs/dialog_lib_fields.cpp

@ -104,13 +104,13 @@ protected:
clearMenu->Enable( !m_dataModel->IsCellClear( row, col ) );
createDerivedSymbolMenu->Enable( m_dataModel->IsRowSingleSymbol( row ) );
if( m_dataModel->GetColFieldName( col ) == GetCanonicalFieldName( FIELD_T::FOOTPRINT ) )
if( m_dataModel->GetColFieldName( col ) == GetCanonicalFieldName( FOOTPRINT_FIELD) )
{
menu.Append( MYID_SELECT_FOOTPRINT, _( "Select Footprint..." ),
_( "Browse for footprint" ) );
menu.AppendSeparator();
}
else if( m_dataModel->GetColFieldName( col ) == GetCanonicalFieldName( FIELD_T::DATASHEET ) )
else if( m_dataModel->GetColFieldName( col ) == GetCanonicalFieldName( DATASHEET_FIELD) )
{
menu.Append( MYID_SHOW_DATASHEET, _( "Show Datasheet" ),
_( "Show datasheet in browser" ) );
@ -414,7 +414,7 @@ void DIALOG_LIB_FIELDS::loadSymbols( const wxArrayString& aSymbolNames )
try
{
symbol = m_parent->GetLibManager().GetSymbol( symbolName, m_libId );
symbol = m_parent->GetLibManager().GetAlias( symbolName, m_libId );
if( symbol )
m_symbolsList.push_back( symbol );
@ -621,10 +621,10 @@ void DIALOG_LIB_FIELDS::OnFieldsCtrlSelectionChanged(wxDataViewEvent& event)
if( enable )
{
wxString fieldName = m_fieldsCtrl->GetTextValue( row, FIELD_NAME_COLUMN );
if( fieldName == GetCanonicalFieldName( FIELD_T::REFERENCE ) ||
fieldName == GetCanonicalFieldName( FIELD_T::VALUE ) ||
fieldName == GetCanonicalFieldName( FIELD_T::FOOTPRINT ) ||
fieldName == GetCanonicalFieldName( FIELD_T::DATASHEET ) )
if( fieldName == GetCanonicalFieldName( REFERENCE_FIELD) ||
fieldName == GetCanonicalFieldName( VALUE_FIELD) ||
fieldName == GetCanonicalFieldName( FOOTPRINT_FIELD) ||
fieldName == GetCanonicalFieldName( DATASHEET_FIELD) )
{
enable = false;
}
@ -886,18 +886,18 @@ void DIALOG_LIB_FIELDS::OnApply(wxCommandEvent& event)
void DIALOG_LIB_FIELDS::UpdateFieldList()
{
auto addMandatoryField =
[&]( FIELD_T fieldId, bool show, bool groupBy )
[&]( int fieldId, bool show, bool groupBy )
{
AddField( GetCanonicalFieldName( fieldId ),
GetDefaultFieldName( fieldId, DO_TRANSLATE ), show, groupBy );
};
// Add mandatory fields first show groupBy
addMandatoryField( FIELD_T::REFERENCE, false, false );
addMandatoryField( FIELD_T::VALUE, true, false );
addMandatoryField( FIELD_T::FOOTPRINT, true, false );
addMandatoryField( FIELD_T::DATASHEET, true, false );
addMandatoryField( FIELD_T::DESCRIPTION, false, false );
addMandatoryField( REFERENCE_FIELD, false, false );
addMandatoryField( VALUE_FIELD, true, false );
addMandatoryField( FOOTPRINT_FIELD, true, false );
addMandatoryField( DATASHEET_FIELD, true, false );
addMandatoryField( DESCRIPTION_FIELD, false, false );
AddField( wxS( "Keywords" ), _( "Keywords" ), true, false );
@ -1063,7 +1063,7 @@ void DIALOG_LIB_FIELDS::SetupColumnProperties( int aCol )
attr->SetReadOnly( false );
// Set some column types to specific editors
if( m_dataModel->GetColFieldName( aCol ) == GetCanonicalFieldName( FIELD_T::FOOTPRINT ) )
if( m_dataModel->GetColFieldName( aCol ) == GetCanonicalFieldName( FOOTPRINT_FIELD) )
{
// Create symbol netlist for footprint picker
wxString symbolNetlist;
@ -1091,7 +1091,7 @@ void DIALOG_LIB_FIELDS::SetupColumnProperties( int aCol )
attr->SetEditor( new GRID_CELL_FPID_EDITOR( this, symbolNetlist ) );
m_dataModel->SetColAttr( attr, aCol );
}
else if( m_dataModel->GetColFieldName( aCol ) == GetCanonicalFieldName( FIELD_T::DATASHEET ) )
else if( m_dataModel->GetColFieldName( aCol ) == GetCanonicalFieldName( DATASHEET_FIELD) )
{
// set datasheet column viewer button
attr->SetEditor( new GRID_CELL_URL_EDITOR( this, PROJECT_SCH::SchSearchS( &Prj() ) ) );
@ -1127,7 +1127,7 @@ void DIALOG_LIB_FIELDS::SetupAllColumnProperties()
bool sortAscending = true;
// Find the VALUE column for initial sorting
int valueCol = m_dataModel->GetFieldNameCol( GetCanonicalFieldName( FIELD_T::VALUE ) );
int valueCol = m_dataModel->GetFieldNameCol( GetCanonicalFieldName( VALUE_FIELD) );
// Set initial sort to VALUE field (ascending) if no previous sort preference exists
if( m_dataModel->GetSortCol() == 0 && valueCol != -1 )

32
eeschema/lib_fields_data_model.cpp

@ -64,7 +64,7 @@ void LIB_FIELDS_EDITOR_GRID_DATA_MODEL::updateDataStoreSymbolField( const LIB_SY
dataElement.m_currentlyEmpty = false;
dataElement.m_isModified = false;
}
else if( const SCH_FIELD* field = aSymbol->GetField( aFieldName ) )
else if( const SCH_FIELD* field = aSymbol->FindField( aFieldName ) )
{
dataElement.m_originalData = field->GetText();
dataElement.m_currentData = field->GetText();
@ -575,7 +575,7 @@ void LIB_FIELDS_EDITOR_GRID_DATA_MODEL::ClearCell( int aRow, int aCol )
bool LIB_FIELDS_EDITOR_GRID_DATA_MODEL::ColIsValue( int aCol )
{
wxCHECK( aCol >= 0 && aCol < static_cast<int>( m_cols.size() ), false );
return m_cols[aCol].m_fieldName == GetCanonicalFieldName( FIELD_T::VALUE );
return m_cols[aCol].m_fieldName == GetCanonicalFieldName( VALUE_FIELD);
}
@ -703,10 +703,6 @@ wxString LIB_FIELDS_EDITOR_GRID_DATA_MODEL::getAttributeValue( const LIB_SYMBOL*
if( aAttributeName == wxS( "Power" ) )
return aSymbol->IsPower() ? wxS( "1" ) : wxS( "0" );
if( aAttributeName == wxS( "LocalPower" ) )
return aSymbol->IsLocalPower() ? wxS( "1" ) : wxS( "0" );
return wxS( "0" );
}
@ -722,20 +718,12 @@ void LIB_FIELDS_EDITOR_GRID_DATA_MODEL::setAttributeValue( LIB_SYMBOL* aSymbol,
aSymbol->SetExcludedFromBOM( aValue == wxS( "1" ) );
else if( aAttributeName == wxS( "${EXCLUDE_FROM_SIM}" ) )
aSymbol->SetExcludedFromSim( aValue == wxS( "1" ) );
else if( aAttributeName == wxS( "LocalPower" ) )
{
// Turning off local power still leaves the global flag set
if( aValue == wxS( "0" ) )
aSymbol->SetGlobalPower();
else
aSymbol->SetLocalPower();
}
else if( aAttributeName == wxS( "Power" ) )
{
if( aValue == wxS( "0" ) )
aSymbol->SetNormal();
else
aSymbol->SetGlobalPower();
aSymbol->SetPower();
}
else
wxLogDebug( "Unknown attribute name: %s", aAttributeName );
@ -923,7 +911,7 @@ void LIB_FIELDS_EDITOR_GRID_DATA_MODEL::ApplyData(
if( srcName.StartsWith( "__DERIVED_SYMBOL_" ) && srcName.EndsWith( "__" ) )
continue;
SCH_FIELD* destField = symbol->GetField( srcName );
SCH_FIELD* destField = symbol->FindField( srcName );
bool userAdded = ( col != -1 && m_cols[col].m_userAdded );
// Add a not existing field if it has a value for this symbol
@ -932,7 +920,7 @@ void LIB_FIELDS_EDITOR_GRID_DATA_MODEL::ApplyData(
if( createField )
{
const VECTOR2I symbolPos = symbol->GetPosition();
destField = new SCH_FIELD( symbol, FIELD_T::USER, srcName );
destField = new SCH_FIELD( symbol, -1, srcName );
destField->SetPosition( symbolPos );
symbol->AddField( destField );
}
@ -940,19 +928,19 @@ void LIB_FIELDS_EDITOR_GRID_DATA_MODEL::ApplyData(
if( !destField )
continue;
if( destField->GetId() == FIELD_T::REFERENCE )
if( destField->GetId() == REFERENCE_FIELD )
{
// Reference is not editable from this dialog
}
else if( destField->GetId() == FIELD_T::VALUE )
else if( destField->GetId() == VALUE_FIELD )
{
// Value field cannot be empty
if( !srcValue.IsEmpty() )
symbol->GetField( FIELD_T::VALUE )->SetText( srcValue );
symbol->GetFieldById( VALUE_FIELD )->SetText( srcValue );
}
else if( destField->GetId() == FIELD_T::FOOTPRINT )
else if( destField->GetId() == FOOTPRINT_FIELD )
{
symbol->GetField(FIELD_T::FOOTPRINT)->SetText( srcValue );
symbol->GetFieldById( FOOTPRINT_FIELD )->SetText( srcValue );
}
else
{

5
eeschema/tools/symbol_editor_control.cpp

@ -217,7 +217,10 @@ bool SYMBOL_EDITOR_CONTROL::Init()
ctxMenu.AddItem( ACTIONS::openDirectory, canOpenExternally && ( symbolSelectedCondition || libSelectedCondition ), 200 );
}
ctxMenu.AddItem( ACTIONS::showLibraryTable, librarySelectedCondition, 300 );
if( ADVANCED_CFG::GetCfg().m_LibraryTableEditor )
{
ctxMenu.AddItem( ACTIONS::showLibraryTable, librarySelectedCondition, 300 );
}
libraryTreeTool->AddContextMenuItems( &ctxMenu );
}

9
include/advanced_config.h

@ -515,6 +515,15 @@ public:
*/
bool m_EnableLibDir;
/**
* Enable library table editor in the context menu.
*
* Setting name: "LibraryTableEditor"
* Valid values: true or false
* Default value: false
*/
bool m_LibraryTableEditor;
/**
* Enable Eeschema printing using Cairo.
*

1
include/widgets/grid_text_button_helpers.h

@ -27,6 +27,7 @@
#include <memory>
#include <search_stack.h>
#include <wx/combo.h>
#include <wx/generic/gridctrl.h>
#include <wx/generic/grideditors.h>

2
pcbnew/generate_footprint_info.cpp

@ -47,7 +47,7 @@ static const wxString DocFormat = wxT(
std::optional<wxString> GetFootprintDocumentationURL( const FOOTPRINT& aFootprint )
{
// Footprints have now a field (FIELD_T::DATASHEET) containing the url datasheet
// Footprints have now a field (DATASHEET)_FIELDcontaining the url datasheet
// But old footprints did not have this field, so this fiels can be empty.
// So we use this field is not empty, and if empty see if the documentation has an URL
const PCB_FIELD* data_field = aFootprint.GetField( DATASHEET_FIELD );

Loading…
Cancel
Save