7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-20 20:11:41 +00:00

Save bom & bom_fmt preset names for jobs.

Also re-fronts Kicad manager frame after editing
job settings.

Also fixes a bug where group-by (but non-shown)
fields didn't get restored.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19627
This commit is contained in:
Jeff Young 2025-01-14 14:37:31 +00:00
parent 77a524fa22
commit 799dadeeec
4 changed files with 43 additions and 49 deletions

View File

@ -30,18 +30,18 @@ JOB::JOB( const std::string& aType, bool aOutputIsDirectory ) :
m_outputPathIsDirectory( aOutputIsDirectory ),
m_description()
{
m_params.emplace_back(
new JOB_PARAM<wxString>( "description", &m_description, m_description ) );
m_params.emplace_back( new JOB_PARAM<wxString>( "description",
&m_description, m_description ) );
if( m_outputPathIsDirectory )
{
m_params.emplace_back(
new JOB_PARAM<wxString>( "output_dir", &m_outputPath, m_outputPath ) );
m_params.emplace_back( new JOB_PARAM<wxString>( "output_dir",
&m_outputPath, m_outputPath ) );
}
else
{
m_params.emplace_back(
new JOB_PARAM<wxString>( "output_filename", &m_outputPath, m_outputPath ) );
m_params.emplace_back( new JOB_PARAM<wxString>( "output_filename",
&m_outputPath, m_outputPath ) );
}
}
@ -110,15 +110,11 @@ wxString JOB::GetFullOutputPath( PROJECT* aProject ) const
if( m_outputPathIsDirectory )
{
wxFileName fn( outPath );
if( fn.IsAbsolute() || outPath.IsEmpty() )
{
fn.AssignDir( m_tempOutputDirectory );
}
else
{
PrependDirectoryToPath( fn, m_tempOutputDirectory );
}
if( fn.IsAbsolute() || outPath.IsEmpty() )
fn.AssignDir( m_tempOutputDirectory );
else
PrependDirectoryToPath( fn, m_tempOutputDirectory );
return fn.GetFullPath();
}
@ -153,19 +149,14 @@ void JOB::SetOutputPath( const wxString& aPath )
bool JOB::OutputPathFullSpecified() const
{
if( m_outputPath.IsEmpty() )
{
return false;
}
wxFileName fn( m_outputPath );
if( m_outputPathIsDirectory )
{
return fn.IsDir();
}
else
{
return !fn.IsDir();
}
}

View File

@ -78,6 +78,12 @@ JOB_EXPORT_SCH_BOM::JOB_EXPORT_SCH_BOM() :
&m_includeExcludedFromBOM,
m_includeExcludedFromBOM ) );
m_params.emplace_back( new JOB_PARAM<wxString>( "bom_preset_name",
&m_bomPresetName,
m_bomPresetName ) );
m_params.emplace_back( new JOB_PARAM<wxString>( "bom_format_preset_name",
&m_bomFmtPresetName,
m_bomFmtPresetName ) );
}

View File

@ -288,11 +288,12 @@ DIALOG_SYMBOL_FIELDS_TABLE::DIALOG_SYMBOL_FIELDS_TABLE( SCH_EDIT_FRAME* parent,
preset.fieldsOrdered.clear();
size_t i = 0;
for( wxString fieldName : m_job->m_fieldsOrdered )
for( const wxString& fieldName : m_job->m_fieldsOrdered )
{
BOM_FIELD field;
field.name = fieldName;
field.show = true;
field.show = !fieldName.StartsWith( wxT( "__" ), &field.name );
field.groupBy = std::find( m_job->m_fieldsGroupBy.begin(), m_job->m_fieldsGroupBy.end(),
field.name )
!= m_job->m_fieldsGroupBy.end();
@ -319,6 +320,7 @@ DIALOG_SYMBOL_FIELDS_TABLE::DIALOG_SYMBOL_FIELDS_TABLE( SCH_EDIT_FRAME* parent,
// Load BOM export format presets
SetUserBomFmtPresets( m_schSettings.m_BomFmtPresets );
BOM_FMT_PRESET fmtPreset = m_schSettings.m_BomFmtSettings;
if( m_job )
{
fmtPreset.name = m_job->m_bomFmtPresetName;
@ -329,6 +331,7 @@ DIALOG_SYMBOL_FIELDS_TABLE::DIALOG_SYMBOL_FIELDS_TABLE( SCH_EDIT_FRAME* parent,
fmtPreset.refRangeDelimiter = m_job->m_refRangeDelimiter;
fmtPreset.stringDelimiter = m_job->m_stringDelimiter;
}
ApplyBomFmtPreset( fmtPreset );
syncBomFmtPresetSelection();
@ -396,8 +399,6 @@ DIALOG_SYMBOL_FIELDS_TABLE::DIALOG_SYMBOL_FIELDS_TABLE( SCH_EDIT_FRAME* parent,
m_buttonExport->Hide();
SetupStandardButtons();
SetTitle( _( "BOM Export Job" ) );
}
}
@ -1455,13 +1456,14 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnOk( wxCommandEvent& aEvent )
for( const BOM_FIELD& modelField : m_dataModel->GetFieldsOrdered() )
{
if( modelField.show )
{
m_job->m_fieldsOrdered.emplace_back( modelField.name );
m_job->m_fieldsLabels.emplace_back( modelField.label );
else
m_job->m_fieldsOrdered.emplace_back( wxT( "__" ) + modelField.name );
if( modelField.groupBy )
m_job->m_fieldsGroupBy.emplace_back( modelField.name );
}
m_job->m_fieldsLabels.emplace_back( modelField.label );
if( modelField.groupBy )
m_job->m_fieldsGroupBy.emplace_back( modelField.name );
}
EndModal( wxID_OK );

View File

@ -551,20 +551,14 @@ void PANEL_JOBSET::buildOutputList()
bool PANEL_JOBSET::OpenJobOptionsForListItem( size_t aItemIndex )
{
JOBSET_JOB& job = m_jobsFile->GetJobs()[aItemIndex];
bool success = false;
JOBSET_JOB& job = m_jobsFile->GetJobs()[aItemIndex];
KIWAY::FACE_T iface = JOB_REGISTRY::GetKifaceType( job.m_type );
if( iface < KIWAY::KIWAY_FACE_COUNT )
{
EnsurePcbSchFramesOpen();
if( m_frame->Kiway().ProcessJobConfigDialog( iface, job.m_job.get(), m_frame ) )
{
m_jobsFile->SetDirty();
UpdateTitle();
return true;
}
success = m_frame->Kiway().ProcessJobConfigDialog( iface, job.m_job.get(), m_frame );
}
else
{
@ -576,11 +570,7 @@ bool PANEL_JOBSET::OpenJobOptionsForListItem( size_t aItemIndex )
DIALOG_EXECUTECOMMAND_JOB_SETTINGS dialog( m_frame, specialJob );
if( dialog.ShowModal() == wxID_OK )
{
m_jobsFile->SetDirty();
UpdateTitle();
return true;
}
success = true;
}
else if( job.m_job->GetType() == "special_copyfiles" )
{
@ -589,15 +579,20 @@ bool PANEL_JOBSET::OpenJobOptionsForListItem( size_t aItemIndex )
DIALOG_COPYFILES_JOB_SETTINGS dialog( m_frame, specialJob );
if( dialog.ShowModal() == wxID_OK )
{
m_jobsFile->SetDirty();
UpdateTitle();
return true;
}
success = true;
}
}
return false;
if( success )
{
m_jobsFile->SetDirty();
UpdateTitle();
}
// Bring the Kicad manager frame back to the front
m_frame->Raise();
return success;
}