Replace "unsaved changes" dialog to Global Fields Editor.
This commit is contained in:
parent
7d62f14dd0
commit
aaf47bbe71
|
@ -93,6 +93,7 @@ protected:
|
|||
|
||||
SCH_EDIT_FRAME* m_frame;
|
||||
SCH_REFERENCE_LIST m_componentRefs;
|
||||
bool m_edited;
|
||||
std::vector<wxString> m_fieldNames;
|
||||
int m_sortColumn;
|
||||
bool m_sortAscending;
|
||||
|
@ -116,6 +117,7 @@ public:
|
|||
FIELDS_EDITOR_GRID_DATA_MODEL( SCH_EDIT_FRAME* aFrame, SCH_REFERENCE_LIST& aComponentList ) :
|
||||
m_frame( aFrame ),
|
||||
m_componentRefs( aComponentList ),
|
||||
m_edited( false ),
|
||||
m_sortAscending( false )
|
||||
{
|
||||
m_componentRefs.SplitReferences();
|
||||
|
@ -237,6 +239,8 @@ public:
|
|||
|
||||
for( const auto& ref : rowGroup.m_Refs )
|
||||
m_dataStore[ ref.GetComp()->GetTimeStamp() ][ fieldName ] = aValue;
|
||||
|
||||
m_edited = true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -513,6 +517,13 @@ public:
|
|||
destField->SetText( srcValue );
|
||||
}
|
||||
}
|
||||
|
||||
m_edited = false;
|
||||
}
|
||||
|
||||
bool IsEdited()
|
||||
{
|
||||
return m_edited;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -847,3 +858,35 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::OnSaveAndContinue( wxCommandEvent& aEvent )
|
|||
m_parent->OnSaveProject( dummyEvent );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_FIELDS_EDITOR_GLOBAL::OnCancel( wxCommandEvent& event )
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_FIELDS_EDITOR_GLOBAL::OnClose( wxCloseEvent& event )
|
||||
{
|
||||
// Commit any pending in-place edits and close the editor
|
||||
m_grid->DisableCellEditControl();
|
||||
|
||||
if( m_dataModel->IsEdited() )
|
||||
{
|
||||
switch( DisplayExitDialog( this, wxEmptyString ) )
|
||||
{
|
||||
case wxID_CANCEL:
|
||||
event.Veto();
|
||||
break;
|
||||
|
||||
case wxID_YES:
|
||||
if( TransferDataFromWindow() )
|
||||
event.Skip();
|
||||
break;
|
||||
|
||||
case wxID_NO:
|
||||
event.Skip();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,6 +64,8 @@ private:
|
|||
void OnTableItemContextMenu( wxGridEvent& event ) override;
|
||||
void OnSizeFieldList( wxSizeEvent& event ) override;
|
||||
void OnSaveAndContinue( wxCommandEvent& aEvent ) override;
|
||||
void OnCancel( wxCommandEvent& event ) override;
|
||||
void OnClose( wxCloseEvent& event ) override;
|
||||
};
|
||||
|
||||
#endif /* DIALOG_FIELDS_EDITOR_GLOBAL_H */
|
||||
|
|
|
@ -120,6 +120,7 @@ DIALOG_FIELDS_EDITOR_GLOBAL_BASE::DIALOG_FIELDS_EDITOR_GLOBAL_BASE( wxWindow* pa
|
|||
this->Centre( wxBOTH );
|
||||
|
||||
// Connect Events
|
||||
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnClose ) );
|
||||
m_groupComponentsBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnGroupComponentsToggled ), NULL, this );
|
||||
m_bRefresh->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnRegroupComponents ), NULL, this );
|
||||
m_fieldsCtrl->Connect( wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, wxDataViewEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnColumnItemToggled ), NULL, this );
|
||||
|
@ -130,12 +131,12 @@ DIALOG_FIELDS_EDITOR_GLOBAL_BASE::DIALOG_FIELDS_EDITOR_GLOBAL_BASE( wxWindow* pa
|
|||
m_grid->Connect( wxEVT_GRID_CELL_RIGHT_CLICK, wxGridEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnTableItemContextMenu ), NULL, this );
|
||||
m_button1->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnSaveAndContinue ), NULL, this );
|
||||
m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnCancel ), NULL, this );
|
||||
m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnOK ), NULL, this );
|
||||
}
|
||||
|
||||
DIALOG_FIELDS_EDITOR_GLOBAL_BASE::~DIALOG_FIELDS_EDITOR_GLOBAL_BASE()
|
||||
{
|
||||
// Disconnect Events
|
||||
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnClose ) );
|
||||
m_groupComponentsBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnGroupComponentsToggled ), NULL, this );
|
||||
m_bRefresh->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnRegroupComponents ), NULL, this );
|
||||
m_fieldsCtrl->Disconnect( wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, wxDataViewEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnColumnItemToggled ), NULL, this );
|
||||
|
@ -146,6 +147,5 @@ DIALOG_FIELDS_EDITOR_GLOBAL_BASE::~DIALOG_FIELDS_EDITOR_GLOBAL_BASE()
|
|||
m_grid->Disconnect( wxEVT_GRID_CELL_RIGHT_CLICK, wxGridEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnTableItemContextMenu ), NULL, this );
|
||||
m_button1->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnSaveAndContinue ), NULL, this );
|
||||
m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnCancel ), NULL, this );
|
||||
m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnOK ), NULL, this );
|
||||
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
<event name="OnAuiPaneRestore"></event>
|
||||
<event name="OnAuiRender"></event>
|
||||
<event name="OnChar"></event>
|
||||
<event name="OnClose"></event>
|
||||
<event name="OnClose">OnClose</event>
|
||||
<event name="OnEnterWindow"></event>
|
||||
<event name="OnEraseBackground"></event>
|
||||
<event name="OnHibernate"></event>
|
||||
|
@ -890,7 +890,7 @@
|
|||
<event name="OnContextHelpButtonClick"></event>
|
||||
<event name="OnHelpButtonClick"></event>
|
||||
<event name="OnNoButtonClick"></event>
|
||||
<event name="OnOKButtonClick">OnOK</event>
|
||||
<event name="OnOKButtonClick"></event>
|
||||
<event name="OnSaveButtonClick"></event>
|
||||
<event name="OnYesButtonClick"></event>
|
||||
</object>
|
||||
|
|
|
@ -55,6 +55,7 @@ class DIALOG_FIELDS_EDITOR_GLOBAL_BASE : public DIALOG_SHIM
|
|||
wxButton* m_sdbSizer1Cancel;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void OnClose( wxCloseEvent& event ) { event.Skip(); }
|
||||
virtual void OnGroupComponentsToggled( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnRegroupComponents( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnColumnItemToggled( wxDataViewEvent& event ) { event.Skip(); }
|
||||
|
@ -64,7 +65,6 @@ class DIALOG_FIELDS_EDITOR_GLOBAL_BASE : public DIALOG_SHIM
|
|||
virtual void OnTableItemContextMenu( wxGridEvent& event ) { event.Skip(); }
|
||||
virtual void OnSaveAndContinue( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnCancel( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnOK( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue