Allow text variables to reference parent sheet's fields.
Fixes https://gitlab.com/kicad/code/kicad/issues/2466
This commit is contained in:
parent
46602148dc
commit
55784afbfe
|
@ -373,6 +373,11 @@ void DIALOG_LABEL_EDITOR::onScintillaCharAdded( wxStyledTextEvent &aEvent )
|
||||||
|
|
||||||
m_CurrentText->GetContextualTextVars( &autocompleteTokens );
|
m_CurrentText->GetContextualTextVars( &autocompleteTokens );
|
||||||
|
|
||||||
|
SCHEMATIC* schematic = m_CurrentText->Schematic();
|
||||||
|
|
||||||
|
if( schematic && schematic->CurrentSheet().Last() )
|
||||||
|
schematic->CurrentSheet().Last()->GetContextualTextVars( &autocompleteTokens );
|
||||||
|
|
||||||
for( std::pair<wxString, wxString> entry : Prj().GetTextVars() )
|
for( std::pair<wxString, wxString> entry : Prj().GetTextVars() )
|
||||||
autocompleteTokens.push_back( entry.first );
|
autocompleteTokens.push_back( entry.first );
|
||||||
}
|
}
|
||||||
|
|
|
@ -363,8 +363,16 @@ void DIALOG_SCH_EDIT_ONE_FIELD::onScintillaCharAdded( wxStyledTextEvent &aEvent
|
||||||
SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( m_field->GetParent() );
|
SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( m_field->GetParent() );
|
||||||
|
|
||||||
if( comp )
|
if( comp )
|
||||||
|
{
|
||||||
comp->GetContextualTextVars( &autocompleteTokens );
|
comp->GetContextualTextVars( &autocompleteTokens );
|
||||||
else if( sheet )
|
|
||||||
|
SCHEMATIC* schematic = comp->Schematic();
|
||||||
|
|
||||||
|
if( schematic && schematic->CurrentSheet().Last() )
|
||||||
|
schematic->CurrentSheet().Last()->GetContextualTextVars( &autocompleteTokens );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( sheet )
|
||||||
sheet->GetContextualTextVars( &autocompleteTokens );
|
sheet->GetContextualTextVars( &autocompleteTokens );
|
||||||
|
|
||||||
for( std::pair<wxString, wxString> entry : Prj().GetTextVars() )
|
for( std::pair<wxString, wxString> entry : Prj().GetTextVars() )
|
||||||
|
|
|
@ -105,7 +105,17 @@ wxString SCH_FIELD::GetShownText( int aDepth ) const
|
||||||
[&]( wxString* token ) -> bool
|
[&]( wxString* token ) -> bool
|
||||||
{
|
{
|
||||||
SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( m_Parent );
|
SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( m_Parent );
|
||||||
return component->ResolveTextVar( token, aDepth + 1 );
|
|
||||||
|
if( component->ResolveTextVar( token, aDepth + 1 ) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
SCHEMATIC* schematic = component->Schematic();
|
||||||
|
SCH_SHEET* sheet = schematic ? schematic->CurrentSheet().Last() : nullptr;
|
||||||
|
|
||||||
|
if( sheet && sheet->ResolveTextVar( token, aDepth + 1 ) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::function<bool( wxString* )> sheetResolver =
|
std::function<bool( wxString* )> sheetResolver =
|
||||||
|
|
|
@ -191,7 +191,10 @@ bool SCH_SHEET::IsRootSheet() const
|
||||||
void SCH_SHEET::GetContextualTextVars( wxArrayString* aVars ) const
|
void SCH_SHEET::GetContextualTextVars( wxArrayString* aVars ) const
|
||||||
{
|
{
|
||||||
for( int i = 0; i < SHEET_MANDATORY_FIELDS; ++i )
|
for( int i = 0; i < SHEET_MANDATORY_FIELDS; ++i )
|
||||||
aVars->push_back( m_fields[i].GetCanonicalName() );
|
aVars->push_back( m_fields[i].GetCanonicalName().Upper() );
|
||||||
|
|
||||||
|
for( size_t i = SHEET_MANDATORY_FIELDS; i < m_fields.size(); ++i )
|
||||||
|
aVars->push_back( m_fields[i].GetName() );
|
||||||
|
|
||||||
aVars->push_back( wxT( "#" ) );
|
aVars->push_back( wxT( "#" ) );
|
||||||
aVars->push_back( wxT( "##" ) );
|
aVars->push_back( wxT( "##" ) );
|
||||||
|
|
|
@ -537,6 +537,14 @@ wxString SCH_TEXT::GetShownText( int aDepth ) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SCHEMATIC* schematic = Schematic();
|
||||||
|
SCH_SHEET* sheet = schematic ? schematic->CurrentSheet().Last() : nullptr;
|
||||||
|
|
||||||
|
if( sheet && sheet->ResolveTextVar( token, aDepth + 1 ) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue