Footprint library nickname comparison fixes.
Footprint library nicknames are case sensitive but the comparison for
the library tree control was case insensitive.
Also make the footprint name comparisons case sensitive as well. While
not strictly necessary, the plan is to start using the name defined in
the footprint file instead of the file name which will allow for case
sensitivity.
Fixes lp:1833701
https://bugs.launchpad.net/kicad/+bug/1833701
(cherry picked from commit d8fff5c820
)
This commit is contained in:
parent
6d60b98dc8
commit
15e6bcc86b
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2011 Jean-Pierre Charras, <jp.charras@wanadoo.fr>
|
||||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -167,12 +167,16 @@ protected:
|
|||
/// FOOTPRINT object list sort function.
|
||||
inline bool operator<( const FOOTPRINT_INFO& item1, const FOOTPRINT_INFO& item2 )
|
||||
{
|
||||
int retv = StrNumCmp( item1.m_nickname, item2.m_nickname, true );
|
||||
int retv = StrNumCmp( item1.m_nickname, item2.m_nickname, false );
|
||||
|
||||
if( retv != 0 )
|
||||
return retv < 0;
|
||||
|
||||
return StrNumCmp( item1.m_fpname, item2.m_fpname, true ) < 0;
|
||||
// Technically footprint names are not case sensitive because the file name is used
|
||||
// as the footprint name. On windows this would be problematic because windows does
|
||||
// not support case sensitive file names by default. This should not cause any issues
|
||||
// and allow for a future change to use the name defined in the footprint file.
|
||||
return StrNumCmp( item1.m_fpname, item2.m_fpname, false ) < 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -288,7 +288,7 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList()
|
|||
m_libList->Append( nicknames[ii] );
|
||||
|
||||
// Search for a previous selection:
|
||||
int index = m_libList->FindString( getCurNickname() );
|
||||
int index = m_libList->FindString( getCurNickname(), true );
|
||||
|
||||
if( index != wxNOT_FOUND )
|
||||
{
|
||||
|
@ -339,7 +339,7 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList()
|
|||
m_footprintList->Append( footprint->GetFootprintName() );
|
||||
}
|
||||
|
||||
int index = m_footprintList->FindString( getCurFootprintName() );
|
||||
int index = m_footprintList->FindString( getCurFootprintName(), true );
|
||||
|
||||
if( index == wxNOT_FOUND )
|
||||
setCurFootprintName( wxEmptyString );
|
||||
|
@ -491,7 +491,8 @@ void FOOTPRINT_VIEWER_FRAME::LoadSettings( wxConfigBase* aCfg )
|
|||
if( aCfg->Read( footprintEditor + ShowGridEntryKeyword, &btmp ) )
|
||||
SetGridVisibility( btmp );
|
||||
|
||||
if( wtmp.SetFromWxString( aCfg->Read( footprintEditor + GridColorEntryKeyword, wxT( "NONE" ) ) ) )
|
||||
if( wtmp.SetFromWxString( aCfg->Read( footprintEditor + GridColorEntryKeyword,
|
||||
wxT( "NONE" ) ) ) )
|
||||
SetGridColor( wtmp );
|
||||
|
||||
// Grid shape, etc.
|
||||
|
@ -683,7 +684,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint( wxCommandEvent& event )
|
|||
setCurNickname( fpid.GetLibNickname() );
|
||||
setCurFootprintName( fpid.GetLibItemName() );
|
||||
|
||||
int index = m_libList->FindString( fpid.GetLibNickname() );
|
||||
int index = m_libList->FindString( fpid.GetLibNickname(), true );
|
||||
|
||||
if( index != wxNOT_FOUND )
|
||||
{
|
||||
|
@ -703,7 +704,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode )
|
|||
if( !getCurNickname() )
|
||||
return;
|
||||
|
||||
int selection = m_footprintList->FindString( getCurFootprintName() );
|
||||
int selection = m_footprintList->FindString( getCurFootprintName(), true );
|
||||
|
||||
if( aMode == NEXT_PART )
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2018-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
|
@ -68,7 +68,7 @@ std::vector<LIB_TREE_ITEM*> FP_TREE_MODEL_ADAPTER::getFootprints( const wxString
|
|||
auto libBounds = std::equal_range( fullListStart, fullListEnd, dummy,
|
||||
[]( const std::unique_ptr<FOOTPRINT_INFO>& a, const std::unique_ptr<FOOTPRINT_INFO>& b )
|
||||
{
|
||||
return StrNumCmp( a->GetLibNickname(), b->GetLibNickname(), true ) < 0;
|
||||
return StrNumCmp( a->GetLibNickname(), b->GetLibNickname(), false ) < 0;
|
||||
} );
|
||||
|
||||
for( auto i = libBounds.first; i != libBounds.second; ++i )
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017 CERN
|
||||
* Copyright (C)-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -117,7 +118,7 @@ void FP_TREE_SYNCHRONIZING_ADAPTER::updateLibrary( LIB_TREE_NODE_LIB& aLibNode )
|
|||
auto footprintIt = std::lower_bound( footprints.begin(), footprints.end(), &dummy,
|
||||
[]( LIB_TREE_ITEM* a, LIB_TREE_ITEM* b )
|
||||
{
|
||||
return StrNumCmp( a->GetName(), b->GetName(), true ) < 0;
|
||||
return StrNumCmp( a->GetName(), b->GetName(), false ) < 0;
|
||||
} );
|
||||
|
||||
if( footprintIt != footprints.end() && dummy.GetName() == (*footprintIt)->GetName() )
|
||||
|
@ -176,7 +177,7 @@ void FP_TREE_SYNCHRONIZING_ADAPTER::GetValue( wxVariant& aVariant, wxDataViewIte
|
|||
|
||||
wxString currentFPName = mod->GetFPID().GetLibItemName();
|
||||
|
||||
// mark modified part with an asterix
|
||||
// mark modified part with an asterisk
|
||||
if( m_frame->GetScreen()->IsModify() )
|
||||
aVariant = currentFPName + " *";
|
||||
else
|
||||
|
@ -223,42 +224,42 @@ bool FP_TREE_SYNCHRONIZING_ADAPTER::GetAttr( wxDataViewItem const& aItem, unsign
|
|||
|
||||
switch( node->Type )
|
||||
{
|
||||
case LIB_TREE_NODE::LIB:
|
||||
if( node->Name == m_frame->GetLoadedFPID().GetLibNickname() )
|
||||
{
|
||||
case LIB_TREE_NODE::LIB:
|
||||
if( node->Name == m_frame->GetLoadedFPID().GetLibNickname() )
|
||||
{
|
||||
#ifdef __WXGTK__
|
||||
// The native wxGTK+ impl ignores background colour, so set the text colour
|
||||
// instead. Works reasonably well in dark themes, less well in light ones....
|
||||
aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
|
||||
// The native wxGTK+ impl ignores background colour, so set the text colour
|
||||
// instead. Works reasonably well in dark themes, less well in light ones....
|
||||
aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
|
||||
#else
|
||||
aAttr.SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
|
||||
aAttr.SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
|
||||
#endif
|
||||
|
||||
// mark modified libs with bold font
|
||||
if( m_frame->GetScreen()->IsModify() && !m_frame->IsCurrentFPFromBoard() )
|
||||
aAttr.SetBold( true );
|
||||
}
|
||||
break;
|
||||
// mark modified libs with bold font
|
||||
if( m_frame->GetScreen()->IsModify() && !m_frame->IsCurrentFPFromBoard() )
|
||||
aAttr.SetBold( true );
|
||||
}
|
||||
break;
|
||||
|
||||
case LIB_TREE_NODE::LIBID:
|
||||
if( node->LibId == m_frame->GetLoadedFPID() )
|
||||
{
|
||||
case LIB_TREE_NODE::LIBID:
|
||||
if( node->LibId == m_frame->GetLoadedFPID() )
|
||||
{
|
||||
#ifdef __WXGTK__
|
||||
// The native wxGTK+ impl ignores background colour, so set the text colour
|
||||
// instead. Works reasonably well in dark themes, less well in light ones....
|
||||
aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
|
||||
// The native wxGTK+ impl ignores background colour, so set the text colour
|
||||
// instead. Works reasonably well in dark themes, less well in light ones....
|
||||
aAttr.SetColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
|
||||
#else
|
||||
aAttr.SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
|
||||
aAttr.SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) );
|
||||
#endif
|
||||
|
||||
// mark modified part with bold font
|
||||
if( m_frame->GetScreen()->IsModify() && !m_frame->IsCurrentFPFromBoard() )
|
||||
aAttr.SetBold( true );
|
||||
}
|
||||
break;
|
||||
// mark modified part with bold font
|
||||
if( m_frame->GetScreen()->IsModify() && !m_frame->IsCurrentFPFromBoard() )
|
||||
aAttr.SetBold( true );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue