2023-02-11 20:49:42 +00:00
|
|
|
// This file Copyright © 2010-2023 Mnemosyne LLC.
|
2022-08-08 18:05:39 +00:00
|
|
|
// It may be used under GPLv2 (SPDX: GPL-2.0-only), GPLv3 (SPDX: GPL-3.0-only),
|
2022-01-20 18:27:56 +00:00
|
|
|
// or any future license endorsed by Mnemosyne LLC.
|
|
|
|
// License text can be found in the licenses/ folder.
|
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
|
|
|
|
2022-09-08 23:26:18 +00:00
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QStandardItemModel>
|
2020-10-31 18:56:12 +00:00
|
|
|
#include <QTimer>
|
2010-07-30 22:31:31 +00:00
|
|
|
#include <QWidget>
|
|
|
|
|
2021-12-14 08:43:27 +00:00
|
|
|
#include <libtransmission/tr-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;
|
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_;
|
|
|
|
|
2022-02-12 17:30:27 +00:00
|
|
|
std::map<QString, int> sitename_counts_;
|
2022-09-08 23:26:18 +00:00
|
|
|
FilterBarComboBox* const activity_combo_ = createActivityCombo();
|
2020-05-27 21:53:12 +00:00
|
|
|
FilterBarComboBox* tracker_combo_ = {};
|
|
|
|
QLabel* count_label_ = {};
|
2022-09-08 23:26:18 +00:00
|
|
|
QStandardItemModel* const tracker_model_ = new QStandardItemModel{ this };
|
2020-10-31 18:56:12 +00:00
|
|
|
QTimer recount_timer_;
|
2022-09-08 23:26:18 +00:00
|
|
|
QLineEdit* const line_edit_ = new QLineEdit{ this };
|
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
|
|
|
};
|