diff --git a/common/lib_table.keywords b/common/lib_table.keywords index feeea0e924..fd679ffa61 100644 --- a/common/lib_table.keywords +++ b/common/lib_table.keywords @@ -6,3 +6,4 @@ type uri options descr +disabled \ No newline at end of file diff --git a/common/lib_table_base.cpp b/common/lib_table_base.cpp index 99e0fc11ed..8c3e46f460 100644 --- a/common/lib_table_base.cpp +++ b/common/lib_table_base.cpp @@ -87,12 +87,20 @@ void LIB_TABLE_ROW::Format( OUTPUTFORMATTER* out, int nestLevel ) const wxString uri = GetFullURI(); uri.Replace( '\\', '/' ); - out->Print( nestLevel, "(lib (name %s)(type %s)(uri %s)(options %s)(descr %s))\n", + 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(), out->Quotew( GetType() ).c_str(), out->Quotew( uri ).c_str(), out->Quotew( GetOptions() ).c_str(), - out->Quotew( GetDescr() ).c_str() + out->Quotew( GetDescr() ).c_str(), + extraOptions.ToStdString().c_str() ); } diff --git a/eeschema/symbol_lib_table.cpp b/eeschema/symbol_lib_table.cpp index 2a573f827b..07ef7c3272 100644 --- a/eeschema/symbol_lib_table.cpp +++ b/eeschema/symbol_lib_table.cpp @@ -124,10 +124,11 @@ void SYMBOL_LIB_TABLE::Parse( LIB_TABLE_LEXER* in ) // After (name), remaining (lib) elements are order independent, and in // some cases optional. - bool sawType = false; - bool sawOpts = false; - bool sawDesc = false; - bool sawUri = false; + bool sawType = false; + bool sawOpts = false; + bool sawDesc = false; + bool sawUri = false; + bool sawDisabled = false; while( ( tok = in->NextTok() ) != T_RIGHT ) { @@ -173,6 +174,13 @@ void SYMBOL_LIB_TABLE::Parse( LIB_TABLE_LEXER* in ) row->SetDescr( in->FromUTF8() ); break; + case T_disabled: + if( sawDisabled ) + in->Duplicate( tok ); + sawDisabled = true; + row->SetEnabled( false ); + break; + default: in->Unexpected( tok ); } @@ -219,7 +227,9 @@ void SYMBOL_LIB_TABLE::Format( OUTPUTFORMATTER* aOutput, int aIndentLevel ) cons aOutput->Print( aIndentLevel, "(sym_lib_table\n" ); for( LIB_TABLE_ROWS_CITER it = rows.begin(); it != rows.end(); ++it ) + { it->Format( aOutput, aIndentLevel+1 ); + } aOutput->Print( aIndentLevel, ")\n" ); } diff --git a/eeschema/symbol_lib_table.h b/eeschema/symbol_lib_table.h index 1d811c1b19..a2244bafd9 100644 --- a/eeschema/symbol_lib_table.h +++ b/eeschema/symbol_lib_table.h @@ -51,11 +51,13 @@ public: LIB_TABLE_ROW( aNick, aURI, aOptions, aDescr ) { SetType( aType ); + SetEnabled( true ); } SYMBOL_LIB_TABLE_ROW() : type( SCH_IO_MGR::SCH_LEGACY ) { + SetEnabled( true ); } bool operator==( const SYMBOL_LIB_TABLE_ROW& aRow ) const; @@ -77,6 +79,7 @@ protected: LIB_TABLE_ROW( aRow ), type( aRow.type ) { + SetEnabled( aRow.GetIsEnabled() ); } private: diff --git a/include/lib_table_base.h b/include/lib_table_base.h index c8c3e844cd..20433ada3b 100644 --- a/include/lib_table_base.h +++ b/include/lib_table_base.h @@ -78,7 +78,8 @@ public: LIB_TABLE_ROW( const wxString& aNick, const wxString& aURI, const wxString& aOptions, const wxString& aDescr = wxEmptyString ) : nickName( aNick ), - description( aDescr ) + description( aDescr ), + enabled( true ) { properties.reset(); SetOptions( aOptions ); @@ -99,6 +100,16 @@ public: */ void SetNickName( const wxString& aNickName ) { nickName = aNickName; } + /** + * @return the enabled status of this library row + */ + bool GetIsEnabled() const { return enabled; } + + /** + * Change the enabled status of this library + */ + void SetEnabled( bool aEnabled = true ) { enabled = aEnabled; } + /** * Return the type of library represented by this row. */ @@ -175,7 +186,8 @@ protected: uri_expanded( aRow.uri_expanded ), #endif options( aRow.options ), - description( aRow.description ) + description( aRow.description ), + enabled( aRow.enabled ) { if( aRow.properties ) properties.reset( new PROPERTIES( *aRow.properties.get() ) ); @@ -200,6 +212,8 @@ private: wxString options; wxString description; + bool enabled = true; ///< Whether the LIB_TABLE_ROW is enabled + std::unique_ptr< PROPERTIES > properties; };