source: trunk/qt/filters.h @ 8216

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

(qt) better integration of sort & filter modes into the preferences mechanism

File size: 1.8 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_FILTERS_H
14#define QTR_FILTERS_H
15
16#include <QMetaType>
17#include <QString>
18#include <QVariant>
19
20class FilterMode
21{
22    private:
23        int myMode;
24    public:
25        FilterMode( int mode=SHOW_ALL ): myMode(mode) { }
26        FilterMode( const QString& name ): myMode(modeFromName(name)) { }
27        static const QString names[];
28        enum { SHOW_ALL, SHOW_ACTIVE, SHOW_DOWNLOADING, SHOW_SEEDING, SHOW_PAUSED, NUM_MODES };
29        static int modeFromName( const QString& name );
30        static const QString& nameFromMode( int mode ) { return names[mode]; }
31        int mode() const { return myMode; }
32        const QString& name() const { return names[myMode]; }
33};
34
35class SortMode
36{
37    private:
38        int myMode;
39    public:
40        SortMode( int mode=SORT_BY_ID ): myMode(mode) { }
41        SortMode( const QString& name ): myMode(modeFromName(name)) { }
42        static const QString names[];
43        enum { SORT_BY_ACTIVITY, SORT_BY_AGE, SORT_BY_ETA, SORT_BY_NAME,
44               SORT_BY_PROGRESS, SORT_BY_RATIO, SORT_BY_SIZE,
45               SORT_BY_STATE, SORT_BY_TRACKER, SORT_BY_ID, NUM_MODES };
46        static int modeFromName( const QString& name );
47        static const QString& nameFromMode( int mode );
48        int mode() const { return myMode; }
49        const QString& name() const { return names[myMode]; }
50};
51
52Q_DECLARE_METATYPE(FilterMode)
53Q_DECLARE_METATYPE(SortMode)
54
55#endif
Note: See TracBrowser for help on using the repository browser.