2010-07-30 22:31:31 +00:00
|
|
|
/*
|
2010-08-01 20:36:13 +00:00
|
|
|
* This file Copyright (C) Mnemosyne LLC
|
2010-07-30 22:31:31 +00:00
|
|
|
*
|
2010-08-01 20:36:13 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
2010-07-30 22:31:31 +00:00
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef QTR_FILTERBAR_H
|
|
|
|
#define QTR_FILTERBAR_H
|
|
|
|
|
|
|
|
#include <QComboBox>
|
|
|
|
#include <QItemDelegate>
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
class QLineEdit;
|
|
|
|
class QPaintEvent;
|
|
|
|
class QStandardItemModel;
|
|
|
|
class QTimer;
|
|
|
|
|
|
|
|
class Prefs;
|
|
|
|
class TorrentFilter;
|
|
|
|
class TorrentModel;
|
|
|
|
|
|
|
|
class FilterBarComboBoxDelegate: public QItemDelegate
|
|
|
|
{
|
2013-01-26 01:19:54 +00:00
|
|
|
Q_OBJECT
|
2010-07-30 22:31:31 +00:00
|
|
|
|
2013-01-26 01:19:54 +00:00
|
|
|
public:
|
|
|
|
FilterBarComboBoxDelegate (QObject * parent, QComboBox * combo);
|
2010-07-30 22:31:31 +00:00
|
|
|
|
2013-01-26 01:19:54 +00:00
|
|
|
public:
|
|
|
|
static bool isSeparator (const QModelIndex &index);
|
|
|
|
static void setSeparator (QAbstractItemModel * model, const QModelIndex& index);
|
2010-07-30 22:31:31 +00:00
|
|
|
|
2013-01-26 01:19:54 +00:00
|
|
|
protected:
|
|
|
|
virtual void paint (QPainter*, const QStyleOptionViewItem&, const QModelIndex&) const;
|
|
|
|
virtual QSize sizeHint (const QStyleOptionViewItem&, const QModelIndex&) const;
|
2010-07-30 22:31:31 +00:00
|
|
|
|
2013-01-26 01:19:54 +00:00
|
|
|
private:
|
|
|
|
QComboBox * myCombo;
|
2010-07-30 22:31:31 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class FilterBarComboBox: public QComboBox
|
|
|
|
{
|
2013-01-26 01:19:54 +00:00
|
|
|
Q_OBJECT
|
2010-07-30 22:31:31 +00:00
|
|
|
|
2013-01-26 01:19:54 +00:00
|
|
|
public:
|
|
|
|
FilterBarComboBox (QWidget * parent = 0);
|
2010-07-30 22:31:31 +00:00
|
|
|
|
2013-01-26 01:19:54 +00:00
|
|
|
protected:
|
|
|
|
virtual void paintEvent (QPaintEvent * e);
|
2010-07-30 22:31:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class FilterBar: public QWidget
|
|
|
|
{
|
2013-01-26 01:19:54 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
FilterBar (Prefs& prefs, TorrentModel& torrents, TorrentFilter& filter, QWidget * parent = 0);
|
|
|
|
~FilterBar ();
|
|
|
|
|
|
|
|
private:
|
|
|
|
QComboBox * createTrackerCombo (QStandardItemModel * );
|
|
|
|
QComboBox * createActivityCombo ();
|
|
|
|
void recountSoon ();
|
|
|
|
void refreshTrackers ();
|
|
|
|
QString getCountString (int n) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
Prefs& myPrefs;
|
|
|
|
TorrentModel& myTorrents;
|
|
|
|
TorrentFilter& myFilter;
|
|
|
|
QComboBox * myActivityCombo;
|
|
|
|
QComboBox * myTrackerCombo;
|
|
|
|
QStandardItemModel * myTrackerModel;
|
|
|
|
QTimer * myRecountTimer;
|
|
|
|
bool myIsBootstrapping;
|
|
|
|
QLineEdit * myLineEdit;
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void recount ();
|
|
|
|
void refreshPref (int key);
|
|
|
|
void onActivityIndexChanged (int index);
|
|
|
|
void onTrackerIndexChanged (int index);
|
|
|
|
void onTorrentModelReset ();
|
|
|
|
void onTorrentModelRowsInserted (const QModelIndex&, int, int);
|
|
|
|
void onTorrentModelRowsRemoved (const QModelIndex&, int, int);
|
|
|
|
void onTorrentModelDataChanged (const QModelIndex&, const QModelIndex&);
|
|
|
|
void onTextChanged (const QString&);
|
2010-07-30 22:31:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|