7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 00:21:25 +00:00

Implement job up/down arrangement

This commit is contained in:
Marek Roszko 2024-10-02 22:53:43 -04:00
parent 3163801019
commit 7abc0b9839
7 changed files with 69 additions and 11 deletions

View File

@ -153,6 +153,26 @@ void JOBSET::RemoveOutput( JOBSET_OUTPUT* aOutput )
}
void JOBSET::MoveJobUp( size_t aJobIdx )
{
if( aJobIdx > 0 )
{
std::swap( m_jobs[aJobIdx], m_jobs[aJobIdx - 1] );
SetDirty();
}
}
void JOBSET::MoveJobDown( size_t aJobIdx )
{
if( aJobIdx < m_jobs.size() - 1 )
{
std::swap( m_jobs[aJobIdx], m_jobs[aJobIdx + 1] );
SetDirty();
}
}
bool JOBSET::SaveToFile( const wxString& aDirectory, bool aForce )
{
bool success = JSON_SETTINGS::SaveToFile( aDirectory, aForce );

View File

@ -95,6 +95,8 @@ public:
JOBS_OUTPUT_HANDLER* aJobOutput );
void RemoveOutput( JOBSET_OUTPUT* aOutput );
void MoveJobUp( size_t aJobIdx );
void MoveJobDown( size_t aJobIdx );
protected:
wxString getFileExt() const override;

View File

@ -193,16 +193,6 @@ public:
m_choiceArchiveformat->AppendString( _( "Zip" ) );
m_choiceArchiveformat->SetSelection( 0 );
if( m_output->m_type == JOBSET_OUTPUT_TYPE::ARCHIVE )
{
JOBS_OUTPUT_ARCHIVE* archive = static_cast<JOBS_OUTPUT_ARCHIVE*>( m_output->m_outputHandler );
}
else
{
JOBS_OUTPUT_FOLDER* folder =
static_cast<JOBS_OUTPUT_FOLDER*>( m_output->m_outputHandler );
}
return true;
}
@ -416,7 +406,7 @@ void PANEL_JOBS::OnJobListDoubleClicked( wxListEvent& aEvent )
KIWAY::FACE_T iface = JOB_REGISTRY::GetKifaceType( job.m_type );
int result = m_frame->Kiway().ProcessJobConfigDialog( iface, job.m_job, m_frame );
m_frame->Kiway().ProcessJobConfigDialog( iface, job.m_job, m_frame );
}
@ -569,3 +559,39 @@ void PANEL_JOBS::EnsurePcbSchFramesOpen()
frame->OpenProjectFiles( std::vector<wxString>( 1, schFn.GetFullPath() ) );
}
}
void PANEL_JOBS::OnJobButtonUp( wxCommandEvent& aEvent )
{
long item = m_jobList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
if( item == -1 )
return;
if( item == 0 )
return;
m_jobsFile->MoveJobUp( item );
rebuildJobList();
m_jobList->SetItemState( item - 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
}
void PANEL_JOBS::OnJobButtonDown( wxCommandEvent& aEvent )
{
long item = m_jobList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
if( item == -1 )
return;
if( item == m_jobList->GetItemCount() - 1 )
return;
m_jobsFile->MoveJobDown( item );
rebuildJobList();
m_jobList->SetItemState( item + 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
}

View File

@ -44,6 +44,8 @@ protected:
virtual void OnAddOutputClick( wxCommandEvent& aEvent ) override;
virtual void OnJobListDoubleClicked( wxListEvent& aEvent ) override;
virtual void OnSaveButtonClick( wxCommandEvent& aEvent ) override;
virtual void OnJobButtonUp( wxCommandEvent& aEvent ) override;
virtual void OnJobButtonDown( wxCommandEvent& aEvent ) override;
bool GetCanClose() override;

View File

@ -92,6 +92,8 @@ PANEL_JOBS_BASE::PANEL_JOBS_BASE( wxWindow* parent, wxWindowID id, const wxPoint
m_jobList->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( PANEL_JOBS_BASE::OnJobListDoubleClicked ), NULL, this );
m_jobList->Connect( wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, wxListEventHandler( PANEL_JOBS_BASE::OnJobListItemRightClick ), NULL, this );
m_buttonAddJob->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_JOBS_BASE::OnAddJobClick ), NULL, this );
m_buttonUp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_JOBS_BASE::OnJobButtonUp ), NULL, this );
m_buttonDown->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_JOBS_BASE::OnJobButtonDown ), NULL, this );
m_buttonSave->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_JOBS_BASE::OnSaveButtonClick ), NULL, this );
m_buttonOutputAdd->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_JOBS_BASE::OnAddOutputClick ), NULL, this );
m_buttonRunAllOutputs->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_JOBS_BASE::OnRunAllJobsClick ), NULL, this );
@ -103,6 +105,8 @@ PANEL_JOBS_BASE::~PANEL_JOBS_BASE()
m_jobList->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( PANEL_JOBS_BASE::OnJobListDoubleClicked ), NULL, this );
m_jobList->Disconnect( wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, wxListEventHandler( PANEL_JOBS_BASE::OnJobListItemRightClick ), NULL, this );
m_buttonAddJob->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_JOBS_BASE::OnAddJobClick ), NULL, this );
m_buttonUp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_JOBS_BASE::OnJobButtonUp ), NULL, this );
m_buttonDown->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_JOBS_BASE::OnJobButtonDown ), NULL, this );
m_buttonSave->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_JOBS_BASE::OnSaveButtonClick ), NULL, this );
m_buttonOutputAdd->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_JOBS_BASE::OnAddOutputClick ), NULL, this );
m_buttonRunAllOutputs->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_JOBS_BASE::OnRunAllJobsClick ), NULL, this );

View File

@ -352,6 +352,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnJobButtonUp</event>
</object>
</object>
<object class="sizeritem" expanded="true">
@ -426,6 +427,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnJobButtonDown</event>
</object>
</object>
<object class="sizeritem" expanded="false">

View File

@ -60,6 +60,8 @@ class PANEL_JOBS_BASE : public PANEL_NOTEBOOK_BASE
virtual void OnJobListDoubleClicked( wxListEvent& event ) { event.Skip(); }
virtual void OnJobListItemRightClick( wxListEvent& event ) { event.Skip(); }
virtual void OnAddJobClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnJobButtonUp( wxCommandEvent& event ) { event.Skip(); }
virtual void OnJobButtonDown( wxCommandEvent& event ) { event.Skip(); }
virtual void OnSaveButtonClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnAddOutputClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRunAllJobsClick( wxCommandEvent& event ) { event.Skip(); }