Commit e66e4ad4 authored by Dick Hollenbeck's avatar Dick Hollenbeck

remove PART_LIBS sorting.

parent 12229246
...@@ -53,51 +53,6 @@ ...@@ -53,51 +53,6 @@
"This may cause some unexpected behavior when loading components into a schematic." ) "This may cause some unexpected behavior when loading components into a schematic." )
bool operator==( const PART_LIB& aLibrary, const wxString& aName )
{
// See our header class_libentry.h for function Cmp_KEEPCASE().
return Cmp_KEEPCASE( aLibrary.GetName(), aName ) == 0;
}
bool operator!=( const PART_LIB& aLibrary, const wxString& aName )
{
return !( aLibrary == aName );
}
wxArrayString PART_LIBS::s_libraryListSortOrder;
bool operator<( const PART_LIB& aItem1, const PART_LIB& aItem2 )
{
// The cache library always is sorted to the end of the library list.
if( aItem2.IsCache() )
return true;
if( aItem1.IsCache() )
return false;
// If the sort order array isn't set, then sort alphabetically except.
if( PART_LIBS::GetSortOrder().IsEmpty() )
return Cmp_KEEPCASE( aItem1.GetName(), aItem2.GetName() ) < 0;
int i1 = PART_LIBS::GetSortOrder().Index( aItem1.GetName(), false );
int i2 = PART_LIBS::GetSortOrder().Index( aItem2.GetName(), false );
if( i1 == wxNOT_FOUND && i2 == wxNOT_FOUND )
return true;
if( i1 == wxNOT_FOUND && i2 != wxNOT_FOUND )
return false;
if( i1 != wxNOT_FOUND && i2 == wxNOT_FOUND )
return true;
return ( i1 - i2 ) < 0;
}
PART_LIB::PART_LIB( int aType, const wxString& aFileName ) : PART_LIB::PART_LIB( int aType, const wxString& aFileName ) :
// start @ != 0 so each additional library added // start @ != 0 so each additional library added
// is immediately detectable, zero would not be. // is immediately detectable, zero would not be.
...@@ -873,19 +828,11 @@ void PART_LIBS::RemoveLibrary( const wxString& aName ) ...@@ -873,19 +828,11 @@ void PART_LIBS::RemoveLibrary( const wxString& aName )
PART_LIB* PART_LIBS::FindLibrary( const wxString& aName ) PART_LIB* PART_LIBS::FindLibrary( const wxString& aName )
{ {
#if 0
BOOST_FOREACH( PART_LIB& lib, *this )
{
if( lib == aName )
return &lib;
}
#else
for( PART_LIBS::iterator it = begin(); it!=end(); ++it ) for( PART_LIBS::iterator it = begin(); it!=end(); ++it )
{ {
if( *it == aName ) if( it->GetName() == aName )
return &*it; return &*it;
} }
#endif
return NULL; return NULL;
} }
...@@ -1057,7 +1004,6 @@ void PART_LIBS::LoadAllLibraries( PROJECT* aProject ) throw( IO_ERROR ) ...@@ -1057,7 +1004,6 @@ void PART_LIBS::LoadAllLibraries( PROJECT* aProject ) throw( IO_ERROR )
wxFileName fn; wxFileName fn;
wxString filename; wxString filename;
wxString libs_not_found; wxString libs_not_found;
wxArrayString sortOrder;
SEARCH_STACK* lib_search = aProject->SchSearchS(); SEARCH_STACK* lib_search = aProject->SchSearchS();
#if defined(DEBUG) && 1 #if defined(DEBUG) && 1
...@@ -1147,18 +1093,8 @@ void PART_LIBS::LoadAllLibraries( PROJECT* aProject ) throw( IO_ERROR ) ...@@ -1147,18 +1093,8 @@ void PART_LIBS::LoadAllLibraries( PROJECT* aProject ) throw( IO_ERROR )
UTF8( libs_not_found ), 0, 0 ); UTF8( libs_not_found ), 0, 0 );
} }
// Put the libraries in the correct order.
PART_LIBS::SetSortOrder( sortOrder );
sort();
#if defined(DEBUG) && 1 #if defined(DEBUG) && 1
printf( "%s: sort order:\n", __func__ ); printf( "%s: lib_names:\n", __func__ );
for( size_t i = 0; i < sortOrder.GetCount(); i++ )
printf( " %s\n", TO_UTF8( sortOrder[i] ) );
printf( "%s: actual order:\n", __func__ );
for( PART_LIBS::const_iterator it = begin(); it < end(); ++it ) for( PART_LIBS::const_iterator it = begin(); it < end(); ++it )
printf( " %s\n", TO_UTF8( it->GetName() ) ); printf( " %s\n", TO_UTF8( it->GetName() ) );
......
...@@ -103,8 +103,6 @@ typedef boost::ptr_vector< PART_LIB > PART_LIBS_BASE; ...@@ -103,8 +103,6 @@ typedef boost::ptr_vector< PART_LIB > PART_LIBS_BASE;
*/ */
class PART_LIBS : public PART_LIBS_BASE, public PROJECT::_ELEM class PART_LIBS : public PART_LIBS_BASE, public PROJECT::_ELEM
{ {
static wxArrayString s_libraryListSortOrder;
public: public:
static int s_modify_generation; ///< helper for GetModifyHash() static int s_modify_generation; ///< helper for GetModifyHash()
...@@ -226,21 +224,9 @@ public: ...@@ -226,21 +224,9 @@ public:
int GetLibraryCount() { return size(); } int GetLibraryCount() { return size(); }
static void SetSortOrder( const wxArrayString& aSortOrder )
{
s_libraryListSortOrder = aSortOrder;
}
static wxArrayString& GetSortOrder()
{
return s_libraryListSortOrder;
}
}; };
bool operator<( const PART_LIB& item1, const PART_LIB& item2 );
/** /**
* Class PART_LIB * Class PART_LIB
* is used to load, save, search, and otherwise manipulate * is used to load, save, search, and otherwise manipulate
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment