~hendrik-grewe/transmission/private-patch

« back to all changes in this revision

Viewing changes to qt/torrent-filter.h

  • Committer: charles
  • Date: 2009-04-09 17:55:47 UTC
  • Revision ID: svn-v4:f4695dd4-2c0a-0410-b89c-da849a56a58e:trunk:8188
(trunk) add the Qt beta into svn 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file Copyright (C) 2009 Charles Kerr <charles@transmissionbt.com>
 
3
 *
 
4
 * This file is licensed by the GPL version 2.  Works owned by the
 
5
 * Transmission project are granted a special exemption to clause 2(b)
 
6
 * so that the bulk of its code can remain under the MIT license.
 
7
 * This exemption does not extend to derived works not owned by
 
8
 * the Transmission project.
 
9
 *
 
10
 * $Id:$
 
11
 */
 
12
 
 
13
#ifndef QTR_TORRENT_FILTER_H
 
14
#define QTR_TORRENT_FILTER_H
 
15
 
 
16
#include <QSortFilterProxyModel>
 
17
 
 
18
struct Prefs;
 
19
 
 
20
class TorrentFilter: public QSortFilterProxyModel
 
21
{
 
22
        Q_OBJECT
 
23
 
 
24
    public:
 
25
        TorrentFilter( Prefs& prefs );
 
26
        virtual ~TorrentFilter( );
 
27
 
 
28
    public:
 
29
        enum ShowMode { SHOW_ALL, SHOW_ACTIVE, SHOW_DOWNLOADING, SHOW_SEEDING, SHOW_PAUSED };
 
30
        ShowMode getShowMode( ) const { return myShowMode; }
 
31
 
 
32
        enum TextMode { FILTER_BY_NAME, FILTER_BY_FILES, FILTER_BY_TRACKER };
 
33
        TextMode getTextMode( ) const { return myTextMode; }
 
34
 
 
35
        enum SortMode{ SORT_BY_ACTIVITY, SORT_BY_AGE, SORT_BY_ETA, SORT_BY_NAME,
 
36
                       SORT_BY_PROGRESS, SORT_BY_RATIO, SORT_BY_SIZE,
 
37
                       SORT_BY_STATE, SORT_BY_TRACKER, SORT_BY_ID };
 
38
        const char * getSortKey( int mode=-1 );
 
39
        SortMode getSortMode( ) const { return mySortMode; }
 
40
 
 
41
        bool isAscending( ) const { return myIsAscending; }
 
42
 
 
43
        int hiddenRowCount( ) const;
 
44
 
 
45
 
 
46
    public slots:
 
47
        void setShowMode( int showMode );
 
48
        void setTextMode( int textMode );
 
49
        void setSortMode( int sortMode );
 
50
        void setText( QString );
 
51
        void sortByActivity( );
 
52
        void sortByAge( );
 
53
        void sortByETA( );
 
54
        void sortById( );
 
55
        void sortByName( );
 
56
        void sortByProgress( );
 
57
        void sortByRatio( );
 
58
        void sortBySize( );
 
59
        void sortByState( );
 
60
        void sortByTracker( );
 
61
        void setAscending( bool );
 
62
        void resort( );
 
63
 
 
64
    protected:
 
65
        virtual bool filterAcceptsRow( int, const QModelIndex& ) const;
 
66
        virtual bool lessThan( const QModelIndex&, const QModelIndex& ) const;
 
67
 
 
68
    private:
 
69
        Prefs& myPrefs;
 
70
        ShowMode myShowMode;
 
71
        TextMode myTextMode;
 
72
        SortMode mySortMode;
 
73
        bool myIsAscending;
 
74
        QString myText;
 
75
};
 
76
 
 
77
#endif