Fix display of datasheet URLs and shorten them if necessary.

Fixes: lp:1676174
* https://bugs.launchpad.net/kicad/+bug/1676174
This commit is contained in:
Jeff Young 2018-02-15 20:15:37 +00:00 committed by Maciej Suminski
parent 908697c9c8
commit e7d98f89a1
3 changed files with 14 additions and 6 deletions

View File

@ -78,8 +78,7 @@ DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const
wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_LIVE_UPDATE | wxSP_3DSASH );
auto details = aShowFootprints ? nullptr : new wxHtmlWindow(
vsplitter, wxID_ANY, wxDefaultPosition, wxDefaultSize,
wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER );
vsplitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );
m_tree = new COMPONENT_TREE( m_splitter_tree_canvas, Prj().SchSymbolLibTable(),
aAdapter, COMPONENT_TREE::WIDGETS::ALL, details );
@ -156,7 +155,7 @@ wxPanel* DIALOG_CHOOSE_COMPONENT::ConstructRightPanel( wxWindow* aParent )
auto sizer = new wxBoxSizer( wxVERTICAL );
m_sch_view_ctrl = new wxPanel( panel, wxID_ANY, wxDefaultPosition, wxSize( -1, -1 ),
wxFULL_REPAINT_ON_RESIZE | wxSUNKEN_BORDER | wxTAB_TRAVERSAL );
wxFULL_REPAINT_ON_RESIZE | wxTAB_TRAVERSAL );
m_sch_view_ctrl->SetLayoutDirection( wxLayout_LeftToRight );
if( m_show_footprints )

View File

@ -42,7 +42,7 @@ static const wxString FieldFormat =
" <td><b>__NAME__</b></td>"
" <td>__VALUE__</td>"
"</tr>";
static const wxString DatasheetLinkFormat = "<a href=\"__VALUE__\">__VALUE__</a>";
static const wxString DatasheetLinkFormat = "<a href=\"__HREF__\">__TEXT__</a>";
class ALIAS_INFO_GENERATOR
@ -170,8 +170,17 @@ protected:
{
case DATASHEET:
{
if( text.IsEmpty() )
text = m_alias->GetDocFileName();
wxString datasheetlink = DatasheetLinkFormat;
datasheetlink.Replace( "__VALUE__", EscapedHTML( text ) );
datasheetlink.Replace( "__HREF__", EscapedHTML( text ) );
if( text.Length() > 75 )
text = text.Left( 72 ) + wxT( "..." );
datasheetlink.Replace( "__TEXT__", EscapedHTML( text ) );
fieldhtml.Replace( "__VALUE__", datasheetlink );
}
break;

View File

@ -86,7 +86,7 @@ COMPONENT_TREE::COMPONENT_TREE( wxWindow* aParent, SYMBOL_LIB_TABLE* aSymLibTabl
auto html_sz = ConvertDialogToPixels( wxPoint( 80, 80 ) );
m_details_ctrl = new wxHtmlWindow(
this, wxID_ANY, wxDefaultPosition, wxSize( html_sz.x, html_sz.y ),
wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER );
wxHW_SCROLLBAR_AUTO );
sizer->Add( m_details_ctrl, 1, wxALL | wxEXPAND, 5 );
}