From d128cf78ab035a2703586ff47e0a390d491746b1 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 22 Jan 2018 17:59:44 +0000 Subject: [PATCH 3/3] Fix delete issues in symbol aliases list in libedit. MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.14.3 (Apple Git-98)" This is a multi-part message in MIME format. --------------2.14.3 (Apple Git-98) Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit The alias list now displays the user model (multiple aliases *of* a root part, rather than a collection of names *including* the root part). This simplified the error detection logic, fixing the first bug in the bug report. Updating the part in the library is now done uniformly on OK (which was the second bug in the bug report). Fixes: lp:1744656 * https://bugs.launchpad.net/kicad/+bug/1744656 --- eeschema/dialogs/dialog_edit_component_in_lib.cpp | 67 ++++++++-------------- .../dialogs/dialog_edit_component_in_lib_base.cpp | 4 +- .../dialogs/dialog_edit_component_in_lib_base.fbp | 2 +- .../dialogs/dialog_edit_component_in_lib_base.h | 2 +- 4 files changed, 28 insertions(+), 47 deletions(-) --------------2.14.3 (Apple Git-98) Content-Type: text/x-patch; name="0003-Fix-delete-issues-in-symbol-aliases-list-in-libedit.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0003-Fix-delete-issues-in-symbol-aliases-list-in-libedit.patch" diff --git a/eeschema/dialogs/dialog_edit_component_in_lib.cpp b/eeschema/dialogs/dialog_edit_component_in_lib.cpp index 04f8fea86..8478901ef 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_lib.cpp @@ -66,7 +66,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::initDlg() { m_AliasLocation = -1; - LIB_PART* component = m_Parent->GetCurPart(); + LIB_PART* component = m_Parent->GetCurPart(); if( component == NULL ) { @@ -74,7 +74,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::initDlg() return; } - wxString title; + wxString title, staticText; bool isRoot = m_Parent->GetAliasName().CmpNoCase( component->GetName() ) == 0; if( !isRoot ) @@ -82,6 +82,9 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::initDlg() title.Printf( _( "Properties for %s (alias of %s)" ), GetChars( m_Parent->GetAliasName() ), GetChars( component->GetName() ) ); + + staticText.Printf( _( "Alias List of %s" ), GetChars( component->GetName() ) ); + m_staticTextAlias->SetLabelText( staticText ); } else title.Printf( _( "Properties for %s" ), GetChars( component->GetName() ) ); @@ -90,17 +93,12 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::initDlg() InitPanelDoc(); InitBasicPanel(); - if( isRoot && component->GetAliasCount() == 1 ) - m_ButtonDeleteAllAlias->Enable( false ); - - /* Place list of alias names in listbox */ + // The component's alias list contains all names (including the root). The UI list + // contains only aliases, so exclude the root. m_PartAliasListCtrl->Append( component->GetAliasNames( false ) ); - if( component->GetAliasCount() <= 1 ) - { - m_ButtonDeleteAllAlias->Enable( false ); - m_ButtonDeleteOneAlias->Enable( false ); - } + // Note: disabling the delete buttons gives us no opportunity to tell the user + // why they're disabled. Leave them enabled and bring up an error message instead. /* Read the Footprint Filter list */ m_FootprintFilterListBox->Append( component->GetFootprints() ); @@ -124,11 +122,10 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnCancelClick( wxCommandEvent& event ) } - void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitPanelDoc() { LIB_ALIAS* alias; - LIB_PART* component = m_Parent->GetCurPart(); + LIB_PART* component = m_Parent->GetCurPart(); if( component == NULL ) return; @@ -154,7 +151,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitPanelDoc() */ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel() { - LIB_PART* component = m_Parent->GetCurPart(); + LIB_PART* component = m_Parent->GetCurPart(); if( m_Parent->GetShowDeMorgan() ) m_AsConvertButt->SetValue( true ); @@ -193,7 +190,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) { /* Update the doc, keyword and doc filename strings */ LIB_ALIAS* alias; - LIB_PART* component = m_Parent->GetCurPart(); + LIB_PART* component = m_Parent->GetCurPart(); if( component == NULL ) { @@ -213,7 +210,11 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) alias->SetKeyWords( m_KeywordsCtrl->GetValue() ); alias->SetDocFileName( m_DocfileCtrl->GetValue() ); - component->SetAliases( m_PartAliasListCtrl->GetStrings() ); + // The UI list contains only aliases (ie: not the root's name), while the component's + // alias list contains all names (including the root). + wxArrayString aliases = m_PartAliasListCtrl->GetStrings(); + aliases.Add( component->GetName() ); + component->SetAliases( aliases ); int unitCount = m_SelNumberOfUnits->GetValue(); ChangeNbUnitsPerPackage( unitCount ); @@ -294,21 +295,17 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::CopyDocFromRootToAlias( wxCommandEvent& e void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllAliasOfPart( wxCommandEvent& event ) { + if( m_PartAliasListCtrl->GetCount() == 0 ) + return; + if( m_PartAliasListCtrl->FindString( m_Parent->GetAliasName() ) != wxNOT_FOUND ) { - wxString msg; - msg.Printf( _( "Alias \"%s\" cannot be removed while it is being edited!" ), - GetChars( m_Parent->GetAliasName() ) ); - DisplayError( this, msg ); + DisplayErrorMessage( this, _( "Delete All must be done from the root symbol." ) ); return; } if( IsOK( this, _( "Remove all aliases from list?" ) ) ) - { m_PartAliasListCtrl->Clear(); - m_ButtonDeleteAllAlias->Enable( false ); - m_ButtonDeleteOneAlias->Enable( false ); - } } @@ -339,9 +336,8 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& event ) if( m_PartAliasListCtrl->FindString( aliasname ) != wxNOT_FOUND ) { wxString msg; - msg.Printf( _( "Alias or component name \"%s\" already in use." ), - GetChars( aliasname ) ); - DisplayError( this, msg ); + msg.Printf( _( "Alias \"%s\" already added." ), GetChars( aliasname ) ); + DisplayInfoMessage( this, msg ); return; } @@ -349,16 +345,11 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& event ) { wxString msg; msg.Printf( _( "Symbol name \"%s\" already exists in library \"%s\"." ), aliasname, library ); - DisplayError( this, msg ); + DisplayErrorMessage( this, msg ); return; } m_PartAliasListCtrl->Append( aliasname ); - - if( m_Parent->GetAliasName().CmpNoCase( component->GetName() ) == 0 ) - m_ButtonDeleteAllAlias->Enable( true ); - - m_ButtonDeleteOneAlias->Enable( true ); } @@ -379,16 +370,6 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAliasOfPart( wxCommandEvent& event } m_PartAliasListCtrl->Delete( m_PartAliasListCtrl->GetSelection() ); - LIB_PART* component = m_Parent->GetCurPart(); - - if( component ) - component->RemoveAlias( aliasname ); - - if( m_PartAliasListCtrl->IsEmpty() ) - { - m_ButtonDeleteAllAlias->Enable( false ); - m_ButtonDeleteOneAlias->Enable( false ); - } } diff --git a/eeschema/dialogs/dialog_edit_component_in_lib_base.cpp b/eeschema/dialogs/dialog_edit_component_in_lib_base.cpp index af3a100b8..134a3d9f8 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib_base.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_lib_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 22 2017) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -196,7 +196,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx m_PanelAlias->SetSizer( bSizerMainPanelAlias ); m_PanelAlias->Layout(); bSizerMainPanelAlias->Fit( m_PanelAlias ); - m_NoteBook->AddPage( m_PanelAlias, _("Alias"), false ); + m_NoteBook->AddPage( m_PanelAlias, _("Aliases"), false ); m_PanelFootprintFilter = new wxPanel( m_NoteBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bPanelFpFilterBoxSizer; bPanelFpFilterBoxSizer = new wxBoxSizer( wxHORIZONTAL ); diff --git a/eeschema/dialogs/dialog_edit_component_in_lib_base.fbp b/eeschema/dialogs/dialog_edit_component_in_lib_base.fbp index a3638a3ed..9648f10a1 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib_base.fbp +++ b/eeschema/dialogs/dialog_edit_component_in_lib_base.fbp @@ -2147,7 +2147,7 @@ - Alias + Aliases 0 1 diff --git a/eeschema/dialogs/dialog_edit_component_in_lib_base.h b/eeschema/dialogs/dialog_edit_component_in_lib_base.h index 8eb0b6c1e..2b3884b7a 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib_base.h +++ b/eeschema/dialogs/dialog_edit_component_in_lib_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 22 2017) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! --------------2.14.3 (Apple Git-98)--