mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 20:44:15 +00:00
Allow the user to disable filters from the side panel.
This commit is contained in:
parent
ff1aaa8733
commit
9b0ea3a055
@ -2231,6 +2231,36 @@ void Preferences::setTorImportGeometry(const QByteArray &geometry)
|
|||||||
setValue("TorrentImportDlg/dimensions", geometry);
|
setValue("TorrentImportDlg/dimensions", geometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Preferences::getStatusFilterState() const
|
||||||
|
{
|
||||||
|
return value("TransferListFilters/statusFilterState", true).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Preferences::setStatusFilterState(const bool checked)
|
||||||
|
{
|
||||||
|
setValue("TransferListFilters/statusFilterState", checked);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Preferences::getLabelFilterState() const
|
||||||
|
{
|
||||||
|
return value("TransferListFilters/labelFilterState", true).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Preferences::setLabelFilterState(const bool checked)
|
||||||
|
{
|
||||||
|
setValue("TransferListFilters/labelFilterState", checked);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Preferences::getTrackerFilterState() const
|
||||||
|
{
|
||||||
|
return value("TransferListFilters/trackerFilterState", true).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Preferences::setTrackerFilterState(const bool checked)
|
||||||
|
{
|
||||||
|
setValue("TransferListFilters/trackerFilterState", checked);
|
||||||
|
}
|
||||||
|
|
||||||
int Preferences::getTransSelFilter() const
|
int Preferences::getTransSelFilter() const
|
||||||
{
|
{
|
||||||
return value("TransferListFilters/selectedFilterIndex", 0).toInt();
|
return value("TransferListFilters/selectedFilterIndex", 0).toInt();
|
||||||
|
@ -500,6 +500,9 @@ public:
|
|||||||
void setTorImportLastContentDir(const QString &path);
|
void setTorImportLastContentDir(const QString &path);
|
||||||
QByteArray getTorImportGeometry() const;
|
QByteArray getTorImportGeometry() const;
|
||||||
void setTorImportGeometry(const QByteArray &geometry);
|
void setTorImportGeometry(const QByteArray &geometry);
|
||||||
|
bool getStatusFilterState() const;
|
||||||
|
bool getLabelFilterState() const;
|
||||||
|
bool getTrackerFilterState() const;
|
||||||
int getTransSelFilter() const;
|
int getTransSelFilter() const;
|
||||||
void setTransSelFilter(const int &index);
|
void setTransSelFilter(const int &index);
|
||||||
QByteArray getTransHeaderState() const;
|
QByteArray getTransHeaderState() const;
|
||||||
@ -528,6 +531,11 @@ public:
|
|||||||
QList<QByteArray> getHostNameCookies(const QString &host_name) const;
|
QList<QByteArray> getHostNameCookies(const QString &host_name) const;
|
||||||
QList<QNetworkCookie> getHostNameQNetworkCookies(const QString& host_name) const;
|
QList<QNetworkCookie> getHostNameQNetworkCookies(const QString& host_name) const;
|
||||||
void setHostNameCookies(const QString &host_name, const QList<QByteArray> &cookies);
|
void setHostNameCookies(const QString &host_name, const QList<QByteArray> &cookies);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setStatusFilterState(bool checked);
|
||||||
|
void setLabelFilterState(bool checked);
|
||||||
|
void setTrackerFilterState(bool checked);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PREFERENCES_H
|
#endif // PREFERENCES_H
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QResizeEvent>
|
#include <QResizeEvent>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QLabel>
|
#include <QCheckBox>
|
||||||
|
|
||||||
#include "transferlistdelegate.h"
|
#include "transferlistdelegate.h"
|
||||||
#include "transferlistwidget.h"
|
#include "transferlistwidget.h"
|
||||||
@ -84,6 +84,15 @@ QSize FiltersBase::minimumSizeHint() const
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FiltersBase::toggleFilter(bool checked)
|
||||||
|
{
|
||||||
|
setVisible(checked);
|
||||||
|
if (checked)
|
||||||
|
applyFilter(currentRow());
|
||||||
|
else
|
||||||
|
applyFilter(0);
|
||||||
|
}
|
||||||
|
|
||||||
StatusFiltersWidget::StatusFiltersWidget(QWidget *parent, TransferListWidget *transferList)
|
StatusFiltersWidget::StatusFiltersWidget(QWidget *parent, TransferListWidget *transferList)
|
||||||
: FiltersBase(parent, transferList)
|
: FiltersBase(parent, transferList)
|
||||||
{
|
{
|
||||||
@ -117,7 +126,9 @@ StatusFiltersWidget::StatusFiltersWidget(QWidget *parent, TransferListWidget *tr
|
|||||||
inactive->setData(Qt::DisplayRole, QVariant(tr("Inactive") + " (0)"));
|
inactive->setData(Qt::DisplayRole, QVariant(tr("Inactive") + " (0)"));
|
||||||
inactive->setData(Qt::DecorationRole, QIcon(":/icons/skin/filterinactive.png"));
|
inactive->setData(Qt::DecorationRole, QIcon(":/icons/skin/filterinactive.png"));
|
||||||
|
|
||||||
setCurrentRow(Preferences::instance()->getTransSelFilter(), QItemSelectionModel::SelectCurrent);
|
const Preferences* const pref = Preferences::instance();
|
||||||
|
setCurrentRow(pref->getTransSelFilter(), QItemSelectionModel::SelectCurrent);
|
||||||
|
toggleFilter(pref->getStatusFilterState());
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusFiltersWidget::~StatusFiltersWidget()
|
StatusFiltersWidget::~StatusFiltersWidget()
|
||||||
@ -164,11 +175,13 @@ LabelFiltersList::LabelFiltersList(QWidget *parent, TransferListWidget *transfer
|
|||||||
noLabel->setData(Qt::DisplayRole, QVariant(tr("Unlabeled (0)")));
|
noLabel->setData(Qt::DisplayRole, QVariant(tr("Unlabeled (0)")));
|
||||||
noLabel->setData(Qt::DecorationRole, IconProvider::instance()->getIcon("inode-directory"));
|
noLabel->setData(Qt::DecorationRole, IconProvider::instance()->getIcon("inode-directory"));
|
||||||
|
|
||||||
QStringList labelList = Preferences::instance()->getTorrentLabels();
|
const Preferences* const pref = Preferences::instance();
|
||||||
|
QStringList labelList = pref->getTorrentLabels();
|
||||||
for (int i=0; i < labelList.size(); ++i)
|
for (int i=0; i < labelList.size(); ++i)
|
||||||
addItem(labelList[i], false);
|
addItem(labelList[i], false);
|
||||||
|
|
||||||
setCurrentRow(0, QItemSelectionModel::SelectCurrent);
|
setCurrentRow(0, QItemSelectionModel::SelectCurrent);
|
||||||
|
toggleFilter(pref->getLabelFilterState());
|
||||||
}
|
}
|
||||||
|
|
||||||
LabelFiltersList::~LabelFiltersList()
|
LabelFiltersList::~LabelFiltersList()
|
||||||
@ -257,7 +270,6 @@ void LabelFiltersList::removeSelectedLabel()
|
|||||||
m_labels.remove(label);
|
m_labels.remove(label);
|
||||||
// Select first label
|
// Select first label
|
||||||
setCurrentRow(0, QItemSelectionModel::SelectCurrent);
|
setCurrentRow(0, QItemSelectionModel::SelectCurrent);
|
||||||
applyFilter(0);
|
|
||||||
// Un display filter
|
// Un display filter
|
||||||
delete takeItem(labelRow);
|
delete takeItem(labelRow);
|
||||||
transferList->removeLabelFromRows(label);
|
transferList->removeLabelFromRows(label);
|
||||||
@ -412,6 +424,7 @@ TrackerFiltersList::TrackerFiltersList(QWidget *parent, TransferListWidget *tran
|
|||||||
setCurrentRow(0, QItemSelectionModel::SelectCurrent);
|
setCurrentRow(0, QItemSelectionModel::SelectCurrent);
|
||||||
connect(m_downloader, SIGNAL(downloadFinished(QString, QString)), SLOT(handleFavicoDownload(QString, QString)));
|
connect(m_downloader, SIGNAL(downloadFinished(QString, QString)), SLOT(handleFavicoDownload(QString, QString)));
|
||||||
connect(m_downloader, SIGNAL(downloadFailure(QString, QString)), SLOT(handleFavicoFailure(QString, QString)));
|
connect(m_downloader, SIGNAL(downloadFailure(QString, QString)), SLOT(handleFavicoFailure(QString, QString)));
|
||||||
|
toggleFilter(Preferences::instance()->getTrackerFilterState());
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackerFiltersList::~TrackerFiltersList()
|
TrackerFiltersList::~TrackerFiltersList()
|
||||||
@ -449,14 +462,14 @@ void TrackerFiltersList::addItem(const QString &tracker, const QString &hash)
|
|||||||
if (host == "") {
|
if (host == "") {
|
||||||
trackerItem->setText(tr("Trackerless (%1)").arg(tmp.size()));
|
trackerItem->setText(tr("Trackerless (%1)").arg(tmp.size()));
|
||||||
if (currentRow() == 1)
|
if (currentRow() == 1)
|
||||||
emit currentRowChanged(1);
|
applyFilter(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
trackerItem->setText(tr("%1 (%2)", "openbittorrent.com (10)").arg(host).arg(tmp.size()));
|
trackerItem->setText(tr("%1 (%2)", "openbittorrent.com (10)").arg(host).arg(tmp.size()));
|
||||||
if (exists) {
|
if (exists) {
|
||||||
if (currentRow() == rowFromTracker(host))
|
if (currentRow() == rowFromTracker(host))
|
||||||
emit currentRowChanged(currentRow());
|
applyFilter(currentRow());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -507,7 +520,7 @@ void TrackerFiltersList::removeItem(const QString &tracker, const QString &hash)
|
|||||||
|
|
||||||
m_trackers.insert(host, tmp);
|
m_trackers.insert(host, tmp);
|
||||||
if (currentRow() == row)
|
if (currentRow() == row)
|
||||||
emit currentRowChanged(row);
|
applyFilter(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackerFiltersList::changeTrackerless(bool trackerless, const QString &hash)
|
void TrackerFiltersList::changeTrackerless(bool trackerless, const QString &hash)
|
||||||
@ -577,7 +590,7 @@ void TrackerFiltersList::applyFilter(int row)
|
|||||||
{
|
{
|
||||||
if (row == 0)
|
if (row == 0)
|
||||||
transferList->applyTrackerFilterAll();
|
transferList->applyTrackerFilterAll();
|
||||||
else
|
else if (isVisible())
|
||||||
transferList->applyTrackerFilter(getHashes(row));
|
transferList->applyTrackerFilter(getHashes(row));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -653,41 +666,50 @@ TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferLi
|
|||||||
: QFrame(parent)
|
: QFrame(parent)
|
||||||
, statusFilters(0)
|
, statusFilters(0)
|
||||||
, trackerFilters(0)
|
, trackerFilters(0)
|
||||||
, torrentsLabel(0)
|
, trackerLabel(0)
|
||||||
{
|
{
|
||||||
|
Preferences* const pref = Preferences::instance();
|
||||||
// Construct lists
|
// Construct lists
|
||||||
QVBoxLayout *vLayout = new QVBoxLayout(this);
|
QVBoxLayout *vLayout = new QVBoxLayout(this);
|
||||||
vLayout->setContentsMargins(0, 4, 0, 0);
|
vLayout->setContentsMargins(0, 4, 0, 0);
|
||||||
QFont font;
|
QFont font;
|
||||||
font.setBold(true);
|
font.setBold(true);
|
||||||
font.setCapitalization(QFont::SmallCaps);
|
font.setCapitalization(QFont::SmallCaps);
|
||||||
torrentsLabel = new QLabel(tr("Torrents"), this);
|
QCheckBox * statusLabel = new QCheckBox(tr("Status"), this);
|
||||||
torrentsLabel->setIndent(2);
|
statusLabel->setChecked(pref->getStatusFilterState());
|
||||||
torrentsLabel->setFont(font);
|
statusLabel->setFont(font);
|
||||||
vLayout->addWidget(torrentsLabel);
|
vLayout->addWidget(statusLabel);
|
||||||
statusFilters = new StatusFiltersWidget(this, transferList);
|
statusFilters = new StatusFiltersWidget(this, transferList);
|
||||||
vLayout->addWidget(statusFilters);
|
vLayout->addWidget(statusFilters);
|
||||||
QLabel *labelsLabel = new QLabel(tr("Labels"), this);
|
QCheckBox *labelLabel = new QCheckBox(tr("Labels"), this);
|
||||||
labelsLabel->setIndent(2);
|
labelLabel->setChecked(pref->getLabelFilterState());
|
||||||
labelsLabel->setFont(font);
|
labelLabel->setFont(font);
|
||||||
vLayout->addWidget(labelsLabel);
|
vLayout->addWidget(labelLabel);
|
||||||
LabelFiltersList *labelFilters = new LabelFiltersList(this, transferList);
|
LabelFiltersList *labelFilters = new LabelFiltersList(this, transferList);
|
||||||
vLayout->addWidget(labelFilters);
|
vLayout->addWidget(labelFilters);
|
||||||
QLabel *trackersLabel = new QLabel(tr("Trackers"), this);
|
trackerLabel = new QCheckBox(tr("Trackers"), this);
|
||||||
trackersLabel->setIndent(2);
|
trackerLabel->setChecked(pref->getTrackerFilterState());
|
||||||
trackersLabel->setFont(font);
|
trackerLabel->setFont(font);
|
||||||
vLayout->addWidget(trackersLabel);
|
vLayout->addWidget(trackerLabel);
|
||||||
trackerFilters = new TrackerFiltersList(this, transferList);
|
trackerFilters = new TrackerFiltersList(this, transferList);
|
||||||
vLayout->addWidget(trackerFilters);
|
vLayout->addWidget(trackerFilters);
|
||||||
setLayout(vLayout);
|
setLayout(vLayout);
|
||||||
setContentsMargins(0,0,0,0);
|
setContentsMargins(0,0,0,0);
|
||||||
vLayout->setSpacing(2);
|
vLayout->setSpacing(2);
|
||||||
|
vLayout->addStretch();
|
||||||
|
|
||||||
|
connect(statusLabel, SIGNAL(toggled(bool)), statusFilters, SLOT(toggleFilter(bool)));
|
||||||
|
connect(statusLabel, SIGNAL(toggled(bool)), pref, SLOT(setStatusFilterState(const bool)));
|
||||||
|
connect(labelLabel, SIGNAL(toggled(bool)), labelFilters, SLOT(toggleFilter(bool)));
|
||||||
|
connect(labelLabel, SIGNAL(toggled(bool)), pref, SLOT(setLabelFilterState(const bool)));
|
||||||
|
connect(trackerLabel, SIGNAL(toggled(bool)), trackerFilters, SLOT(toggleFilter(bool)));
|
||||||
|
connect(trackerLabel, SIGNAL(toggled(bool)), pref, SLOT(setTrackerFilterState(const bool)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListFiltersWidget::resizeEvent(QResizeEvent *event)
|
void TransferListFiltersWidget::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
int height = event->size().height();
|
int height = event->size().height();
|
||||||
int minHeight = statusFilters->height() + (3 * torrentsLabel->height());
|
int minHeight = statusFilters->height() + (3 * trackerLabel->height());
|
||||||
trackerFilters->setMinimumHeight((height - minHeight) / 2);
|
trackerFilters->setMinimumHeight((height - minHeight) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QResizeEvent;
|
class QResizeEvent;
|
||||||
class QLabel;
|
class QCheckBox;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
class TransferListWidget;
|
class TransferListWidget;
|
||||||
@ -54,6 +54,9 @@ public:
|
|||||||
virtual QSize sizeHint() const;
|
virtual QSize sizeHint() const;
|
||||||
virtual QSize minimumSizeHint() const;
|
virtual QSize minimumSizeHint() const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void toggleFilter(bool checked);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TransferListWidget *transferList;
|
TransferListWidget *transferList;
|
||||||
|
|
||||||
@ -172,7 +175,7 @@ private:
|
|||||||
StatusFiltersWidget *statusFilters;
|
StatusFiltersWidget *statusFilters;
|
||||||
TrackerFiltersList *trackerFilters;
|
TrackerFiltersList *trackerFilters;
|
||||||
//for use in resizeEvent()
|
//for use in resizeEvent()
|
||||||
QLabel *torrentsLabel;
|
QCheckBox *trackerLabel;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TRANSFERLISTFILTERSWIDGET_H
|
#endif // TRANSFERLISTFILTERSWIDGET_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user