Add ability to set custom user descriptions on jobs

This commit is contained in:
Marek Roszko 2024-12-28 21:18:15 -05:00
parent db197b6577
commit 09c8cfedd3
42 changed files with 109 additions and 58 deletions

View File

@ -26,8 +26,12 @@ JOB::JOB( const std::string& aType, bool aOutputIsDirectory ) :
m_varOverrides(),
m_tempOutputDirectory(),
m_outputPath(),
m_outputPathIsDirectory( aOutputIsDirectory )
m_outputPathIsDirectory( aOutputIsDirectory ),
m_description()
{
m_params.emplace_back(
new JOB_PARAM<wxString>( "description", &m_description, m_description ) );
if( m_outputPathIsDirectory )
{
m_params.emplace_back(
@ -64,7 +68,7 @@ void JOB::ToJson( nlohmann::json& j ) const
}
wxString JOB::GetDescription()
wxString JOB::GetDefaultDescription() const
{
return wxEmptyString;
}

View File

@ -140,7 +140,7 @@ public:
virtual void FromJson( const nlohmann::json& j );
virtual void ToJson( nlohmann::json& j ) const;
virtual wxString GetDescription();
virtual wxString GetDefaultDescription() const;
const std::vector<JOB_PARAM_BASE*>& GetParams() {
return m_params;
@ -175,7 +175,8 @@ protected:
wxString m_tempOutputDirectory;
wxString m_outputPath;
bool m_outputPathIsDirectory;
bool m_outputPathIsDirectory;
wxString m_description;
std::vector<JOB_PARAM_BASE*> m_params;

View File

@ -139,7 +139,7 @@ JOB_EXPORT_PCB_3D::JOB_EXPORT_PCB_3D() :
}
wxString JOB_EXPORT_PCB_3D::GetDescription()
wxString JOB_EXPORT_PCB_3D::GetDefaultDescription() const
{
return wxString::Format( _( "3D model export" ) );
}

View File

@ -106,7 +106,7 @@ class KICOMMON_API JOB_EXPORT_PCB_3D : public JOB
{
public:
JOB_EXPORT_PCB_3D();
wxString GetDescription() override;
wxString GetDefaultDescription() const override;
void SetStepFormat( EXPORTER_STEP_PARAMS::FORMAT aFormat );

View File

@ -118,7 +118,7 @@ JOB_EXPORT_PCB_DRILL::JOB_EXPORT_PCB_DRILL() :
}
wxString JOB_EXPORT_PCB_DRILL::GetDescription()
wxString JOB_EXPORT_PCB_DRILL::GetDefaultDescription() const
{
return wxString::Format( _( "Drill data export" ), m_format );
}

View File

@ -31,7 +31,7 @@ class KICOMMON_API JOB_EXPORT_PCB_DRILL : public JOB
public:
JOB_EXPORT_PCB_DRILL();
wxString GetDescription() override;
wxString GetDefaultDescription() const override;
wxString m_filename;

View File

@ -52,7 +52,7 @@ JOB_EXPORT_PCB_DXF::JOB_EXPORT_PCB_DXF() :
}
wxString JOB_EXPORT_PCB_DXF::GetDescription()
wxString JOB_EXPORT_PCB_DXF::GetDefaultDescription() const
{
return wxString::Format( _( "PCB DXF export" ) );
}

View File

@ -32,7 +32,7 @@ class KICOMMON_API JOB_EXPORT_PCB_DXF : public JOB_EXPORT_PCB_PLOT
{
public:
JOB_EXPORT_PCB_DXF();
wxString GetDescription() override;
wxString GetDefaultDescription() const override;
enum class DXF_UNITS
{

View File

@ -76,7 +76,7 @@ JOB_EXPORT_PCB_GERBER::JOB_EXPORT_PCB_GERBER() :
}
wxString JOB_EXPORT_PCB_GERBER::GetDescription()
wxString JOB_EXPORT_PCB_GERBER::GetDefaultDescription() const
{
return wxString::Format( _( "Single gerber export" ) );
}

View File

@ -32,7 +32,7 @@ class KICOMMON_API JOB_EXPORT_PCB_GERBER : public JOB_EXPORT_PCB_PLOT
public:
JOB_EXPORT_PCB_GERBER( const std::string& aType );
JOB_EXPORT_PCB_GERBER();
wxString GetDescription() override;
wxString GetDefaultDescription() const override;
bool m_subtractSolderMaskFromSilk;
bool m_includeNetlistAttributes;

View File

@ -41,7 +41,7 @@ JOB_EXPORT_PCB_GERBERS::JOB_EXPORT_PCB_GERBERS() :
}
wxString JOB_EXPORT_PCB_GERBERS::GetDescription()
wxString JOB_EXPORT_PCB_GERBERS::GetDefaultDescription() const
{
return wxString::Format( _( "Multi gerber export" ) );
}

View File

@ -32,7 +32,7 @@ class KICOMMON_API JOB_EXPORT_PCB_GERBERS : public JOB_EXPORT_PCB_GERBER
{
public:
JOB_EXPORT_PCB_GERBERS();
wxString GetDescription() override;
wxString GetDefaultDescription() const override;
LSET m_layersIncludeOnAll;

View File

@ -67,7 +67,7 @@ JOB_EXPORT_PCB_IPC2581::JOB_EXPORT_PCB_IPC2581() :
}
wxString JOB_EXPORT_PCB_IPC2581::GetDescription()
wxString JOB_EXPORT_PCB_IPC2581::GetDefaultDescription() const
{
return wxString::Format( _( "IPC2581 export" ) );
}

View File

@ -29,7 +29,7 @@ class KICOMMON_API JOB_EXPORT_PCB_IPC2581 : public JOB
{
public:
JOB_EXPORT_PCB_IPC2581();
wxString GetDescription() override;
wxString GetDefaultDescription() const override;
void SetDefaultOutputPath( const wxString& aReferenceName );

View File

@ -51,7 +51,7 @@ JOB_EXPORT_PCB_ODB::JOB_EXPORT_PCB_ODB() :
}
wxString JOB_EXPORT_PCB_ODB::GetDescription()
wxString JOB_EXPORT_PCB_ODB::GetDefaultDescription() const
{
return wxString::Format( _( "ODB++ export" ) );
}

View File

@ -28,7 +28,7 @@ class KICOMMON_API JOB_EXPORT_PCB_ODB : public JOB
{
public:
JOB_EXPORT_PCB_ODB();
wxString GetDescription() override;
wxString GetDefaultDescription() const override;
void SetDefaultOutputPath( const wxString& aReferenceName );

View File

@ -56,7 +56,7 @@ JOB_EXPORT_PCB_PDF::JOB_EXPORT_PCB_PDF() :
}
wxString JOB_EXPORT_PCB_PDF::GetDescription()
wxString JOB_EXPORT_PCB_PDF::GetDefaultDescription() const
{
return wxString::Format( _( "PCB PDF export" ) );
}

View File

@ -32,7 +32,7 @@ class KICOMMON_API JOB_EXPORT_PCB_PDF : public JOB_EXPORT_PCB_PLOT
{
public:
JOB_EXPORT_PCB_PDF();
wxString GetDescription() override;
wxString GetDefaultDescription() const override;
bool m_useDrillOrigin;
};

View File

@ -86,7 +86,7 @@ JOB_EXPORT_PCB_POS::JOB_EXPORT_PCB_POS() :
}
wxString JOB_EXPORT_PCB_POS::GetDescription()
wxString JOB_EXPORT_PCB_POS::GetDefaultDescription() const
{
return wxString::Format( _( "Placement data export" ) );
}

