mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
Add context menu to jobset list items
This commit is contained in:
parent
a055d95f0c
commit
e61d1c771d
@ -173,6 +173,13 @@ void JOBSET::MoveJobDown( size_t aJobIdx )
|
||||
}
|
||||
|
||||
|
||||
void JOBSET::RemoveJob( size_t aJobIdx )
|
||||
{
|
||||
m_jobs.erase( m_jobs.begin() + aJobIdx );
|
||||
SetDirty();
|
||||
}
|
||||
|
||||
|
||||
bool JOBSET::SaveToFile( const wxString& aDirectory, bool aForce )
|
||||
{
|
||||
bool success = JSON_SETTINGS::SaveToFile( aDirectory, aForce );
|
||||
|
@ -97,6 +97,7 @@ public:
|
||||
void RemoveOutput( JOBSET_OUTPUT* aOutput );
|
||||
void MoveJobUp( size_t aJobIdx );
|
||||
void MoveJobDown( size_t aJobIdx );
|
||||
void RemoveJob( size_t aJobIdx );
|
||||
|
||||
protected:
|
||||
wxString getFileExt() const override;
|
||||
|
@ -315,11 +315,21 @@ PANEL_JOBS::PANEL_JOBS( wxAuiNotebook* aParent, KICAD_MANAGER_FRAME* aFrame,
|
||||
m_buttonDown->SetBitmap( KiBitmapBundle( BITMAPS::small_down ) );
|
||||
m_buttonOutputAdd->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) );
|
||||
|
||||
m_jobList->Connect( wxEVT_MENU, wxCommandEventHandler( PANEL_JOBS::onJobListMenu ),
|
||||
nullptr, this );
|
||||
|
||||
rebuildJobList();
|
||||
buildOutputList();
|
||||
}
|
||||
|
||||
|
||||
PANEL_JOBS::~PANEL_JOBS()
|
||||
{
|
||||
m_jobList->Disconnect( wxEVT_MENU, wxCommandEventHandler( PANEL_JOBS::onJobListMenu ),
|
||||
nullptr, this );
|
||||
}
|
||||
|
||||
|
||||
void PANEL_JOBS::RemoveOutput( JOBSET_OUTPUT* aOutput )
|
||||
{
|
||||
auto it = m_outputPanelMap.find( aOutput );
|
||||
@ -396,13 +406,11 @@ void PANEL_JOBS::buildOutputList()
|
||||
}
|
||||
|
||||
|
||||
void PANEL_JOBS::OnJobListDoubleClicked( wxListEvent& aEvent )
|
||||
void PANEL_JOBS::openJobOptionsForListItem( size_t aItemIndex )
|
||||
{
|
||||
EnsurePcbSchFramesOpen();
|
||||
|
||||
long item = aEvent.GetIndex();
|
||||
|
||||
JOBSET_JOB& job = m_jobsFile->GetJobs()[item];
|
||||
JOBSET_JOB& job = m_jobsFile->GetJobs()[aItemIndex];
|
||||
|
||||
KIWAY::FACE_T iface = JOB_REGISTRY::GetKifaceType( job.m_type );
|
||||
|
||||
@ -410,6 +418,56 @@ void PANEL_JOBS::OnJobListDoubleClicked( wxListEvent& aEvent )
|
||||
}
|
||||
|
||||
|
||||
void PANEL_JOBS::OnJobListDoubleClicked( wxListEvent& aEvent )
|
||||
{
|
||||
long item = aEvent.GetIndex();
|
||||
|
||||
openJobOptionsForListItem( item );
|
||||
}
|
||||
|
||||
|
||||
void PANEL_JOBS::OnJobListItemRightClick( wxListEvent& event )
|
||||
{
|
||||
wxMenu menu;
|
||||
menu.Append( wxID_EDIT, _( "Edit..." ) );
|
||||
menu.Append( wxID_DELETE, _( "Delete" ) );
|
||||
|
||||
m_jobList->PopupMenu( &menu, event.GetPoint() );
|
||||
}
|
||||
|
||||
|
||||
void PANEL_JOBS::onJobListMenu( wxCommandEvent& aEvent )
|
||||
{
|
||||
switch( aEvent.GetId() )
|
||||
{
|
||||
case wxID_EDIT:
|
||||
{
|
||||
long item = m_jobList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
|
||||
|
||||
if( item == -1 )
|
||||
return;
|
||||
|
||||
openJobOptionsForListItem( item );
|
||||
}
|
||||
break;
|
||||
|
||||
case wxID_DELETE:
|
||||
{
|
||||
long item = m_jobList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
|
||||
|
||||
if( item == -1 )
|
||||
return;
|
||||
|
||||
m_jobsFile->RemoveJob( item );
|
||||
rebuildJobList();
|
||||
break;
|
||||
}
|
||||
|
||||
default: wxFAIL_MSG( wxT( "Unknown ID in context menu event" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PANEL_JOBS::OnSaveButtonClick( wxCommandEvent& aEvent )
|
||||
{
|
||||
m_jobsFile->SaveToFile();
|
||||
|
@ -35,6 +35,8 @@ public:
|
||||
PANEL_JOBS( wxAuiNotebook* aParent, KICAD_MANAGER_FRAME* aFrame,
|
||||
std::unique_ptr<JOBSET> aJobsFile );
|
||||
|
||||
~PANEL_JOBS();
|
||||
|
||||
void RemoveOutput( JOBSET_OUTPUT* aOutput );
|
||||
|
||||
void EnsurePcbSchFramesOpen();
|
||||
@ -43,6 +45,7 @@ protected:
|
||||
virtual void OnAddJobClick( wxCommandEvent& aEvent ) override;
|
||||
virtual void OnAddOutputClick( wxCommandEvent& aEvent ) override;
|
||||
virtual void OnJobListDoubleClicked( wxListEvent& aEvent ) override;
|
||||
virtual void OnJobListItemRightClick( wxListEvent& event ) override;
|
||||
virtual void OnSaveButtonClick( wxCommandEvent& aEvent ) override;
|
||||
virtual void OnJobButtonUp( wxCommandEvent& aEvent ) override;
|
||||
virtual void OnJobButtonDown( wxCommandEvent& aEvent ) override;
|
||||
@ -54,6 +57,8 @@ private:
|
||||
void updateTitle();
|
||||
void buildOutputList();
|
||||
void addJobOutputPanel( JOBSET_OUTPUT* aOutput );
|
||||
void onJobListMenu( wxCommandEvent& aEvent );
|
||||
void openJobOptionsForListItem( size_t aItemIndex );
|
||||
|
||||
wxAuiNotebook* m_parentBook;
|
||||
KICAD_MANAGER_FRAME* m_frame;
|
||||
|
Loading…
x
Reference in New Issue
Block a user