source: trunk/qt/filterbar.h @ 14241

Last change on this file since 14241 was 14241, checked in by jordan, 9 years ago

Copyedit the license's revised text: (1) remove unnecessary repitition use of the word 'license' from the top of the header and source files (2) add the standard 'we hope it's useful, but no warranty' clause to COPYING (3) make explicit that linking OpenSSL is allowed (see https://people.gnome.org/~markmc/openssl-and-the-gpl.html for background) (4) sync the Qt and GTK+ clients' license popups with COPYING's revised text

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