48#include <wx/filedlg.h>
49#include <wx/filename.h>
52#include <wx/textdlg.h>
55#define COLUMN_MARGIN 4
57#define COLUMN_MARGIN 15
72template <
typename PRESET>
73int findPresetIndexByPointer(
const wxChoice* aChoice,
const PRESET* aPreset )
75 for(
unsigned i = 0; i < aChoice->GetCount(); ++i )
77 if( aChoice->GetClientData( i ) ==
static_cast<const void*
>( aPreset ) )
78 return static_cast<int>( i );
85template <
typename PRESET>
86int findPresetIndexByName(
const wxChoice* aChoice,
const std::map<wxString, PRESET>& aPresets,
87 const wxString& aName )
89 auto presetIt = aPresets.find( aName );
91 return presetIt == aPresets.end() ? wxNOT_FOUND : findPresetIndexByPointer( aChoice, &presetIt->second );
102class VIEW_CONTROLS_GRID_TRICKS :
public GRID_TRICKS
105 VIEW_CONTROLS_GRID_TRICKS( WX_GRID* aGrid ) :
111 void doPopupSelection( wxCommandEvent& aEvent )
override
114 m_grid->PostSizeEvent();
133 int row =
m_grid->GetGridCursorRow();
134 int col =
m_grid->GetGridCursorCol();
136 wxMenuItem* revertMenu = aMenu.Append( MYID_REVERT_ROW,
_(
"Revert Row" ),
137 _(
"Revert the fields in this row" ) );
138 wxMenuItem* clearMenu = aMenu.Append( MYID_CLEAR_CELL,
_(
"Clear Cell" ),
139 _(
"Clear the cell value" ) );
140 aMenu.AppendSeparator();
142 if( row >= 0 && col >= 0 )
145 clearMenu->Enable(
m_grid->IsEditable() &&
m_dataModel->CanClearCell( row, col ) );
149 revertMenu->Enable(
false );
150 clearMenu->Enable(
false );
159 if(
m_dialog->m_variantListBox->GetCount() < 2 )
163 std::vector<wxGridCellCoords> cells;
164 bool hasSelection =
m_grid->IsSelection();
166 if(
m_grid->IsEditable() )
168 for(
int row = 0; row <
m_grid->GetNumberRows(); ++row )
170 for(
int col = 0; col <
m_grid->GetNumberCols(); ++col )
172 bool selected = hasSelection ?
m_grid->IsInSelection( row, col )
173 : row ==
m_grid->GetGridCursorRow() && col ==
m_grid->GetGridCursorCol();
175 if( selected &&
m_grid->IsColShown( col ) &&
m_dataModel->CanCopyCellFromVariant( row, col ) )
177 cells.emplace_back( row, col );
183 wxMenu* variantsMenu =
new wxMenu;
185 for(
unsigned int i = 0; i <
m_dialog->m_variantListBox->GetCount(); ++i )
187 wxString
name =
m_dialog->m_variantListBox->GetString( i );
189 wxString label =
name;
190 label.Replace( wxS(
"&" ), wxS(
"&&" ) );
192 wxMenuItem* item = variantsMenu->Append( wxID_ANY, label );
193 item->Enable( !cells.empty() && variant !=
m_dataModel->GetCurrentVariant() );
196 wxEVT_COMMAND_MENU_SELECTED,
197 [
this, variant, cells]( wxCommandEvent& )
204 aMenu.AppendSeparator();
205 aMenu.AppendSubMenu( variantsMenu,
_(
"Copy from Variant" ) )->Enable( !cells.empty() );
211 if( !
m_grid->CommitPendingChanges(
false ) || aCells.empty() )
214 for(
const wxGridCellCoords& cell : aCells )
215 m_dataModel->CopyCellFromVariant( cell.GetRow(), cell.GetCol(), aVariant );
223 wxGridEvent event(
m_grid->GetId(), wxEVT_GRID_CELL_CHANGED,
m_grid, aCells.front().GetRow(),
224 aCells.front().GetCol() );
225 m_grid->GetEventHandler()->ProcessEvent( event );
232 int row =
m_grid->GetGridCursorRow();
233 int col =
m_grid->GetGridCursorCol();
235 if( aEvent.GetId() == MYID_REVERT_ROW )
237 if(
m_grid->CommitPendingChanges(
false ) )
247 else if( aEvent.GetId() == MYID_CLEAR_CELL )
249 if(
m_grid->CommitPendingChanges(
false ) )
318 wxGridCellAttr* attr =
new wxGridCellAttr;
319 attr->SetReadOnly(
true );
322 attr =
new wxGridCellAttr;
323 attr->SetRenderer(
new wxGridCellBoolRenderer() );
325 attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
328 attr =
new wxGridCellAttr;
329 attr->SetRenderer(
new wxGridCellBoolRenderer() );
331 attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
337 m_filter->SetDescriptiveText(
_(
"Filter" ) );
340 m_grid->EnableCursorRowColumnHighlight();
406 [&]() -> std::pair<int, int>
417 if( aInputFileName.IsEmpty() )
418 return wxEmptyString;
420 wxFileName fn( aInputFileName );
423 return fn.GetFullPath();
437 aPreset.fieldsOrdered.clear();
444 field.
name = fieldName;
445 field.
show = !fieldName.StartsWith( wxT(
"__" ), &field.
name );
455 aPreset.fieldsOrdered.emplace_back( field );
503 if( modelField.show )
510 if( modelField.groupBy )
529 bool modified =
false;
558 if( aSaveCurrentSettings &&
m_loadedSettings.m_BomFmtSettings != fmtSettings )
570 return ConvertDialogToPixels( wxSize( 600, 300 ) );
576 m_grid->Connect( wxEVT_GRID_RANGE_SELECTED,
584 m_grid->Disconnect( wxEVT_GRID_RANGE_SELECTED,
598 std::set<int> selectedRows;
600 wxGridCellCoordsArray topLeft =
m_grid->GetSelectionBlockTopLeft();
601 wxGridCellCoordsArray bottomRight =
m_grid->GetSelectionBlockBottomRight();
603 for(
size_t i = 0; i < topLeft.size(); ++i )
605 for(
int row = topLeft[i].GetRow(); row <= bottomRight[i].GetRow(); ++row )
606 selectedRows.insert( row );
609 wxGridCellCoordsArray selectedCells =
m_grid->GetSelectedCells();
611 for(
size_t i = 0; i < selectedCells.size(); ++i )
612 selectedRows.insert( selectedCells[i].GetRow() );
614 for(
int row :
m_grid->GetSelectedRows() )
615 selectedRows.insert( row );
617 int cursorRow =
m_grid->GetGridCursorRow();
619 if( selectedRows.empty() && cursorRow >= 0 && cursorRow <
getDataModel()->GetNumberRows() )
620 selectedRows.insert( cursorRow );
628 std::set<KIID_PATH> selectedItemKeys;
633 selectedItemKeys.insert( key );
636 return selectedItemKeys;
642 if( aItemKeys.empty() )
647 bool firstSelection =
true;
649 for(
int row = 0; row <
getDataModel()->GetNumberRows(); ++row )
653 if( aItemKeys.count( key ) )
655 m_grid->SelectRow( row,
true );
659 m_grid->SetGridCursor( row,
m_grid->GetGridCursorCol() );
660 firstSelection =
false;
679 [
this, sidebarCollapsed, sashPosition, variantSashPosition]()
681 if( sidebarCollapsed )
709 return m_grid->FromDIP( it->second );
715 for(
int i = 0; i <
m_grid->GetNumberCols(); i++ )
717 if(
m_grid->IsColShown( i ) )
724 std::string fieldName(
getDataModel()->GetColFieldName( i ).ToUTF8() );
749 m_grid->EnableEditing( !aReadOnly );
765 wxGridCellAttr* attr =
new wxGridCellAttr;
766 attr->SetReadOnly(
false );
772 attr->SetRenderer(
new wxGridCellStringRenderer() );
779 attr->SetRenderer(
new wxGridCellStringRenderer() );
797 attr->SetAlignment( wxALIGN_RIGHT, wxALIGN_CENTER );
798 attr->SetRenderer(
new wxGridCellNumberRenderer() );
803 attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
815 attr->SetRenderer(
new wxGridCellStringRenderer() );
816 attr->SetEditor(
m_grid->GetDefaultEditor() );
829 m_grid->AutoSizeColumns(
false );
831 bool sortAscending =
true;
833 for(
int col = 0; col <
m_grid->GetNumberCols(); ++col )
859 std::string key(
getDataModel()->GetColFieldName( col ).ToUTF8() );
863 m_grid->SetColSize( col, storedWidth );
868 int maxWidth = defaultDlgSize.x / 3;
870 m_grid->SetColSize( col, std::clamp( textWidth, 100, maxWidth ) );
880 m_grid->SetSortingColumn( sortCol, sortAscending );
894 if( aIsLeftPanelCollapsed )
942 int row = aEvent.GetRow();
945 if( aEvent.GetCol() != -1 || row < 0 || row >=
getDataModel()->GetNumberRows() )
959 if( !
m_grid->CommitPendingChanges() )
962 int col =
m_grid->GetGridCursorCol();
966 if( col >= 0 && col < m_grid->GetNumberCols() )
967 m_grid->SetGridCursor( row, col );
976#if defined( __WXOSX__ )
977 wxPoint pos = aEvent.GetPosition();
978 wxRect ctrlRect =
m_filter->GetScreenRect();
979 int buttonWidth = ctrlRect.GetHeight();
982 if(
m_filter->IsSearchButtonVisible() && pos.x < buttonWidth )
983 SetCursor( wxCURSOR_ARROW );
984 else if(
m_filter->IsCancelButtonVisible() && pos.x > ctrlRect.GetWidth() - buttonWidth )
985 SetCursor( wxCURSOR_ARROW );
987 SetCursor( wxCURSOR_IBEAM );
998 int remainingWidth =
m_viewControlsGrid->GetSize().GetX() - showColWidth - groupByColWidth;
1023 int row = aEvent.GetRow();
1025 wxCHECK( row < m_viewControlsGrid->GetNumberRows(), );
1027 switch( aEvent.GetCol() )
1038 m_grid->SetColLabelValue( dataCol, label );
1070 if(
getDataModel()->ColIsQuantity( dataCol ) && value )
1072 DisplayError(
this,
_(
"The Quantity column cannot be grouped by." ) );
1080 if(
getDataModel()->ColIsItemNumber( dataCol ) && value )
1082 DisplayError(
this,
_(
"The Item Number column cannot be grouped by." ) );
1110 wxTextEntryDialog dlg(
this,
_(
"New field name:" ),
_(
"Add Field" ) );
1112 if( dlg.ShowModal() != wxID_OK )
1115 wxString fieldName = dlg.GetValue();
1117 if( fieldName.IsEmpty() )
1127 DisplayError(
this, wxString::Format(
_(
"Field name '%s' already in use." ), fieldName ) );
1150 DisplayError(
this, wxString::Format(
_(
"The first %d fields are mandatory." ),
1159 if( col != -1 &&
getDataModel()->ColIsItemIdentifier( col ) )
1161 DisplayError(
this, wxString::Format(
_(
"The '%s' field cannot be removed." ),
1167 return IsOK(
this, wxString::Format(
_(
"Are you sure you want to remove the field '%s'?" ),
1181 std::erase_if( preset.fieldsOrdered,
1184 return f.name == fieldName;
1200 if( selectedRows.empty() )
1203 int row = selectedRows[0];
1209 DisplayError(
this, wxString::Format(
_(
"The first %d fields are mandatory and names cannot be changed." ),
1220 wxCHECK_RET( col != -1, wxS(
"Existing field name missing from data model" ) );
1224 DisplayError(
this, wxString::Format(
_(
"The '%s' field cannot be renamed." ),
1229 wxTextEntryDialog dlg(
this,
_(
"New field name:" ),
_(
"Rename Field" ), fieldName );
1231 if( dlg.ShowModal() != wxID_OK )
1234 wxString newFieldName = dlg.GetValue();
1237 if( newFieldName == fieldName )
1240 if( newFieldName.IsEmpty() )
1247 if(
getDataModel()->GetFieldNameCol( newFieldName ) != -1 )
1249 wxString confirm_msg = wxString::Format(
_(
"Field name %s already exists." ), newFieldName );
1258 if( labelIsAutogenerated )
1318 int sortCol = aEvent.GetCol();
1330 if(
m_grid->IsSortingBy( sortCol ) )
1333 ascending = !
m_grid->IsSortOrderAscending();
1351 int origPos = aEvent.GetCol();
1359 int newPos =
m_grid->GetColPos( origPos );
1362 if( newPos < origPos )
1384 wxPoint pos = aEvent.GetPosition();
1386 m_grid->CalcUnscrolledPosition( pos.x, pos.y, &ux, &uy );
1387 int row =
m_grid->YToRow( uy );
1388 int col =
m_grid->XToCol( ux );
1390 if( row == wxNOT_FOUND || col == wxNOT_FOUND )
1392 m_grid->GetGridWindow()->UnsetToolTip();
1396 wxString rawValue =
getDataModel()->GetValue( row, col );
1398 if( rawValue.Contains( wxT(
"${" ) ) )
1399 m_grid->GetGridWindow()->SetToolTip( rawValue );
1401 m_grid->GetGridWindow()->UnsetToolTip();
1407 if( aEvent.GetWheelAxis() != wxMOUSE_WHEEL_VERTICAL || aEvent.GetModifiers() != wxMOD_SHIFT )
1422 int scrollLines = aEvent.IsPageScroll() ?
m_grid->GetScrollPageSize( wxHORIZONTAL )
1423 : aEvent.GetLinesPerAction();
1425 wxPoint viewStart =
m_grid->GetViewStart();
1426 m_grid->Scroll( viewStart.x - lines * scrollLines, viewStart.y );
1450 wxFileName fn(
Prj().AbsolutePath(
m_parentFrame->GetCurrentFileName() ) );
1453 wxFileDialog saveDlg(
this,
_(
"Bill of Materials Output File" ),
path, fn.GetFullName(),
1458 if( saveDlg.ShowModal() == wxID_CANCEL )
1461 wxFileName file = wxFileName( saveDlg.GetPath() );
1462 wxString defaultPath = fn.GetPathWithSep();
1464 if(
IsOK(
this, wxString::Format(
_(
"Do you want to use a path relative to\n'%s'?" ), defaultPath ) ) )
1466 if( !file.MakeRelativeTo( defaultPath ) )
1482 _(
"Changes have not yet been saved. Export unsaved data?" ),
"",
_(
"OK" ),
1493 std::function<bool( wxString* )> textResolver =
1494 [&]( wxString* token ) ->
bool
1499 wxString sourceFileName =
m_parentFrame->GetCurrentFileName();
1502 if(
path.IsEmpty() )
1508 if(
path.IsEmpty() )
1510 DisplayError(
this,
_(
"No output file specified in Export tab." ) );
1520 wxFileName outputFile = wxFileName::FileName(
path );
1525 msg.Printf(
_(
"Could not open/create path '%s'." ), outputFile.GetPath() );
1530 wxFFile out( outputFile.GetFullPath(),
"wb" );
1532 if( !out.IsOpened() )
1534 msg.Printf(
_(
"Could not create BOM output '%s'." ), outputFile.GetFullPath() );
1543 msg.Printf(
_(
"Could not write BOM output '%s'." ), outputFile.GetFullPath() );
1557 msg.Printf(
_(
"Wrote BOM output to '%s'" ), outputFile.GetFullPath() );
1571 if( saveIncludeExcudedFromBOM )
1594 std::vector<BOM_PRESET> ret;
1596 for(
const std::pair<const wxString, BOM_PRESET>& pair :
m_bomPresets )
1598 if( !pair.second.readOnly )
1599 ret.emplace_back( pair.second );
1611 for(
const BOM_PRESET& preset : aPresetList )
1629 wxCommandEvent
dummy;
1636 BOM_PRESET preset = aPreset;
1638 if( preset.fieldsOrdered.empty() )
1642 if( builtIn.name == BOM_PRESET::DefaultEditing().name )
1678 for(
int i = 0; i <
getDataModel()->GetColsCount(); i++ )
1680 const wxString& fieldName(
getDataModel()->GetColFieldName( i ) );
1705 wxASSERT_MSG(
true,
"Fields control has a field not found in the data model." );
1709 std::string fieldNameStr( fieldName.ToUTF8() );
1714 m_grid->SetColLabelValue( col, label );
1717 m_grid->SetColSize( col, storedWidth );
1769 return BOM_PRESET::BuiltInPresets();
1778 int default_idx = 0;
1782 wxString label = preset.readOnly ? wxGetTranslation( presetName ) : presetName;
1785 if( presetName == BOM_PRESET::DefaultEditing().
name )
1809 return aPresetCount - (
m_job ? 1 : 3 );
1815 return m_job ? wxNOT_FOUND : aPresetCount - 2;
1821 return m_job ? wxNOT_FOUND : aPresetCount - 1;
1836 [&](
const std::pair<const wxString, BOM_PRESET>& aPair )
1838 const BOM_PRESET& preset = aPair.second;
1841 if( !( preset.sortAsc == current.sortAsc
1842 && preset.filterString == current.filterString
1843 && preset.filterScope == current.filterScope
1844 && preset.groupSymbols == current.groupSymbols
1845 && preset.excludeDNP == current.excludeDNP
1846 && preset.includeExcludedFromBOM == current.includeExcludedFromBOM ) )
1851 if( preset.sortField != current.sortField )
1855 std::vector<BOM_FIELD> A,
B;
1857 for(
const BOM_FIELD& field : preset.fieldsOrdered )
1859 if( field.show || field.groupBy )
1860 A.emplace_back( field );
1863 for(
const BOM_FIELD& field : current.fieldsOrdered )
1865 if( field.show || field.groupBy )
1866 B.emplace_back( field );
1872 if( it != m_bomPresets.end() )
1874 m_cbBomPresets->SetSelection( findPresetIndexByPointer( m_cbBomPresets, &it->second ) );
1878 m_cbBomPresets->SetSelection( presetDashDashDashIndex( m_cbBomPresets->GetCount() ) );
1881 m_currentBomPreset =
static_cast<BOM_PRESET*
>( m_cbBomPresets->GetClientData( m_cbBomPresets->GetSelection() ) );
1906 auto resetSelection =
1911 if( presetIndex == wxNOT_FOUND )
1931 wxTextEntryDialog dlg(
this,
_(
"BOM preset name:" ),
_(
"Save BOM Preset" ),
name );
1933 if( dlg.ShowModal() != wxID_OK )
1939 name = dlg.GetValue();
1955 else if( preset->readOnly )
1957 wxMessageBox(
_(
"Default presets cannot be modified.\nPlease use a different name." ),
1958 _(
"Error" ), wxOK | wxICON_ERROR,
this );
1965 if( !
IsOK(
this,
_(
"Overwrite existing preset?" ) ) )
1972 preset->name =
name;
1989 wxArrayString headers;
1990 std::vector<wxArrayString> items;
1992 headers.Add(
_(
"Presets" ) );
1996 if( !preset.readOnly )
2000 items.emplace_back( item );
2013 if( idx != wxNOT_FOUND && presetIt !=
m_bomPresets.end() )
2059 if( selection != wxNOT_FOUND )
2062 current.
name = preset->name;
2081 std::vector<BOM_FMT_PRESET> ret;
2085 if( !preset.readOnly )
2086 ret.emplace_back( preset );
2116 wxCommandEvent
dummy;
2174 int default_idx = 0;
2178 wxString label = preset.readOnly ? wxGetTranslation( presetName ) : presetName;
2208 [&](
const std::pair<const wxString, BOM_FMT_PRESET>& aPair )
2210 return ( aPair.second.fieldDelimiter == current.fieldDelimiter
2211 && aPair.second.stringDelimiter == current.stringDelimiter
2212 && aPair.second.refDelimiter == current.refDelimiter
2213 && aPair.second.refRangeDelimiter == current.refRangeDelimiter
2214 && aPair.second.keepTabs == current.keepTabs
2215 && aPair.second.keepLineBreaks == current.keepLineBreaks
2216 && aPair.second.includeByteOrderMark == current.includeByteOrderMark );
2254 auto resetSelection =
2259 if( presetIndex == wxNOT_FOUND )
2279 wxTextEntryDialog dlg(
this,
_(
"BOM preset name:" ),
_(
"Save BOM Preset" ),
name );
2281 if( dlg.ShowModal() != wxID_OK )
2287 name = dlg.GetValue();
2305 wxMessageBox(
_(
"Default presets cannot be modified.\nPlease use a different name." ),
2306 _(
"Error" ), wxOK | wxICON_ERROR,
this );
2313 if( !
IsOK(
this,
_(
"Overwrite existing preset?" ) ) )
2337 wxArrayString headers;
2338 std::vector<wxArrayString> items;
2340 headers.Add(
_(
"Presets" ) );
2342 for( std::pair<const wxString, BOM_FMT_PRESET>& pair :
m_bomFmtPresets )
2344 if( !pair.second.readOnly )
2347 item.Add( pair.first );
2348 items.emplace_back( item );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
STD_BITMAP_BUTTON * m_addVariantButton
wxTextCtrl * m_textStringDelimiter
STD_BITMAP_BUTTON * m_renameVariantButton
wxTextCtrl * m_textRefDelimiter
wxTextCtrl * m_outputFileName
wxChoice * m_cbBomFmtPresets
wxCheckBox * m_checkIncludeByteOrderMark
DIALOG_FIELDS_TABLE_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Fields Table"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER)
STD_BITMAP_BUTTON * m_removeFieldButton
wxTextCtrl * m_textOutput
STD_BITMAP_BUTTON * m_renameFieldButton
wxTextCtrl * m_textFieldDelimiter
wxSplitterWindow * m_splitterMainWindow
wxCheckBox * m_checkKeepTabs
STD_BITMAP_BUTTON * m_copyVariantButton
wxCheckBox * m_checkKeepLineBreaks
STD_BITMAP_BUTTON * m_bMenu
STD_BITMAP_BUTTON * m_deleteVariantButton
STD_BITMAP_BUTTON * m_sidebarButton
STD_BITMAP_BUTTON * m_browseButton
STD_BITMAP_BUTTON * m_addFieldButton
STD_BITMAP_BUTTON * m_editVariantDescButton
WX_GRID * m_viewControlsGrid
wxListBox * m_variantListBox
STD_BITMAP_BUTTON * m_bRefreshPreview
wxChoice * m_cbBomPresets
wxTextCtrl * m_textRefRangeDelimiter
STD_BITMAP_BUTTON * m_bRefresh
wxCheckBox * m_groupSymbolsBox
wxSplitterWindow * m_splitter_left
std::map< wxString, BOM_PRESET > m_bomPresets
BOM_PRESET * m_lastSelectedBomPreset
void saveJobSettings(JOB_EXPORT_BOM &aJob)
virtual wxGridCellEditor * createReferenceEditor()
void SetUserBomFmtPresets(std::vector< BOM_FMT_PRESET > &aPresetList)
wxSize GetDefaultDialogSize() const
virtual wxGridCellEditor * createDatasheetEditor()=0
virtual bool resolveTextVar(wxString *aToken) const =0
int getStoredColumnWidth(const std::string &aFieldName) const
BOM_FMT_PRESET * m_lastSelectedBomFmtPreset
void syncBomFmtPresetSelection()
void OnColMove(wxGridEvent &aEvent)
void EnableSelectionEvents()
void DisableSelectionEvents()
int presetDashDashDashIndex(int aPresetCount) const
void OnColSort(wxGridEvent &aEvent)
BOM_PRESET * m_currentBomPreset
void OnGridMouseMove(wxMouseEvent &aEvent)
bool savePresets(bool aSaveCurrentSettings)
Store what changed since rememberLoadedPresets(); true if anything did.
wxArrayString m_bomFmtPresetMRU
void OnSizeViewControlsGrid(wxSizeEvent &event) override
void OnViewControlsCellChanged(wxGridEvent &aEvent) override
BOM_FMT_PRESET * m_currentBomFmtPreset
int presetDeletePresetIndex(int aPresetCount) const
void OnTableRangeSelectionChanged(wxGridRangeSelectEvent &aEvent)
wxString getSelectedVariant() const
void rememberLoadedPresets()
Remember the presets as loaded, which may differ from the stored ones after normalization.
void doApplyBomFmtPreset(const BOM_FMT_PRESET &aPreset)
void OnFilterText(wxCommandEvent &aEvent) override
void doApplyBomPreset(const BOM_PRESET &aPreset)
void OnPageChanged(wxNotebookEvent &aEvent) override
void ShowHideColumn(int aCol, bool aShow)
void OnExport(wxCommandEvent &aEvent) override
virtual void OnTableSelectionChanged(const std::set< int > &aRows)=0
void updateBomPresetSelection(const wxString &aName)
void OnFilterScope(wxCommandEvent &aEvent) override
BOM_FMT_PRESET GetCurrentBomFmtSettings()
Returns a formatting configuration corresponding to the values in the UI controls of the dialog.
void RestorePanelLayout()
void RestoreGridSelection(const std::set< KIID_PATH > &aItemKeys)
Restore a selection previously returned by SaveGridSelection().
std::map< FIELD_T, int > m_mandatoryFieldListIndexes
virtual wxGridCellEditor * createFootprintEditor()
void onBomFmtPresetChanged(wxCommandEvent &aEvent)
int presetSavePresetIndex(int aPresetCount) const
void OnRenameField(wxCommandEvent &aEvent) override
void OnGroupSymbolsToggled(wxCommandEvent &aEvent) override
void OnPreviewRefresh(wxCommandEvent &aEvent) override
virtual std::vector< BOM_PRESET > getBuiltInBomPresets() const
void updateBomFmtPresetSelection(const wxString &aName)
void OnTableColSize(wxGridSizeEvent &event) override
void SetUserBomPresets(std::vector< BOM_PRESET > &aPresetList)
void ApplyBomFmtPreset(const wxString &aPresetName)
DIALOG_FIELDS_TABLE(wxWindow *aParent, FIELDS_TABLE_SETTINGS &aPanelSettings, FIELDS_TABLE_BOM_SETTINGS &aBomSettings, JOB_EXPORT_BOM *aJob)
~DIALOG_FIELDS_TABLE() override
void SetupColumnProperties(int aCol)
FIELDS_TABLE_BOM_SETTINGS & m_cfgBomSettings
void loadDefaultBomPresets()
static void loadJobBomFmtPreset(const JOB_EXPORT_BOM &aJob, BOM_FMT_PRESET &aPreset)
FIELDS_TABLE_SETTINGS & m_cfgDialogSettings
std::map< wxString, BOM_FMT_PRESET > m_bomFmtPresets
static void loadJobBomPreset(const JOB_EXPORT_BOM &aJob, BOM_PRESET &aPreset)
BOM_PRESET getDataModelBomPreset()
void updateExpanderColumn()
virtual wxString resolveVariant() const =0
std::set< int > GetSelectedGridRows() const
Return the explicitly selected grid rows, or the cursor row if the selection is empty.
wxArrayString m_bomPresetMRU
void OnGridMouseWheel(wxMouseEvent &aEvent)
void OnSidebarToggle(wxCommandEvent &event) override
void rebuildBomPresetsWidget()
void OnAddField(wxCommandEvent &aEvent) override
std::vector< BOM_PRESET > GetUserBomPresets() const
void onBomPresetChanged(wxCommandEvent &aEvent)
virtual void onBomSettingsChanged()
void SetReadOnly(bool aReadOnly)
std::set< KIID_PATH > SaveGridSelection()
Save the grid selection by stable item identity so it can survive a row rebuild.
void ApplyBomPreset(const wxString &aPresetName)
void OnFilterMouseMoved(wxMouseEvent &event) override
void OnRegroupSymbols(wxCommandEvent &aEvent) override
void OnOutputFileBrowseClicked(wxCommandEvent &aEvent) override
void OnTableValueChanged(wxGridEvent &event) override
void syncBomPresetSelection()
virtual FIELDS_TABLE_DATA_MODEL_BASE * getDataModel() const =0
VIEW_CONTROLS_GRID_DATA_MODEL * m_viewControlsDataModel
FIELDS_TABLE_BOM_SETTINGS m_loadedSettings
static wxString GetDefaultBomFileName(const wxString &aInputFileName)
Derive the default BOM output file name from the input file name by swapping the extension to CSV.
std::vector< BOM_FMT_PRESET > GetUserBomFmtPresets() const
void OnTableLabelClick(wxGridEvent &event) override
void rebuildBomFmtPresetsWidget()
void setSideBarButtonLook(bool aIsLeftPanelCollapsed)
void AddField(const wxString &aFieldName, const wxString &aLabelValue, bool aShow, bool aGroupBy, bool aAddedByUser=false)
void loadDefaultBomFmtPresets()
void OnRemoveField(wxCommandEvent &aEvent) override
void SetupAllColumnProperties()
void OptOut(wxWindow *aWindow)
Opt out of control state saving.
EDA_BASE_FRAME * m_parentFrame
wxString GetTextSelection(int aColumn=0)
Return the selected text from aColumn in the wxListCtrl in the dialog.
void SetListLabel(const wxString &aLabel)
Contains everything completly generic to fields tables data models, as well as column functionality t...
virtual void SetCurrentVariant(const wxString &aVariantName)=0
Select the displayed variant, retaining un-applied edits in every variant.
void SetSorting(int aCol, bool aAscending)
int GetNumberCols() override
void MoveColumn(int aCol, int aNewPos)
void SetShowColumn(int aCol, bool aShow)
void SetIncludeExcludedFromBOM(bool aInclude)
virtual void AddColumn(const wxString &aFieldName, const wxString &aLabel, bool aAddedByUser)=0
bool GetGroupColumn(int aCol)
void SetColLabelValue(int aCol, const wxString &aLabel) override
void SetFilterScope(BOM_FILTER_SCOPE aScope)
BOM_PRESET GetBomSettings()
int GetFieldNameCol(const wxString &aFieldName) const
void RemoveColumn(int aCol)
bool GetIncludeExcludedFromBOM()
void SetGroupingEnabled(bool aGroup)
int GetColDataWidth(int aCol)
virtual void ExpandCollapseRow(int aRow)=0
void RenameColumn(int aCol, const wxString &newName)
void SetGroupColumn(int aCol, bool aGroup)
void SetFilter(const wxString &aFilter)
wxString GetColLabelValue(int aCol) override
bool GetShowColumn(int aCol)
void ApplyBomPreset(const BOM_PRESET &aPreset)
virtual void RebuildRows()=0
DIALOG_FIELDS_TABLE * m_dialog
FIELDS_TABLE_GRID_TRICKS(DIALOG_FIELDS_TABLE *aDialog, WX_GRID *aGrid, FIELDS_TABLE_DATA_MODEL_BASE *aDataModel)
virtual void showFieldsTablePopupMenu(wxMenu &aMenu, wxGridEvent &aEvent)
void appendPopupMenuItems(wxMenu &aMenu) override
void copyFromVariant(const wxString &aVariant, const std::vector< wxGridCellCoords > &aCells)
FIELDS_TABLE_DATA_MODEL_BASE * m_dataModel
void doPopupSelection(wxCommandEvent &aEvent) override
void showPopupMenu(wxMenu &aMenu, wxGridEvent &aEvent) override
virtual void doFieldsTablePopupSelection(wxCommandEvent &aEvent)
A text control validator used for validating the text allowed in fields.
This class works around a bug in wxGrid where the first keystroke doesn't get sent through the valida...
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
GRID_TRICKS(WX_GRID *aGrid)
virtual void doPopupSelection(wxCommandEvent &event)
virtual void showPopupMenu(wxMenu &menu, wxGridEvent &aEvent)
WX_GRID * m_grid
I don't own the grid, but he owns me.
wxString m_stringDelimiter
wxString m_fieldDelimiter
bool m_includeByteOrderMark
std::vector< wxString > m_fieldsOrdered
wxString m_refRangeDelimiter
std::vector< wxString > m_fieldsLabels
void SetSelectedVariant(const wxString &aVariant)
std::vector< wxString > m_fieldsGroupBy
wxString m_bomFmtPresetName
BOM_FILTER_SCOPE m_filterScope
void SetConfiguredOutputPath(const wxString &aPath)
Sets the configured output path for the job, this path is always saved to file.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
static REPORTER & GetInstance()
virtual ROW_STATE GetRowState(int aRow) const
void SetColAttr(wxGridCellAttr *aAttr, int aCol) override
wxString GetGeneratedFieldDisplayName(const wxString &aSource)
Returns any variables unexpanded, e.g.
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject, bool aAllowEscapes)
Replace any environment variable & text variable references with their values.
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, RESOLUTION_CONTEXT aContext)
wxString ResolveProjectPath(const wxString &aPath, const PROJECT *aProject, const std::function< bool(wxString *)> *aTextResolver)
Expand a user-entered file path as ExpandPathVariables() does, then anchor a relative result at the p...
wxString NormalizeFilePathForTextVars(const wxString &aPath)
Normalize a file path so its text variables survive ExpandTextVars.
bool EnsureFileDirectoryExists(wxFileName *aTargetFullFileName, const wxString &aBaseFilename, REPORTER *aReporter)
Make aTargetFullFileName absolute and create the path of this file if it doesn't yet exist.
bool IsGeneratedField(const wxString &aFieldName)
Returns true if the entire string is generated, e.g is a single text var reference.
int OKOrCancelDialog(wxWindow *aParent, const wxString &aWarning, const wxString &aMessage, const wxString &aDetailedMessage, const wxString &aOKLabel, const wxString &aCancelLabel, bool *aApplyToAll)
Display a warning dialog with aMessage and returns the user response.
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
This file is part of the common library.
static bool isValidColumnWidth(int aWidth)
static constexpr int MAX_COL_WIDTH
Base window classes and related definitions.
#define DISPLAY_NAME_COLUMN
#define SHOW_FIELD_COLUMN
@ GRIDTRICKS_FIRST_SHOWHIDE
@ GRIDTRICKS_FIRST_CLIENT_ID
static const std::string CsvFileExtension
static wxString CsvFileWildcard()
KICOMMON_API wxSize GetTextSize(const wxString &aSingleLine, wxWindow *aWindow)
Return the size of aSingleLine of text when it is rendered in aWindow using whatever font is currentl...
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
std::vector< FAB_LAYER_COLOR > dummy
wxString GetDefaultVariantName()
bool includeByteOrderMark
static BOM_FMT_PRESET CSV()
static std::vector< BOM_FMT_PRESET > BuiltInPresets()
wxString refRangeDelimiter
Dialog settings for the lib/symbol/footprint table editors across the various editors.
bool FieldNamesAreDuplicates(const wxString &aLhs, const wxString &aRhs, std::initializer_list< FIELD_T > aMandatoryFields)
Test whether two field names should be treated as duplicates for the purposes of field name uniquenes...
wxString GetDefaultFieldName(FIELD_T aFieldId, TRANSLATION aTranslation)
Return a default symbol field name for a mandatory field type.
FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
@ DATASHEET
name of datasheet
@ REFERENCE
Field Reference of part, i.e. "IC21".
Functions to provide common constants and other functions to assist in making a consistent UI.
Custom text control validator definitions.
Definition of file extensions used in Kicad.
bool IsRowCollapsed(ROW_STATE aState)
enum KICOMMON_API ROW_STATE
Used primarily by the fields tables to collapse multiple grouped symbols, etc.
bool IsRowExpanded(ROW_STATE aState)