Harmonize more APIs.

This commit is contained in:
Jeff Young 2024-04-06 10:16:06 +01:00
parent 968ca7c5c3
commit 494001ed4c
7 changed files with 7 additions and 13 deletions

View File

@ -79,7 +79,7 @@ public:
return aItem && aItem->Type() == LIB_FIELD_T; return aItem && aItem->Type() == LIB_FIELD_T;
} }
wxString GetTypeName() const override wxString GetFriendlyName() const override
{ {
return _( "Field" ); return _( "Field" );
} }

View File

@ -70,7 +70,7 @@ void LIB_ITEM::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_IT
{ {
wxString msg; wxString msg;
aList.emplace_back( _( "Type" ), GetTypeName() ); aList.emplace_back( _( "Type" ), GetFriendlyName() );
if( const SYMBOL* parent = GetParentSymbol() ) if( const SYMBOL* parent = GetParentSymbol() )
{ {

View File

@ -98,12 +98,6 @@ public:
ERC = 0x04 ERC = 0x04
}; };
/**
* Provide a user-consumable name of the object type. Perform localization when
* called so that run-time language selection works.
*/
virtual wxString GetTypeName() const = 0;
static inline bool ClassOf( const EDA_ITEM* aItem ) static inline bool ClassOf( const EDA_ITEM* aItem )
{ {
if( !aItem ) if( !aItem )

View File

@ -60,7 +60,7 @@ public:
return aItem && aItem->Type() == LIB_PIN_T; return aItem && aItem->Type() == LIB_PIN_T;
} }
wxString GetTypeName() const override wxString GetFriendlyName() const override
{ {
return _( "Pin" ); return _( "Pin" );
} }

View File

@ -49,7 +49,7 @@ public:
return aItem && aItem->Type() == LIB_SHAPE_T; return aItem && aItem->Type() == LIB_SHAPE_T;
} }
wxString GetTypeName() const override wxString GetFriendlyName() const override
{ {
return ShowShape(); return ShowShape();
} }

View File

@ -55,7 +55,7 @@ public:
return aItem && aItem->Type() == LIB_TEXT_T; return aItem && aItem->Type() == LIB_TEXT_T;
} }
wxString GetTypeName() const override wxString GetFriendlyName() const override
{ {
return _( "Text" ); return _( "Text" );
} }

View File

@ -92,7 +92,7 @@ protected:
HANDLER_RESULT<ResponseType>( HandlerType::* aHandler )( RequestType&, HANDLER_RESULT<ResponseType>( HandlerType::* aHandler )( RequestType&,
const HANDLER_CONTEXT& ) ) const HANDLER_CONTEXT& ) )
{ {
std::string typeName = RequestType().GetTypeName(); std::string typeName = RequestType().GetFriendlyName();
wxASSERT_MSG( !m_handlers.count( typeName ), wxASSERT_MSG( !m_handlers.count( typeName ),
wxString::Format( "Duplicate API handler for type %s", typeName ) ); wxString::Format( "Duplicate API handler for type %s", typeName ) );
@ -138,7 +138,7 @@ private:
if( !aRequest.message().UnpackTo( &aDest ) ) if( !aRequest.message().UnpackTo( &aDest ) )
{ {
std::string msg = fmt::format( "could not unpack message of type {} from request", std::string msg = fmt::format( "could not unpack message of type {} from request",
aDest.GetTypeName() ); aDest.GetFriendlyName() );
aReply.mutable_status()->set_status( ApiStatusCode::AS_BAD_REQUEST ); aReply.mutable_status()->set_status( ApiStatusCode::AS_BAD_REQUEST );
aReply.mutable_status()->set_error_message( msg ); aReply.mutable_status()->set_error_message( msg );
return false; return false;