board_stackup_manager: fix incorrect behavior when adding a new dielectric layer.

From Master branch
Fixes #12680
https://gitlab.com/kicad/code/kicad/issues/12680
This commit is contained in:
jean-pierre charras 2022-10-20 11:46:38 +02:00
parent bf95906f90
commit 2827835720
3 changed files with 12 additions and 6 deletions

View File

@ -40,10 +40,11 @@ static int DEFAULT_COL_WIDTHS[] = { 200, 600 };
EDA_LIST_DIALOG::EDA_LIST_DIALOG( wxWindow* aParent, const wxString& aTitle,
const wxArrayString& aItemHeaders,
const std::vector<wxArrayString>& aItemList,
const wxString& aPreselectText ) :
const wxString& aPreselectText, bool aSortList ) :
EDA_LIST_DIALOG_BASE( aParent, wxID_ANY, aTitle )
{
m_itemsList = &aItemList;
m_sortList = aSortList;
m_filterBox->SetHint( _( "Filter" ) );
@ -234,5 +235,6 @@ static int wxCALLBACK myCompareFunction( wxIntPtr aItem1, wxIntPtr aItem2,
void EDA_LIST_DIALOG::sortList()
{
m_listBox->SortItems( myCompareFunction, 0 );
if( m_sortList )
m_listBox->SortItems( myCompareFunction, 0 );
}

View File

@ -52,7 +52,8 @@ public:
*/
EDA_LIST_DIALOG( wxWindow* aParent, const wxString& aTitle, const wxArrayString& aItemHeaders,
const std::vector<wxArrayString>& aItemList,
const wxString& aPreselectText = wxEmptyString );
const wxString& aPreselectText = wxEmptyString,
bool aSortList = true );
void SetListLabel( const wxString& aLabel );
void SetOKLabel( const wxString& aLabel );
@ -80,6 +81,7 @@ private:
private:
const std::vector<wxArrayString>* m_itemsList;
bool m_sortList;
};

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2019-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
@ -307,7 +307,8 @@ void PANEL_SETUP_BOARD_STACKUP::onAddDielectricLayer( wxCommandEvent& event )
}
}
EDA_LIST_DIALOG dlg( m_parentDialog, _( "Add Dielectric Layer" ), headers, d_list );
EDA_LIST_DIALOG dlg( m_parentDialog, _( "Add Dielectric Layer" ), headers, d_list,
wxEmptyString, false /* do not sort the list: it is **expected** in stack order */);
dlg.SetListLabel( _( "Select layer to add:" ) );
dlg.HideFilter();
@ -363,7 +364,8 @@ void PANEL_SETUP_BOARD_STACKUP::onRemoveDielectricLayer( wxCommandEvent& event )
}
}
EDA_LIST_DIALOG dlg( m_parentDialog, _( "Remove Dielectric Layer" ), headers, d_list );
EDA_LIST_DIALOG dlg( m_parentDialog, _( "Remove Dielectric Layer" ), headers, d_list,
wxEmptyString, false /* do not sort the list: it is **expected** in stack order */);
dlg.SetListLabel( _( "Select layer to remove:" ) );
dlg.HideFilter();