diff --git a/common/validators.cpp b/common/validators.cpp index 4cfa9d6d62..6c5fbb15e8 100644 --- a/common/validators.cpp +++ b/common/validators.cpp @@ -268,54 +268,6 @@ void REGEX_VALIDATOR::compileRegEx( const wxString& aRegEx, int aFlags ) } -bool LIB_ID_VALIDATOR::Validate( wxWindow *aParent ) -{ - LIB_ID dummy; - - // If window is disabled, simply return - if( !m_validatorWindow->IsEnabled() ) - return true; - - wxTextEntry* const text = GetTextEntry(); - - if( !text ) - return false; - - wxString msg; - wxString val( text->GetValue() ); - wxString tmp = val.Clone(); // For trailing and leading white space tests. - - // Allow empty string if empty filter not set to allow clearing the LIB_ID. - if( !(GetStyle() & wxFILTER_EMPTY) && val.IsEmpty() ) - return true; - - if( tmp.Trim() != val ) // Trailing white space. - { - msg = _( "Entry contains trailing white space." ); - } - else if( tmp.Trim( false ) != val ) // Leading white space. - { - msg = _( "Entry contains leading white space." ); - } - else if( dummy.Parse( val ) != -1 || !dummy.IsValid() ) // Is valid LIB_ID. - { - msg.Printf( _( "'%s' is not a valid library identifier format." ), val ); - } - - if( !msg.empty() ) - { - m_validatorWindow->SetFocus(); - - wxMessageBox( msg, _( "Library Identifier Validation Error" ), - wxOK | wxICON_EXCLAMATION, aParent ); - - return false; - } - - return true; -} - - NETNAME_VALIDATOR::NETNAME_VALIDATOR( wxString *aVal ) : wxTextValidator(), m_allowSpaces( false ) diff --git a/eeschema/fields_grid_table.cpp b/eeschema/fields_grid_table.cpp index e7d7ea64e8..9a049ebc2e 100644 --- a/eeschema/fields_grid_table.cpp +++ b/eeschema/fields_grid_table.cpp @@ -100,7 +100,6 @@ FIELDS_GRID_TABLE::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* a m_fieldNameValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_NAME ), m_referenceValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), REFERENCE_FIELD ), m_valueValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), VALUE_FIELD ), - m_libIdValidator(), m_urlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ), m_nonUrlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ), m_filepathValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETFILENAME ) @@ -122,7 +121,6 @@ FIELDS_GRID_TABLE::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_EDIT_FRAME* a m_fieldNameValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_NAME ), m_referenceValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), REFERENCE_FIELD ), m_valueValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), VALUE_FIELD ), - m_libIdValidator(), m_urlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ), m_nonUrlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ), m_filepathValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETFILENAME ) @@ -143,7 +141,6 @@ FIELDS_GRID_TABLE::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_EDIT_FRAME* a m_fieldNameValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_NAME ), m_referenceValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETNAME_V ), m_valueValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), VALUE_FIELD ), - m_libIdValidator(), m_urlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ), m_nonUrlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ), m_filepathValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), SHEETFILENAME_V ) @@ -164,7 +161,6 @@ FIELDS_GRID_TABLE::FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_EDIT_FRAME* a m_fieldNameValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_NAME ), m_referenceValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), 0 ), m_valueValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), 0 ), - m_libIdValidator(), m_urlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ), m_nonUrlValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), FIELD_VALUE ), m_filepathValidator( aFrame->IsType( FRAME_SCH_SYMBOL_EDITOR ), 0 ) @@ -200,7 +196,7 @@ void FIELDS_GRID_TABLE::initGrid( WX_GRID* aGrid ) m_footprintAttr = new wxGridCellAttr; GRID_CELL_FPID_EDITOR* fpIdEditor = new GRID_CELL_FPID_EDITOR( m_dialog, m_symbolNetlist ); - fpIdEditor->SetValidator( m_libIdValidator ); + fpIdEditor->SetValidator( m_nonUrlValidator ); m_footprintAttr->SetEditor( fpIdEditor ); m_urlAttr = new wxGridCellAttr; diff --git a/eeschema/fields_grid_table.h b/eeschema/fields_grid_table.h index d0429c0c20..c63bed16f9 100644 --- a/eeschema/fields_grid_table.h +++ b/eeschema/fields_grid_table.h @@ -128,7 +128,6 @@ private: SCH_FIELD_VALIDATOR m_fieldNameValidator; SCH_FIELD_VALIDATOR m_referenceValidator; SCH_FIELD_VALIDATOR m_valueValidator; - LIB_ID_VALIDATOR m_libIdValidator; SCH_FIELD_VALIDATOR m_urlValidator; SCH_FIELD_VALIDATOR m_nonUrlValidator; SCH_FIELD_VALIDATOR m_filepathValidator; diff --git a/include/validators.h b/include/validators.h index 4dcaa0c523..dffa9e8d21 100644 --- a/include/validators.h +++ b/include/validators.h @@ -170,34 +170,6 @@ protected: wxRegEx m_regEx; }; -/** - * Custom validator that verifies that a string defines a valid #LIB_ID. - * - * The default validation allows empty #LIB_ID strings to allow the #LIB_ID to be cleared. - * Use SetStyle( wxFILTER_EMPTY ) to force a valid #LIB_ID string. - */ -class LIB_ID_VALIDATOR : public wxTextValidator -{ -public: - /** - * @param aLibIdType is the type of #LIB_ID object to validate. - * @param aValue is a pointer to a wxString containing the value to validate. - */ - LIB_ID_VALIDATOR( wxString* aValue = nullptr ) : - wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue ) - { - SetCharExcludes( wxT( "\r\n\t" ) ); - } - - virtual wxObject* Clone() const override - { - return new LIB_ID_VALIDATOR( *this ); - } - - bool Validate( wxWindow* aParent ) override; -}; - - class NETNAME_VALIDATOR : public wxTextValidator { public: