Wayne, I have recreated the patch set once again, and there is no reference to "printf" in any of these patch files.
Please apply with the --ignore-whitepace flag, the file /include/lib_table_grid.h is full of MS-DOS line endings and I believe this is the cause. Patch set attached, hopefully works this time! Thanks, Oliver On Tue, Nov 21, 2017 at 10:02 AM, Oliver Walters < oliver.henry.walt...@gmail.com> wrote: > Wayne, > > Ok, apologies I thought I had addressed that (I haven't had a chance to go > back and look at these patches). I'll do so tonight. > > On Tue, Nov 21, 2017 at 10:00 AM, Wayne Stambaugh <stambau...@gmail.com> > wrote: > >> I looked at patches 3-6 and I didn't see where the printf was removed. >> >> On 11/20/2017 05:47 PM, Oliver Walters wrote: >> > The printf() statement should be removed in one of the subsequent >> > patches, as should the removal of that line. I'm unable to check this >> > right now, are you able to confirm if one of the later patches fixes >> > this problem? >> > >> > On Tue, Nov 21, 2017 at 9:44 AM, Wayne Stambaugh <stambau...@gmail.com >> > <mailto:stambau...@gmail.com>> wrote: >> > >> > I made a change to fix a bug with the default plugin type when >> appending >> > a new row to the table which caused the conflict. This where I >> noticed >> > the printf() debugging statement. I also noticed that it appears >> that >> > you removed a scroll to row call and I'm not sure how to reconcile >> the >> > conflict. Did you remove the scroll to row call on purpose or >> wasn't it >> > necessary. I don't want to break that behavior. >> > >> > On 11/20/2017 04:29 PM, Oliver Walters wrote: >> > > Wayne, >> > > >> > > I think it is a whitespace issue, does it apply if you add >> > > --ignore-whitespace to git-am ? >> > > >> > > On Tue, Nov 21, 2017 at 1:03 AM, Wayne Stambaugh < >> stambau...@gmail.com <mailto:stambau...@gmail.com> >> > > <mailto:stambau...@gmail.com <mailto:stambau...@gmail.com>>> >> wrote: >> > > >> > > Oliver, >> > > >> > > No go yet again. It looks like my commit 8b2b1381 is causing >> a conflict >> > > with patch 2 so please rebase your patches. I also noticed a >> printf() >> > > debugging statement in patch 2. Please remove this and make >> sure there >> > > are not any other printf() statements in your patches. Sorry >> about >> > > asking you to fix these issues but I really don't have the >> time to fix >> > > patches right now. >> > > >> > > Cheers, >> > > >> > > Wayne >> > > >> > > On 11/20/2017 1:20 AM, Oliver Walters wrote: >> > > > Wayne, >> > > > >> > > > I'm at a loss too. git am fails on 0002 but git apply works >> fine on each >> > > > individual patch. >> > > > >> > > > On Mon, Nov 20, 2017 at 3:29 AM, Wayne Stambaugh < >> stambau...@gmail.com <mailto:stambau...@gmail.com> >> > <mailto:stambau...@gmail.com <mailto:stambau...@gmail.com>> >> > > > <mailto:stambau...@gmail.com <mailto:stambau...@gmail.com> >> > <mailto:stambau...@gmail.com <mailto:stambau...@gmail.com>>>> >> wrote: >> > > > >> > > > Oliver, >> > > > >> > > > Still no luck. Did you possible do something to mess >> up the >> > > commit >> > > > ordering? I am applying these patches on top a clean >> master >> > > branch so >> > > > I'm not sure what is going on here. I'm getting the >> > following >> > > error >> > > > from `git am` when I attempt to merge patch 2: >> > > > >> > > > Applying: Toggle LIB_TABLE_ROW enabled/disabled in grid >> > editor >> > > > error: patch failed: >> > eeschema/dialogs/dialog_sym_lib_table.cpp:350 >> > > > error: eeschema/dialogs/dialog_sym_lib_table.cpp: >> patch does >> > > not apply >> > > > error: patch failed: include/lib_table_grid.h:32 >> > > > error: include/lib_table_grid.h: patch does not apply >> > > > Patch failed at 0001 Toggle LIB_TABLE_ROW >> > enabled/disabled in grid >> > > > editor >> > > > The copy of the patch that failed is found in: >> > > .git/rebase-apply/patch >> > > > When you have resolved this problem, run "git am >> > --continue". >> > > > If you prefer to skip this patch, run "git am --skip" >> > instead. >> > > > To restore the original branch and stop patching, run >> > "git am >> > > --abort". >> > > > >> > > > If any one has any ideas, I'm open to suggestion. If >> these >> > > patches were >> > > > generated properly, there should be no issues applying >> them. >> > > > >> > > > Cheers, >> > > > >> > > > Wayne >> > > > >> > > > On 11/18/2017 07:11 PM, Oliver Walters wrote: >> > > > > Wayne >> > > > > >> > > > > Please find updated patch set attached. I have >> rebased and >> > > built from >> > > > > commit b6884d and it all works fine. >> > > > > >> > > > > Thanks >> > > > > >> > > > > On Sun, Nov 19, 2017 at 4:42 AM, Wayne Stambaugh >> > > <stambau...@gmail.com <mailto:stambau...@gmail.com> >> > <mailto:stambau...@gmail.com <mailto:stambau...@gmail.com>> >> > > <mailto:stambau...@gmail.com <mailto:stambau...@gmail.com> >> > <mailto:stambau...@gmail.com <mailto:stambau...@gmail.com>>> >> > > > > <mailto:stambau...@gmail.com >> > <mailto:stambau...@gmail.com> <mailto:stambau...@gmail.com >> > <mailto:stambau...@gmail.com>> >> > > <mailto:stambau...@gmail.com <mailto:stambau...@gmail.com> >> > <mailto:stambau...@gmail.com <mailto:stambau...@gmail.com>>>>> >> wrote: >> > > > > >> > > > > Oliver, >> > > > > >> > > > > I just tried to apply your patches and ran into >> some >> > > issues. >> > > > Patch 1 >> > > > > applies but patch 2 fails. Would you please >> > rebase your >> > > > patches so I >> > > > > can get them merged as soon as possible. >> > > > > >> > > > > Thanks, >> > > > > >> > > > > Wayne >> > > > > >> > > > > On 11/15/2017 06:41 AM, Oliver Walters wrote: >> > > > > > Wayne, et al, >> > > > > > >> > > > > > I am really liking the way that the new symbol >> table >> > > works! >> > > > Thanks for >> > > > > > the huge effort that has gone into this. >> > > > > > >> > > > > > One thing that I have noticed is that when >> > opening (for >> > > > e.g.) the >> > > > > > component chooser, the UI hangs while all the >> > libraries >> > > > load. Previously >> > > > > > there was a progress dialog which at least >> informed >> > > the user >> > > > what was >> > > > > > going on. >> > > > > > >> > > > > > I have re-implemented this dialog in the >> attached >> > > patch set. >> > > > > > >> > > > > > Further, I have also implemented a way to >> > individually >> > > > enable / disable >> > > > > > each row in the library tables (this works for >> > SYMBOL_LIB >> > > > and FP_LIB). >> > > > > > >> > > > > > This is based on the idea by Tomasz. Example >> > > screenshot below: >> > > > > > >> > > > > > Inline image 1 >> > > > > > >> > > > > > I have tweaked the base LIB_TABLE_GRID code such >> > that >> > > > disabled entries >> > > > > > are greyed out and made italic. The enabled / >> > disabled >> > > status is >> > > > > > persistent in the sym/fp_lib_table files. Older >> > version of >> > > > xxx_lib_table >> > > > > > files are read with all rows enabled by default. >> > > > > > >> > > > > > Please find patch set attached. >> > > > > > >> > > > > > Regards, >> > > > > > Oliver >> > > > > > >> > > > > > >> > > > > > >> > > > > > _______________________________________________ >> > > > > > Mailing list: >> > https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers> >> > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers>> >> > > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers> >> > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers>>> >> > > > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers> >> > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers>> >> > > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers> >> > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers>>>> >> > > > > > Post to : >> > kicad-developers@lists.launchpad.net >> > <mailto:kicad-developers@lists.launchpad.net> >> > > <mailto:kicad-developers@lists.launchpad.net >> > <mailto:kicad-developers@lists.launchpad.net>> >> > > > <mailto:kicad-developers@lists.launchpad.net >> > <mailto:kicad-developers@lists.launchpad.net> >> > > <mailto:kicad-developers@lists.launchpad.net >> > <mailto:kicad-developers@lists.launchpad.net>>> >> > > > > <mailto:kicad-developers@lists.launchpad.net >> > <mailto:kicad-developers@lists.launchpad.net> >> > > <mailto:kicad-developers@lists.launchpad.net >> > <mailto:kicad-developers@lists.launchpad.net>> >> > > > <mailto:kicad-developers@lists.launchpad.net >> > <mailto:kicad-developers@lists.launchpad.net> >> > > <mailto:kicad-developers@lists.launchpad.net >> > <mailto:kicad-developers@lists.launchpad.net>>>> >> > > > > > Unsubscribe : >> > https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers> >> > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers>> >> > > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers> >> > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers>>> >> > > > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers> >> > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers>> >> > > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers> >> > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers>>>> >> > > > > > More help : >> > https://help.launchpad.net/ListHelp >> > <https://help.launchpad.net/ListHelp> >> > > <https://help.launchpad.net/ListHelp >> > <https://help.launchpad.net/ListHelp>> >> > > > <https://help.launchpad.net/ListHelp >> > <https://help.launchpad.net/ListHelp> >> > > <https://help.launchpad.net/ListHelp >> > <https://help.launchpad.net/ListHelp>>> >> > > > > <https://help.launchpad.net/ListHelp >> > <https://help.launchpad.net/ListHelp> >> > > <https://help.launchpad.net/ListHelp >> > <https://help.launchpad.net/ListHelp>> >> > > > <https://help.launchpad.net/ListHelp >> > <https://help.launchpad.net/ListHelp> >> > > <https://help.launchpad.net/ListHelp >> > <https://help.launchpad.net/ListHelp>>>> >> > > > > > >> > > > > >> > > > > _______________________________________________ >> > > > > Mailing list: >> > https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers> >> > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers>> >> > > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers> >> > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers>>> >> > > > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers> >> > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers>> >> > > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers> >> > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers>>>> >> > > > > Post to : kicad-developers@lists.launchp >> ad.net >> > <mailto:kicad-developers@lists.launchpad.net> >> > > <mailto:kicad-developers@lists.launchpad.net >> > <mailto:kicad-developers@lists.launchpad.net>> >> > > > <mailto:kicad-developers@lists.launchpad.net >> > <mailto:kicad-developers@lists.launchpad.net> >> > > <mailto:kicad-developers@lists.launchpad.net >> > <mailto:kicad-developers@lists.launchpad.net>>> >> > > > > <mailto:kicad-developers@lists.launchpad.net >> > <mailto:kicad-developers@lists.launchpad.net> >> > > <mailto:kicad-developers@lists.launchpad.net >> > <mailto:kicad-developers@lists.launchpad.net>> >> > > > <mailto:kicad-developers@lists.launchpad.net >> > <mailto:kicad-developers@lists.launchpad.net> >> > > <mailto:kicad-developers@lists.launchpad.net >> > <mailto:kicad-developers@lists.launchpad.net>>>> >> > > > > Unsubscribe : >> > https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers> >> > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers>> >> > > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers> >> > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers>>> >> > > > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers> >> > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers>> >> > > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers> >> > > <https://launchpad.net/~kicad-developers >> > <https://launchpad.net/~kicad-developers>>>> >> > > > > More help : https://help.launchpad.net/ListHelp >> > <https://help.launchpad.net/ListHelp> >> > > <https://help.launchpad.net/ListHelp >> > <https://help.launchpad.net/ListHelp>> >> > > > <https://help.launchpad.net/ListHelp >> > <https://help.launchpad.net/ListHelp> >> > > <https://help.launchpad.net/ListHelp >> > <https://help.launchpad.net/ListHelp>>> >> > > > > <https://help.launchpad.net/ListHelp >> > <https://help.launchpad.net/ListHelp> >> > > <https://help.launchpad.net/ListHelp >> > <https://help.launchpad.net/ListHelp>> >> > > > <https://help.launchpad.net/ListHelp >> > <https://help.launchpad.net/ListHelp> >> > > <https://help.launchpad.net/ListHelp >> > <https://help.launchpad.net/ListHelp>>>> >> > > > > >> > > > > >> > > > >> > > > >> > > >> > > >> > >> > >> > >
From 5c5e6ca2fa655148fea013c5609862e1f7e7c1b9 Mon Sep 17 00:00:00 2001 From: Oliver <oliver.henry.walt...@gmail.com> Date: Wed, 15 Nov 2017 22:32:23 +1100 Subject: [PATCH 6/6] Improved LIB_TABLE rendering - Moved "Active" to first column - Changed text attributes for disabled rows --- include/lib_table_grid.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/include/lib_table_grid.h b/include/lib_table_grid.h index c35c4f4..94726b5 100644 --- a/include/lib_table_grid.h +++ b/include/lib_table_grid.h @@ -24,15 +24,18 @@ #include <wx/grid.h> +const wxColour COLOUR_ROW_ENABLED( 0, 0, 0 ); +const wxColour COLOUR_ROW_DISABLED( 100, 100, 100 ); + /// The library table grid column order is established by this sequence. enum COL_ORDER { + COL_ENABLED, COL_NICKNAME, COL_URI, COL_TYPE, COL_OPTIONS, COL_DESCR, - COL_ENABLED, COL_COUNT // keep as last }; @@ -180,12 +183,53 @@ public: case COL_TYPE: return _( "Plugin Type" ); case COL_OPTIONS: return _( "Options" ); case COL_DESCR: return _( "Description" ); - case COL_ENABLED: return _( "Enabled" ); + case COL_ENABLED: return _( "Active" ); default: return wxEmptyString; } } + /** + * Customize the appearance of LIB_TABLE_ROW entries + * - If not enabled, greyed out and italic + */ + virtual wxGridCellAttr* GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind) override + { + auto* attr = wxGridTableBase::GetAttr( aRow, aCol, aKind ); + + if( aRow < (int) size() ) + { + if( !attr ) + { + attr = new wxGridCellAttr(); + } + + wxFont font; + + if( attr->HasFont() ) + { + font = attr->GetFont(); + } + + LIB_TABLE_ROW* r = at( (size_t) aRow ); + + if( r && r->GetIsEnabled() ) + { + font.SetStyle( wxFONTSTYLE_NORMAL ); + attr->SetTextColour( COLOUR_ROW_ENABLED ); + } + else + { + font.SetStyle( wxFONTSTYLE_ITALIC ); + attr->SetTextColour( COLOUR_ROW_DISABLED ); + } + + attr->SetFont( font ); + } + + return attr; + } + protected: virtual LIB_TABLE_ROW* at( size_t aIndex ) = 0; -- 2.7.4
From 78e27feadc7f91b1a5214da7eddf922c087aaf0a Mon Sep 17 00:00:00 2001 From: Oliver <oliver.henry.walt...@gmail.com> Date: Wed, 15 Nov 2017 21:48:38 +1100 Subject: [PATCH 5/6] Add progress dialog when loading symbol libraries - Provides UX feedback for user --- eeschema/cmp_tree_model_adapter.cpp | 22 +++++++++++++++++++++- eeschema/cmp_tree_model_adapter.h | 12 ++++++++++++ eeschema/getpart.cpp | 7 ++----- eeschema/viewlibs.cpp | 10 ++-------- 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/eeschema/cmp_tree_model_adapter.cpp b/eeschema/cmp_tree_model_adapter.cpp index d88119b..d9b8cd6 100644 --- a/eeschema/cmp_tree_model_adapter.cpp +++ b/eeschema/cmp_tree_model_adapter.cpp @@ -24,7 +24,7 @@ #include <eda_pattern_match.h> #include <wx/tokenzr.h> #include <symbol_lib_table.h> - +#include <wx/progdlg.h> CMP_TREE_MODEL_ADAPTER::WIDTH_CACHE CMP_TREE_MODEL_ADAPTER::m_width_cache; @@ -135,6 +135,26 @@ void CMP_TREE_MODEL_ADAPTER::AddLibrary( wxString const& aLibNickname ) } +void CMP_TREE_MODEL_ADAPTER::AddLibrariesWithProgress( const std::vector<wxString>& aNicknames, EDA_DRAW_FRAME* aParent ) +{ + auto* prg = new wxProgressDialog( + _( "Loading symbol libraries" ), + wxEmptyString, + aNicknames.size(), + aParent ); + + unsigned int ii = 0; + + for( auto nickname : aNicknames ) + { + prg->Update( ii++, wxString::Format( _( "Loading library '%s'" ), nickname ) ); + AddLibrary( nickname ); + } + + prg->Destroy(); +} + + void CMP_TREE_MODEL_ADAPTER::AddAliasList( wxString const& aNodeName, wxArrayString const& aAliasNameList ) diff --git a/eeschema/cmp_tree_model_adapter.h b/eeschema/cmp_tree_model_adapter.h index bb96d0b..06f6c68 100644 --- a/eeschema/cmp_tree_model_adapter.h +++ b/eeschema/cmp_tree_model_adapter.h @@ -24,6 +24,7 @@ #include <lib_id.h> +#include <draw_frame.h> #include <cmp_tree_model.h> #include <wx/hashmap.h> @@ -155,6 +156,17 @@ public: */ void AddLibrary( wxString const& aLibNickname ); + + /** + * Add all the libraries in a SYMBOL_LIB_TABLE to the model, + * displaying a progress dialog attached to the parent frame + * + * @param aNicknames is the list of library nicknames + * @param aParent is the parent window to display the progress dialog + */ + void AddLibrariesWithProgress( const std::vector<wxString>& aNicknames, EDA_DRAW_FRAME* aParent ); + + /** * Add the given list of components, by name. To be called in the setup * phase. diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index 2648012..4ece335 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -148,14 +148,11 @@ SCH_BASE_FRAME::COMPONENT_SELECTION SCH_BASE_FRAME::SelectComponentFromLibrary( adapter->SetPreselectNode( aHistoryList[0].LibId, aHistoryList[0].Unit ); } - std::vector< wxString > libNicknames = libs->GetLogicalLibs(); + const std::vector< wxString > libNicknames = libs->GetLogicalLibs(); if( !loaded ) { - for( auto nickname : libNicknames ) - { - adapter->AddLibrary( nickname ); - } + adapter->AddLibrariesWithProgress( libNicknames, this ); } if( aHighlight && aHighlight->IsValid() ) diff --git a/eeschema/viewlibs.cpp b/eeschema/viewlibs.cpp index fce60b5..3d1de7c 100644 --- a/eeschema/viewlibs.cpp +++ b/eeschema/viewlibs.cpp @@ -44,7 +44,6 @@ #include <cmp_tree_model_adapter.h> #include <symbol_lib_table.h> - void LIB_VIEW_FRAME::OnSelectSymbol( wxCommandEvent& aEvent ) { wxString dialogTitle; @@ -53,14 +52,9 @@ void LIB_VIEW_FRAME::OnSelectSymbol( wxCommandEvent& aEvent ) // Container doing search-as-you-type. auto adapter( CMP_TREE_MODEL_ADAPTER::Create( libs ) ); - std::vector< wxString > libNicknames; - - libNicknames = libs->GetLogicalLibs(); + const auto libNicknames = libs->GetLogicalLibs(); - for( auto nickname : libNicknames ) - { - adapter->AddLibrary( nickname ); - } + adapter->AddLibrariesWithProgress( libNicknames, this ); dialogTitle.Printf( _( "Choose Component (%d items loaded)" ), adapter->GetComponentsCount() ); -- 2.7.4
From 46279764bf214ba3dd151ae354fcef2b50fbbd67 Mon Sep 17 00:00:00 2001 From: Oliver <oliver.henry.walt...@gmail.com> Date: Wed, 15 Nov 2017 20:41:19 +1100 Subject: [PATCH 4/6] Only enumerate active libraries --- common/lib_table_base.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/lib_table_base.cpp b/common/lib_table_base.cpp index b78d8d7..0dbff32 100644 --- a/common/lib_table_base.cpp +++ b/common/lib_table_base.cpp @@ -368,7 +368,10 @@ std::vector<wxString> LIB_TABLE::GetLogicalLibs() { for( LIB_TABLE_ROWS_CITER it = cur->rows.begin(); it!=cur->rows.end(); ++it ) { - unique.insert( it->GetNickName() ); + if( it->GetIsEnabled() ) + { + unique.insert( it->GetNickName() ); + } } } while( ( cur = cur->fallBack ) != 0 ); -- 2.7.4
From d518bd7df2d06f1f6bb8eb06b3a6a1669166e699 Mon Sep 17 00:00:00 2001 From: Oliver <oliver.henry.walt...@gmail.com> Date: Wed, 15 Nov 2017 20:30:32 +1100 Subject: [PATCH 3/6] Load "disabled" for footprint libraries --- common/fp_lib_table.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/common/fp_lib_table.cpp b/common/fp_lib_table.cpp index 99a2afc..8eff009 100644 --- a/common/fp_lib_table.cpp +++ b/common/fp_lib_table.cpp @@ -109,10 +109,11 @@ void FP_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 ) { @@ -158,6 +159,13 @@ void FP_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 ); } -- 2.7.4
From 403e17af813a3ada0a962f0886c9da1f23d7a221 Mon Sep 17 00:00:00 2001 From: Oliver <oliver.henry.walt...@gmail.com> Date: Wed, 15 Nov 2017 17:56:38 +1100 Subject: [PATCH 2/6] Toggle LIB_TABLE_ROW enabled/disabled in grid editor - Checkbox editor for enabled / disabled status --- common/lib_table_base.cpp | 3 ++- eeschema/dialogs/dialog_sym_lib_table.cpp | 23 +++++++++++++---------- include/lib_table_grid.h | 10 ++++++++++ pcbnew/dialogs/dialog_fp_lib_table.cpp | 21 +++++++++++---------- 4 files changed, 36 insertions(+), 21 deletions(-) diff --git a/common/lib_table_base.cpp b/common/lib_table_base.cpp index 8c3e46f..b78d8d7 100644 --- a/common/lib_table_base.cpp +++ b/common/lib_table_base.cpp @@ -211,7 +211,8 @@ bool LIB_TABLE_ROW::operator==( const LIB_TABLE_ROW& r ) const return nickName == r.nickName && uri_user == r.uri_user && options == r.options - && description == r.description; + && description == r.description + && enabled == r.enabled; } diff --git a/eeschema/dialogs/dialog_sym_lib_table.cpp b/eeschema/dialogs/dialog_sym_lib_table.cpp index 1fa429d..8352310 100644 --- a/eeschema/dialogs/dialog_sym_lib_table.cpp +++ b/eeschema/dialogs/dialog_sym_lib_table.cpp @@ -168,27 +168,30 @@ DIALOG_SYMBOL_LIB_TABLE::DIALOG_SYMBOL_LIB_TABLE( wxTopLevelWindow* aParent, // pluginChoices.Add( SCH_IO_MGR::ShowType( SCH_IO_MGR::SCH_KICAD ) ); pluginChoices.Add( SCH_IO_MGR::ShowType( SCH_IO_MGR::SCH_LEGACY ) ); - wxGridCellAttr* attr; - - attr = new wxGridCellAttr; - attr->SetEditor( new wxGridCellChoiceEditor( pluginChoices ) ); - m_project_grid->SetColAttr( COL_TYPE, attr ); - - attr = new wxGridCellAttr; - attr->SetEditor( new wxGridCellChoiceEditor( pluginChoices ) ); - m_global_grid->SetColAttr( COL_TYPE, attr ); - populateEnvironReadOnlyTable(); for( int i=0; i<2; ++i ) { wxGrid* g = i==0 ? m_global_grid : m_project_grid; + // Set special attributes + wxGridCellAttr* attr; + + attr = new wxGridCellAttr; + attr->SetEditor( new wxGridCellChoiceEditor( pluginChoices ) ); + g->SetColAttr( COL_TYPE, attr ); + + attr = new wxGridCellAttr; + attr->SetEditor( new wxGridCellBoolEditor() ); + attr->SetRenderer( new wxGridCellBoolRenderer() ); + g->SetColAttr( COL_ENABLED, attr ); + // all but COL_OPTIONS, which is edited with Option Editor anyways. g->AutoSizeColumn( COL_NICKNAME, false ); g->AutoSizeColumn( COL_TYPE, false ); g->AutoSizeColumn( COL_URI, false ); g->AutoSizeColumn( COL_DESCR, false ); + g->AutoSizeColumn( COL_ENABLED, false ); // would set this to width of title, if it was easily known. g->SetColSize( COL_OPTIONS, 80 ); diff --git a/include/lib_table_grid.h b/include/lib_table_grid.h index 64c2f90..c35c4f4 100644 --- a/include/lib_table_grid.h +++ b/include/lib_table_grid.h @@ -32,6 +32,8 @@ enum COL_ORDER COL_TYPE, COL_OPTIONS, COL_DESCR, + COL_ENABLED, + COL_COUNT // keep as last }; @@ -62,6 +64,8 @@ public: case COL_TYPE: return r->GetType(); case COL_OPTIONS: return r->GetOptions(); case COL_DESCR: return r->GetDescr(); + // Render a boolean value as its text equivalent + case COL_ENABLED: return r->GetIsEnabled() ? "1" : ""; default: ; // fall thru to wxEmptyString } @@ -83,6 +87,10 @@ public: case COL_TYPE: r->SetType( aValue ); break; case COL_OPTIONS: r->SetOptions( aValue ); break; case COL_DESCR: r->SetDescr( aValue ); break; + case COL_ENABLED: + // Any non-empty string will set enabled to true + r->SetEnabled( !aValue.IsEmpty() ); + break; } } } @@ -172,6 +180,8 @@ public: case COL_TYPE: return _( "Plugin Type" ); case COL_OPTIONS: return _( "Options" ); case COL_DESCR: return _( "Description" ); + case COL_ENABLED: return _( "Enabled" ); + default: return wxEmptyString; } } diff --git a/pcbnew/dialogs/dialog_fp_lib_table.cpp b/pcbnew/dialogs/dialog_fp_lib_table.cpp index eb8b905..ee80d9c 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table.cpp +++ b/pcbnew/dialogs/dialog_fp_lib_table.cpp @@ -195,22 +195,23 @@ public: choices.Add( IO_MGR::ShowType( IO_MGR::GITHUB ) ); */ - wxGridCellAttr* attr; - - attr = new wxGridCellAttr; - attr->SetEditor( new wxGridCellChoiceEditor( choices ) ); - m_project_grid->SetColAttr( COL_TYPE, attr ); - - attr = new wxGridCellAttr; - attr->SetEditor( new wxGridCellChoiceEditor( choices ) ); - m_global_grid->SetColAttr( COL_TYPE, attr ); - populateEnvironReadOnlyTable(); for( int i=0; i<2; ++i ) { wxGrid* g = i==0 ? m_global_grid : m_project_grid; + wxGridCellAttr* attr; + + attr = new wxGridCellAttr; + attr->SetEditor( new wxGridCellChoiceEditor( choices ) ); + g->SetColAttr( COL_TYPE, attr ); + + attr = new wxGridCellAttr; + attr->SetEditor( new wxGridCellBoolEditor() ); + attr->SetRenderer( new wxGridCellBoolRenderer() ); + g->SetColAttr( COL_ENABLED, attr ); + // all but COL_OPTIONS, which is edited with Option Editor anyways. g->AutoSizeColumn( COL_NICKNAME, false ); g->AutoSizeColumn( COL_TYPE, false ); -- 2.7.4
From b8229f3463abf015d612c585258499aa7e230d9c Mon Sep 17 00:00:00 2001 From: Oliver <oliver.henry.walt...@gmail.com> Date: Wed, 15 Nov 2017 16:48:31 +1100 Subject: [PATCH 1/6] Added "enabled" parameter for LIB_TABLE_ROW - Read and write from lib-table working --- common/lib_table.keywords | 1 + common/lib_table_base.cpp | 12 ++++++++++-- eeschema/symbol_lib_table.cpp | 18 ++++++++++++++---- eeschema/symbol_lib_table.h | 3 +++ include/lib_table_base.h | 18 ++++++++++++++++-- 5 files changed, 44 insertions(+), 8 deletions(-) diff --git a/common/lib_table.keywords b/common/lib_table.keywords index feeea0e..fd679ff 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 99e0fc1..8c3e46f 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 2a573f8..07ef7c3 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 1d811c1..a2244ba 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 c8c3e84..20433ad 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 ); @@ -100,6 +101,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. */ virtual const wxString GetType() const = 0; @@ -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; }; -- 2.7.4
_______________________________________________ Mailing list: https://launchpad.net/~kicad-developers Post to : kicad-developers@lists.launchpad.net Unsubscribe : https://launchpad.net/~kicad-developers More help : https://help.launchpad.net/ListHelp