Formatting (and auto reduction).
This commit is contained in:
parent
5449a92878
commit
de49f5090d
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2010-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2012-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2012-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -31,7 +31,7 @@
|
|||
#include <lib_table_base.h>
|
||||
#include <lib_table_lexer.h>
|
||||
#include <macros.h>
|
||||
|
||||
#include <string_utils.h>
|
||||
|
||||
#define OPT_SEP '|' ///< options separator character
|
||||
|
||||
|
@ -87,9 +87,7 @@ void LIB_TABLE_ROW::Format( OUTPUTFORMATTER* out, int nestLevel ) const
|
|||
wxString extraOptions;
|
||||
|
||||
if( !GetIsEnabled() )
|
||||
{
|
||||
extraOptions += "(disabled)";
|
||||
}
|
||||
|
||||
out->Print( nestLevel, "(lib (name %s)(type %s)(uri %s)(options %s)(descr %s)%s)\n",
|
||||
out->Quotew( GetNickName() ).c_str(),
|
||||
|
@ -97,8 +95,7 @@ void LIB_TABLE_ROW::Format( OUTPUTFORMATTER* out, int nestLevel ) const
|
|||
out->Quotew( uri ).c_str(),
|
||||
out->Quotew( GetOptions() ).c_str(),
|
||||
out->Quotew( GetDescr() ).c_str(),
|
||||
extraOptions.ToStdString().c_str()
|
||||
);
|
||||
extraOptions.ToStdString().c_str() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -196,7 +193,7 @@ LIB_TABLE_ROW* LIB_TABLE::findRow( const wxString& aNickName, bool aCheckIfEnabl
|
|||
{
|
||||
row = &cur->rows[entry.second];
|
||||
|
||||
if( !aCheckIfEnabled || ( aCheckIfEnabled && row->GetIsEnabled() ) )
|
||||
if( !aCheckIfEnabled || row->GetIsEnabled() )
|
||||
return row;
|
||||
}
|
||||
}
|
||||
|
@ -212,7 +209,7 @@ LIB_TABLE_ROW* LIB_TABLE::findRow( const wxString& aNickName, bool aCheckIfEnabl
|
|||
{
|
||||
row = &cur->rows[entry.second];
|
||||
|
||||
if( !aCheckIfEnabled || ( aCheckIfEnabled && row->GetIsEnabled() ) )
|
||||
if( !aCheckIfEnabled || row->GetIsEnabled() )
|
||||
return row;
|
||||
}
|
||||
}
|
||||
|
@ -262,22 +259,19 @@ const LIB_TABLE_ROW* LIB_TABLE::FindRowByURI( const wxString& aURI )
|
|||
|
||||
std::vector<wxString> LIB_TABLE::GetLogicalLibs()
|
||||
{
|
||||
// Only return unique logical library names. Use std::set::insert() to
|
||||
// quietly reject any duplicates, which can happen when encountering a duplicate
|
||||
// nickname from one of the fall back table(s).
|
||||
// Only return unique logical library names. Use std::set::insert() to quietly reject any
|
||||
// duplicates (usually due to encountering a duplicate nickname in a fallback table).
|
||||
|
||||
std::set< wxString > unique;
|
||||
std::vector< wxString > ret;
|
||||
const LIB_TABLE* cur = this;
|
||||
std::set<wxString> unique;
|
||||
std::vector<wxString> ret;
|
||||
const LIB_TABLE* cur = this;
|
||||
|
||||
do
|
||||
{
|
||||
for( LIB_TABLE_ROWS_CITER it = cur->rows.begin(); it!=cur->rows.end(); ++it )
|
||||
{
|
||||
if( it->GetIsEnabled() )
|
||||
{
|
||||
unique.insert( it->GetNickName() );
|
||||
}
|
||||
}
|
||||
|
||||
} while( ( cur = cur->fallBack ) != nullptr );
|
||||
|
@ -286,9 +280,7 @@ std::vector<wxString> LIB_TABLE::GetLogicalLibs()
|
|||
|
||||
// return a sorted, unique set of nicknames in a std::vector<wxString> to caller
|
||||
for( std::set< wxString >::const_iterator it = unique.begin(); it!=unique.end(); ++it )
|
||||
{
|
||||
ret.push_back( *it );
|
||||
}
|
||||
|
||||
// We want to allow case-sensitive duplicates but sort by case-insensitive ordering
|
||||
std::sort( ret.begin(), ret.end(),
|
||||
|
@ -327,13 +319,12 @@ bool LIB_TABLE::InsertRow( LIB_TABLE_ROW* aRow, bool doReplace )
|
|||
|
||||
|
||||
void LIB_TABLE::Load( const wxString& aFileName )
|
||||
|
||||
{
|
||||
// It's OK if footprint library tables are missing.
|
||||
if( wxFileName::IsFileReadable( aFileName ) )
|
||||
{
|
||||
FILE_LINE_READER reader( aFileName );
|
||||
LIB_TABLE_LEXER lexer( &reader );
|
||||
FILE_LINE_READER reader( aFileName );
|
||||
LIB_TABLE_LEXER lexer( &reader );
|
||||
|
||||
Parse( &lexer );
|
||||
}
|
||||
|
@ -380,7 +371,9 @@ PROPERTIES* LIB_TABLE::ParseOptions( const std::string& aOptionsList )
|
|||
break; // process the pair
|
||||
}
|
||||
else
|
||||
{
|
||||
pair += *cp++;
|
||||
}
|
||||
}
|
||||
|
||||
// stash the pair
|
||||
|
@ -396,7 +389,9 @@ PROPERTIES* LIB_TABLE::ParseOptions( const std::string& aOptionsList )
|
|||
props[name] = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
props[pair] = ""; // property is present, but with no value.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -189,8 +189,8 @@ void SYMBOL_TREE_SYNCHRONIZING_ADAPTER::updateLibrary( LIB_TREE_NODE_LIB& aLibNo
|
|||
}
|
||||
|
||||
|
||||
LIB_TREE_NODE::PTR_VECTOR::iterator SYMBOL_TREE_SYNCHRONIZING_ADAPTER::deleteLibrary(
|
||||
LIB_TREE_NODE::PTR_VECTOR::iterator& aLibNodeIt )
|
||||
LIB_TREE_NODE::PTR_VECTOR::iterator
|
||||
SYMBOL_TREE_SYNCHRONIZING_ADAPTER::deleteLibrary( LIB_TREE_NODE::PTR_VECTOR::iterator& aLibNodeIt )
|
||||
{
|
||||
LIB_TREE_NODE* node = aLibNodeIt->get();
|
||||
m_libHashes.erase( node->m_Name );
|
||||
|
|
|
@ -76,7 +76,7 @@ void FP_TREE_SYNCHRONIZING_ADAPTER::Sync()
|
|||
// Remove the library if it no longer exists or it exists in both the global and the
|
||||
// project library but the project library entry is disabled.
|
||||
if( !m_libs->HasLibrary( name, true )
|
||||
|| ( m_libs->FindRow( name, true ) != m_libs->FindRow( name, false ) ) )
|
||||
|| m_libs->FindRow( name, true ) != m_libs->FindRow( name, false ) )
|
||||
{
|
||||
it = deleteLibrary( it );
|
||||
continue;
|
||||
|
@ -89,7 +89,7 @@ void FP_TREE_SYNCHRONIZING_ADAPTER::Sync()
|
|||
// Look for new libraries
|
||||
size_t count = m_libMap.size();
|
||||
|
||||
for( const auto& libName : m_libs->GetLogicalLibs() )
|
||||
for( const wxString& libName : m_libs->GetLogicalLibs() )
|
||||
{
|
||||
if( m_libMap.count( libName ) == 0 )
|
||||
{
|
||||
|
@ -122,10 +122,10 @@ void FP_TREE_SYNCHRONIZING_ADAPTER::updateLibrary( LIB_TREE_NODE_LIB& aLibNode )
|
|||
// libraries with lots of footprints.
|
||||
FOOTPRINT_INFO_IMPL dummy( wxEmptyString, (*nodeIt)->m_Name );
|
||||
auto footprintIt = std::lower_bound( footprints.begin(), footprints.end(), &dummy,
|
||||
[]( LIB_TREE_ITEM* a, LIB_TREE_ITEM* b )
|
||||
{
|
||||
return StrNumCmp( a->GetName(), b->GetName(), false ) < 0;
|
||||
} );
|
||||
[]( LIB_TREE_ITEM* a, LIB_TREE_ITEM* b )
|
||||
{
|
||||
return StrNumCmp( a->GetName(), b->GetName(), false ) < 0;
|
||||
} );
|
||||
|
||||
if( footprintIt != footprints.end() && dummy.GetName() == (*footprintIt)->GetName() )
|
||||
{
|
||||
|
@ -143,7 +143,7 @@ void FP_TREE_SYNCHRONIZING_ADAPTER::updateLibrary( LIB_TREE_NODE_LIB& aLibNode )
|
|||
}
|
||||
|
||||
// now the footprint list contains only new aliases that need to be added to the tree
|
||||
for( auto footprint : footprints )
|
||||
for( LIB_TREE_ITEM* footprint : footprints )
|
||||
aLibNode.AddItem( footprint );
|
||||
|
||||
aLibNode.AssignIntrinsicRanks();
|
||||
|
@ -151,8 +151,8 @@ void FP_TREE_SYNCHRONIZING_ADAPTER::updateLibrary( LIB_TREE_NODE_LIB& aLibNode )
|
|||
}
|
||||
|
||||
|
||||
LIB_TREE_NODE::PTR_VECTOR::iterator FP_TREE_SYNCHRONIZING_ADAPTER::deleteLibrary(
|
||||
LIB_TREE_NODE::PTR_VECTOR::iterator& aLibNodeIt )
|
||||
LIB_TREE_NODE::PTR_VECTOR::iterator
|
||||
FP_TREE_SYNCHRONIZING_ADAPTER::deleteLibrary( LIB_TREE_NODE::PTR_VECTOR::iterator& aLibNodeIt )
|
||||
{
|
||||
LIB_TREE_NODE* node = aLibNodeIt->get();
|
||||
m_libMap.erase( node->m_Name );
|
||||
|
@ -170,7 +170,7 @@ void FP_TREE_SYNCHRONIZING_ADAPTER::GetValue( wxVariant& aVariant, wxDataViewIte
|
|||
return;
|
||||
}
|
||||
|
||||
auto node = ToNode( aItem );
|
||||
LIB_TREE_NODE* node = ToNode( aItem );
|
||||
|
||||
switch( aCol )
|
||||
{
|
||||
|
@ -186,9 +186,14 @@ void FP_TREE_SYNCHRONIZING_ADAPTER::GetValue( wxVariant& aVariant, wxDataViewIte
|
|||
aVariant = node->m_Name;
|
||||
}
|
||||
else if( node->m_Pinned )
|
||||
{
|
||||
aVariant = GetPinningSymbol() + node->m_Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
aVariant = node->m_Name;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 1:
|
||||
|
@ -235,7 +240,7 @@ bool FP_TREE_SYNCHRONIZING_ADAPTER::GetAttr( wxDataViewItem const& aItem, unsign
|
|||
if( m_frame->IsCurrentFPFromBoard() )
|
||||
return false;
|
||||
|
||||
auto node = ToNode( aItem );
|
||||
LIB_TREE_NODE* node = ToNode( aItem );
|
||||
wxCHECK( node, false );
|
||||
|
||||
switch( node->m_Type )
|
||||
|
|
Loading…
Reference in New Issue