Component table improvements
This commit is contained in:
parent
6cefb68c7d
commit
d4e41c4f97
|
@ -88,13 +88,16 @@ protected:
|
|||
bool m_Show; ///< Is this column visible?
|
||||
bool m_ReadOnly; ///< Is this column read only?
|
||||
|
||||
bool m_sort; ///< Is this column used for sorting?
|
||||
|
||||
public:
|
||||
BOM_COLUMN( unsigned int aId, BOM_COLUMN_TYPE aType, const wxString aTitle, bool aShow, bool aReadOnly = false ) :
|
||||
BOM_COLUMN( unsigned int aId, BOM_COLUMN_TYPE aType, const wxString aTitle, bool aShow, bool aReadOnly = false, bool aSort = true ) :
|
||||
m_id( aId ),
|
||||
m_Type( aType ),
|
||||
m_Title( aTitle.Strip( wxString::both ) ),
|
||||
m_Show( aShow ),
|
||||
m_ReadOnly( aReadOnly )
|
||||
m_ReadOnly( aReadOnly ),
|
||||
m_sort( aSort )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -103,11 +106,13 @@ public:
|
|||
wxString Title() const { return m_Title; }
|
||||
bool IsVisible() const { return m_Show; }
|
||||
bool IsReadOnly() const { return m_ReadOnly; }
|
||||
bool IsUsedToSort() const { return m_sort; }
|
||||
|
||||
//TODO - Should renaming of columns be allowed?
|
||||
//bool SetTitle( const wxString aTitle );
|
||||
void SetVisible( bool aShow = true ) { m_Show = aShow; }
|
||||
void SetReadOnly( bool aReadOnly = true ) { m_ReadOnly = aReadOnly; }
|
||||
void SetUsedToSort( bool aSort = true ) { m_sort = aSort; }
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -53,7 +53,9 @@ static BOM_TABLE_ROW const* ItemToRow( wxDataViewItem aItem )
|
|||
}
|
||||
}
|
||||
|
||||
BOM_FIELD_VALUES::BOM_FIELD_VALUES( wxString aRefDes ) : m_refDes( aRefDes )
|
||||
BOM_FIELD_VALUES::BOM_FIELD_VALUES( wxString aRefDes, FIELD_VALUE_MAP* aTemplate ) :
|
||||
m_refDes( aRefDes ),
|
||||
m_templateValues( aTemplate )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -87,6 +89,24 @@ bool BOM_FIELD_VALUES::GetBackupValue( unsigned int aFieldId, wxString& aValue )
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the template value for a provided field ID (if it exists)
|
||||
*/
|
||||
bool BOM_FIELD_VALUES::GetTemplateValue( unsigned int aFieldId, wxString& aValue ) const
|
||||
{
|
||||
if( !m_templateValues )
|
||||
return false;
|
||||
|
||||
auto search = m_templateValues->find( aFieldId );
|
||||
|
||||
if( search == m_templateValues->end() )
|
||||
return false;
|
||||
|
||||
aValue = search->second;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value for the provided field ID
|
||||
* Field value is set under any of the following conditions:
|
||||
|
@ -102,18 +122,6 @@ void BOM_FIELD_VALUES::SetFieldValue( unsigned int aFieldId, wxString aValue, bo
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the backup value for the provided field ID
|
||||
* If the backup value is already set, new value is ignored
|
||||
*/
|
||||
void BOM_FIELD_VALUES::SetBackupValue( unsigned int aFieldId, wxString aValue )
|
||||
{
|
||||
if( m_backupValues.count( aFieldId ) == 0 || m_backupValues[aFieldId].IsEmpty() )
|
||||
{
|
||||
m_backupValues[aFieldId] = aValue;
|
||||
}
|
||||
}
|
||||
|
||||
bool BOM_FIELD_VALUES::HasValueChanged( unsigned int aFieldId) const
|
||||
{
|
||||
wxString currentValue, backupValue;
|
||||
|
@ -133,6 +141,14 @@ void BOM_FIELD_VALUES::RevertChanges( unsigned int aFieldId )
|
|||
SetFieldValue( aFieldId, backupValue, true );
|
||||
}
|
||||
|
||||
void BOM_FIELD_VALUES::SetBackupPoint()
|
||||
{
|
||||
for( auto it = m_currentValues.begin(); it != m_currentValues.end(); ++it )
|
||||
{
|
||||
m_backupValues[it->first] = it->second;
|
||||
}
|
||||
}
|
||||
|
||||
BOM_TABLE_ROW::BOM_TABLE_ROW() : m_columnList( nullptr )
|
||||
{
|
||||
}
|
||||
|
@ -317,6 +333,10 @@ bool BOM_TABLE_GROUP::AddComponent( BOM_TABLE_COMPONENT* aComponent )
|
|||
|
||||
for( auto* column : m_columnList->Columns )
|
||||
{
|
||||
// Ignore any columns marked as "not used for sorting"
|
||||
if( !column->IsUsedToSort() )
|
||||
continue;
|
||||
|
||||
match = TestField( column, aComponent );
|
||||
|
||||
// Escape on first mismatch
|
||||
|
@ -554,7 +574,6 @@ bool BOM_TABLE_COMPONENT::AddUnit( SCH_REFERENCE aUnit )
|
|||
}
|
||||
|
||||
m_fieldValues->SetFieldValue( column->Id(), value );
|
||||
m_fieldValues->SetBackupValue( column->Id(), value );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -563,6 +582,7 @@ bool BOM_TABLE_COMPONENT::AddUnit( SCH_REFERENCE aUnit )
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the value associated with a particular field
|
||||
* If no field is found, return an empty string
|
||||
|
@ -582,8 +602,15 @@ wxString BOM_TABLE_COMPONENT::GetFieldValue( unsigned int aFieldId ) const
|
|||
}
|
||||
|
||||
if( m_fieldValues )
|
||||
{
|
||||
m_fieldValues->GetFieldValue( aFieldId, value );
|
||||
|
||||
if( value.IsEmpty() )
|
||||
{
|
||||
m_fieldValues->GetTemplateValue( aFieldId, value );
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -966,9 +993,9 @@ void BOM_TABLE_MODEL::AddComponentFields( SCH_COMPONENT* aCmp )
|
|||
continue;
|
||||
|
||||
ColumnList.AddColumn( new BOM_COLUMN( ColumnList.NextFieldId(),
|
||||
BOM_COL_TYPE_USER,
|
||||
field->GetName(),
|
||||
true, false ) );
|
||||
BOM_COL_TYPE_USER,
|
||||
field->GetName(),
|
||||
true, false ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -976,8 +1003,9 @@ void BOM_TABLE_MODEL::AddComponentFields( SCH_COMPONENT* aCmp )
|
|||
* Add a list of component items to the BOM manager
|
||||
* Creates consolidated groups of components as required
|
||||
*/
|
||||
void BOM_TABLE_MODEL::SetComponents( SCH_REFERENCE_LIST aRefs )
|
||||
void BOM_TABLE_MODEL::SetComponents( SCH_REFERENCE_LIST aRefs, const TEMPLATE_FIELDNAMES& aTemplateFields )
|
||||
{
|
||||
|
||||
// Add default columns
|
||||
AddDefaultColumns();
|
||||
|
||||
|
@ -993,10 +1021,33 @@ void BOM_TABLE_MODEL::SetComponents( SCH_REFERENCE_LIST aRefs )
|
|||
}
|
||||
}
|
||||
|
||||
// Add template fields if they are not already added
|
||||
for( auto field : aTemplateFields )
|
||||
{
|
||||
BOM_COLUMN* col;
|
||||
|
||||
col = ColumnList.GetColumnByTitle( field.m_Name );
|
||||
|
||||
if( !col )
|
||||
{
|
||||
col = new BOM_COLUMN( ColumnList.NextFieldId(),
|
||||
BOM_COL_TYPE_USER,
|
||||
field.m_Name,
|
||||
true, false );
|
||||
|
||||
ColumnList.AddColumn( col );
|
||||
}
|
||||
|
||||
// Add template value for that field
|
||||
m_fieldTemplates[col->Id()] = field.m_Value;
|
||||
}
|
||||
|
||||
// Group multi-unit components together
|
||||
m_components.clear();
|
||||
m_fieldValues.clear();
|
||||
|
||||
|
||||
// Iterate through each unique component
|
||||
for( unsigned int ii=0; ii<aRefs.GetCount(); ii++ )
|
||||
{
|
||||
auto ref = aRefs.GetItem( ii );
|
||||
|
@ -1033,7 +1084,7 @@ void BOM_TABLE_MODEL::SetComponents( SCH_REFERENCE_LIST aRefs )
|
|||
|
||||
if( !dataFound )
|
||||
{
|
||||
values = new BOM_FIELD_VALUES( refDes );
|
||||
values = new BOM_FIELD_VALUES( refDes, &m_fieldTemplates );
|
||||
m_fieldValues.push_back( std::unique_ptr<BOM_FIELD_VALUES>( values ) );
|
||||
}
|
||||
|
||||
|
@ -1043,6 +1094,17 @@ void BOM_TABLE_MODEL::SetComponents( SCH_REFERENCE_LIST aRefs )
|
|||
m_components.push_back( std::unique_ptr<BOM_TABLE_COMPONENT>( newComponent ) );
|
||||
}
|
||||
}
|
||||
|
||||
SetBackupPoint();
|
||||
}
|
||||
|
||||
void BOM_TABLE_MODEL::SetBackupPoint()
|
||||
{
|
||||
// Mark backup locations for all values
|
||||
for( auto& vals : m_fieldValues )
|
||||
{
|
||||
vals->SetBackupPoint();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -58,13 +58,13 @@ typedef std::map<unsigned int, wxString> FIELD_VALUE_MAP;
|
|||
class BOM_FIELD_VALUES
|
||||
{
|
||||
public:
|
||||
BOM_FIELD_VALUES(wxString aRefDes);
|
||||
BOM_FIELD_VALUES( wxString aRefDes, FIELD_VALUE_MAP* aTemplate );
|
||||
|
||||
bool GetFieldValue( unsigned int aFieldId, wxString& aValue ) const;
|
||||
bool GetBackupValue( unsigned int aFieldId, wxString& aValue ) const;
|
||||
bool GetTemplateValue( unsigned int aFieldId, wxString& aValue ) const;
|
||||
|
||||
void SetFieldValue( unsigned int aFieldId, wxString aValue, bool aOverwrite = false );
|
||||
void SetBackupValue( unsigned int aFieldId, wxString aValue );
|
||||
|
||||
wxString GetReference() const { return m_refDes; }
|
||||
|
||||
|
@ -72,6 +72,8 @@ public:
|
|||
|
||||
void RevertChanges( unsigned int aFieldId );
|
||||
|
||||
void SetBackupPoint();
|
||||
|
||||
protected:
|
||||
//! The RefDes to which these values correspond
|
||||
wxString m_refDes;
|
||||
|
@ -81,6 +83,9 @@ protected:
|
|||
|
||||
//! Backup values for each column
|
||||
FIELD_VALUE_MAP m_backupValues;
|
||||
|
||||
//! Template values for each column
|
||||
FIELD_VALUE_MAP* m_templateValues;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -140,7 +145,7 @@ public:
|
|||
BOM_TABLE_GROUP( BOM_COLUMN_LIST* aColumnList );
|
||||
virtual ~BOM_TABLE_GROUP() {}
|
||||
|
||||
// Set display properties for
|
||||
// Set display properties for a group row
|
||||
virtual bool GetAttr( unsigned int aFieldId, wxDataViewItemAttr& aAttr ) const override;
|
||||
|
||||
// Get group row value
|
||||
|
@ -231,6 +236,9 @@ protected:
|
|||
// Vector of field values mapped to field IDs
|
||||
std::vector<std::unique_ptr<BOM_FIELD_VALUES>> m_fieldValues;
|
||||
|
||||
// Template field values
|
||||
FIELD_VALUE_MAP m_fieldTemplates;
|
||||
|
||||
// BOM Preferences
|
||||
//! Group components based on values
|
||||
bool m_groupColumns = true;
|
||||
|
@ -307,7 +315,7 @@ public:
|
|||
|
||||
wxArrayString GetRowData( unsigned int aRow, std::vector<BOM_COLUMN*> aColumns ) const;
|
||||
|
||||
void SetComponents( SCH_REFERENCE_LIST aRefs );
|
||||
void SetComponents( SCH_REFERENCE_LIST aRefs, const TEMPLATE_FIELDNAMES& aTemplateFields );
|
||||
void AddComponentFields( SCH_COMPONENT* aCmp );
|
||||
|
||||
void RevertFieldChanges();
|
||||
|
@ -315,6 +323,8 @@ public:
|
|||
|
||||
bool HaveFieldsChanged() const;
|
||||
|
||||
void SetBackupPoint();
|
||||
|
||||
std::vector<SCH_REFERENCE> GetChangedComponents();
|
||||
unsigned int CountChangedComponents();
|
||||
};
|
||||
|
|
|
@ -63,6 +63,12 @@ DIALOG_BOM_EDITOR::DIALOG_BOM_EDITOR( SCH_EDIT_FRAME* parent ) :
|
|||
wxDATAVIEW_CELL_ACTIVATABLE,
|
||||
100 );
|
||||
|
||||
auto sortColumn = m_columnListCtrl->AppendToggleColumn(
|
||||
_( "Sort" ),
|
||||
wxDATAVIEW_CELL_ACTIVATABLE,
|
||||
100 );
|
||||
|
||||
|
||||
// Resize the columns appropriately
|
||||
m_columnListCtrl->Update();
|
||||
|
||||
|
@ -75,6 +81,11 @@ DIALOG_BOM_EDITOR::DIALOG_BOM_EDITOR( SCH_EDIT_FRAME* parent ) :
|
|||
nameColumn->SetWidth( wxCOL_WIDTH_AUTOSIZE );
|
||||
nameColumn->SetResizeable( true );
|
||||
|
||||
sortColumn->SetWidth( wxCOL_WIDTH_AUTOSIZE );
|
||||
sortColumn->SetResizeable( true );
|
||||
|
||||
m_columnListCtrl->Update();
|
||||
|
||||
// Read all components
|
||||
LoadComponents();
|
||||
|
||||
|
@ -109,6 +120,44 @@ DIALOG_BOM_EDITOR::~DIALOG_BOM_EDITOR()
|
|||
//TODO
|
||||
}
|
||||
|
||||
void DIALOG_BOM_EDITOR::OnCloseButton( wxCommandEvent& event )
|
||||
{
|
||||
CloseDialog();
|
||||
}
|
||||
|
||||
bool DIALOG_BOM_EDITOR::CloseDialog()
|
||||
{
|
||||
if( !m_bom->HaveFieldsChanged() )
|
||||
{
|
||||
Destroy();
|
||||
return true;
|
||||
}
|
||||
|
||||
int result = DisplayExitDialog( this, _( "Changes exist in component table" ) );
|
||||
|
||||
switch( result )
|
||||
{
|
||||
case wxID_CANCEL:
|
||||
return false;
|
||||
case wxID_NO:
|
||||
break;
|
||||
case wxID_YES:
|
||||
ApplyAllChanges();
|
||||
break;
|
||||
}
|
||||
|
||||
Destroy();
|
||||
return true;
|
||||
}
|
||||
|
||||
void DIALOG_BOM_EDITOR::OnDialogClosed( wxCloseEvent& event )
|
||||
{
|
||||
if( !CloseDialog() )
|
||||
{
|
||||
event.Veto();
|
||||
}
|
||||
}
|
||||
|
||||
/* Struct for keeping track of schematic sheet changes
|
||||
* Stores:
|
||||
* SHEET_PATH - Schematic to apply changes to
|
||||
|
@ -121,90 +170,85 @@ typedef struct
|
|||
PICKED_ITEMS_LIST items;
|
||||
} SheetUndoList;
|
||||
|
||||
/**
|
||||
* When the component table dialog is closed,
|
||||
* work out if we need to save any changed.
|
||||
* If so, capture those changes and push them to the undo stack.
|
||||
*/
|
||||
bool DIALOG_BOM_EDITOR::TransferDataFromWindow()
|
||||
void DIALOG_BOM_EDITOR::ApplyAllChanges()
|
||||
{
|
||||
if( m_bom->HaveFieldsChanged() )
|
||||
if( !m_bom->HaveFieldsChanged() )
|
||||
return;
|
||||
|
||||
/**
|
||||
* As we may be saving changes across multiple sheets,
|
||||
* we need to first determine which changes need to be made to which sheet.
|
||||
* To this end, we perform the following:
|
||||
* 1. Save the "path" of the currently displayed sheet
|
||||
* 2. Create a MAP of <SheetPath:ChangeList> changes that need to be made
|
||||
* 3. Push UNDO actions to appropriate sheets
|
||||
* 4. Perform all the update actions
|
||||
* 5. Reset the view to the current sheet
|
||||
*/
|
||||
|
||||
auto currentSheet = m_parent->GetCurrentSheet();
|
||||
|
||||
//! Create a map of changes required for each sheet
|
||||
std::map<wxString, SheetUndoList> undoSheetMap;
|
||||
|
||||
// List of components that have changed
|
||||
auto changed = m_bom->GetChangedComponents();
|
||||
|
||||
ITEM_PICKER picker;
|
||||
|
||||
// Iterate through each of the components that were changed
|
||||
for( auto ref : changed )
|
||||
{
|
||||
/**
|
||||
* As we may be saving changes across multiple sheets,
|
||||
* we need to first determine which changes need to be made to which sheet.
|
||||
* To this end, we perform the following:
|
||||
* 1. Save the "path" of the currently displayed sheet
|
||||
* 2. Create a MAP of <SheetPath:ChangeList> changes that need to be made
|
||||
* 3. Push UNDO actions to appropriate sheets
|
||||
* 4. Perform all the update actions
|
||||
* 5. Reset the view to the current sheet
|
||||
// Extract the SCH_COMPONENT* object
|
||||
auto cmp = ref.GetComp();
|
||||
|
||||
wxString path = ref.GetSheetPath().Path();
|
||||
|
||||
// Push the component into the picker list
|
||||
picker = ITEM_PICKER( cmp, UR_CHANGED );
|
||||
picker.SetFlags( cmp->GetFlags() );
|
||||
|
||||
/*
|
||||
* If there is not currently an undo list for the given sheet,
|
||||
* create an empty one
|
||||
*/
|
||||
|
||||
auto currentSheet = m_parent->GetCurrentSheet();
|
||||
|
||||
//! Create a map of changes required for each sheet
|
||||
std::map<wxString, SheetUndoList> undoSheetMap;
|
||||
|
||||
// List of components that have changed
|
||||
auto changed = m_bom->GetChangedComponents();
|
||||
|
||||
ITEM_PICKER picker;
|
||||
|
||||
// Iterate through each of the components that were changed
|
||||
for( auto ref : changed )
|
||||
if( undoSheetMap.count( path ) == 0 )
|
||||
{
|
||||
// Extract the SCH_COMPONENT* object
|
||||
auto cmp = ref.GetComp();
|
||||
SheetUndoList newList;
|
||||
|
||||
wxString path = ref.GetSheetPath().Path();
|
||||
newList.path = ref.GetSheetPath();
|
||||
|
||||
// Push the component into the picker list
|
||||
picker = ITEM_PICKER( cmp, UR_CHANGED );
|
||||
picker.SetFlags( cmp->GetFlags() );
|
||||
|
||||
/*
|
||||
* If there is not currently an undo list for the given sheet,
|
||||
* create an empty one
|
||||
*/
|
||||
|
||||
if( undoSheetMap.count( path ) == 0 )
|
||||
{
|
||||
SheetUndoList newList;
|
||||
|
||||
newList.path = ref.GetSheetPath();
|
||||
|
||||
undoSheetMap[path] = newList;
|
||||
}
|
||||
|
||||
auto& pickerList = undoSheetMap[path];
|
||||
|
||||
pickerList.items.PushItem( picker );
|
||||
undoSheetMap[path] = newList;
|
||||
}
|
||||
|
||||
// Iterate through each sheet that needs updating
|
||||
for( auto it = undoSheetMap.begin(); it != undoSheetMap.end(); ++it )
|
||||
{
|
||||
auto undo = it->second;
|
||||
|
||||
m_parent->SetCurrentSheet( undo.path );
|
||||
m_parent->SaveCopyInUndoList( undo.items, UR_CHANGED );
|
||||
m_parent->OnModify();
|
||||
}
|
||||
|
||||
// Make all component changes
|
||||
m_bom->ApplyFieldChanges();
|
||||
|
||||
// Redraw the current sheet and mark as dirty
|
||||
m_parent->Refresh();
|
||||
m_parent->OnModify();
|
||||
|
||||
// Reset the view to where we left the user
|
||||
m_parent->SetCurrentSheet(currentSheet);
|
||||
auto& pickerList = undoSheetMap[path];
|
||||
|
||||
pickerList.items.PushItem( picker );
|
||||
}
|
||||
|
||||
return true;
|
||||
// Iterate through each sheet that needs updating
|
||||
for( auto it = undoSheetMap.begin(); it != undoSheetMap.end(); ++it )
|
||||
{
|
||||
auto undo = it->second;
|
||||
|
||||
m_parent->SetCurrentSheet( undo.path );
|
||||
m_parent->SaveCopyInUndoList( undo.items, UR_CHANGED );
|
||||
m_parent->OnModify();
|
||||
}
|
||||
|
||||
// Make all component changes
|
||||
m_bom->ApplyFieldChanges();
|
||||
|
||||
// Redraw the current sheet and mark as dirty
|
||||
m_parent->Refresh();
|
||||
m_parent->OnModify();
|
||||
|
||||
// Reset the view to where we left the user
|
||||
m_parent->SetCurrentSheet(currentSheet);
|
||||
|
||||
// Instruct the table to set the current values as the new backup values
|
||||
m_bom->SetBackupPoint();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -252,7 +296,7 @@ void DIALOG_BOM_EDITOR::LoadComponents()
|
|||
sheets.GetComponents( m_parent->Prj().SchLibs(), refs, false );
|
||||
|
||||
// Pass the references through to the model
|
||||
m_bom->SetComponents( refs );
|
||||
m_bom->SetComponents( refs, m_parent->GetTemplateFieldNames() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -273,6 +317,7 @@ void DIALOG_BOM_EDITOR::LoadColumnNames()
|
|||
|
||||
data.push_back( wxVariant( col->Title() ) ); // Column title (string)
|
||||
data.push_back( wxVariant( col->IsVisible() ) ); // Column visibility (bool)
|
||||
data.push_back( wxVariant( col->IsUsedToSort() ) ); // Column is used to sort
|
||||
|
||||
m_columnListCtrl->AppendItem( data );
|
||||
}
|
||||
|
@ -318,6 +363,10 @@ void DIALOG_BOM_EDITOR::OnColumnItemToggled( wxDataViewEvent& event )
|
|||
m_bom->RemoveColumn( bomColumn );
|
||||
}
|
||||
break;
|
||||
case 2: // Column used to sort
|
||||
bomColumn->SetUsedToSort( bValue );
|
||||
m_bom->ReloadTable();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -337,7 +386,11 @@ void DIALOG_BOM_EDITOR::OnGroupComponentsToggled( wxCommandEvent& event )
|
|||
void DIALOG_BOM_EDITOR::OnUpdateUI( wxUpdateUIEvent& event )
|
||||
{
|
||||
m_regroupComponentsButton->Enable( m_bom->GetColumnGrouping() );
|
||||
m_reloadTableButton->Enable( m_bom->HaveFieldsChanged() );
|
||||
|
||||
bool changes = m_bom->HaveFieldsChanged();
|
||||
|
||||
m_applyChangesButton->Enable( changes );
|
||||
m_revertChangesButton->Enable( changes );
|
||||
|
||||
UpdateTitle();
|
||||
}
|
||||
|
@ -353,6 +406,12 @@ void DIALOG_BOM_EDITOR::OnRegroupComponents( wxCommandEvent& event )
|
|||
Update();
|
||||
}
|
||||
|
||||
void DIALOG_BOM_EDITOR::OnApplyFieldChanges( wxCommandEvent& event )
|
||||
{
|
||||
ApplyAllChanges();
|
||||
Update();
|
||||
}
|
||||
|
||||
void DIALOG_BOM_EDITOR::OnRevertFieldChanges( wxCommandEvent& event )
|
||||
{
|
||||
if( m_bom->HaveFieldsChanged() )
|
||||
|
|
|
@ -57,13 +57,12 @@ private:
|
|||
|
||||
BOM_TABLE_MODEL::MODEL_PTR m_bom;
|
||||
|
||||
void LoadComponents( void );
|
||||
void LoadComponents();
|
||||
|
||||
void LoadColumnNames( void );
|
||||
void ReloadColumns( void );
|
||||
void LoadColumnNames();
|
||||
void ReloadColumns();
|
||||
|
||||
// Called when the OK button is pressed
|
||||
virtual bool TransferDataFromWindow() override;
|
||||
void ApplyAllChanges();
|
||||
|
||||
// Checkbox event callbacks
|
||||
virtual void OnColumnItemToggled( wxDataViewEvent& event ) override;
|
||||
|
@ -71,6 +70,8 @@ private:
|
|||
|
||||
virtual void OnRevertFieldChanges( wxCommandEvent& event ) override;
|
||||
|
||||
virtual void OnApplyFieldChanges( wxCommandEvent& event ) override;
|
||||
|
||||
virtual void OnRegroupComponents( wxCommandEvent& event ) override;
|
||||
|
||||
// Called after a value in the table has changed
|
||||
|
@ -82,6 +83,12 @@ private:
|
|||
// Called when a cell is right-clicked
|
||||
virtual void OnTableItemContextMenu( wxDataViewEvent& event ) override;
|
||||
|
||||
// Called when the dialog is closed
|
||||
virtual void OnDialogClosed( wxCloseEvent& event ) override;
|
||||
virtual void OnCloseButton( wxCommandEvent& event ) override;
|
||||
|
||||
bool CloseDialog();
|
||||
|
||||
void UpdateTitle( void );
|
||||
|
||||
virtual void OnUpdateUI( wxUpdateUIEvent& event ) override;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Feb 19 2017)
|
||||
// C++ code generated with wxFormBuilder (version Apr 1 2017)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
|
@ -10,10 +10,10 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
BEGIN_EVENT_TABLE( DIALOG_BOM_EDITOR_BASE, DIALOG_SHIM )
|
||||
EVT_CLOSE( DIALOG_BOM_EDITOR_BASE::_wxFB_OnDialogClosed )
|
||||
EVT_UPDATE_UI( wxID_ANY, DIALOG_BOM_EDITOR_BASE::_wxFB_OnUpdateUI )
|
||||
EVT_CHECKBOX( OPT_GROUP_COMPONENTS, DIALOG_BOM_EDITOR_BASE::_wxFB_OnGroupComponentsToggled )
|
||||
EVT_BUTTON( ID_BUTTON_REGROUP, DIALOG_BOM_EDITOR_BASE::_wxFB_OnRegroupComponents )
|
||||
EVT_BUTTON( ID_BUTTON_REVERT_CHANGES, DIALOG_BOM_EDITOR_BASE::_wxFB_OnRevertFieldChanges )
|
||||
EVT_DATAVIEW_ITEM_VALUE_CHANGED( wxID_ANY, DIALOG_BOM_EDITOR_BASE::_wxFB_OnColumnItemToggled )
|
||||
EVT_DATAVIEW_COLUMN_REORDERED( wxID_ANY, DIALOG_BOM_EDITOR_BASE::_wxFB_OnBomColumReordered )
|
||||
EVT_DATAVIEW_COLUMN_SORTED( wxID_ANY, DIALOG_BOM_EDITOR_BASE::_wxFB_OnBomColumnSorted )
|
||||
|
@ -21,6 +21,9 @@ BEGIN_EVENT_TABLE( DIALOG_BOM_EDITOR_BASE, DIALOG_SHIM )
|
|||
EVT_DATAVIEW_ITEM_CONTEXT_MENU( wxID_ANY, DIALOG_BOM_EDITOR_BASE::_wxFB_OnTableItemContextMenu )
|
||||
EVT_DATAVIEW_ITEM_EDITING_DONE( wxID_ANY, DIALOG_BOM_EDITOR_BASE::_wxFB_OnTableValueChanged )
|
||||
EVT_DATAVIEW_SELECTION_CHANGED( wxID_ANY, DIALOG_BOM_EDITOR_BASE::_wxFB_OnSelectionChanged )
|
||||
EVT_BUTTON( ID_BUTTON_APPLY, DIALOG_BOM_EDITOR_BASE::_wxFB_OnApplyFieldChanges )
|
||||
EVT_BUTTON( ID_BUTTON_REVERT, DIALOG_BOM_EDITOR_BASE::_wxFB_OnRevertFieldChanges )
|
||||
EVT_BUTTON( wxID_CANCEL, DIALOG_BOM_EDITOR_BASE::_wxFB_OnCloseButton )
|
||||
END_EVENT_TABLE()
|
||||
|
||||
DIALOG_BOM_EDITOR_BASE::DIALOG_BOM_EDITOR_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
|
||||
|
@ -30,6 +33,9 @@ DIALOG_BOM_EDITOR_BASE::DIALOG_BOM_EDITOR_BASE( wxWindow* parent, wxWindowID id,
|
|||
wxBoxSizer* bHorizontalSizer;
|
||||
bHorizontalSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxBoxSizer* bSizer61;
|
||||
bSizer61 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_panel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
wxBoxSizer* bSizer7;
|
||||
bSizer7 = new wxBoxSizer( wxVERTICAL );
|
||||
|
@ -54,12 +60,6 @@ DIALOG_BOM_EDITOR_BASE::DIALOG_BOM_EDITOR_BASE( wxWindow* parent, wxWindowID id,
|
|||
m_regroupComponentsButton = new wxButton( sbSizer1->GetStaticBox(), ID_BUTTON_REGROUP, _("Regroup components"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
sbSizer1->Add( m_regroupComponentsButton, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
m_reloadTableButton = new wxButton( sbSizer1->GetStaticBox(), ID_BUTTON_REVERT_CHANGES, _("Revert all changes"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_reloadTableButton->Enable( false );
|
||||
m_reloadTableButton->SetToolTip( _("Reload table (reverts component field changes)") );
|
||||
|
||||
sbSizer1->Add( m_reloadTableButton, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
bSizer6->Add( sbSizer1, 0, wxEXPAND, 5 );
|
||||
|
||||
|
@ -80,21 +80,6 @@ DIALOG_BOM_EDITOR_BASE::DIALOG_BOM_EDITOR_BASE( wxWindow* parent, wxWindowID id,
|
|||
|
||||
bSizer6->Add( bSizer9, 5, wxEXPAND, 5 );
|
||||
|
||||
wxStaticBoxSizer* sbSizer4;
|
||||
sbSizer4 = new wxStaticBoxSizer( new wxStaticBox( m_leftPanel, wxID_ANY, _("Apply changes") ), wxVERTICAL );
|
||||
|
||||
m_sdbSizer1 = new wxStdDialogButtonSizer();
|
||||
m_sdbSizer1OK = new wxButton( sbSizer4->GetStaticBox(), wxID_OK );
|
||||
m_sdbSizer1->AddButton( m_sdbSizer1OK );
|
||||
m_sdbSizer1Cancel = new wxButton( sbSizer4->GetStaticBox(), wxID_CANCEL );
|
||||
m_sdbSizer1->AddButton( m_sdbSizer1Cancel );
|
||||
m_sdbSizer1->Realize();
|
||||
|
||||
sbSizer4->Add( m_sdbSizer1, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
bSizer6->Add( sbSizer4, 0, wxEXPAND, 10 );
|
||||
|
||||
|
||||
m_leftPanel->SetSizer( bSizer6 );
|
||||
m_leftPanel->Layout();
|
||||
|
@ -119,7 +104,28 @@ DIALOG_BOM_EDITOR_BASE::DIALOG_BOM_EDITOR_BASE( wxWindow* parent, wxWindowID id,
|
|||
m_panel->SetSizer( bSizer7 );
|
||||
m_panel->Layout();
|
||||
bSizer7->Fit( m_panel );
|
||||
bHorizontalSizer->Add( m_panel, 1, wxEXPAND | wxALL, 5 );
|
||||
bSizer61->Add( m_panel, 1, wxEXPAND | wxALL, 5 );
|
||||
|
||||
wxBoxSizer* bSizer71;
|
||||
bSizer71 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_applyChangesButton = new wxButton( this, ID_BUTTON_APPLY, _("Apply Changes"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer71->Add( m_applyChangesButton, 0, wxALL, 5 );
|
||||
|
||||
m_revertChangesButton = new wxButton( this, ID_BUTTON_REVERT, _("Revert Changes"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer71->Add( m_revertChangesButton, 0, wxALL, 5 );
|
||||
|
||||
|
||||
bSizer71->Add( 0, 0, 1, wxEXPAND, 5 );
|
||||
|
||||
m_closeButton = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer71->Add( m_closeButton, 0, wxALL, 5 );
|
||||
|
||||
|
||||
bSizer61->Add( bSizer71, 0, wxEXPAND, 5 );
|
||||
|
||||
|
||||
bHorizontalSizer->Add( bSizer61, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
this->SetSizer( bHorizontalSizer );
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Feb 19 2017)
|
||||
// C++ code generated with wxFormBuilder (version Apr 1 2017)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
|
@ -32,7 +32,8 @@ class DIALOG_SHIM;
|
|||
|
||||
#define OPT_GROUP_COMPONENTS 1000
|
||||
#define ID_BUTTON_REGROUP 1001
|
||||
#define ID_BUTTON_REVERT_CHANGES 1002
|
||||
#define ID_BUTTON_APPLY 1002
|
||||
#define ID_BUTTON_REVERT 1003
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Class DIALOG_BOM_EDITOR_BASE
|
||||
|
@ -43,10 +44,10 @@ class DIALOG_BOM_EDITOR_BASE : public DIALOG_SHIM
|
|||
private:
|
||||
|
||||
// Private event handlers
|
||||
void _wxFB_OnDialogClosed( wxCloseEvent& event ){ OnDialogClosed( event ); }
|
||||
void _wxFB_OnUpdateUI( wxUpdateUIEvent& event ){ OnUpdateUI( event ); }
|
||||
void _wxFB_OnGroupComponentsToggled( wxCommandEvent& event ){ OnGroupComponentsToggled( event ); }
|
||||
void _wxFB_OnRegroupComponents( wxCommandEvent& event ){ OnRegroupComponents( event ); }
|
||||
void _wxFB_OnRevertFieldChanges( wxCommandEvent& event ){ OnRevertFieldChanges( event ); }
|
||||
void _wxFB_OnColumnItemToggled( wxDataViewEvent& event ){ OnColumnItemToggled( event ); }
|
||||
void _wxFB_OnBomColumReordered( wxDataViewEvent& event ){ OnBomColumReordered( event ); }
|
||||
void _wxFB_OnBomColumnSorted( wxDataViewEvent& event ){ OnBomColumnSorted( event ); }
|
||||
|
@ -54,6 +55,9 @@ class DIALOG_BOM_EDITOR_BASE : public DIALOG_SHIM
|
|||
void _wxFB_OnTableItemContextMenu( wxDataViewEvent& event ){ OnTableItemContextMenu( event ); }
|
||||
void _wxFB_OnTableValueChanged( wxDataViewEvent& event ){ OnTableValueChanged( event ); }
|
||||
void _wxFB_OnSelectionChanged( wxDataViewEvent& event ){ OnSelectionChanged( event ); }
|
||||
void _wxFB_OnApplyFieldChanges( wxCommandEvent& event ){ OnApplyFieldChanges( event ); }
|
||||
void _wxFB_OnRevertFieldChanges( wxCommandEvent& event ){ OnRevertFieldChanges( event ); }
|
||||
void _wxFB_OnCloseButton( wxCommandEvent& event ){ OnCloseButton( event ); }
|
||||
|
||||
|
||||
protected:
|
||||
|
@ -62,19 +66,18 @@ class DIALOG_BOM_EDITOR_BASE : public DIALOG_SHIM
|
|||
wxPanel* m_leftPanel;
|
||||
wxCheckBox* m_groupComponentsBox;
|
||||
wxButton* m_regroupComponentsButton;
|
||||
wxButton* m_reloadTableButton;
|
||||
wxDataViewListCtrl* m_columnListCtrl;
|
||||
wxStdDialogButtonSizer* m_sdbSizer1;
|
||||
wxButton* m_sdbSizer1OK;
|
||||
wxButton* m_sdbSizer1Cancel;
|
||||
wxPanel* m_panel4;
|
||||
wxDataViewCtrl* m_bomView;
|
||||
wxButton* m_applyChangesButton;
|
||||
wxButton* m_revertChangesButton;
|
||||
wxButton* m_closeButton;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void OnDialogClosed( wxCloseEvent& event ) { event.Skip(); }
|
||||
virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); }
|
||||
virtual void OnGroupComponentsToggled( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnRegroupComponents( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnRevertFieldChanges( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnColumnItemToggled( wxDataViewEvent& event ) { event.Skip(); }
|
||||
virtual void OnBomColumReordered( wxDataViewEvent& event ) { event.Skip(); }
|
||||
virtual void OnBomColumnSorted( wxDataViewEvent& event ) { event.Skip(); }
|
||||
|
@ -82,11 +85,14 @@ class DIALOG_BOM_EDITOR_BASE : public DIALOG_SHIM
|
|||
virtual void OnTableItemContextMenu( wxDataViewEvent& event ) { event.Skip(); }
|
||||
virtual void OnTableValueChanged( wxDataViewEvent& event ) { event.Skip(); }
|
||||
virtual void OnSelectionChanged( wxDataViewEvent& event ) { event.Skip(); }
|
||||
virtual void OnApplyFieldChanges( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnRevertFieldChanges( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnCloseButton( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
public:
|
||||
|
||||
DIALOG_BOM_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("BOM editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 1047,471 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
DIALOG_BOM_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("BOM editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 775,654 ), long style = wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER );
|
||||
~DIALOG_BOM_EDITOR_BASE();
|
||||
|
||||
void m_splitter1OnIdle( wxIdleEvent& )
|
||||
|
|
Loading…
Reference in New Issue