View File

@ -30,7 +30,7 @@ class KICOMMON_API JOB_EXPORT_PCB_POS : public JOB
{
public:
JOB_EXPORT_PCB_POS();
wxString GetDescription() override;
wxString GetDefaultDescription() const override;
void SetDefaultOutputPath( const wxString& aReferenceName );

View File

@ -52,7 +52,7 @@ JOB_EXPORT_PCB_SVG::JOB_EXPORT_PCB_SVG() :
}
wxString JOB_EXPORT_PCB_SVG::GetDescription()
wxString JOB_EXPORT_PCB_SVG::GetDefaultDescription() const
{
return wxString::Format( _( "PCB SVG export" ) );
}

View File

@ -32,7 +32,7 @@ class KICOMMON_API JOB_EXPORT_PCB_SVG : public JOB_EXPORT_PCB_PLOT
{
public:
JOB_EXPORT_PCB_SVG();
wxString GetDescription() override;
wxString GetDefaultDescription() const override;
int m_pageSizeMode;
unsigned int m_precision;

View File

@ -81,7 +81,7 @@ JOB_EXPORT_SCH_BOM::JOB_EXPORT_SCH_BOM() :
}
wxString JOB_EXPORT_SCH_BOM::GetDescription()
wxString JOB_EXPORT_SCH_BOM::GetDefaultDescription() const
{
return wxString::Format( _( "Schematic BOM export" ) );
}

View File

