source: trunk/qt/filterbar.h @ 13927

Last change on this file since 13927 was 13927, checked in by jordan, 10 years ago

in the Qt and GTK+ clients, move the torrent count indicator from the statusbar to the filterbar

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