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
63template <
typename PRESET>
64int findPresetIndexByPointer(
const wxChoice* aChoice,
const PRESET* aPreset )
66 for(
unsigned i = 0; i < aChoice->GetCount(); ++i )
68 if( aChoice->GetClientData( i ) ==
static_cast<const void*
>( aPreset ) )
69 return static_cast<int>( i );
76template <
typename PRESET>
77int findPresetIndexByName(
const wxChoice* aChoice,
const std::map<wxString, PRESET>& aPresets,
78 const wxString& aName )
80 auto presetIt = aPresets.find( aName );
82 return presetIt == aPresets.end() ? wxNOT_FOUND : findPresetIndexByPointer( aChoice, &presetIt->second );
96 VIEW_CONTROLS_GRID_TRICKS(
WX_GRID* aGrid ) :
102 void doPopupSelection( wxCommandEvent& aEvent )
override
105 m_grid->PostSizeEvent();
124 int row =
m_grid->GetGridCursorRow();
125 int col =
m_grid->GetGridCursorCol();
127 wxMenuItem* revertMenu = aMenu.Append( MYID_REVERT_ROW,
_(
"Revert Row" ),
128 _(
"Revert the fields in this row" ) );
129 wxMenuItem* clearMenu = aMenu.Append( MYID_CLEAR_CELL,
_(
"Clear Cell" ),
130 _(
"Clear the cell value" ) );
131 aMenu.AppendSeparator();
133 if( row >= 0 && col >= 0 )
136 clearMenu->Enable(
m_grid->IsEditable() &&
m_dataModel->CanClearCell( row, col ) );
140 revertMenu->Enable(
false );
141 clearMenu->Enable(
false );
150 if(
m_dialog->m_variantListBox->GetCount() < 2 )
154 std::vector<wxGridCellCoords> cells;
155 bool hasSelection =
m_grid->IsSelection();
157 if(
m_grid->IsEditable() )
159 for(
int row = 0; row <
m_grid->GetNumberRows(); ++row )
161 for(
int col = 0; col <
m_grid->GetNumberCols(); ++col )
163 bool selected = hasSelection ?
m_grid->IsInSelection( row, col )
164 : row ==
m_grid->GetGridCursorRow() && col ==
m_grid->GetGridCursorCol();
166 if( selected &&
m_grid->IsColShown( col ) &&
m_dataModel->CanCopyCellFromVariant( row, col ) )
168 cells.emplace_back( row, col );
174 wxMenu* variantsMenu =
new wxMenu;
176 for(
unsigned int i = 0; i <
m_dialog->m_variantListBox->GetCount(); ++i )
178 wxString
name =
m_dialog->m_variantListBox->GetString( i );
180 wxString label =
name;
181 label.Replace( wxS(
"&" ), wxS(
"&&" ) );
183 wxMenuItem* item = variantsMenu->Append( wxID_ANY, label );
184 item->Enable( !cells.empty() && variant !=
m_dataModel->GetCurrentVariant() );
187 wxEVT_COMMAND_MENU_SELECTED,
188 [
this, variant, cells]( wxCommandEvent& )
195 aMenu.AppendSeparator();
196 aMenu.AppendSubMenu( variantsMenu,
_(
"Copy from Variant" ) )->Enable( !cells.empty() );
202 if( !
m_grid->CommitPendingChanges(
false ) || aCells.empty() )
205 for(
const wxGridCellCoords& cell : aCells )
206 m_dataModel->CopyCellFromVariant( cell.GetRow(), cell.GetCol(), aVariant );
214 wxGridEvent event(
m_grid->GetId(), wxEVT_GRID_CELL_CHANGED,
m_grid, aCells.front().GetRow(),
215 aCells.front().GetCol() );
216 m_grid->GetEventHandler()->ProcessEvent( event );
223 int row =
m_grid->GetGridCursorRow();
224 int col =
m_grid->GetGridCursorCol();
226 if( aEvent.GetId() == MYID_REVERT_ROW )
228 if(
m_grid->CommitPendingChanges(
false ) )
238 else if( aEvent.GetId() == MYID_CLEAR_CELL )
240 if(
m_grid->CommitPendingChanges(
false ) )
309 wxGridCellAttr* attr =
new wxGridCellAttr;
310 attr->SetReadOnly(
true );
313 attr =
new wxGridCellAttr;
314 attr->SetRenderer(
new wxGridCellBoolRenderer() );
316 attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
319 attr =
new wxGridCellAttr;
320 attr->SetRenderer(
new wxGridCellBoolRenderer() );
322 attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
328 m_filter->SetDescriptiveText(
_(
"Filter" ) );
331 m_grid->EnableCursorRowColumnHighlight();
397 [&]() -> std::pair<int, int>
408 if( aInputFileName.IsEmpty() )
409 return wxEmptyString;
411 wxFileName fn( aInputFileName );
414 return fn.GetFullPath();
428 aPreset.fieldsOrdered.clear();
435 field.
name = fieldName;
436 field.
show = !fieldName.StartsWith( wxT(
"__" ), &field.
name );
446 aPreset.fieldsOrdered.emplace_back( field );
494 if( modelField.show )
501 if( modelField.groupBy )
511 bool modified =
false;
539 if( aSaveCurrentSettings &&
m_cfgBomSettings.m_BomFmtSettings != fmtSettings )
551 return ConvertDialogToPixels( wxSize( 600, 300 ) );
557 m_grid->Connect( wxEVT_GRID_RANGE_SELECTED,
565 m_grid->Disconnect( wxEVT_GRID_RANGE_SELECTED,
579 std::set<int> selectedRows;
581 wxGridCellCoordsArray topLeft =
m_grid->GetSelectionBlockTopLeft();
582 wxGridCellCoordsArray bottomRight =
m_grid->GetSelectionBlockBottomRight();
584 for(
size_t i = 0; i < topLeft.size(); ++i )
586 for(
int row = topLeft[i].GetRow(); row <= bottomRight[i].GetRow(); ++row )
587 selectedRows.insert( row );
590 wxGridCellCoordsArray selectedCells =
m_grid->GetSelectedCells();
592 for(
size_t i = 0; i < selectedCells.size(); ++i )
593 selectedRows.insert( selectedCells[i].GetRow() );
595 for(
int row :
m_grid->GetSelectedRows() )
596 selectedRows.insert( row );
598 int cursorRow =
m_grid->GetGridCursorRow();
600 if( selectedRows.empty() && cursorRow >= 0 && cursorRow <
getDataModel()->GetNumberRows() )
601 selectedRows.insert( cursorRow );
609 std::set<KIID_PATH> selectedItemKeys;
614 selectedItemKeys.insert( key );
617 return selectedItemKeys;
623 if( aItemKeys.empty() )
628 bool firstSelection =
true;
630 for(
int row = 0; row <
getDataModel()->GetNumberRows(); ++row )
634 if( aItemKeys.count( key ) )
636 m_grid->SelectRow( row,
true );
640 m_grid->SetGridCursor( row,
m_grid->GetGridCursorCol() );
641 firstSelection =
false;
660 [
this, sidebarCollapsed, sashPosition, variantSashPosition]()
662 if( sidebarCollapsed )
685 for(
int i = 0; i <
m_grid->GetNumberCols(); i++ )
687 if(
m_grid->IsColShown( i ) )
689 std::string fieldName(
getDataModel()->GetColFieldName( i ).ToUTF8() );
714 m_grid->EnableEditing( !aReadOnly );
730 wxGridCellAttr* attr =
new wxGridCellAttr;
731 attr->SetReadOnly(
false );
737 attr->SetRenderer(
new wxGridCellStringRenderer() );
744 attr->SetRenderer(
new wxGridCellStringRenderer() );
762 attr->SetAlignment( wxALIGN_RIGHT, wxALIGN_CENTER );
763 attr->SetRenderer(
new wxGridCellNumberRenderer() );
768 attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
780 attr->SetRenderer(
new wxGridCellStringRenderer() );
781 attr->SetEditor(
m_grid->GetDefaultEditor() );
794 m_grid->AutoSizeColumns(
false );
796 bool sortAscending =
true;
798 for(
int col = 0; col <
m_grid->GetNumberCols(); ++col )
824 std::string key(
getDataModel()->GetColFieldName( col ).ToUTF8() );
833 int maxWidth = defaultDlgSize.x / 3;
835 m_grid->SetColSize( col, std::clamp( textWidth, 100, maxWidth ) );
845 m_grid->SetSortingColumn( sortCol, sortAscending );
859 if( aIsLeftPanelCollapsed )
907 int row = aEvent.GetRow();
910 if( aEvent.GetCol() != -1 || row < 0 || row >=
getDataModel()->GetNumberRows() )
924 if( !
m_grid->CommitPendingChanges() )
927 int col =
m_grid->GetGridCursorCol();
931 if( col >= 0 && col < m_grid->GetNumberCols() )
932 m_grid->SetGridCursor( row, col );
941#if defined( __WXOSX__ )
942 wxPoint pos = aEvent.GetPosition();
943 wxRect ctrlRect =
m_filter->GetScreenRect();
944 int buttonWidth = ctrlRect.GetHeight();
947 if(
m_filter->IsSearchButtonVisible() && pos.x < buttonWidth )
948 SetCursor( wxCURSOR_ARROW );
949 else if(
m_filter->IsCancelButtonVisible() && pos.x > ctrlRect.GetWidth() - buttonWidth )
950 SetCursor( wxCURSOR_ARROW );
952 SetCursor( wxCURSOR_IBEAM );
963 int remainingWidth =
m_viewControlsGrid->GetSize().GetX() - showColWidth - groupByColWidth;
988 int row = aEvent.GetRow();
990 wxCHECK( row < m_viewControlsGrid->GetNumberRows(), );
992 switch( aEvent.GetCol() )
1003 m_grid->SetColLabelValue( dataCol, label );
1035 if(
getDataModel()->ColIsQuantity( dataCol ) && value )
1037 DisplayError(
this,
_(
"The Quantity column cannot be grouped by." ) );
1045 if(
getDataModel()->ColIsItemNumber( dataCol ) && value )
1047 DisplayError(
this,
_(
"The Item Number column cannot be grouped by." ) );
1075 wxTextEntryDialog dlg(
this,
_(
"New field name:" ),
_(
"Add Field" ) );
1077 if( dlg.ShowModal() != wxID_OK )
1080 wxString fieldName = dlg.GetValue();
1082 if( fieldName.IsEmpty() )
1092 DisplayError(
this, wxString::Format(
_(
"Field name '%s' already in use." ), fieldName ) );
1115 DisplayError(
this, wxString::Format(
_(
"The first %d fields are mandatory." ),
1124 if( col != -1 &&
getDataModel()->ColIsItemIdentifier( col ) )
1126 DisplayError(
this, wxString::Format(
_(
"The '%s' field cannot be removed." ),
1132 return IsOK(
this, wxString::Format(
_(
"Are you sure you want to remove the field '%s'?" ),
1158 if( selectedRows.empty() )
1161 int row = selectedRows[0];
1167 DisplayError(
this, wxString::Format(
_(
"The first %d fields are mandatory and names cannot be changed." ),
1178 wxCHECK_RET( col != -1, wxS(
"Existing field name missing from data model" ) );
1182 DisplayError(
this, wxString::Format(
_(
"The '%s' field cannot be renamed." ),
1187 wxTextEntryDialog dlg(
this,
_(
"New field name:" ),
_(
"Rename Field" ), fieldName );
1189 if( dlg.ShowModal() != wxID_OK )
1192 wxString newFieldName = dlg.GetValue();
1195 if( newFieldName == fieldName )
1198 if( newFieldName.IsEmpty() )
1205 if(
getDataModel()->GetFieldNameCol( newFieldName ) != -1 )
1207 wxString confirm_msg = wxString::Format(
_(
"Field name %s already exists." ), newFieldName );
1216 if( labelIsAutogenerated )
1276 int sortCol = aEvent.GetCol();
1288 if(
m_grid->IsSortingBy( sortCol ) )
1291 ascending = !
m_grid->IsSortOrderAscending();
1309 int origPos = aEvent.GetCol();
1317 int newPos =
m_grid->GetColPos( origPos );
1320 if( newPos < origPos )
1342 wxPoint pos = aEvent.GetPosition();
1344 m_grid->CalcUnscrolledPosition( pos.x, pos.y, &ux, &uy );
1345 int row =
m_grid->YToRow( uy );
1346 int col =
m_grid->XToCol( ux );
1348 if( row == wxNOT_FOUND || col == wxNOT_FOUND )
1350 m_grid->GetGridWindow()->UnsetToolTip();
1354 wxString rawValue =
getDataModel()->GetValue( row, col );
1356 if( rawValue.Contains( wxT(
"${" ) ) )
1357 m_grid->GetGridWindow()->SetToolTip( rawValue );
1359 m_grid->GetGridWindow()->UnsetToolTip();
1365 if( aEvent.GetWheelAxis() != wxMOUSE_WHEEL_VERTICAL || aEvent.GetModifiers() != wxMOD_SHIFT )
1380 int scrollLines = aEvent.IsPageScroll() ?
m_grid->GetScrollPageSize( wxHORIZONTAL )
1381 : aEvent.GetLinesPerAction();
1383 wxPoint viewStart =
m_grid->GetViewStart();
1384 m_grid->Scroll( viewStart.x - lines * scrollLines, viewStart.y );
1409 wxFileName fn(
Prj().AbsolutePath(
m_parentFrame->GetCurrentFileName() ) );
1412 wxFileDialog saveDlg(
this,
_(
"Bill of Materials Output File" ),
path, fn.GetFullName(),
1417 if( saveDlg.ShowModal() == wxID_CANCEL )
1420 wxFileName file = wxFileName( saveDlg.GetPath() );
1421 wxString defaultPath = fn.GetPathWithSep();
1423 if(
IsOK(
this, wxString::Format(
_(
"Do you want to use a path relative to\n'%s'?" ), defaultPath ) ) )
1425 if( !file.MakeRelativeTo( defaultPath ) )
1441 _(
"Changes have not yet been saved. Export unsaved data?" ),
"",
_(
"OK" ),
1452 std::function<bool( wxString* )> textResolver =
1453 [&]( wxString* token ) ->
bool
1458 wxString sourceFileName =
m_parentFrame->GetCurrentFileName();
1461 if(
path.IsEmpty() )
1467 if(
path.IsEmpty() )
1469 DisplayError(
this,
_(
"No output file specified in Export tab." ) );
1479 wxFileName outputFile = wxFileName::FileName(
path );
1484 msg.Printf(
_(
"Could not open/create path '%s'." ), outputFile.GetPath() );
1489 wxFFile out( outputFile.GetFullPath(),
"wb" );
1491 if( !out.IsOpened() )
1493 msg.Printf(
_(
"Could not create BOM output '%s'." ), outputFile.GetFullPath() );
1502 msg.Printf(
_(
"Could not write BOM output '%s'." ), outputFile.GetFullPath() );
1516 msg.Printf(
_(
"Wrote BOM output to '%s'" ), outputFile.GetFullPath() );
1530 if( saveIncludeExcudedFromBOM )
1553 std::vector<BOM_PRESET> ret;
1555 for(
const std::pair<const wxString, BOM_PRESET>& pair :
m_bomPresets )
1557 if( !pair.second.readOnly )
1558 ret.emplace_back( pair.second );
1570 for(
const BOM_PRESET& preset : aPresetList )
1588 wxCommandEvent
dummy;
1595 BOM_PRESET preset = aPreset;
1597 if( preset.fieldsOrdered.empty() )
1601 if( builtIn.name == BOM_PRESET::DefaultEditing().name )
1637 for(
int i = 0; i <
getDataModel()->GetColsCount(); i++ )
1639 const wxString& fieldName(
getDataModel()->GetColFieldName( i ) );
1664 wxASSERT_MSG(
true,
"Fields control has a field not found in the data model." );
1668 std::string fieldNameStr( fieldName.ToUTF8() );
1673 m_grid->SetColLabelValue( col, label );
1728 return BOM_PRESET::BuiltInPresets();
1737 int default_idx = 0;
1741 wxString label = preset.readOnly ? wxGetTranslation( presetName ) : presetName;
1744 if( presetName == BOM_PRESET::DefaultEditing().
name )
1768 return aPresetCount - (
m_job ? 1 : 3 );
1774 return m_job ? wxNOT_FOUND : aPresetCount - 2;
1780 return m_job ? wxNOT_FOUND : aPresetCount - 1;
1795 [&](
const std::pair<const wxString, BOM_PRESET>& aPair )
1797 const BOM_PRESET& preset = aPair.second;
1800 if( !( preset.sortAsc == current.sortAsc
1801 && preset.filterString == current.filterString
1802 && preset.filterScope == current.filterScope
1803 && preset.groupSymbols == current.groupSymbols
1804 && preset.excludeDNP == current.excludeDNP
1805 && preset.includeExcludedFromBOM == current.includeExcludedFromBOM ) )
1810 if( preset.sortField != current.sortField )
1814 std::vector<BOM_FIELD>
A,
B;
1816 for(
const BOM_FIELD& field : preset.fieldsOrdered )
1818 if( field.show || field.groupBy )
1819 A.emplace_back( field );
1822 for(
const BOM_FIELD& field : current.fieldsOrdered )
1824 if( field.show || field.groupBy )
1825 B.emplace_back( field );
1831 if( it != m_bomPresets.end() )
1833 m_cbBomPresets->SetSelection( findPresetIndexByPointer( m_cbBomPresets, &it->second ) );
1837 m_cbBomPresets->SetSelection( presetDashDashDashIndex( m_cbBomPresets->GetCount() ) );
1840 m_currentBomPreset =
static_cast<BOM_PRESET*
>( m_cbBomPresets->GetClientData( m_cbBomPresets->GetSelection() ) );
1865 auto resetSelection =
1870 if( presetIndex == wxNOT_FOUND )
1890 wxTextEntryDialog dlg(
this,
_(
"BOM preset name:" ),
_(
"Save BOM Preset" ),
name );
1892 if( dlg.ShowModal() != wxID_OK )
1898 name = dlg.GetValue();
1914 else if( preset->readOnly )
1916 wxMessageBox(
_(
"Default presets cannot be modified.\nPlease use a different name." ),
1917 _(
"Error" ), wxOK | wxICON_ERROR,
this );
1924 if( !
IsOK(
this,
_(
"Overwrite existing preset?" ) ) )
1931 preset->name =
name;
1948 wxArrayString headers;
1949 std::vector<wxArrayString> items;
1951 headers.Add(
_(
"Presets" ) );
1955 if( !preset.readOnly )
1959 items.emplace_back( item );
1972 if( idx != wxNOT_FOUND && presetIt !=
m_bomPresets.end() )
2018 if( selection != wxNOT_FOUND )
2021 current.
name = preset->name;
2040 std::vector<BOM_FMT_PRESET> ret;
2044 if( !preset.readOnly )
2045 ret.emplace_back( preset );
2075 wxCommandEvent
dummy;
2133 int default_idx = 0;
2137 wxString label = preset.readOnly ? wxGetTranslation( presetName ) : presetName;
2167 [&](
const std::pair<const wxString, BOM_FMT_PRESET>& aPair )
2169 return ( aPair.second.fieldDelimiter == current.fieldDelimiter
2170 && aPair.second.stringDelimiter == current.stringDelimiter
2171 && aPair.second.refDelimiter == current.refDelimiter
2172 && aPair.second.refRangeDelimiter == current.refRangeDelimiter
2173 && aPair.second.keepTabs == current.keepTabs
2174 && aPair.second.keepLineBreaks == current.keepLineBreaks
2175 && aPair.second.includeByteOrderMark == current.includeByteOrderMark );
2213 auto resetSelection =
2218 if( presetIndex == wxNOT_FOUND )
2238 wxTextEntryDialog dlg(
this,
_(
"BOM preset name:" ),
_(
"Save BOM Preset" ),
name );
2240 if( dlg.ShowModal() != wxID_OK )
2246 name = dlg.GetValue();
2264 wxMessageBox(
_(
"Default presets cannot be modified.\nPlease use a different name." ),
2265 _(
"Error" ), wxOK | wxICON_ERROR,
this );
2272 if( !
IsOK(
this,
_(
"Overwrite existing preset?" ) ) )
2296 wxArrayString headers;
2297 std::vector<wxArrayString> items;
2299 headers.Add(
_(
"Presets" ) );
2301 for( std::pair<const wxString, BOM_FMT_PRESET>& pair :
m_bomFmtPresets )
2303 if( !pair.second.readOnly )
2306 item.Add( pair.first );
2307 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
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)
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 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
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 const wxString AbsolutePath(const wxString &aFileName) const
Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.
virtual ROW_STATE GetRowState(int aRow) const
void SetColAttr(wxGridCellAttr *aAttr, int aCol) override
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject)
Replace any environment variable & text variable references with their values.
wxString GetGeneratedFieldDisplayName(const wxString &aSource)
Returns any variables unexpanded, e.g.
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, RESOLUTION_CONTEXT aContext)
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.
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)