mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-13 17:53:11 +02:00
EDA_LIST_DIALOG: Simplify ctor args
Sometimes you want to add these in the ctor of the child class based on some logic and having to construct the vector in the init-list is a bit ugly. Theoretically allows to not require a vector too.
This commit is contained in:
parent
7f4a1bf64a
commit
4bebd09bd0
@ -41,8 +41,7 @@ static int DEFAULT_COL_WIDTHS[] = { 200, 300 };
|
||||
EDA_LIST_DIALOG::EDA_LIST_DIALOG( wxWindow* aParent, const wxString& aTitle,
|
||||
const wxArrayString& aItemHeaders,
|
||||
const std::vector<wxArrayString>& aItemList,
|
||||
const wxString& aPreselectText, bool aSortList,
|
||||
const std::vector<std::pair<wxString, bool*>>& aExtraCheckboxes ) :
|
||||
const wxString& aPreselectText, bool aSortList ) :
|
||||
EDA_LIST_DIALOG_BASE( aParent, wxID_ANY, aTitle ),
|
||||
m_sortList( aSortList )
|
||||
{
|
||||
@ -63,11 +62,6 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( wxWindow* aParent, const wxString& aTitle,
|
||||
// columns, different column names, and column widths.
|
||||
m_hash_key = TO_UTF8( aTitle );
|
||||
|
||||
for( const auto& [label, valuePtr] : aExtraCheckboxes )
|
||||
{
|
||||
AddExtraCheckbox( label, valuePtr );
|
||||
}
|
||||
|
||||
SetupStandardButtons();
|
||||
|
||||
Layout();
|
||||
@ -87,14 +81,16 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( wxWindow* aParent, const wxString& aTitle, boo
|
||||
|
||||
void EDA_LIST_DIALOG::AddExtraCheckbox( const wxString& aLabel, bool* aValuePtr )
|
||||
{
|
||||
if( m_extraCheckboxMap.size() == 0 )
|
||||
{
|
||||
m_ExtrasSizer->AddSpacer( 5 );
|
||||
}
|
||||
wxCHECK2_MSG( aValuePtr, return, wxT( "Null pointer for checkbox value." ) );
|
||||
|
||||
int flags = wxBOTTOM;
|
||||
|
||||
if( m_ExtrasSizer->GetItemCount() > 0 )
|
||||
flags |= wxTOP;
|
||||
|
||||
wxCheckBox* cb = new wxCheckBox( this, wxID_ANY, aLabel );
|
||||
cb->SetValue( *aValuePtr );
|
||||
m_ExtrasSizer->Add( cb, 0, wxBOTTOM, 5 );
|
||||
m_ExtrasSizer->Add( cb, 0, flags, 5 );
|
||||
m_extraCheckboxMap[cb] = aValuePtr;
|
||||
}
|
||||
|
||||
|
@ -735,9 +735,12 @@ wxString SCH_BASE_FRAME::SelectLibrary( const wxString& aDialogTitle, const wxSt
|
||||
|
||||
wxString libraryName = Prj().GetRString( PROJECT::SCH_LIB_SELECT );
|
||||
|
||||
EDA_LIST_DIALOG dlg( this, aDialogTitle, headers, itemsToDisplay, libraryName, false, aExtraCheckboxes );
|
||||
EDA_LIST_DIALOG dlg( this, aDialogTitle, headers, itemsToDisplay, libraryName, false );
|
||||
dlg.SetListLabel( aListLabel );
|
||||
|
||||
for( const auto& [label, val] : aExtraCheckboxes )
|
||||
dlg.AddExtraCheckbox( label, val );
|
||||
|
||||
wxButton* newLibraryButton = new wxButton( &dlg, ID_MAKE_NEW_LIBRARY, _( "New Library..." ) );
|
||||
dlg.m_ButtonsSizer->Prepend( 80, 20 );
|
||||
dlg.m_ButtonsSizer->Prepend( newLibraryButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 10 );
|
||||
|
@ -73,7 +73,6 @@
|
||||
#include <tools/sch_tool_utils.h>
|
||||
#include <tools/sch_edit_table_tool.h>
|
||||
#include <drawing_sheet/ds_proxy_undo_item.h>
|
||||
#include <eda_list_dialog.h>
|
||||
#include <view/view_controls.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <wx_filename.h>
|
||||
|
@ -26,7 +26,7 @@
|
||||
#define EDA_LIST_DIALOG_H
|
||||
|
||||
|
||||
#include <../common/dialogs/eda_list_dialog_base.h>
|
||||
#include <dialogs/eda_list_dialog_base.h>
|
||||
|
||||
|
||||
class EDA_DRAW_FRAME;
|
||||
@ -53,8 +53,7 @@ public:
|
||||
EDA_LIST_DIALOG( wxWindow* aParent, const wxString& aTitle, const wxArrayString& aItemHeaders,
|
||||
const std::vector<wxArrayString>& aItemList,
|
||||
const wxString& aPreselectText = wxEmptyString,
|
||||
bool aSortList = true,
|
||||
const std::vector<std::pair<wxString, bool*>>& aExtraCheckboxes = {} );
|
||||
bool aSortList = true );
|
||||
|
||||
EDA_LIST_DIALOG( wxWindow* aParent, const wxString& aTitle, bool aSortList = true );
|
||||
|
||||
|
@ -429,9 +429,12 @@ wxString PCB_BASE_EDIT_FRAME::SelectLibrary( const wxString& aDialogTitle, const
|
||||
|
||||
wxString libraryName = Prj().GetRString( PROJECT::PCB_LIB_NICKNAME );
|
||||
|
||||
EDA_LIST_DIALOG dlg( this, aDialogTitle, headers, itemsToDisplay, libraryName, false, aExtraCheckboxes );
|
||||
EDA_LIST_DIALOG dlg( this, aDialogTitle, headers, itemsToDisplay, libraryName, false );
|
||||
dlg.SetListLabel( aListLabel );
|
||||
|
||||
for( const auto& [label, val] : aExtraCheckboxes )
|
||||
dlg.AddExtraCheckbox( label, val );
|
||||
|
||||
wxButton* newLibraryButton = new wxButton( &dlg, ID_MAKE_NEW_LIBRARY, _( "New Library..." ) );
|
||||
dlg.m_ButtonsSizer->Prepend( 80, 20 );
|
||||
dlg.m_ButtonsSizer->Prepend( newLibraryButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 10 );
|
||||
@ -1313,5 +1316,3 @@ void PCB_BASE_FRAME::GetLibraryItemsForListDialog( wxArrayString& aHeaders,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user