mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 00:21:25 +00:00
More MANDATORY_FIELDS work.
Also fixes a crasher when Cancelling a FIELDS_GRID dialog with one of the grid editors currently open. Fixes https://gitlab.com/kicad/code/kicad/-/issues/19762
This commit is contained in:
parent
c9001cc187
commit
fccb661487
eeschema
@ -40,6 +40,8 @@ public:
|
||||
DIALOG_LABEL_PROPERTIES( SCH_EDIT_FRAME* parent, SCH_LABEL_BASE* aLabel );
|
||||
~DIALOG_LABEL_PROPERTIES();
|
||||
|
||||
FIELDS_GRID_TABLE* GetFieldsGridTable() { return m_fields; }
|
||||
|
||||
private:
|
||||
/**
|
||||
* wxEVT_COMMAND_ENTER event handler for single-line control.
|
||||
|
@ -1046,6 +1046,13 @@ bool FIELDS_GRID_TABLE::BoolFromString( const wxString& aValue ) const
|
||||
}
|
||||
|
||||
|
||||
void FIELDS_GRID_TABLE::DetachFields()
|
||||
{
|
||||
for( SCH_FIELD& field : *this )
|
||||
field.SetParent( nullptr );
|
||||
}
|
||||
|
||||
|
||||
void FIELDS_GRID_TRICKS::showPopupMenu( wxMenu& menu, wxGridEvent& aEvent )
|
||||
{
|
||||
if( m_grid->GetGridCursorRow() == FOOTPRINT_FIELD && m_grid->GetGridCursorCol() == FDC_VALUE
|
||||
|
@ -119,6 +119,8 @@ public:
|
||||
wxString StringFromBool( bool aValue ) const;
|
||||
bool BoolFromString( const wxString& aValue ) const;
|
||||
|
||||
void DetachFields();
|
||||
|
||||
protected:
|
||||
void initGrid( WX_GRID* aGrid );
|
||||
|
||||
|
@ -1507,18 +1507,28 @@ VECTOR2I SCH_FIELD::GetParentPosition() const
|
||||
|
||||
bool SCH_FIELD::IsMandatory() const
|
||||
{
|
||||
if( m_parent && m_parent->Type() == SCH_SHEET_T )
|
||||
if( !m_parent )
|
||||
return false;
|
||||
|
||||
switch( m_parent->Type() )
|
||||
{
|
||||
case SCH_SHEET_T:
|
||||
return m_id == SHEETNAME
|
||||
|| m_id == SHEETFILENAME;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
case SCH_SYMBOL_T:
|
||||
case LIB_SYMBOL_T:
|
||||
return m_id == REFERENCE_FIELD
|
||||
|| m_id == VALUE_FIELD
|
||||
|| m_id == FOOTPRINT_FIELD
|
||||
|| m_id == DATASHEET_FIELD
|
||||
|| m_id == DESCRIPTION_FIELD;
|
||||
|
||||
case SCH_GLOBAL_LABEL_T:
|
||||
return m_id == INTERSHEET_REFS;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1326,6 +1326,11 @@ void SCH_IO_KICAD_SEXPR::saveText( SCH_TEXT* aText )
|
||||
aText->EDA_TEXT::Format( m_out, 0 );
|
||||
KICAD_FORMAT::FormatUuid( m_out, aText->m_Uuid );
|
||||
|
||||
if( label && label->Type() == SCH_GLOBAL_LABEL_T )
|
||||
m_nextFreeFieldId = GLOBALLABEL_MANDATORY_FIELD_COUNT;
|
||||
else
|
||||
m_nextFreeFieldId = 0;
|
||||
|
||||
if( label )
|
||||
{
|
||||
for( SCH_FIELD& field : label->GetFields() )
|
||||
|
@ -1799,7 +1799,7 @@ SCH_GLOBALLABEL::SCH_GLOBALLABEL( const VECTOR2I& pos, const wxString& text ) :
|
||||
|
||||
SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
|
||||
|
||||
m_fields.emplace_back( SCH_FIELD( pos, 0, this, wxT( "Sheet References" ) ) );
|
||||
m_fields.emplace_back( SCH_FIELD( pos, INTERSHEET_REFS, this, wxT( "Sheet References" ) ) );
|
||||
m_fields[0].SetText( wxT( "${INTERSHEET_REFS}" ) );
|
||||
m_fields[0].SetVisible( false );
|
||||
m_fields[0].SetLayer( LAYER_INTERSHEET_REFS );
|
||||
|
@ -130,6 +130,17 @@ enum FLAG_SHAPE : unsigned int
|
||||
};
|
||||
|
||||
|
||||
enum GLOBALLABEL_FIELD_T
|
||||
{
|
||||
INTERSHEET_REFS = 0,
|
||||
|
||||
/// The first 2 are mandatory, and must be instantiated in SCH_SHEET
|
||||
GLOBALLABEL_MANDATORY_FIELD_COUNT
|
||||
};
|
||||
|
||||
#define GLOBALLABEL_MANDATORY_FIELDS { INTERSHEET_REFS }
|
||||
|
||||
|
||||
class SCH_LABEL_BASE : public SCH_TEXT
|
||||
{
|
||||
public:
|
||||
|
@ -1692,6 +1692,7 @@ SCH_TEXT* SCH_DRAWING_TOOLS::createNewText( const VECTOR2I& aPosition, int aType
|
||||
// QuasiModal required for syntax help and Scintilla auto-complete
|
||||
if( dlg.ShowQuasiModal() != wxID_OK )
|
||||
{
|
||||
dlg.GetFieldsGridTable()->DetachFields();
|
||||
delete labelItem;
|
||||
return nullptr;
|
||||
}
|
||||
@ -1735,6 +1736,7 @@ SCH_TEXT* SCH_DRAWING_TOOLS::createNewText( const VECTOR2I& aPosition, int aType
|
||||
return textItem;
|
||||
}
|
||||
|
||||
|
||||
SCH_SHEET_PIN* SCH_DRAWING_TOOLS::createNewSheetPin( SCH_SHEET* aSheet, const VECTOR2I& aPosition )
|
||||
{
|
||||
SCHEMATIC_SETTINGS& settings = aSheet->Schematic()->Settings();
|
||||
@ -1751,6 +1753,7 @@ SCH_SHEET_PIN* SCH_DRAWING_TOOLS::createNewSheetPin( SCH_SHEET* aSheet, const VE
|
||||
return pin;
|
||||
}
|
||||
|
||||
|
||||
SCH_SHEET_PIN* SCH_DRAWING_TOOLS::createNewSheetPinFromLabel( SCH_SHEET* aSheet,
|
||||
const VECTOR2I& aPosition,
|
||||
SCH_HIERLABEL* aLabel )
|
||||
|
Loading…
Reference in New Issue
Block a user