Add updating of visiblity, position, etc. to fields.
Fixes: lp:1752752 * https://bugs.launchpad.net/kicad/+bug/1752752 Fixes: lp:1643890 * https://bugs.launchpad.net/kicad/+bug/1643890 (cherry picked from commit 9f60005)
This commit is contained in:
parent
23189f8e1b
commit
99fb938b8f
|
@ -43,6 +43,7 @@ DIALOG_UPDATE_FIELDS::DIALOG_UPDATE_FIELDS( SCH_EDIT_FRAME* aParent,
|
|||
: DIALOG_UPDATE_FIELDS_BASE( aParent ), m_frame( aParent ),
|
||||
m_components( aComponents ), m_createUndo( aCreateUndoEntry )
|
||||
{
|
||||
m_sdbSizerOK->SetDefault();
|
||||
}
|
||||
|
||||
|
||||
|
@ -89,10 +90,10 @@ bool DIALOG_UPDATE_FIELDS::TransferDataFromWindow()
|
|||
|
||||
bool DIALOG_UPDATE_FIELDS::TransferDataToWindow()
|
||||
{
|
||||
if( !wxDialog::TransferDataToWindow() )
|
||||
if( !wxDialog::TransferDataToWindow() || !m_components.size() )
|
||||
return false;
|
||||
|
||||
// Collect all field names from library parts of components that are going to be updated
|
||||
// Collect all user field names from library parts of components that are going to be updated
|
||||
{
|
||||
for( auto component : m_components )
|
||||
{
|
||||
|
@ -106,7 +107,9 @@ bool DIALOG_UPDATE_FIELDS::TransferDataToWindow()
|
|||
for( auto it = drawItems.begin( LIB_FIELD_T ); it != drawItems.end( LIB_FIELD_T ); ++it )
|
||||
{
|
||||
const LIB_FIELD* field = static_cast<const LIB_FIELD*>( &( *it ) );
|
||||
m_fields.insert( field->GetName( false ) );
|
||||
|
||||
if( field->GetId() >= MANDATORY_FIELDS )
|
||||
m_fields.insert( field->GetName( false ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -114,12 +117,18 @@ bool DIALOG_UPDATE_FIELDS::TransferDataToWindow()
|
|||
// Update the listbox widget
|
||||
m_fieldsBox->Clear();
|
||||
|
||||
for( int i = 0; i < MANDATORY_FIELDS; ++i )
|
||||
{
|
||||
m_fieldsBox->Append( m_components.front()->GetField( i )->GetName( false ) );
|
||||
|
||||
if( i != REFERENCE && i != VALUE )
|
||||
m_fieldsBox->Check( i, true );
|
||||
}
|
||||
|
||||
for( const auto& field : m_fields )
|
||||
{
|
||||
int idx = m_fieldsBox->Append( field );
|
||||
|
||||
if( field != "Reference" && field != "Value" )
|
||||
m_fieldsBox->Check( idx, true );
|
||||
m_fieldsBox->Check( idx, true );
|
||||
}
|
||||
|
||||
// Now all widgets have the size fixed, call FinishDialogSettings
|
||||
|
@ -174,10 +183,30 @@ void DIALOG_UPDATE_FIELDS::updateFields( SCH_COMPONENT* aComponent )
|
|||
|
||||
// If the library field is empty an update would clear an existing entry.
|
||||
// Check if this is the desired behavior.
|
||||
auto newText = libField->GetText();
|
||||
if( !newText.empty() || !m_omitEmpty->IsChecked() )
|
||||
if( !libField->GetText().empty() || m_resetEmpty->IsChecked() )
|
||||
field->SetText( libField->GetText() );
|
||||
|
||||
if( m_resetVisibility->IsChecked() )
|
||||
field->SetVisible( libField->IsVisible() );
|
||||
|
||||
if( m_resetPosition->IsChecked() )
|
||||
{
|
||||
field->SetText( newText );
|
||||
field->SetTextAngle( libField->GetTextAngle() );
|
||||
|
||||
// Board fields are board-relative; symbol editor fields are component-relative
|
||||
if( m_createUndo )
|
||||
field->SetTextPos( libField->GetTextPos() + aComponent->GetPosition() );
|
||||
else
|
||||
field->SetTextPos( libField->GetTextPos() );
|
||||
}
|
||||
|
||||
if( m_resetSizeAndStyle->IsChecked() )
|
||||
{
|
||||
field->SetHorizJustify( libField->GetHorizJustify() );
|
||||
field->SetVertJustify( libField->GetVertJustify() );
|
||||
field->SetTextSize( libField->GetTextSize() );
|
||||
field->SetItalic( libField->IsItalic() );
|
||||
field->SetBold( libField->IsBold() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Feb 6 2018)
|
||||
// C++ code generated with wxFormBuilder (version Dec 30 2017)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -16,38 +16,63 @@ DIALOG_UPDATE_FIELDS_BASE::DIALOG_UPDATE_FIELDS_BASE( wxWindow* parent, wxWindow
|
|||
wxBoxSizer* m_mainSizer;
|
||||
m_mainSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_infoLabel = new wxStaticText( this, wxID_ANY, _("Select fields to update:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_infoLabel->Wrap( -1 );
|
||||
m_mainSizer->Add( m_infoLabel, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
wxBoxSizer* bUpperSizer;
|
||||
bUpperSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
wxStaticBoxSizer* sbSizer2;
|
||||
sbSizer2 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Fields to Update:") ), wxVERTICAL );
|
||||
|
||||
wxArrayString m_fieldsBoxChoices;
|
||||
m_fieldsBox = new wxCheckListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_fieldsBoxChoices, wxLB_NEEDED_SB );
|
||||
m_mainSizer->Add( m_fieldsBox, 1, wxALL|wxEXPAND, 5 );
|
||||
m_fieldsBox = new wxCheckListBox( sbSizer2->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_fieldsBoxChoices, wxLB_NEEDED_SB );
|
||||
m_fieldsBox->SetMinSize( wxSize( -1,150 ) );
|
||||
|
||||
sbSizer2->Add( m_fieldsBox, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
wxBoxSizer* m_selBtnSizer;
|
||||
m_selBtnSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_selAllBtn = new wxButton( this, wxID_ANY, _("Select All"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_selBtnSizer->Add( m_selAllBtn, 1, wxALL|wxEXPAND, 5 );
|
||||
m_selAllBtn = new wxButton( sbSizer2->GetStaticBox(), wxID_ANY, _("Select All"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_selBtnSizer->Add( m_selAllBtn, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_selNoneBtn = new wxButton( this, wxID_ANY, _("Select None"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_selBtnSizer->Add( m_selNoneBtn, 1, wxALL|wxEXPAND, 5 );
|
||||
m_selNoneBtn = new wxButton( sbSizer2->GetStaticBox(), wxID_ANY, _("Select None"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_selBtnSizer->Add( m_selNoneBtn, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
|
||||
m_mainSizer->Add( m_selBtnSizer, 0, wxEXPAND, 5 );
|
||||
sbSizer2->Add( m_selBtnSizer, 0, wxEXPAND, 5 );
|
||||
|
||||
m_removeExtraBox = new wxCheckBox( this, wxID_ANY, _("Remove extra fields"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
|
||||
bUpperSizer->Add( sbSizer2, 1, wxEXPAND|wxTOP|wxLEFT, 10 );
|
||||
|
||||
wxStaticBoxSizer* sbSizer1;
|
||||
sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options:") ), wxVERTICAL );
|
||||
|
||||
m_removeExtraBox = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Remove fields not in library"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_removeExtraBox->SetToolTip( _("Removes fields that do not occur in the original library symbols") );
|
||||
|
||||
m_mainSizer->Add( m_removeExtraBox, 0, wxALL, 5 );
|
||||
sbSizer1->Add( m_removeExtraBox, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_omitEmpty = new wxCheckBox( this, wxID_ANY, _("Omit empty fields"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_omitEmpty->SetToolTip( _("Do not clear existing entries if library field is empty") );
|
||||
m_resetEmpty = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Reset fields which are empty in library"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_resetEmpty->SetToolTip( _("Do not clear existing entries if library field is empty") );
|
||||
|
||||
m_mainSizer->Add( m_omitEmpty, 0, wxALL, 5 );
|
||||
sbSizer1->Add( m_resetEmpty, 0, wxALL, 5 );
|
||||
|
||||
m_staticline = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
|
||||
m_mainSizer->Add( m_staticline, 0, wxEXPAND | wxALL, 5 );
|
||||
|
||||
sbSizer1->Add( 0, 0, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 );
|
||||
|
||||
m_resetVisibility = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Reset field visibilities"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
sbSizer1->Add( m_resetVisibility, 0, wxALL, 5 );
|
||||
|
||||
m_resetSizeAndStyle = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Reset field text sizes and styles"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
sbSizer1->Add( m_resetSizeAndStyle, 0, wxALL, 5 );
|
||||
|
||||
m_resetPosition = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Reset field positions"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
sbSizer1->Add( m_resetPosition, 0, wxALL, 5 );
|
||||
|
||||
|
||||
bUpperSizer->Add( sbSizer1, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 );
|
||||
|
||||
|
||||
m_mainSizer->Add( bUpperSizer, 1, wxEXPAND, 5 );
|
||||
|
||||
m_sdbSizer = new wxStdDialogButtonSizer();
|
||||
m_sdbSizerOK = new wxButton( this, wxID_OK );
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Feb 6 2018)
|
||||
// C++ code generated with wxFormBuilder (version Dec 30 2017)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -13,16 +13,15 @@
|
|||
#include <wx/intl.h>
|
||||
#include "dialog_shim.h"
|
||||
#include <wx/string.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/checklst.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/font.h>
|
||||
#include <wx/colour.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/checklst.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/statbox.h>
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/statline.h>
|
||||
#include <wx/dialog.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -36,13 +35,14 @@ class DIALOG_UPDATE_FIELDS_BASE : public DIALOG_SHIM
|
|||
private:
|
||||
|
||||
protected:
|
||||
wxStaticText* m_infoLabel;
|
||||
wxCheckListBox* m_fieldsBox;
|
||||
wxButton* m_selAllBtn;
|
||||
wxButton* m_selNoneBtn;
|
||||
wxCheckBox* m_removeExtraBox;
|
||||
wxCheckBox* m_omitEmpty;
|
||||
wxStaticLine* m_staticline;
|
||||
wxCheckBox* m_resetEmpty;
|
||||
wxCheckBox* m_resetVisibility;
|
||||
wxCheckBox* m_resetSizeAndStyle;
|
||||
wxCheckBox* m_resetPosition;
|
||||
wxStdDialogButtonSizer* m_sdbSizer;
|
||||
wxButton* m_sdbSizerOK;
|
||||
wxButton* m_sdbSizerCancel;
|
||||
|
|
Loading…
Reference in New Issue