source: trunk/qt/filterbar.h @ 11092

Last change on this file since 11092 was 11092, checked in by charles, 11 years ago

(trunk qt) synchronize the copyright notices

  • Property svn:keywords set to Date Rev Author Id
File size: 2.5 KB
Line 
1/*
2 * This file Copyright (C) Mnemosyne LLC
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2
6 * as published by the Free Software Foundation.
7 *
8 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
9 *
10 * $Id: filterbar.h 11092 2010-08-01 20:36:13Z charles $
11 */
12
13#ifndef QTR_FILTERBAR_H
14#define QTR_FILTERBAR_H
15
16#include <QComboBox>
17#include <QItemDelegate>
18#include <QWidget>
19
20class QLineEdit;
21class QPaintEvent;
22class QStandardItemModel;
23class QTimer;
24
25class Prefs;
26class TorrentFilter;
27class TorrentModel;
28
29class FilterBarComboBoxDelegate: public QItemDelegate
30{
31        Q_OBJECT
32
33    public:
34        FilterBarComboBoxDelegate( QObject * parent, QComboBox * combo );
35
36    public:
37        static bool isSeparator( const QModelIndex &index );
38        static void setSeparator( QAbstractItemModel * model, const QModelIndex& index );
39
40    protected:
41        virtual void paint( QPainter*, const QStyleOptionViewItem&, const QModelIndex& ) const;
42        virtual QSize sizeHint( const QStyleOptionViewItem&, const QModelIndex& ) const;
43
44    private:
45        QComboBox * myCombo;
46
47};
48
49class FilterBarComboBox: public QComboBox
50{
51        Q_OBJECT
52
53    public:
54        FilterBarComboBox( QWidget * parent = 0 );
55
56    protected:
57        virtual void paintEvent( QPaintEvent * e );
58};
59
60
61class FilterBar: public QWidget
62{
63        Q_OBJECT
64
65    public:
66        FilterBar( Prefs& prefs, TorrentModel& torrents, TorrentFilter& filter, QWidget * parent = 0 );
67        ~FilterBar( );
68
69    private:
70        QComboBox * createTrackerCombo( QStandardItemModel *  );
71        QComboBox * createActivityCombo( );
72        void recountSoon( );
73        void refreshTrackers( );
74
75    private:
76        Prefs& myPrefs;
77        TorrentModel& myTorrents;
78        TorrentFilter& myFilter;
79        QComboBox * myActivityCombo;
80        QComboBox * myTrackerCombo;
81        QStandardItemModel * myTrackerModel;
82        QTimer * myRecountTimer;
83        bool myIsBootstrapping;
84        QLineEdit * myLineEdit;
85
86    private slots:
87        void recount( );
88        void refreshPref( int key );
89        void onActivityIndexChanged( int index );
90        void onTrackerIndexChanged( int index );
91        void onTorrentModelReset( );
92        void onTorrentModelRowsInserted( const QModelIndex&, int, int );
93        void onTorrentModelRowsRemoved( const QModelIndex&, int, int );
94        void onTorrentModelDataChanged( const QModelIndex&, const QModelIndex& );
95        void onTextChanged( const QString& );
96};
97
98#endif
Note: See TracBrowser for help on using the repository browser.