2
* Xmission - a cross-platform bittorrent client
3
* Copyright (C) 2007 Charles Kerr <charles@rebelbase.com>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; version 2 of the License.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
* $Id: filter.cc 3178 2007-09-26 01:55:04Z charles $
25
TorrentFilter :: GetFlags( const tr_torrent * tor )
28
const tr_stat * s = tr_torrentStat( (tr_torrent*)tor );
32
case TR_STATUS_DOWNLOAD:
33
flags |= FLAG_LEECHING;
38
flags |= FLAG_SEEDING;
41
case TR_STATUS_STOPPING:
42
case TR_STATUS_STOPPED:
44
case TR_STATUS_CHECK_WAIT:
48
flags |= ( ( s->rateUpload + s->rateDownload ) > 0.01 )
52
flags |= s->leftUntilDone
62
TorrentFilter :: CountHits( const torrents_v & torrents,
65
memset( counts, '\0', sizeof(int) * N_FILTERS );
66
foreach_const( torrents_v, torrents, it ) {
67
const int flags = GetFlags( *it );
68
if( flags & FLAG_ALL ) ++counts[ALL];
69
if( flags & FLAG_LEECHING ) ++counts[LEECHING];
70
if( flags & FLAG_SEEDING ) ++counts[SEEDING];
71
if( flags & FLAG_ACTIVE ) ++counts[ACTIVE];
72
if( flags & FLAG_IDLE ) ++counts[IDLE];
73
if( flags & FLAG_COMPLETE ) ++counts[COMPLETE];
74
if( flags & FLAG_INCOMPLETE ) ++counts[INCOMPLETE];
79
TorrentFilter :: GetName( int show, int count )
81
static const wxString names[N_FILTERS] = {
91
assert( 0<=show && show<N_FILTERS );
93
wxString xstr = names[show];
95
xstr += wxString::Format(_T(" (%d)"), count );
100
TorrentFilter :: RemoveFailures( int show,
101
torrents_v & torrents )
105
foreach_const( torrents_v, torrents, it ) {
106
const int flags = GetFlags( *it );
107
if( ( ( show == ALL ) && ( flags & FLAG_ALL ) )
108
|| ( ( show == LEECHING ) && ( flags & FLAG_LEECHING ) )
109
|| ( ( show == SEEDING ) && ( flags & FLAG_SEEDING ) )
110
|| ( ( show == ACTIVE ) && ( flags & FLAG_ACTIVE ) )
111
|| ( ( show == IDLE ) && ( flags & FLAG_IDLE ) )
112
|| ( ( show == COMPLETE ) && ( flags & FLAG_COMPLETE ) )
113
|| ( ( show == INCOMPLETE ) && ( flags & FLAG_INCOMPLETE ) ) )
114
tmp.push_back( *it );
117
torrents.swap( tmp );