2010-07-30 22:31:31 +00:00
|
|
|
/*
|
2015-06-10 21:27:11 +00:00
|
|
|
* This file Copyright (C) 2010-2015 Mnemosyne LLC
|
2010-07-30 22:31:31 +00:00
|
|
|
*
|
2014-01-21 03:10:30 +00:00
|
|
|
* It may be used under the GNU GPL versions 2 or 3
|
2014-01-19 01:09:44 +00:00
|
|
|
* or any future license endorsed by Mnemosyne LLC.
|
2010-07-30 22:31:31 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-03-29 16:37:21 +00:00
|
|
|
#pragma once
|
2010-07-30 22:31:31 +00:00
|
|
|
|
2020-06-23 23:54:08 +00:00
|
|
|
#include <bitset>
|
|
|
|
#include <map>
|
2019-11-12 01:37:05 +00:00
|
|
|
|
2020-10-31 18:56:12 +00:00
|
|
|
#include <QTimer>
|
2010-07-30 22:31:31 +00:00
|
|
|
#include <QWidget>
|
|
|
|
|
2020-06-24 18:28:54 +00:00
|
|
|
#include "FaviconCache.h"
|
2020-08-11 18:11:55 +00:00
|
|
|
#include "Macros.h"
|
2020-06-23 21:11:16 +00:00
|
|
|
#include "Torrent.h"
|
|
|
|
#include "Typedefs.h"
|
|
|
|
|
2013-02-01 20:58:55 +00:00
|
|
|
class QLabel;
|
2017-02-11 10:44:34 +00:00
|
|
|
class QLineEdit;
|
2010-07-30 22:31:31 +00:00
|
|
|
class QStandardItemModel;
|
2020-10-31 18:56:12 +00:00
|
|
|
class QString;
|
2010-07-30 22:31:31 +00:00
|
|
|
|
2015-06-10 21:27:11 +00:00
|
|
|
class FilterBarComboBox;
|
2010-07-30 22:31:31 +00:00
|
|
|
class Prefs;
|
|
|
|
class TorrentFilter;
|
|
|
|
class TorrentModel;
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
class FilterBar : public QWidget
|
2010-07-30 22:31:31 +00:00
|
|
|
{
|
2013-01-26 01:19:54 +00:00
|
|
|
Q_OBJECT
|
2020-08-11 18:11:55 +00:00
|
|
|
TR_DISABLE_COPY_MOVE(FilterBar)
|
2013-01-26 01:19:54 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
public:
|
2017-04-20 16:02:19 +00:00
|
|
|
FilterBar(Prefs& prefs, TorrentModel const& torrents, TorrentFilter const& filter, QWidget* parent = nullptr);
|
2013-01-26 01:19:54 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
public slots:
|
|
|
|
void clear();
|
2015-10-24 20:56:45 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
private:
|
|
|
|
FilterBarComboBox* createTrackerCombo(QStandardItemModel*);
|
|
|
|
FilterBarComboBox* createActivityCombo();
|
|
|
|
void refreshTrackers();
|
2013-01-26 01:19:54 +00:00
|
|
|
|
2020-06-23 23:54:08 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
ACTIVITY,
|
|
|
|
TRACKERS,
|
|
|
|
|
|
|
|
NUM_FLAGS
|
|
|
|
};
|
|
|
|
|
|
|
|
using Pending = std::bitset<NUM_FLAGS>;
|
2015-06-12 22:12:12 +00:00
|
|
|
|
2020-05-27 21:53:12 +00:00
|
|
|
Prefs& prefs_;
|
|
|
|
TorrentModel const& torrents_;
|
|
|
|
TorrentFilter const& filter_;
|
|
|
|
|
2020-06-24 18:28:54 +00:00
|
|
|
std::map<FaviconCache::Key, int> tracker_counts_;
|
2020-05-27 21:53:12 +00:00
|
|
|
FilterBarComboBox* activity_combo_ = {};
|
|
|
|
FilterBarComboBox* tracker_combo_ = {};
|
|
|
|
QLabel* count_label_ = {};
|
|
|
|
QStandardItemModel* tracker_model_ = {};
|
2020-10-31 18:56:12 +00:00
|
|
|
QTimer recount_timer_;
|
2020-05-27 21:53:12 +00:00
|
|
|
QLineEdit* line_edit_ = {};
|
2020-06-23 23:54:08 +00:00
|
|
|
Pending pending_ = {};
|
2020-05-27 21:53:12 +00:00
|
|
|
bool is_bootstrapping_ = {};
|
2020-06-23 23:54:08 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void recount();
|
|
|
|
void recountSoon(Pending const& fields);
|
2021-08-15 09:41:48 +00:00
|
|
|
|
|
|
|
void recountActivitySoon()
|
|
|
|
{
|
|
|
|
recountSoon(Pending().set(ACTIVITY));
|
|
|
|
}
|
|
|
|
|
|
|
|
void recountTrackersSoon()
|
|
|
|
{
|
|
|
|
recountSoon(Pending().set(TRACKERS));
|
|
|
|
}
|
|
|
|
|
|
|
|
void recountAllSoon()
|
|
|
|
{
|
|
|
|
recountSoon(Pending().set(ACTIVITY).set(TRACKERS));
|
|
|
|
}
|
2020-06-23 23:54:08 +00:00
|
|
|
|
|
|
|
void refreshPref(int key);
|
|
|
|
void onActivityIndexChanged(int index);
|
|
|
|
void onTextChanged(QString const&);
|
|
|
|
void onTorrentsChanged(torrent_ids_t const&, Torrent::fields_t const& fields);
|
|
|
|
void onTrackerIndexChanged(int index);
|
2010-07-30 22:31:31 +00:00
|
|
|
};
|