Allow TemplateFieldNames to specify URL-behaviour.
Fixes: lp:1785879 * https://bugs.launchpad.net/kicad/+bug/1785879
This commit is contained in:
parent
d2eb9e0735
commit
e932eed738
|
@ -140,7 +140,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( SCH_EDIT
|
|||
|
||||
m_cmp = aComponent;
|
||||
m_part = GetParent()->GetLibPart( m_cmp->GetLibId(), true );
|
||||
m_fields = new FIELDS_GRID_TABLE<SCH_FIELD>( this, false, m_part );
|
||||
m_fields = new FIELDS_GRID_TABLE<SCH_FIELD>( this, aParent, m_part );
|
||||
|
||||
m_delayedFocusRow = REFERENCE;
|
||||
m_delayedFocusColumn = FDC_VALUE;
|
||||
|
|
|
@ -123,7 +123,7 @@ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB( LIB_EDIT
|
|||
|
||||
m_parent = aParent;
|
||||
m_libEntry = aLibEntry;
|
||||
m_fields = new FIELDS_GRID_TABLE<LIB_FIELD>( this, true, m_libEntry );
|
||||
m_fields = new FIELDS_GRID_TABLE<LIB_FIELD>( this, aParent, m_libEntry );
|
||||
|
||||
m_delayedFocusRow = REFERENCE;
|
||||
m_delayedFocusColumn = FDC_VALUE;
|
||||
|
|
|
@ -105,14 +105,19 @@ bool PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::TransferDataToGrid()
|
|||
{
|
||||
m_grid->SetCellValue( row, 0, m_fields[row].m_Name );
|
||||
m_grid->SetCellValue( row, 1, m_fields[row].m_Visible ? wxT( "1" ) : wxEmptyString );
|
||||
m_grid->SetCellValue( row, 2, m_fields[row].m_URL ? wxT( "1" ) : wxEmptyString );
|
||||
|
||||
// Set cell properties
|
||||
m_grid->SetCellAlignment( row, 0, wxALIGN_LEFT, wxALIGN_CENTRE );
|
||||
|
||||
// Render the Visible column as a check box
|
||||
// Render the Visible and URL columns as check boxes
|
||||
m_grid->SetCellRenderer( row, 1, new wxGridCellBoolRenderer() );
|
||||
m_grid->SetReadOnly( row, 1 ); // Not really; we delegate interactivity to GRID_TRICKS
|
||||
m_grid->SetCellAlignment( row, 1, wxALIGN_CENTRE, wxALIGN_CENTRE );
|
||||
|
||||
m_grid->SetCellRenderer( row, 2, new wxGridCellBoolRenderer() );
|
||||
m_grid->SetReadOnly( row, 2 ); // Not really; we delegate interactivity to GRID_TRICKS
|
||||
m_grid->SetCellAlignment( row, 2, wxALIGN_CENTRE, wxALIGN_CENTRE );
|
||||
}
|
||||
|
||||
m_grid->Thaw();
|
||||
|
@ -130,6 +135,7 @@ bool PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::TransferDataFromGrid()
|
|||
{
|
||||
m_fields[row].m_Name = m_grid->GetCellValue( row, 0 );
|
||||
m_fields[row].m_Visible = ( m_grid->GetCellValue( row, 1 ) != wxEmptyString );
|
||||
m_fields[row].m_URL = ( m_grid->GetCellValue( row, 2 ) != wxEmptyString );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -158,8 +164,9 @@ void PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::AdjustGridColumns( int aWidth )
|
|||
// Account for scroll bars
|
||||
aWidth -= ( m_grid->GetSize().x - m_grid->GetClientSize().x );
|
||||
|
||||
m_grid->SetColSize( 0, aWidth - m_checkboxColWidth );
|
||||
m_grid->SetColSize( 0, aWidth - 2 * m_checkboxColWidth );
|
||||
m_grid->SetColSize( 1, m_checkboxColWidth );
|
||||
m_grid->SetColSize( 2, m_checkboxColWidth );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Aug 2 2018)
|
||||
// C++ code generated with wxFormBuilder (version Dec 30 2017)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -22,7 +22,7 @@ PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE::PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE
|
|||
m_grid = new WX_GRID( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE );
|
||||
|
||||
// Grid
|
||||
m_grid->CreateGrid( 0, 2 );
|
||||
m_grid->CreateGrid( 0, 3 );
|
||||
m_grid->EnableEditing( true );
|
||||
m_grid->EnableGridLines( true );
|
||||
m_grid->EnableDragGridSize( false );
|
||||
|
@ -31,11 +31,13 @@ PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE::PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE
|
|||
// Columns
|
||||
m_grid->SetColSize( 0, 300 );
|
||||
m_grid->SetColSize( 1, 60 );
|
||||
m_grid->SetColSize( 2, 60 );
|
||||
m_grid->EnableDragColMove( false );
|
||||
m_grid->EnableDragColSize( true );
|
||||
m_grid->SetColLabelSize( 22 );
|
||||
m_grid->SetColLabelValue( 0, _("Name") );
|
||||
m_grid->SetColLabelValue( 1, _("Visible") );
|
||||
m_grid->SetColLabelValue( 2, _("URL") );
|
||||
m_grid->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
|
||||
|
||||
// Rows
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<wxFormBuilder_Project>
|
||||
<FileVersion major="1" minor="14" />
|
||||
<FileVersion major="1" minor="13" />
|
||||
<object class="Project" expanded="1">
|
||||
<property name="class_decoration"></property>
|
||||
<property name="code_generation">C++</property>
|
||||
|
@ -14,7 +14,6 @@
|
|||
<property name="file">panel_eeschema_template_fieldnames_base</property>
|
||||
<property name="first_id">1000</property>
|
||||
<property name="help_provider">none</property>
|
||||
<property name="indent_with_spaces"></property>
|
||||
<property name="internationalize">1</property>
|
||||
<property name="name">PanelEeschemaTemplateFieldnames</property>
|
||||
<property name="namespace"></property>
|
||||
|
@ -49,20 +48,13 @@
|
|||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style">wxTAB_TRAVERSAL</property>
|
||||
<event name="OnAuiPaneActivated"></event>
|
||||
<event name="OnAuiFindManager"></event>
|
||||
<event name="OnAuiPaneButton"></event>
|
||||
<event name="OnAuiPaneClose"></event>
|
||||
<event name="OnAuiPaneMaximize"></event>
|
||||
<event name="OnAuiPaneRestore"></event>
|
||||
<event name="OnAuiRender"></event>
|
||||
<event name="OnAux1DClick"></event>
|
||||
<event name="OnAux1Down"></event>
|
||||
<event name="OnAux1Up"></event>
|
||||
<event name="OnAux2DClick"></event>
|
||||
<event name="OnAux2Down"></event>
|
||||
<event name="OnAux2Up"></event>
|
||||
<event name="OnChar"></event>
|
||||
<event name="OnCharHook"></event>
|
||||
<event name="OnEnterWindow"></event>
|
||||
<event name="OnEraseBackground"></event>
|
||||
<event name="OnInitDialog"></event>
|
||||
|
@ -128,10 +120,10 @@
|
|||
<property name="close_button">1</property>
|
||||
<property name="col_label_horiz_alignment">wxALIGN_CENTRE</property>
|
||||
<property name="col_label_size">22</property>
|
||||
<property name="col_label_values">"Name" "Visible"</property>
|
||||
<property name="col_label_values">"Name" "Visible" "URL"</property>
|
||||
<property name="col_label_vert_alignment">wxALIGN_CENTRE</property>
|
||||
<property name="cols">2</property>
|
||||
<property name="column_sizes">300,60</property>
|
||||
<property name="cols">3</property>
|
||||
<property name="column_sizes">300,60,60</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="default_pane">0</property>
|
||||
|
@ -186,14 +178,7 @@
|
|||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style">wxBORDER_SIMPLE</property>
|
||||
<event name="OnAux1DClick"></event>
|
||||
<event name="OnAux1Down"></event>
|
||||
<event name="OnAux1Up"></event>
|
||||
<event name="OnAux2DClick"></event>
|
||||
<event name="OnAux2Down"></event>
|
||||
<event name="OnAux2Up"></event>
|
||||
<event name="OnChar"></event>
|
||||
<event name="OnCharHook"></event>
|
||||
<event name="OnEnterWindow"></event>
|
||||
<event name="OnEraseBackground"></event>
|
||||
<event name="OnGridCellChange"></event>
|
||||
|
@ -281,7 +266,6 @@
|
|||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="current"></property>
|
||||
<property name="default">0</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="disabled"></property>
|
||||
|
@ -295,10 +279,9 @@
|
|||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="hover"></property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Add Field</property>
|
||||
<property name="margins"></property>
|
||||
<property name="markup">0</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
|
@ -313,9 +296,8 @@
|
|||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="position"></property>
|
||||
<property name="pressed"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="selected"></property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
|
@ -329,15 +311,8 @@
|
|||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<event name="OnAux1DClick"></event>
|
||||
<event name="OnAux1Down"></event>
|
||||
<event name="OnAux1Up"></event>
|
||||
<event name="OnAux2DClick"></event>
|
||||
<event name="OnAux2Down"></event>
|
||||
<event name="OnAux2Up"></event>
|
||||
<event name="OnButtonClick">OnAddButtonClick</event>
|
||||
<event name="OnChar"></event>
|
||||
<event name="OnCharHook"></event>
|
||||
<event name="OnEnterWindow"></event>
|
||||
<event name="OnEraseBackground"></event>
|
||||
<event name="OnKeyDown"></event>
|
||||
|
@ -384,7 +359,6 @@
|
|||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="current"></property>
|
||||
<property name="default">0</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="disabled"></property>
|
||||
|
@ -398,10 +372,9 @@
|
|||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="hover"></property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Delete Field</property>
|
||||
<property name="margins"></property>
|
||||
<property name="markup">0</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
|
@ -416,9 +389,8 @@
|
|||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="position"></property>
|
||||
<property name="pressed"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="selected"></property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
|
@ -432,15 +404,8 @@
|
|||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<event name="OnAux1DClick"></event>
|
||||
<event name="OnAux1Down"></event>
|
||||
<event name="OnAux1Up"></event>
|
||||
<event name="OnAux2DClick"></event>
|
||||
<event name="OnAux2Down"></event>
|
||||
<event name="OnAux2Up"></event>
|
||||
<event name="OnButtonClick">OnDeleteButtonClick</event>
|
||||
<event name="OnChar"></event>
|
||||
<event name="OnCharHook"></event>
|
||||
<event name="OnEnterWindow"></event>
|
||||
<event name="OnEraseBackground"></event>
|
||||
<event name="OnKeyDown"></event>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Aug 2 2018)
|
||||
// C++ code generated with wxFormBuilder (version Dec 30 2017)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -19,10 +19,10 @@ class WX_GRID;
|
|||
#include <wx/font.h>
|
||||
#include <wx/grid.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/bmpbuttn.h>
|
||||
#include <wx/bitmap.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/icon.h>
|
||||
#include <wx/bmpbuttn.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/panel.h>
|
||||
|
|
|
@ -479,13 +479,12 @@ void SCH_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
|
|||
|
||||
try
|
||||
{
|
||||
m_TemplateFieldNames.Parse( &lexer );
|
||||
m_templateFieldNames.Parse( &lexer );
|
||||
}
|
||||
catch( const IO_ERROR& DBG( e ) )
|
||||
{
|
||||
// @todo show error msg
|
||||
DBG( printf( "templatefieldnames parsing error: '%s'\n",
|
||||
TO_UTF8( e.What() ) ); )
|
||||
DBG( printf( "templatefieldnames parsing error: '%s'\n", TO_UTF8( e.What() ) ); )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -552,7 +551,7 @@ void SCH_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg )
|
|||
|
||||
// Save template fieldnames
|
||||
STRING_FORMATTER sf;
|
||||
m_TemplateFieldNames.Format( &sf, 0 );
|
||||
m_templateFieldNames.Format( &sf, 0 );
|
||||
|
||||
wxString record = FROM_UTF8( sf.GetString().c_str() );
|
||||
record.Replace( wxT("\n"), wxT(""), true ); // strip all newlines
|
||||
|
@ -582,6 +581,23 @@ void LIB_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
|
|||
step.y = aCfg->Read( repeatLibStepYEntry, (long)DEFAULT_REPEAT_OFFSET_Y );
|
||||
SetRepeatStep( step );
|
||||
m_showPinElectricalTypeName = aCfg->Read( showPinElectricalType, true );
|
||||
|
||||
wxString templateFieldNames = aCfg->Read( FieldNamesEntry, wxEmptyString );
|
||||
|
||||
if( !templateFieldNames.IsEmpty() )
|
||||
{
|
||||
TEMPLATE_FIELDNAMES_LEXER lexer( TO_UTF8( templateFieldNames ) );
|
||||
|
||||
try
|
||||
{
|
||||
m_templateFieldNames.Parse( &lexer );
|
||||
}
|
||||
catch( const IO_ERROR& DBG( e ) )
|
||||
{
|
||||
// @todo show error msg
|
||||
DBG( printf( "templatefieldnames parsing error: '%s'\n", TO_UTF8( e.What() ) ); )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <kiway_player.h>
|
||||
#include <dialog_shim.h>
|
||||
#include <fields_grid_table.h>
|
||||
#include <sch_base_frame.h>
|
||||
#include <sch_field.h>
|
||||
#include <sch_validators.h>
|
||||
#include <validators.h>
|
||||
|
@ -32,7 +33,6 @@
|
|||
#include <template_fieldnames.h>
|
||||
#include <widgets/grid_icon_text_helpers.h>
|
||||
#include <widgets/grid_text_button_helpers.h>
|
||||
#include <wx/regex.h>
|
||||
|
||||
#include "eda_doc.h"
|
||||
|
||||
|
@ -45,12 +45,13 @@ enum
|
|||
|
||||
|
||||
template <class T>
|
||||
FIELDS_GRID_TABLE<T>::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, bool aInLibEdit, LIB_PART* aPart ) :
|
||||
FIELDS_GRID_TABLE<T>::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame,
|
||||
LIB_PART* aPart ) :
|
||||
m_frame( aFrame ),
|
||||
m_userUnits( aDialog->GetUserUnits() ),
|
||||
m_part( aPart ),
|
||||
m_inLibEdit( aInLibEdit ),
|
||||
m_fieldNameValidator( aInLibEdit, FIELD_NAME ),
|
||||
m_referenceValidator( aInLibEdit, REFERENCE )
|
||||
m_fieldNameValidator( aFrame->IsType( FRAME_SCH_LIB_EDITOR ), FIELD_NAME ),
|
||||
m_referenceValidator( aFrame->IsType( FRAME_SCH_LIB_EDITOR ), REFERENCE )
|
||||
{
|
||||
// Build the various grid cell attributes.
|
||||
|
||||
|
@ -176,8 +177,6 @@ bool FIELDS_GRID_TABLE<T>::CanSetValueAs( int aRow, int aCol, const wxString& aT
|
|||
template <class T>
|
||||
wxGridCellAttr* FIELDS_GRID_TABLE<T>::GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind )
|
||||
{
|
||||
static wxRegEx urlPrefix( wxT( "((https?)|(file)):\/\/" ) );
|
||||
|
||||
switch( aCol )
|
||||
{
|
||||
case FDC_NAME:
|
||||
|
@ -200,7 +199,7 @@ wxGridCellAttr* FIELDS_GRID_TABLE<T>::GetAttr( int aRow, int aCol, wxGridCellAtt
|
|||
}
|
||||
else if( aRow == VALUE )
|
||||
{
|
||||
if( m_inLibEdit )
|
||||
if( m_frame->IsType( FRAME_SCH_LIB_EDITOR ) )
|
||||
{
|
||||
// This field is the lib name and the default value when loading this component
|
||||
// in schematic. The value is now not editable here (in this dialog) because
|
||||
|
@ -227,11 +226,16 @@ wxGridCellAttr* FIELDS_GRID_TABLE<T>::GetAttr( int aRow, int aCol, wxGridCellAtt
|
|||
m_urlAttr->IncRef();
|
||||
return m_urlAttr;
|
||||
}
|
||||
else if( urlPrefix.Matches( GetValue( aRow, aCol ) ) )
|
||||
else
|
||||
{
|
||||
// Treat any user-defined field that starts with http:// or https:// as a URL
|
||||
m_urlAttr->IncRef();
|
||||
return m_urlAttr;
|
||||
wxString fieldname = GetValue( aRow, FDC_NAME );
|
||||
const TEMPLATE_FIELDNAME* templateFn = m_frame->GetTemplateFieldName( fieldname );
|
||||
|
||||
if( templateFn && templateFn->m_URL )
|
||||
{
|
||||
m_urlAttr->IncRef();
|
||||
return m_urlAttr;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
|
|
|
@ -30,6 +30,10 @@
|
|||
#include <sch_component.h>
|
||||
#include <grid_tricks.h>
|
||||
|
||||
class SCH_BASE_FRAME;
|
||||
class DIALOG_SHIM;
|
||||
|
||||
|
||||
class FIELDS_GRID_TRICKS : public GRID_TRICKS
|
||||
{
|
||||
public:
|
||||
|
@ -67,7 +71,7 @@ template <class T>
|
|||
class FIELDS_GRID_TABLE : public wxGridTableBase, public std::vector<T>
|
||||
{
|
||||
public:
|
||||
FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, bool aInLibEdit, LIB_PART* aPart );
|
||||
FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame, LIB_PART* aPart );
|
||||
~FIELDS_GRID_TABLE();
|
||||
|
||||
int GetNumberRows() override { return (int) this->size(); }
|
||||
|
@ -91,10 +95,10 @@ public:
|
|||
void SetValueAsBool( int aRow, int aCol, bool aValue ) override;
|
||||
|
||||
private:
|
||||
SCH_BASE_FRAME* m_frame;
|
||||
EDA_UNITS_T m_userUnits;
|
||||
LIB_PART* m_part;
|
||||
|
||||
bool m_inLibEdit;
|
||||
SCH_FIELD_VALIDATOR m_fieldNameValidator;
|
||||
SCH_FIELD_VALIDATOR m_referenceValidator;
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <draw_frame.h>
|
||||
|
||||
#include <sch_screen.h>
|
||||
#include "template_fieldnames.h"
|
||||
|
||||
class PAGE_INFO;
|
||||
class TITLE_BLOCK;
|
||||
|
@ -77,10 +78,12 @@ LIB_PART* SchGetLibPart( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable,
|
|||
class SCH_BASE_FRAME : public EDA_DRAW_FRAME
|
||||
{
|
||||
protected:
|
||||
wxPoint m_repeatStep; ///< the increment value of the position of an item
|
||||
///< when it is repeated
|
||||
int m_repeatDeltaLabel; ///< the increment value of labels like bus members
|
||||
///< when they are repeated
|
||||
TEMPLATES m_templateFieldNames;
|
||||
|
||||
wxPoint m_repeatStep; ///< the increment value of the position of an item
|
||||
///< when it is repeated
|
||||
int m_repeatDeltaLabel; ///< the increment value of labels like bus members
|
||||
///< when they are repeated
|
||||
|
||||
|
||||
public:
|
||||
|
@ -206,6 +209,25 @@ public:
|
|||
|
||||
void OnConfigurePaths( wxCommandEvent& aEvent );
|
||||
|
||||
/**
|
||||
* Return a template field names list for read only access.
|
||||
*/
|
||||
const TEMPLATE_FIELDNAMES& GetTemplateFieldNames() const
|
||||
{
|
||||
return m_templateFieldNames.GetTemplateFieldNames();
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for \a aName in the the template field name list.
|
||||
*
|
||||
* @param aName A wxString object containing the field name to search for.
|
||||
* @return the template fieldname if found; NULL otherwise.
|
||||
*/
|
||||
const TEMPLATE_FIELDNAME* GetTemplateFieldName( const wxString& aName ) const
|
||||
{
|
||||
return m_templateFieldNames.GetFieldName( aName );
|
||||
}
|
||||
|
||||
virtual void OnEditSymbolLibTable( wxCommandEvent& aEvent );
|
||||
|
||||
/**
|
||||
|
|
|
@ -181,8 +181,6 @@ private:
|
|||
static wxPoint m_lastSheetPinPosition; ///< Last sheet pin position.
|
||||
|
||||
protected:
|
||||
TEMPLATES m_TemplateFieldNames;
|
||||
|
||||
/**
|
||||
* Initializing accessor for the pin text size
|
||||
*/
|
||||
|
@ -313,25 +311,7 @@ public:
|
|||
*/
|
||||
int AddTemplateFieldName( const TEMPLATE_FIELDNAME& aFieldName )
|
||||
{
|
||||
return m_TemplateFieldNames.AddTemplateFieldName( aFieldName );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a template field names list for read only access.
|
||||
*/
|
||||
const TEMPLATE_FIELDNAMES& GetTemplateFieldNames()
|
||||
{
|
||||
return m_TemplateFieldNames.GetTemplateFieldNames();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the field names template for read only access.
|
||||
*/
|
||||
const TEMPLATES& GetTemplates()
|
||||
{
|
||||
return m_TemplateFieldNames;
|
||||
return m_templateFieldNames.AddTemplateFieldName( aFieldName );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -339,7 +319,7 @@ public:
|
|||
*/
|
||||
void DeleteAllTemplateFieldNames()
|
||||
{
|
||||
m_TemplateFieldNames.DeleteAllTemplateFieldNames();
|
||||
m_templateFieldNames.DeleteAllTemplateFieldNames();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -82,12 +82,12 @@ void TEMPLATE_FIELDNAME::Format( OUTPUTFORMATTER* out, int nestLevel ) const
|
|||
{
|
||||
out->Print( nestLevel, "(field (name %s)", out->Quotew( m_Name ).c_str() );
|
||||
|
||||
if( !m_Value.IsEmpty() )
|
||||
out->Print( 0, "(value %s)", out->Quotew( m_Value ).c_str() );
|
||||
|
||||
if( m_Visible )
|
||||
out->Print( 0, " visible" );
|
||||
|
||||
if( m_URL )
|
||||
out->Print( 0, " url" );
|
||||
|
||||
out->Print( 0, ")\n" );
|
||||
}
|
||||
|
||||
|
@ -116,8 +116,8 @@ void TEMPLATE_FIELDNAME::Parse( TEMPLATE_FIELDNAMES_LEXER* in )
|
|||
switch( tok )
|
||||
{
|
||||
case T_value:
|
||||
// older format; silently skip
|
||||
in->NeedSYMBOLorNUMBER();
|
||||
m_Value = FROM_UTF8( in->CurText() );
|
||||
in->NeedRIGHT();
|
||||
break;
|
||||
|
||||
|
@ -125,8 +125,12 @@ void TEMPLATE_FIELDNAME::Parse( TEMPLATE_FIELDNAMES_LEXER* in )
|
|||
m_Visible = true;
|
||||
break;
|
||||
|
||||
case T_url:
|
||||
m_URL = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
in->Expecting( "value|visible" );
|
||||
in->Expecting( "value|url|visible" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -219,14 +223,14 @@ int TEMPLATES::AddTemplateFieldName( const TEMPLATE_FIELDNAME& aFieldName )
|
|||
}
|
||||
|
||||
|
||||
bool TEMPLATES::HasFieldName( const wxString& aName ) const
|
||||
const TEMPLATE_FIELDNAME* TEMPLATES::GetFieldName( const wxString& aName ) const
|
||||
{
|
||||
for( size_t i=0; i<m_Fields.size(); ++i )
|
||||
for( const TEMPLATE_FIELDNAME& field : m_Fields )
|
||||
{
|
||||
if( m_Fields[i].m_Name == aName )
|
||||
return true;
|
||||
if( field.m_Name == aName )
|
||||
return &field;
|
||||
}
|
||||
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,25 +71,27 @@ enum NumFieldType {
|
|||
struct TEMPLATE_FIELDNAME
|
||||
{
|
||||
wxString m_Name; ///< The field name
|
||||
wxString m_Value; ///< The default value or empty
|
||||
bool m_Visible; ///< If first appearance of the field's editor has as visible.
|
||||
bool m_URL; ///< If field should have a browse button
|
||||
|
||||
TEMPLATE_FIELDNAME() :
|
||||
m_Visible( false )
|
||||
m_Visible( false ),
|
||||
m_URL( false )
|
||||
{
|
||||
}
|
||||
|
||||
TEMPLATE_FIELDNAME( const wxString& aName ) :
|
||||
m_Name( aName ),
|
||||
m_Visible( false )
|
||||
m_Visible( false ),
|
||||
m_URL( false )
|
||||
{
|
||||
}
|
||||
|
||||
TEMPLATE_FIELDNAME( const TEMPLATE_FIELDNAME& ref )
|
||||
{
|
||||
m_Name = ref.m_Name;
|
||||
m_Value = ref.m_Value;
|
||||
m_Visible = ref.m_Visible;
|
||||
m_URL = ref.m_URL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -171,19 +173,19 @@ public:
|
|||
* Function GetTemplateFieldName
|
||||
* returns a template fieldnames list for read only access.
|
||||
*/
|
||||
const TEMPLATE_FIELDNAMES& GetTemplateFieldNames()
|
||||
const TEMPLATE_FIELDNAMES& GetTemplateFieldNames() const
|
||||
{
|
||||
return m_Fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function HasFieldName
|
||||
* checks for \a aName in the the template field name list.
|
||||
* Function GetFieldName
|
||||
* searches for \a aName in the the template field name list.
|
||||
*
|
||||
* @param aName A wxString object containing the field name to search for.
|
||||
* @return True if \a aName is found in the list.
|
||||
* @return the template fieldname if found; NULL otherwise.
|
||||
*/
|
||||
bool HasFieldName( const wxString& aName ) const;
|
||||
const TEMPLATE_FIELDNAME* GetFieldName( const wxString& aName ) const;
|
||||
};
|
||||
|
||||
#endif // _TEMPLATE_FIELDNAME_H_
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
field
|
||||
name
|
||||
templatefields
|
||||
url
|
||||
value
|
||||
visible
|
||||
|
|
Loading…
Reference in New Issue