Changeset 2914
- Timestamp:
- Aug 23, 2007, 7:21:42 PM (15 years ago)
- Location:
- trunk/wx
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wx/torrent-list.cc
r2849 r2914 19 19 */ 20 20 21 #include <iostream>22 21 #include <wx/intl.h> 23 22 #include <torrent-list.h> … … 535 534 } 536 535 536 bool 537 TorrentListCtrl :: IsSorted( ) const 538 { 539 bool is_sorted = true; 540 long prevItem=-1, curItem=-1; 541 542 uglyHack = const_cast<TorrentListCtrl*>(this); 543 while( is_sorted ) 544 { 545 prevItem = curItem; 546 curItem = GetNextItem( curItem, wxLIST_NEXT_ALL, wxLIST_STATE_DONTCARE ); 547 if ( curItem == -1 ) 548 break; 549 if( prevItem>=0 && curItem>=0 ) 550 if( Compare( prevItem, curItem, prevSortCol ) > 0 ) 551 is_sorted = false; 552 } 553 uglyHack = 0; 554 555 return is_sorted; 556 } 557 537 558 void 538 559 TorrentListCtrl :: Resort( ) 539 560 { 540 uglyHack = this;541 542 561 myConfig->Write( _T("torrent-sort-column"), columnKeys[abs(prevSortCol)] ); 543 562 myConfig->Write( _T("torrent-sort-is-descending"), prevSortCol < 0 ); 544 563 545 SortItems( Compare, prevSortCol ); 546 547 const int n = GetItemCount (); 548 str2int_t tmp; 549 for( int i=0; i<n; ++i ) { 550 int idx = GetItemData( i ); 551 const tr_info_t* info = tr_torrentInfo( myTorrents[idx] ); 552 tmp[info->hashString] = i; 553 } 554 myHashToItem.swap( tmp ); 555 uglyHack = NULL; 564 if( !IsSorted ( ) ) 565 { 566 uglyHack = this; 567 SortItems( Compare, prevSortCol ); 568 569 const int n = GetItemCount (); 570 str2int_t tmp; 571 for( int i=0; i<n; ++i ) { 572 int idx = GetItemData( i ); 573 const tr_info_t* info = tr_torrentInfo( myTorrents[idx] ); 574 tmp[info->hashString] = i; 575 } 576 myHashToItem.swap( tmp ); 577 uglyHack = NULL; 578 } 556 579 } 557 580 -
trunk/wx/torrent-list.h
r2849 r2914 121 121 void OnItemSelected( wxListEvent& ); 122 122 void OnItemDeselected( wxListEvent& ); 123 123 bool IsSorted( ) const; 124 124 125 125 private:
Note: See TracChangeset
for help on using the changeset viewer.