@ -30,7 +30,7 @@ class KICOMMON_API JOB_EXPORT_SCH_BOM : public JOB
{
public:
JOB_EXPORT_SCH_BOM();
wxString GetDescription() override;
wxString GetDefaultDescription() const override;
// Basic options
wxString m_filename;

View File

@ -56,7 +56,7 @@ JOB_EXPORT_SCH_NETLIST::JOB_EXPORT_SCH_NETLIST() :
}
wxString JOB_EXPORT_SCH_NETLIST::GetDescription()
wxString JOB_EXPORT_SCH_NETLIST::GetDefaultDescription() const
{
return wxString::Format( _( "Schematic Netlist Export" ) );
}

View File

@ -29,7 +29,7 @@ class KICOMMON_API JOB_EXPORT_SCH_NETLIST : public JOB
{
public:
JOB_EXPORT_SCH_NETLIST();
wxString GetDescription() override;
wxString GetDefaultDescription() const override;
wxString m_filename;

View File

@ -123,7 +123,7 @@ JOB_EXPORT_SCH_PLOT_PDF::JOB_EXPORT_SCH_PLOT_PDF() :
}
wxString JOB_EXPORT_SCH_PLOT_PDF::GetDescription()
wxString JOB_EXPORT_SCH_PLOT_PDF::GetDefaultDescription() const
{
return wxString::Format( _( "Schematic PDF Plot" ) );
}
@ -136,7 +136,7 @@ JOB_EXPORT_SCH_PLOT_DXF ::JOB_EXPORT_SCH_PLOT_DXF () :
}
wxString JOB_EXPORT_SCH_PLOT_DXF::GetDescription()
wxString JOB_EXPORT_SCH_PLOT_DXF::GetDefaultDescription() const
{
return wxString::Format( _( "Schematic DXF Plot" ) );
}
@ -149,7 +149,7 @@ JOB_EXPORT_SCH_PLOT_SVG::JOB_EXPORT_SCH_PLOT_SVG() :
}
wxString JOB_EXPORT_SCH_PLOT_SVG::GetDescription()
wxString JOB_EXPORT_SCH_PLOT_SVG::GetDefaultDescription() const
{
return wxString::Format( _( "Schematic SVG Plot" ) );
}
@ -162,7 +162,7 @@ JOB_EXPORT_SCH_PLOT_PS::JOB_EXPORT_SCH_PLOT_PS() :
}
wxString JOB_EXPORT_SCH_PLOT_PS::GetDescription()
wxString JOB_EXPORT_SCH_PLOT_PS::GetDefaultDescription() const
{
return wxString::Format( _( "Schematic PS Plot" ) );
}
@ -175,7 +175,7 @@ JOB_EXPORT_SCH_PLOT_HPGL::JOB_EXPORT_SCH_PLOT_HPGL() :
}
wxString JOB_EXPORT_SCH_PLOT_HPGL::GetDescription()
wxString JOB_EXPORT_SCH_PLOT_HPGL::GetDefaultDescription() const
{
return wxString::Format( _( "Schematic HPGL Plot" ) );
}

View File

@ -106,7 +106,7 @@ class KICOMMON_API JOB_EXPORT_SCH_PLOT_PDF : public JOB_EXPORT_SCH_PLOT
{
public:
JOB_EXPORT_SCH_PLOT_PDF();
wxString GetDescription() override;
wxString GetDefaultDescription() const override;
};
@ -114,7 +114,7 @@ class KICOMMON_API JOB_EXPORT_SCH_PLOT_DXF : public JOB_EXPORT_SCH_PLOT
{
public:
JOB_EXPORT_SCH_PLOT_DXF();
wxString GetDescription() override;
wxString GetDefaultDescription() const override;
};
@ -122,7 +122,7 @@ class KICOMMON_API JOB_EXPORT_SCH_PLOT_SVG : public JOB_EXPORT_SCH_PLOT
{
public:
JOB_EXPORT_SCH_PLOT_SVG();
wxString GetDescription() override;
wxString GetDefaultDescription() const override;
};
@ -130,7 +130,7 @@ class KICOMMON_API JOB_EXPORT_SCH_PLOT_PS : public JOB_EXPORT_SCH_PLOT
{
public:
JOB_EXPORT_SCH_PLOT_PS();
wxString GetDescription() override;
wxString GetDefaultDescription() const override;
};
@ -138,7 +138,7 @@ class KICOMMON_API JOB_EXPORT_SCH_PLOT_HPGL : public JOB_EXPORT_SCH_PLOT
{
public:
JOB_EXPORT_SCH_PLOT_HPGL();
wxString GetDescription() override;
wxString GetDefaultDescription() const override;
};
#endif

View File

@ -30,7 +30,7 @@ JOB_EXPORT_SCH_PYTHONBOM::JOB_EXPORT_SCH_PYTHONBOM() :
}
wxString JOB_EXPORT_SCH_PYTHONBOM::GetDescription()
wxString JOB_EXPORT_SCH_PYTHONBOM::GetDefaultDescription() const
{
return wxString::Format( _( "Schematic PythonBOM export" ) );
}

View File

@ -29,7 +29,7 @@ class KICOMMON_API JOB_EXPORT_SCH_PYTHONBOM : public JOB
{
public:
JOB_EXPORT_SCH_PYTHONBOM();
wxString GetDescription() override;
wxString GetDefaultDescription() const override;
wxString m_filename;
};

View File

@ -32,7 +32,7 @@ JOB_PCB_DRC::JOB_PCB_DRC() :
}
wxString JOB_PCB_DRC::GetDescription()
wxString JOB_PCB_DRC::GetDefaultDescription() const
{
return wxString::Format( _( "Perform PCB DRC" ) );
}

View File

@ -26,7 +26,7 @@ class KICOMMON_API JOB_PCB_DRC : public JOB_RC
{
public:
JOB_PCB_DRC();
wxString GetDescription() override;
wxString GetDefaultDescription() const override;
bool m_reportAllTrackErrors;
bool m_parity;

View File

@ -72,7 +72,7 @@ JOB_PCB_RENDER::JOB_PCB_RENDER() :
}
wxString JOB_PCB_RENDER::GetDescription()
wxString JOB_PCB_RENDER::GetDefaultDescription() const
{
return _( "Render PCB" );
}

View File

@ -32,7 +32,7 @@ class KICOMMON_API JOB_PCB_RENDER : public JOB
{
public:
JOB_PCB_RENDER();
wxString GetDescription() override;
wxString GetDefaultDescription() const override;
wxString m_filename;

View File

@ -28,7 +28,7 @@ JOB_SCH_ERC::JOB_SCH_ERC() :
}
wxString JOB_SCH_ERC::GetDescription()
wxString JOB_SCH_ERC::GetDefaultDescription() const
{
return wxString::Format( _( "Perform Schematic ERC" ) );
}

View File

@ -26,5 +26,5 @@ class KICOMMON_API JOB_SCH_ERC : public JOB_RC
{
public:
JOB_SCH_ERC();
wxString GetDescription() override;
wxString GetDefaultDescription() const override;
};

View File

@ -34,7 +34,7 @@ JOB_SPECIAL_EXECUTE::JOB_SPECIAL_EXECUTE() :
new JOB_PARAM<bool>( "record_output", &m_recordOutput, m_recordOutput ) );
}
wxString JOB_SPECIAL_EXECUTE::GetDescription()
wxString JOB_SPECIAL_EXECUTE::GetDefaultDescription() const
{
return wxString( "Execute command: " ) + m_command;
}

View File

@ -29,7 +29,7 @@ class KICOMMON_API JOB_SPECIAL_EXECUTE : public JOB
public:
JOB_SPECIAL_EXECUTE();
wxString GetDescription() override;
wxString GetDefaultDescription() const override;
wxString m_command;

View File

