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
This commit is contained in:
parent
aa9897d932
commit
d8fff5c820
|
@ -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
|
||||
|
@ -168,12 +168,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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2012-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2008-2016 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -317,7 +317,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 )
|
||||
{
|
||||
|
@ -368,7 +368,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 );
|
||||
|
@ -508,7 +508,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.
|
||||
|
@ -765,7 +766,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 )
|
||||
{
|
||||
|
@ -785,7 +786,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
|
||||
|
@ -109,7 +110,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() )
|
||||
|
@ -164,7 +165,7 @@ void FP_TREE_SYNCHRONIZING_ADAPTER::GetValue( wxVariant& aVariant, wxDataViewIte
|
|||
{
|
||||
wxString currentFPName = m_frame->GetBoard()->m_Modules->GetFPID().GetLibItemName();
|
||||
|
||||
// mark modified part with an asterix
|
||||
// mark modified part with an asterisk
|
||||
if( m_frame->GetScreen()->IsModify() )
|
||||
aVariant = currentFPName + " *";
|
||||
else
|
||||
|
@ -207,42 +208,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