* fix the torrent list's flicker on periodic refresh by resorting only when it's needed
This commit is contained in:
parent
2bc52d3bfe
commit
4b6da6cbca
|
@ -18,7 +18,6 @@
|
||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <wx/intl.h>
|
#include <wx/intl.h>
|
||||||
#include <torrent-list.h>
|
#include <torrent-list.h>
|
||||||
|
|
||||||
|
@ -534,14 +533,37 @@ TorrentListCtrl :: Sort( int column )
|
||||||
Resort ();
|
Resort ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
TorrentListCtrl :: IsSorted( ) const
|
||||||
|
{
|
||||||
|
bool is_sorted = true;
|
||||||
|
long prevItem=-1, curItem=-1;
|
||||||
|
|
||||||
|
uglyHack = const_cast<TorrentListCtrl*>(this);
|
||||||
|
while( is_sorted )
|
||||||
|
{
|
||||||
|
prevItem = curItem;
|
||||||
|
curItem = GetNextItem( curItem, wxLIST_NEXT_ALL, wxLIST_STATE_DONTCARE );
|
||||||
|
if ( curItem == -1 )
|
||||||
|
break;
|
||||||
|
if( prevItem>=0 && curItem>=0 )
|
||||||
|
if( Compare( prevItem, curItem, prevSortCol ) > 0 )
|
||||||
|
is_sorted = false;
|
||||||
|
}
|
||||||
|
uglyHack = 0;
|
||||||
|
|
||||||
|
return is_sorted;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TorrentListCtrl :: Resort( )
|
TorrentListCtrl :: Resort( )
|
||||||
{
|
{
|
||||||
uglyHack = this;
|
|
||||||
|
|
||||||
myConfig->Write( _T("torrent-sort-column"), columnKeys[abs(prevSortCol)] );
|
myConfig->Write( _T("torrent-sort-column"), columnKeys[abs(prevSortCol)] );
|
||||||
myConfig->Write( _T("torrent-sort-is-descending"), prevSortCol < 0 );
|
myConfig->Write( _T("torrent-sort-is-descending"), prevSortCol < 0 );
|
||||||
|
|
||||||
|
if( !IsSorted ( ) )
|
||||||
|
{
|
||||||
|
uglyHack = this;
|
||||||
SortItems( Compare, prevSortCol );
|
SortItems( Compare, prevSortCol );
|
||||||
|
|
||||||
const int n = GetItemCount ();
|
const int n = GetItemCount ();
|
||||||
|
@ -554,6 +576,7 @@ TorrentListCtrl :: Resort( )
|
||||||
myHashToItem.swap( tmp );
|
myHashToItem.swap( tmp );
|
||||||
uglyHack = NULL;
|
uglyHack = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
****
|
****
|
||||||
|
|
|
@ -120,7 +120,7 @@ class TorrentListCtrl: public wxListCtrl
|
||||||
void OnSort( wxListEvent& );
|
void OnSort( wxListEvent& );
|
||||||
void OnItemSelected( wxListEvent& );
|
void OnItemSelected( wxListEvent& );
|
||||||
void OnItemDeselected( wxListEvent& );
|
void OnItemDeselected( wxListEvent& );
|
||||||
|
bool IsSorted( ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
tr_handle_t * myHandle;
|
tr_handle_t * myHandle;
|
||||||
|
|
Loading…
Reference in New Issue