@ -44,6 +44,7 @@ KICOMMON_API void to_json( nlohmann::json& j, const JOBSET_JOB& f )
{
j = nlohmann::json{ { "id", f.m_id },
{ "type", f.m_type },
{ "description", f.m_description },
{ "settings", nlohmann::json::object( {} ) }
};
@ -55,6 +56,7 @@ KICOMMON_API void from_json( const nlohmann::json& j, JOBSET_JOB& f )
{
j.at( "type" ).get_to( f.m_type );
j.at( "id" ).get_to( f.m_id );
f.m_description = j.value( "description", "" );
nlohmann::json settings_obj = j.at( "settings" );
@ -140,6 +142,21 @@ bool JOBSET_JOB::operator==( const JOBSET_JOB & rhs ) const
}
wxString JOBSET_JOB::GetDescription() const
{
return m_description.IsEmpty() ? m_job->GetDefaultDescription() : m_description;
}
void JOBSET_JOB::SetDescription( const wxString& aDescription )
{
if( aDescription == m_job->GetDefaultDescription() )
m_description = wxEmptyString;
else
m_description = aDescription;
}
bool JOBSET_OUTPUT::operator==( const JOBSET_OUTPUT& rhs ) const
{
return rhs.m_type == m_type;

View File

@ -36,9 +36,13 @@ struct KICOMMON_API JOBSET_JOB
JOBSET_JOB( wxString id, wxString type, JOB* job ) : m_id( id ), m_type( type ), m_job( job ) {}
wxString m_id;
wxString m_type;
std::shared_ptr<JOB> m_job;
wxString m_id;
wxString m_type;
wxString m_description;
std::shared_ptr<JOB> m_job;
wxString GetDescription() const;
void SetDescription( const wxString& aDescription );
bool operator==( const JOBSET_JOB& rhs ) const;
};

View File

@ -44,6 +44,7 @@
#include <jobs/job_special_execute.h>
#include <dialogs/dialog_special_execute.h>
#include <wx/textdlg.h>
struct JOB_TYPE_INFO
@ -175,7 +176,7 @@ public:
int i = 0;
for( JOBSET_JOB& job : jobs )
{
arrayStr.Add( job.m_job->GetDescription() );
arrayStr.Add( job.GetDescription() );
auto it = std::find_if( m_output->m_only.begin(), m_output->m_only.end(),
[&]( const wxString& only )
@ -262,7 +263,7 @@ public:
long itemIndex = m_jobList->InsertItem( m_jobList->GetItemCount(), imageIdx );
m_jobList->SetItem( itemIndex, jobNoColId, wxString::Format( "%d", num++ ) );
m_jobList->SetItem( itemIndex, jobDescColId, job.m_job->GetDescription() );
m_jobList->SetItem( itemIndex, jobDescColId, job.GetDescription() );
}
}
@ -509,7 +510,7 @@ void PANEL_JOBS::rebuildJobList()
{
long itemIndex =
m_jobList->InsertItem( m_jobList->GetItemCount(), wxString::Format( "%d", num++ ) );
m_jobList->SetItem( itemIndex, 1, job.m_job->GetDescription() );
m_jobList->SetItem( itemIndex, 1, job.GetDescription() );
}
updateTitle();
@ -621,7 +622,9 @@ void PANEL_JOBS::OnJobListDoubleClicked( wxListEvent& aEvent )
void PANEL_JOBS::OnJobListItemRightClick( wxListEvent& event )
{
wxMenu menu;
menu.Append( wxID_EDIT, _( "Edit..." ) );
menu.Append( wxID_PROPERTIES, _( "Edit Options" ) );
menu.Append( wxID_EDIT, _( "Edit Description" ) );
menu.AppendSeparator();
menu.Append( wxID_DELETE, _( "Delete" ) );
m_jobList->PopupMenu( &menu, event.GetPoint() );
@ -632,7 +635,7 @@ void PANEL_JOBS::onJobListMenu( wxCommandEvent& aEvent )
{
switch( aEvent.GetId() )
{
case wxID_EDIT:
case wxID_PROPERTIES:
{
long item = m_jobList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
@ -643,6 +646,28 @@ void PANEL_JOBS::onJobListMenu( wxCommandEvent& aEvent )
}
break;
case wxID_EDIT:
{
long item = m_jobList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
if( item == -1 )
return;
JOBSET_JOB& job = m_jobsFile->GetJobs()[item];
wxString desc = job.GetDescription();
wxString newDesc = wxGetTextFromUser( _( "Enter new description:" ), _( "Edit Description" ), desc );
if( desc != newDesc )
{
job.SetDescription( newDesc );
m_jobsFile->SetDirty();
updateTitle();
m_jobList->SetItem( item, 1, job.GetDescription() );
}
}
break;
break;
case wxID_DELETE:
{
long item = m_jobList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );

View File

@ -149,7 +149,7 @@ bool JOBS_RUNNER::RunJobsForOutput( JOBSET_OUTPUT* aOutput, bool aBail )
for( const JOBSET_JOB& job : jobsForOutput )
{
msg += wxString::Format( wxT( "|%-5d | %-50s\n" ), jobNum,
job.m_job->GetDescription() );
job.GetDescription() );
jobNum++;
}
msg += wxT( "|--------------------------------\n" );
@ -169,7 +169,7 @@ bool JOBS_RUNNER::RunJobsForOutput( JOBSET_OUTPUT* aOutput, bool aBail )
if( m_reporter != nullptr )
{
msg = wxT( "|--------------------------------\n" );
msg += wxString::Format( wxT( "| Running job %d, %s" ), jobNum, job.m_job->GetDescription() );
msg += wxString::Format( wxT( "| Running job %d, %s" ), jobNum, job.GetDescription() );
msg += wxT( "\n" );
msg += wxT( "|--------------------------------\n" );