source: trunk/qt/filters.h @ 11072

Last change on this file since 11072 was 11072, checked in by charles, 12 years ago

(trunk qt) #3459 "Qt client's filterbar should be updated to match the GTK+ client's" -- fixed

  • Property svn:keywords set to Date Rev Author Id
File size: 1.8 KB
Line 
1/*
2 * This file Copyright (C) 2009-2010 Mnemosyne LLC
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: filters.h 11072 2010-07-30 22:31:31Z charles $
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,
29               SHOW_QUEUED, SHOW_VERIFYING, SHOW_ERROR, NUM_MODES };
30        static int modeFromName( const QString& name );
31        static const QString& nameFromMode( int mode ) { return names[mode]; }
32        int mode() const { return myMode; }
33        const QString& name() const { return names[myMode]; }
34};
35
36class SortMode
37{
38    private:
39        int myMode;
40    public:
41        SortMode( int mode=SORT_BY_ID ): myMode(mode) { }
42        SortMode( const QString& name ): myMode(modeFromName(name)) { }
43        static const QString names[];
44        enum { SORT_BY_ACTIVITY, SORT_BY_AGE, SORT_BY_ETA, SORT_BY_NAME,
45               SORT_BY_PROGRESS, SORT_BY_RATIO, SORT_BY_SIZE,
46               SORT_BY_STATE, SORT_BY_TRACKER, SORT_BY_ID, NUM_MODES };
47        static int modeFromName( const QString& name );
48        static const QString& nameFromMode( int mode );
49        int mode() const { return myMode; }
50        const QString& name() const { return names[myMode]; }
51};
52
53Q_DECLARE_METATYPE(FilterMode)
54Q_DECLARE_METATYPE(SortMode)
55
56#endif
Note: See TracBrowser for help on using the repository browser.