mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-30 11:38:50 -07:00
Implement tracker list in the side panel. Closes #170.
This commit is contained in:
parent
36d2bee557
commit
f0d5ce4b98
15 changed files with 391 additions and 2 deletions
|
@ -36,6 +36,8 @@
|
|||
TransferListSortModel::TransferListSortModel(QObject *parent)
|
||||
: QSortFilterProxyModel(parent)
|
||||
, filter0(TorrentFilter::ALL)
|
||||
, labelFilterEnabled(false)
|
||||
, trackerFilterEnabled(false)
|
||||
{}
|
||||
|
||||
void TransferListSortModel::setStatusFilter(const TorrentFilter::TorrentFilter &filter) {
|
||||
|
@ -45,7 +47,7 @@ void TransferListSortModel::setStatusFilter(const TorrentFilter::TorrentFilter &
|
|||
}
|
||||
}
|
||||
|
||||
void TransferListSortModel::setLabelFilter(QString const& label) {
|
||||
void TransferListSortModel::setLabelFilter(const QString &label) {
|
||||
if (!labelFilterEnabled || labelFilter != label) {
|
||||
labelFilterEnabled = true;
|
||||
labelFilter = label;
|
||||
|
@ -61,6 +63,22 @@ void TransferListSortModel::disableLabelFilter() {
|
|||
}
|
||||
}
|
||||
|
||||
void TransferListSortModel::setTrackerFilter(const QStringList &hashes) {
|
||||
if (!trackerFilterEnabled || trackerFilter != hashes) {
|
||||
trackerFilterEnabled = true;
|
||||
trackerFilter = hashes;
|
||||
invalidateFilter();
|
||||
}
|
||||
}
|
||||
|
||||
void TransferListSortModel::disableTrackerFilter() {
|
||||
if (trackerFilterEnabled) {
|
||||
trackerFilterEnabled = false;
|
||||
trackerFilter = QStringList();
|
||||
invalidateFilter();
|
||||
}
|
||||
}
|
||||
|
||||
bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex &right) const {
|
||||
const int column = sortColumn();
|
||||
|
||||
|
@ -197,6 +215,7 @@ bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex
|
|||
bool TransferListSortModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const {
|
||||
return matchStatusFilter(sourceRow, sourceParent)
|
||||
&& matchLabelFilter(sourceRow, sourceParent)
|
||||
&& matchTrackerFilter(sourceRow, sourceParent)
|
||||
&& QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent);
|
||||
}
|
||||
|
||||
|
@ -258,3 +277,14 @@ bool TransferListSortModel::matchLabelFilter(int sourceRow, const QModelIndex &s
|
|||
|
||||
return model->index(sourceRow, TorrentModelItem::TR_LABEL, sourceParent).data().toString() == labelFilter;
|
||||
}
|
||||
|
||||
bool TransferListSortModel::matchTrackerFilter(int sourceRow, const QModelIndex &sourceParent) const {
|
||||
if (!trackerFilterEnabled)
|
||||
return true;
|
||||
|
||||
TorrentModel *model = qobject_cast<TorrentModel *>(sourceModel());
|
||||
if (!model)
|
||||
return false;
|
||||
|
||||
return trackerFilter.contains(model->torrentHash(sourceRow));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue