Fields Data Model: pull more UI controls interaction out of class

This commit is contained in:
Mike Williams 2023-03-01 10:06:00 -05:00
parent cccd708860
commit 97eed8c8a2
4 changed files with 142 additions and 83 deletions

View File

@ -156,8 +156,8 @@ BOM_PRESET DIALOG_SYMBOL_FIELDS_TABLE::bomPresetGroupedByValue(
std::pair<std::string, bool>( "Footprint", false ),
std::pair<std::string, bool>( "Quantity", false ),
} ),
std::map<std::string, int>(), std::map<std::string, bool>(), std::vector<wxString>(),
_HKI( "" ), true );
std::map<std::string, int>(), std::vector<wxString>(), _( "Reference" ), true, _HKI( "" ),
true );
BOM_PRESET DIALOG_SYMBOL_FIELDS_TABLE::bomPresetGroupedByValueFootprint(
@ -176,8 +176,8 @@ BOM_PRESET DIALOG_SYMBOL_FIELDS_TABLE::bomPresetGroupedByValueFootprint(
std::pair<std::string, bool>( "Footprint", true ),
std::pair<std::string, bool>( "Quantity", false ),
} ),
std::map<std::string, int>(), std::map<std::string, bool>(), std::vector<wxString>(),
_HKI( "" ), true );
std::map<std::string, int>(), std::vector<wxString>(), _( "Reference" ), true, _HKI( "" ),
true );
DIALOG_SYMBOL_FIELDS_TABLE::DIALOG_SYMBOL_FIELDS_TABLE( SCH_EDIT_FRAME* parent ) :
@ -270,8 +270,6 @@ DIALOG_SYMBOL_FIELDS_TABLE::DIALOG_SYMBOL_FIELDS_TABLE( SCH_EDIT_FRAME* parent )
"cycle through presets in the popup." ),
KeyNameFromKeyCode( PRESET_SWITCH_KEY ), KeyNameFromKeyCode( PRESET_SWITCH_KEY ) ) );
m_dataModel->RebuildRows( m_filter, m_groupSymbolsBox, m_fieldsCtrl );
m_grid->UseNativeColHeader( true );
m_grid->SetTable( m_dataModel, true );
@ -289,8 +287,6 @@ DIALOG_SYMBOL_FIELDS_TABLE::DIALOG_SYMBOL_FIELDS_TABLE( SCH_EDIT_FRAME* parent )
ApplyBomPreset( m_schSettings.m_BomSettings );
syncBomPresetSelection();
SetupColumnProperties();
m_grid->SelectRow( 0 );
m_grid->SetGridCursor( 0, 1 );
SetInitialFocus( m_grid );
@ -378,12 +374,12 @@ void DIALOG_SYMBOL_FIELDS_TABLE::SetupColumnProperties()
else
m_grid->SetColSize( col, Clamp( 100, textWidth, maxWidth ) );
}
}
if( m_schSettings.m_BomSettings.column_sorts.count( key ) )
{
sortCol = col;
sortAscending = m_schSettings.m_BomSettings.column_sorts[key];
}
if( m_schSettings.m_BomSettings.sort_field == m_dataModel->GetColFieldName( col ) )
{
sortCol = col;
sortAscending = m_schSettings.m_BomSettings.sort_asc;
}
}
@ -395,13 +391,16 @@ void DIALOG_SYMBOL_FIELDS_TABLE::SetupColumnProperties()
if( col == -1 )
continue;
if( m_fieldsCtrl->GetToggleValue( i, SHOW_FIELD_COLUMN ) )
bool show = m_fieldsCtrl->GetToggleValue( i, SHOW_FIELD_COLUMN );
m_dataModel->SetShowColumn( col, show );
if( show )
m_grid->ShowCol( col );
else
m_grid->HideCol( col );
}
m_dataModel->Sort( sortCol, sortAscending );
m_dataModel->SetSorting( sortCol, sortAscending );
m_grid->SetSortingColumn( sortCol, sortAscending );
}
@ -717,8 +716,8 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnRenameField( wxCommandEvent& event )
void DIALOG_SYMBOL_FIELDS_TABLE::OnFilterText( wxCommandEvent& aEvent )
{
m_schSettings.m_BomSettings.filter_string = m_filter->GetValue();
m_dataModel->RebuildRows( m_filter, m_groupSymbolsBox, m_fieldsCtrl );
m_dataModel->Sort( m_grid->GetSortingColumn(), m_grid->IsSortOrderAscending() );
m_dataModel->SetFilter( m_filter->GetValue() );
m_dataModel->RebuildRows();
m_grid->ForceRefresh();
syncBomPresetSelection();
@ -771,6 +770,7 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnColumnItemToggled( wxDataViewEvent& event )
m_schSettings.m_BomSettings.fields_show[fieldName] = value;
int dataCol = m_dataModel->GetFieldNameCol( fieldName );
m_dataModel->SetShowColumn( dataCol, value );
if( dataCol != -1 )
{
@ -795,11 +795,12 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnColumnItemToggled( wxDataViewEvent& event )
m_fieldsCtrl->SetToggleValue( value, row, col );
}
std::string fieldName( m_fieldsCtrl->GetTextValue( row, FIELD_NAME_COLUMN ).ToUTF8() );
m_schSettings.m_BomSettings.fields_group_by[fieldName] = value;
wxString fieldName = m_fieldsCtrl->GetTextValue( row, FIELD_NAME_COLUMN );
std::string fieldNameStr( fieldName.ToUTF8() );
m_schSettings.m_BomSettings.fields_group_by[fieldNameStr] = value;
m_dataModel->RebuildRows( m_filter, m_groupSymbolsBox, m_fieldsCtrl );
m_dataModel->Sort( m_grid->GetSortingColumn(), m_grid->IsSortOrderAscending() );
m_dataModel->SetGroupColumn( m_dataModel->GetFieldNameCol( fieldName ), value );
m_dataModel->RebuildRows();
m_grid->ForceRefresh();
break;
}
@ -815,8 +816,8 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnColumnItemToggled( wxDataViewEvent& event )
void DIALOG_SYMBOL_FIELDS_TABLE::OnGroupSymbolsToggled( wxCommandEvent& event )
{
m_schSettings.m_BomSettings.group_symbols = m_groupSymbolsBox->GetValue();
m_dataModel->RebuildRows( m_filter, m_groupSymbolsBox, m_fieldsCtrl );
m_dataModel->Sort( m_grid->GetSortingColumn(), m_grid->IsSortOrderAscending() );
m_dataModel->SetGroupingEnabled( m_groupSymbolsBox->GetValue() );
m_dataModel->RebuildRows();
m_grid->ForceRefresh();
syncBomPresetSelection();
@ -843,10 +844,11 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnColSort( wxGridEvent& aEvent )
}
// We only support sorting on one column at this time
m_schSettings.m_BomSettings.column_sorts.clear();
m_schSettings.m_BomSettings.column_sorts[key] = ascending;
m_schSettings.m_BomSettings.sort_field = m_dataModel->GetColFieldName( sortCol );
m_schSettings.m_BomSettings.sort_asc = ascending;
m_dataModel->Sort( sortCol, ascending );
m_dataModel->SetSorting( sortCol, ascending );
m_dataModel->RebuildRows();
m_grid->ForceRefresh();
syncBomPresetSelection();
@ -919,8 +921,7 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnTableColSize( wxGridSizeEvent& aEvent )
void DIALOG_SYMBOL_FIELDS_TABLE::OnRegroupSymbols( wxCommandEvent& aEvent )
{
m_dataModel->RebuildRows( m_filter, m_groupSymbolsBox, m_fieldsCtrl );
m_dataModel->Sort( m_grid->GetSortingColumn(), m_grid->IsSortOrderAscending() );
m_dataModel->RebuildRows();
m_grid->ForceRefresh();
}
@ -1017,9 +1018,6 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnSaveAndContinue( wxCommandEvent& aEvent )
void DIALOG_SYMBOL_FIELDS_TABLE::OnPreviewRefresh( wxCommandEvent& event )
{
}
@ -1243,7 +1241,8 @@ void DIALOG_SYMBOL_FIELDS_TABLE::syncBomPresetSelection()
{
return ( aPair.second.fields_show == current.fields_show
&& aPair.second.fields_group_by == current.fields_group_by
&& aPair.second.column_sorts == current.column_sorts
&& aPair.second.sort_field == current.sort_field
&& aPair.second.sort_asc == current.sort_asc
&& aPair.second.column_order == current.column_order
&& aPair.second.filter_string == current.filter_string
&& aPair.second.group_symbols == current.group_symbols );
@ -1345,8 +1344,9 @@ void DIALOG_SYMBOL_FIELDS_TABLE::onBomPresetChanged( wxCommandEvent& aEvent )
m_bomPresets[name] = BOM_PRESET( name, m_schSettings.m_BomSettings.fields_show,
m_schSettings.m_BomSettings.fields_group_by,
m_schSettings.m_BomSettings.column_widths,
m_schSettings.m_BomSettings.column_sorts,
m_schSettings.m_BomSettings.column_order,
m_schSettings.m_BomSettings.sort_field,
m_schSettings.m_BomSettings.sort_asc,
m_schSettings.m_BomSettings.filter_string,
m_schSettings.m_BomSettings.group_symbols );
}
@ -1363,8 +1363,9 @@ void DIALOG_SYMBOL_FIELDS_TABLE::onBomPresetChanged( wxCommandEvent& aEvent )
preset->fields_show = m_schSettings.m_BomSettings.fields_show;
preset->fields_group_by = m_schSettings.m_BomSettings.fields_group_by;
preset->column_widths = m_schSettings.m_BomSettings.column_widths;
preset->column_sorts = m_schSettings.m_BomSettings.column_sorts;
preset->column_order = m_schSettings.m_BomSettings.column_order;
preset->sort_field = m_schSettings.m_BomSettings.sort_field;
preset->sort_asc = m_schSettings.m_BomSettings.sort_asc;
preset->filter_string = m_schSettings.m_BomSettings.filter_string;
preset->group_symbols = m_schSettings.m_BomSettings.group_symbols;
@ -1441,7 +1442,9 @@ void DIALOG_SYMBOL_FIELDS_TABLE::onBomPresetChanged( wxCommandEvent& aEvent )
void DIALOG_SYMBOL_FIELDS_TABLE::doApplyBomPreset( const BOM_PRESET& aPreset )
{
// Set a good default sort
m_dataModel->Sort( m_dataModel->GetFieldNameCol( _( "Reference" ) ), false );
int fieldNameCol = m_dataModel->GetFieldNameCol( _( "Reference" ) );
m_dataModel->SetSorting( fieldNameCol, false );
m_grid->SetSortingColumn( fieldNameCol, false );
for( int i = 0; i < m_fieldsCtrl->GetItemCount(); i++ )
{
@ -1457,32 +1460,49 @@ void DIALOG_SYMBOL_FIELDS_TABLE::doApplyBomPreset( const BOM_PRESET& aPreset )
int width = aPreset.column_widths.count( fieldName ) ? aPreset.column_widths.at( fieldName )
: -1;
// Set shown colums
m_fieldsCtrl->SetToggleValue( show, i, SHOW_FIELD_COLUMN );
m_dataModel->SetShowColumn( col, show );
if( show )
m_grid->ShowCol( col );
else
m_grid->HideCol( col );
// Set grouped columns
m_fieldsCtrl->SetToggleValue( groupBy, i, GROUP_BY_COLUMN );
m_dataModel->SetGroupColumn( col, groupBy );
if( aPreset.column_sorts.count( fieldName ) )
m_dataModel->Sort( col, false );
// Set sorting
if( aPreset.sort_field == fieldName )
{
m_dataModel->SetSorting( col, aPreset.sort_asc );
m_grid->SetSortingColumn( col, aPreset.sort_asc );
}
// Set grid column sizes
if( width != -1 )
m_grid->SetColSize( col, width );
}
m_dataModel->SetGroupingEnabled( aPreset.group_symbols );
m_groupSymbolsBox->SetValue( aPreset.group_symbols );
m_dataModel->SetFieldsOrder( aPreset.column_order );
m_dataModel->SetFilter( aPreset.filter_string );
m_filter->ChangeValue( aPreset.filter_string );
SetupColumnProperties();
m_filter->ChangeValue( aPreset.filter_string );
m_groupSymbolsBox->SetValue( aPreset.group_symbols );
m_dataModel->RebuildRows();
m_grid->ForceRefresh();
m_schSettings.m_BomSettings.fields_show = aPreset.fields_show;
m_schSettings.m_BomSettings.fields_group_by = aPreset.fields_group_by;
m_schSettings.m_BomSettings.column_widths = aPreset.column_widths;
m_schSettings.m_BomSettings.column_sorts = aPreset.column_sorts;
m_schSettings.m_BomSettings.sort_field = aPreset.sort_field;
m_schSettings.m_BomSettings.sort_asc = aPreset.sort_asc;
m_schSettings.m_BomSettings.column_order = aPreset.column_order;
m_schSettings.m_BomSettings.filter_string = aPreset.filter_string;
m_schSettings.m_BomSettings.group_symbols = aPreset.group_symbols;

View File

@ -1,6 +1,4 @@
#include <wx/string.h>
#include <wx/srchctrl.h>
#include <wx/checkbox.h>
#include <wx/debug.h>
#include <wx/grid.h>
#include <widgets/wx_grid.h>
@ -35,6 +33,7 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::AddColumn( const wxString& aFieldName, const
}
}
void FIELDS_EDITOR_GRID_DATA_MODEL::RemoveColumn( int aCol )
{
for( unsigned i = 0; i < m_symbolsList.GetCount(); ++i )
@ -46,6 +45,7 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::RemoveColumn( int aCol )
m_cols.erase( m_cols.begin() + aCol );
}
void FIELDS_EDITOR_GRID_DATA_MODEL::RenameColumn( int aCol, const wxString& newName )
{
for( unsigned i = 0; i < m_symbolsList.GetCount(); ++i )
@ -85,6 +85,7 @@ const std::vector<wxString> FIELDS_EDITOR_GRID_DATA_MODEL::GetFieldsOrder()
return fields;
}
void FIELDS_EDITOR_GRID_DATA_MODEL::SetFieldsOrder( const std::vector<wxString>& aNewOrder )
{
size_t foundCount = 0;
@ -123,6 +124,7 @@ wxString FIELDS_EDITOR_GRID_DATA_MODEL::GetValue( int aRow, int aCol )
}
}
wxString FIELDS_EDITOR_GRID_DATA_MODEL::GetValue( const DATA_MODEL_ROW& group, int aCol )
{
std::vector<SCH_REFERENCE> references;
@ -186,6 +188,7 @@ wxString FIELDS_EDITOR_GRID_DATA_MODEL::GetValue( const DATA_MODEL_ROW& group, i
return fieldValue;
}
void FIELDS_EDITOR_GRID_DATA_MODEL::SetValue( int aRow, int aCol, const wxString& aValue )
{
if( ColIsReference( aCol ) || ColIsQuantity( aCol ) )
@ -199,6 +202,7 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::SetValue( int aRow, int aCol, const wxString
m_edited = true;
}
bool FIELDS_EDITOR_GRID_DATA_MODEL::cmp( const DATA_MODEL_ROW& lhGroup,
const DATA_MODEL_ROW& rhGroup,
FIELDS_EDITOR_GRID_DATA_MODEL* dataModel, int sortCol,
@ -238,14 +242,9 @@ bool FIELDS_EDITOR_GRID_DATA_MODEL::cmp( const DATA_MODEL_ROW& lhGroup,
}
}
void FIELDS_EDITOR_GRID_DATA_MODEL::Sort( int aColumn, bool ascending )
void FIELDS_EDITOR_GRID_DATA_MODEL::Sort()
{
if( aColumn < 0 )
aColumn = 0;
m_sortColumn = aColumn;
m_sortAscending = ascending;
CollapseForSort();
// We're going to sort the rows based on their first reference, so the first reference
@ -270,6 +269,7 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::Sort( int aColumn, bool ascending )
ExpandAfterSort();
}
bool FIELDS_EDITOR_GRID_DATA_MODEL::unitMatch( const SCH_REFERENCE& lhRef,
const SCH_REFERENCE& rhRef )
{
@ -281,14 +281,15 @@ bool FIELDS_EDITOR_GRID_DATA_MODEL::unitMatch( const SCH_REFERENCE& lhRef,
}
bool FIELDS_EDITOR_GRID_DATA_MODEL::groupMatch( const SCH_REFERENCE& lhRef,
const SCH_REFERENCE& rhRef,
wxDataViewListCtrl* fieldsCtrl )
const SCH_REFERENCE& rhRef )
{
int refCol = GetFieldNameCol( _( "Reference" ) );
bool matchFound = false;
// First check the reference column. This can be done directly out of the
// SCH_REFERENCEs as the references can't be edited in the grid.
if( fieldsCtrl->GetToggleValue( REFERENCE_FIELD, GROUP_BY_COLUMN ) )
if( m_cols[refCol].m_group )
{
// if we're grouping by reference, then only the prefix must match
if( lhRef.GetRef() != rhRef.GetRef() )
@ -302,12 +303,16 @@ bool FIELDS_EDITOR_GRID_DATA_MODEL::groupMatch( const SCH_REFERENCE& lhRef,
// Now check all the other columns. This must be done out of the dataStore
// for the refresh button to work after editing.
for( int i = REFERENCE_FIELD + 1; i < fieldsCtrl->GetItemCount(); ++i )
for( size_t i = 0; i < m_cols.size(); ++i )
{
if( !fieldsCtrl->GetToggleValue( i, GROUP_BY_COLUMN ) )
//Handled already
if( (int) i == refCol )
continue;
wxString fieldName = fieldsCtrl->GetTextValue( i, FIELD_NAME_COLUMN );
if( !m_cols[i].m_group )
continue;
wxString fieldName = m_cols[i].m_fieldName;
if( m_dataStore[lhRefID][fieldName] != m_dataStore[rhRefID][fieldName] )
return false;
@ -318,9 +323,8 @@ bool FIELDS_EDITOR_GRID_DATA_MODEL::groupMatch( const SCH_REFERENCE& lhRef,
return matchFound;
}
void FIELDS_EDITOR_GRID_DATA_MODEL::RebuildRows( wxSearchCtrl* aFilter,
wxCheckBox* aGroupSymbolsBox,
wxDataViewListCtrl* aFieldsCtrl )
void FIELDS_EDITOR_GRID_DATA_MODEL::RebuildRows()
{
if( GetView() )
{
@ -338,8 +342,7 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::RebuildRows( wxSearchCtrl* aFilter,
{
SCH_REFERENCE ref = m_symbolsList[i];
if( !aFilter->GetValue().IsEmpty()
&& !WildCompareString( aFilter->GetValue(), ref.GetFullRef(), false ) )
if( !m_filter.IsEmpty() && !WildCompareString( m_filter, ref.GetFullRef(), false ) )
{
continue;
}
@ -358,7 +361,7 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::RebuildRows( wxSearchCtrl* aFilter,
row.m_Refs.push_back( ref );
break;
}
else if( aGroupSymbolsBox->GetValue() && groupMatch( ref, rowRef, aFieldsCtrl ) )
else if( m_groupingEnabled && groupMatch( ref, rowRef ) )
{
matchFound = true;
row.m_Refs.push_back( ref );
@ -376,6 +379,8 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::RebuildRows( wxSearchCtrl* aFilter,
wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_rows.size() );
GetView()->ProcessTableMessage( msg );
}
Sort();
}
void FIELDS_EDITOR_GRID_DATA_MODEL::ExpandRow( int aRow )

View File

@ -1,6 +1,5 @@
#include <sch_reference_list.h>
#include <wx/grid.h>
#include <wx/srchctrl.h>
// The field name in the data model (translated)
#define DISPLAY_NAME_COLUMN 0
@ -45,16 +44,12 @@ struct DATA_MODEL_COL
};
class FIELDS_EDITOR_GRID_DATA_MODEL : public wxGridTableBase
{
public:
FIELDS_EDITOR_GRID_DATA_MODEL( SCH_EDIT_FRAME* aFrame, SCH_REFERENCE_LIST& aSymbolsList ) :
m_frame( aFrame ),
m_symbolsList( aSymbolsList ),
m_edited( false ),
m_sortColumn( 0 ),
m_sortAscending( false )
m_frame( aFrame ), m_symbolsList( aSymbolsList ), m_edited( false ), m_sortColumn( 0 ),
m_sortAscending( false ), m_groupingEnabled( false )
{
m_symbolsList.SplitReferences();
}
@ -62,20 +57,34 @@ public:
void AddColumn( const wxString& aFieldName, const wxString& aLabel, bool aAddedByUser );
void RemoveColumn( int aCol );
void RenameColumn( int aCol, const wxString& newName );
void MoveColumn( int aCol, int aNewPos ) { std::swap( m_cols[aCol], m_cols[aNewPos] ); }
void MoveColumn( int aCol, int aNewPos )
{
wxCHECK_RET( aCol >= 0 && aCol < (int) m_cols.size(), "Invalid Column Number" );
std::swap( m_cols[aCol], m_cols[aNewPos] );
}
int GetNumberRows() override { return (int) m_rows.size(); }
int GetNumberCols() override { return (int) m_cols.size(); }
void SetColLabelValue( int aCol, const wxString& aLabel ) override
{
wxCHECK_RET( aCol >= 0 && aCol < (int) m_cols.size(), "Invalid Column Number" );
m_cols[aCol].m_label = aLabel;
}
wxString GetColLabelValue( int aCol ) override { return m_cols[aCol].m_label; }
wxString GetColLabelValue( int aCol ) override
{
wxCHECK( aCol >= 0 && aCol < (int) m_cols.size(), wxString() );
return m_cols[aCol].m_label;
}
wxString GetColFieldName( int aCol )
{
wxCHECK( aCol >= 0 && aCol < (int) m_cols.size(), wxString() );
return m_cols[aCol].m_fieldName;
}
wxString GetColFieldName( int aCol ) { return m_cols[aCol].m_fieldName; }
int GetFieldNameCol( wxString aFieldName );
const std::vector<wxString> GetFieldsOrder();
@ -95,24 +104,30 @@ public:
std::vector<SCH_REFERENCE> GetRowReferences( int aRow ) const
{
wxCHECK( aRow < (int) m_rows.size(), std::vector<SCH_REFERENCE>() );
wxCHECK( aRow >= 0 && aRow < (int) m_rows.size(), std::vector<SCH_REFERENCE>() );
return m_rows[aRow].m_Refs;
}
bool ColIsReference( int aCol )
{
return ( aCol < (int) m_cols.size() ) && m_cols[aCol].m_fieldName == _( "Reference" );
wxCHECK( aCol >= 0 && aCol < (int) m_cols.size(), false );
return m_cols[aCol].m_fieldName == _( "Reference" );
}
bool ColIsQuantity( int aCol )
{
return ( aCol < (int) m_cols.size() ) && m_cols[aCol].m_fieldName == _( "Qty" );
wxCHECK( aCol >= 0 && aCol < (int) m_cols.size(), false );
return m_cols[aCol].m_fieldName == _( "Qty" );
}
void Sort( int aColumn, bool ascending );
void SetSorting( int aCol, bool ascending )
{
wxCHECK_RET( aCol >= 0 && aCol < (int) m_cols.size(), "Invalid Column Number" );
m_sortColumn = aCol;
m_sortAscending = ascending;
}
void RebuildRows( wxSearchCtrl* aFilter, wxCheckBox* aGroupSymbolsBox,
wxDataViewListCtrl* aFieldsCtrl );
void RebuildRows();
void ExpandRow( int aRow );
void CollapseRow( int aRow );
void ExpandCollapseRow( int aRow );
@ -125,12 +140,28 @@ public:
int GetDataWidth( int aCol );
void SetFilter( const wxString& aFilter ) { m_filter = aFilter; }
void SetGroupingEnabled( bool group ) { m_groupingEnabled = group; }
void SetGroupColumn( int aCol, bool group )
{
wxCHECK_RET( aCol >= 0 && aCol < (int) m_cols.size(), "Invalid Column Number" );
m_cols[aCol].m_group = group;
}
void SetShowColumn( int aCol, bool show )
{
wxCHECK_RET( aCol >= 0 && aCol < (int) m_cols.size(), "Invalid Column Number" );
m_cols[aCol].m_show = show;
}
private:
static bool cmp( const DATA_MODEL_ROW& lhGroup, const DATA_MODEL_ROW& rhGroup,
FIELDS_EDITOR_GRID_DATA_MODEL* dataModel, int sortCol, bool ascending );
bool unitMatch( const SCH_REFERENCE& lhRef, const SCH_REFERENCE& rhRef );
bool groupMatch( const SCH_REFERENCE& lhRef, const SCH_REFERENCE& rhRef,
wxDataViewListCtrl* fieldsCtrl );
bool groupMatch( const SCH_REFERENCE& lhRef, const SCH_REFERENCE& rhRef );
void Sort();
protected:
SCH_EDIT_FRAME* m_frame;
@ -138,6 +169,8 @@ protected:
bool m_edited;
int m_sortColumn;
bool m_sortAscending;
wxString m_filter;
bool m_groupingEnabled;
std::vector<DATA_MODEL_COL> m_cols;
std::vector<DATA_MODEL_ROW> m_rows;

View File

@ -31,14 +31,15 @@ class NGSPICE_SIMULATOR_SETTINGS;
struct BOM_PRESET
{
BOM_PRESET( const wxString& aName = wxEmptyString ) :
name( aName ), readOnly(false), group_symbols( false) { }
name( aName ), readOnly(false), sort_asc( true ), group_symbols( false) { }
BOM_PRESET( const wxString& aName,
const std::map<std::string, bool>& aFieldsShow,
const std::map<std::string, bool>& aFieldsGroupBy,
const std::map<std::string, int>& aColumnWidths,
const std::map<std::string, bool>& aColumnSorts,
const std::vector<wxString>& aColumnOrder,
const wxString& aSortField,
bool aSortAscending,
const wxString& aFilterString,
bool aGroupSymbols
) :
@ -47,7 +48,6 @@ struct BOM_PRESET
fields_show( aFieldsShow ),
fields_group_by( aFieldsGroupBy ),
column_widths( aColumnWidths ),
column_sorts( aColumnSorts ),
column_order( aColumnOrder ),
filter_string( aFilterString ),
group_symbols( aGroupSymbols )
@ -59,8 +59,9 @@ struct BOM_PRESET
std::map<std::string, bool> fields_show;
std::map<std::string, bool> fields_group_by;
std::map<std::string, int> column_widths;
std::map<std::string, bool> column_sorts;
std::vector<wxString> column_order;
wxString sort_field;
bool sort_asc;
wxString filter_string;
bool group_symbols;
};