diff --git a/common/properties/pg_properties.cpp b/common/properties/pg_properties.cpp index 1c2f223beb..b29b50e621 100644 --- a/common/properties/pg_properties.cpp +++ b/common/properties/pg_properties.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include // reg-ex describing a signed valid value with a unit @@ -141,7 +142,7 @@ wxPGProperty* PGPropertyFactory( const PROPERTY_BASE* aProperty ) } else if( typeId == TYPE_HASH( wxString ) ) { - ret = new wxStringProperty(); + ret = new PGPROPERTY_STRING(); } else { @@ -326,3 +327,20 @@ void PGPROPERTY_COLORENUM::OnCustomPaint( wxDC& aDC, const wxRect& aRect, aPaintData.m_drawnWidth = aRect.width; } + + +wxString PGPROPERTY_STRING::ValueToString( wxVariant& aValue, int aFlags ) const +{ + if( aValue.GetType() != wxPG_VARIANT_TYPE_STRING ) + return wxEmptyString; + + return UnescapeString( aValue.GetString() ); +} + + +bool PGPROPERTY_STRING::StringToValue( wxVariant& aVariant, const wxString& aString, + int aFlags ) const +{ + aVariant = EscapeString( aString, CTX_QUOTED_STR ); + return true; +} diff --git a/include/properties/pg_properties.h b/include/properties/pg_properties.h index faa704ec13..9854ec9852 100644 --- a/include/properties/pg_properties.h +++ b/include/properties/pg_properties.h @@ -146,4 +146,21 @@ protected: std::function m_colorFunc; }; + +class PGPROPERTY_STRING : public wxStringProperty +{ +public: + PGPROPERTY_STRING( const wxString& aLabel = wxPG_LABEL, const wxString& aName = wxPG_LABEL, + const wxString& aValue = wxEmptyString ) : + wxStringProperty( aLabel, aName, aValue ) + {} + + virtual ~PGPROPERTY_STRING() = default; + + wxString ValueToString( wxVariant& aValue, int aFlags = 0 ) const override; + + bool StringToValue( wxVariant& aVariant, const wxString& aString, + int aFlags = 0 ) const override; +}; + #endif /* PG_PROPERTIES_H */ diff --git a/pcbnew/dialogs/pcb_properties_panel.cpp b/pcbnew/dialogs/pcb_properties_panel.cpp index d5e524e2d6..10bade877f 100644 --- a/pcbnew/dialogs/pcb_properties_panel.cpp +++ b/pcbnew/dialogs/pcb_properties_panel.cpp @@ -32,6 +32,7 @@ #include #include #include +#include PCB_PROPERTIES_PANEL::PCB_PROPERTIES_PANEL( wxWindow* aParent, PCB_EDIT_FRAME* aFrame ) @@ -140,7 +141,7 @@ void PCB_PROPERTIES_PANEL::updateLists( const BOARD* aBoard ) // Regenerate nets for( const auto& netinfo : aBoard->GetNetInfo().NetsByNetcode() ) { - nets.Add( netinfo.second->GetNetname(), netinfo.first ); + nets.Add( UnescapeString( netinfo.second->GetNetname() ), netinfo.first ); } auto netProperty = m_propMgr.GetProperty( TYPE_HASH( BOARD_CONNECTED_ITEM ),