source: trunk/qt/torrent-filter.h @ 8194

Last change on this file since 8194 was 8194, checked in by charles, 13 years ago

(trunk qt) remember sorting & filtering mode between sessions

File size: 2.4 KB
Line 
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
18struct Prefs;
19struct QString;
20
21class TorrentFilter: public QSortFilterProxyModel
22{
23        Q_OBJECT
24
25    public:
26        TorrentFilter( Prefs& prefs );
27        virtual ~TorrentFilter( );
28
29    public:
30        enum ShowMode { SHOW_ALL, SHOW_ACTIVE, SHOW_DOWNLOADING, SHOW_SEEDING, SHOW_PAUSED };
31        ShowMode getShowMode( ) const { return myShowMode; }
32        ShowMode getShowModeFromName( const QString& name ) const;
33        const char * getShowName( int mode=-1 ) const;
34
35        enum TextMode { FILTER_BY_NAME, FILTER_BY_FILES, FILTER_BY_TRACKER };
36        TextMode getTextMode( ) const { return myTextMode; }
37
38        enum SortMode{ SORT_BY_ACTIVITY, SORT_BY_AGE, SORT_BY_ETA, SORT_BY_NAME,
39                       SORT_BY_PROGRESS, SORT_BY_RATIO, SORT_BY_SIZE,
40                       SORT_BY_STATE, SORT_BY_TRACKER, SORT_BY_ID };
41        SortMode getSortMode( ) const { return mySortMode; }
42        SortMode getSortModeFromName( const QString& name) const;
43        const char * getSortName( int mode=-1 ) const;
44
45        bool isAscending( ) const { return myIsAscending; }
46
47        int hiddenRowCount( ) const;
48
49
50    public slots:
51        void setShowMode( int showMode );
52        void setTextMode( int textMode );
53        void setSortMode( int sortMode );
54        void setText( QString );
55        void sortByActivity( );
56        void sortByAge( );
57        void sortByETA( );
58        void sortById( );
59        void sortByName( );
60        void sortByProgress( );
61        void sortByRatio( );
62        void sortBySize( );
63        void sortByState( );
64        void sortByTracker( );
65        void setAscending( bool );
66        void resort( );
67
68    protected:
69        virtual bool filterAcceptsRow( int, const QModelIndex& ) const;
70        virtual bool lessThan( const QModelIndex&, const QModelIndex& ) const;
71
72    private:
73        Prefs& myPrefs;
74        ShowMode myShowMode;
75        TextMode myTextMode;
76        SortMode mySortMode;
77        bool myIsAscending;
78        QString myText;
79};
80
81#endif
Note: See TracBrowser for help on using the repository browser.