mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 20:44:15 +00:00
Follow project coding style. Issue #2192.
This commit is contained in:
parent
d2ffbc44f1
commit
98350bae5d
@ -38,16 +38,19 @@ TransferListSortModel::TransferListSortModel(QObject *parent)
|
||||
, filter0(TorrentFilter::ALL)
|
||||
, labelFilterEnabled(false)
|
||||
, trackerFilterEnabled(false)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
void TransferListSortModel::setStatusFilter(const TorrentFilter::TorrentFilter &filter) {
|
||||
void TransferListSortModel::setStatusFilter(const TorrentFilter::TorrentFilter &filter)
|
||||
{
|
||||
if (filter != filter0) {
|
||||
filter0 = filter;
|
||||
invalidateFilter();
|
||||
}
|
||||
}
|
||||
|
||||
void TransferListSortModel::setLabelFilter(const QString &label) {
|
||||
void TransferListSortModel::setLabelFilter(const QString &label)
|
||||
{
|
||||
if (!labelFilterEnabled || labelFilter != label) {
|
||||
labelFilterEnabled = true;
|
||||
labelFilter = label;
|
||||
@ -55,7 +58,8 @@ void TransferListSortModel::setLabelFilter(const QString &label) {
|
||||
}
|
||||
}
|
||||
|
||||
void TransferListSortModel::disableLabelFilter() {
|
||||
void TransferListSortModel::disableLabelFilter()
|
||||
{
|
||||
if (labelFilterEnabled) {
|
||||
labelFilterEnabled = false;
|
||||
labelFilter = QString();
|
||||
@ -63,7 +67,8 @@ void TransferListSortModel::disableLabelFilter() {
|
||||
}
|
||||
}
|
||||
|
||||
void TransferListSortModel::setTrackerFilter(const QStringList &hashes) {
|
||||
void TransferListSortModel::setTrackerFilter(const QStringList &hashes)
|
||||
{
|
||||
if (!trackerFilterEnabled || trackerFilter != hashes) {
|
||||
trackerFilterEnabled = true;
|
||||
trackerFilter = hashes;
|
||||
@ -71,7 +76,8 @@ void TransferListSortModel::setTrackerFilter(const QStringList &hashes) {
|
||||
}
|
||||
}
|
||||
|
||||
void TransferListSortModel::disableTrackerFilter() {
|
||||
void TransferListSortModel::disableTrackerFilter()
|
||||
{
|
||||
if (trackerFilterEnabled) {
|
||||
trackerFilterEnabled = false;
|
||||
trackerFilter = QStringList();
|
||||
@ -79,7 +85,8 @@ void TransferListSortModel::disableTrackerFilter() {
|
||||
}
|
||||
}
|
||||
|
||||
bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex &right) const {
|
||||
bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
|
||||
{
|
||||
const int column = sortColumn();
|
||||
|
||||
if (column == TorrentModelItem::TR_NAME) {
|
||||
@ -200,26 +207,31 @@ bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex
|
||||
|
||||
return dateL < dateR;
|
||||
}
|
||||
else
|
||||
else {
|
||||
return prioL < prioR;
|
||||
}
|
||||
else if ((invalidL == false) && (invalidR == false))
|
||||
}
|
||||
else if ((invalidL == false) && (invalidR == false)) {
|
||||
return QSortFilterProxyModel::lessThan(left, right);
|
||||
else
|
||||
}
|
||||
else {
|
||||
return !invalidL;
|
||||
}
|
||||
}
|
||||
|
||||
return QSortFilterProxyModel::lessThan(left, right);
|
||||
}
|
||||
|
||||
bool TransferListSortModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const {
|
||||
bool TransferListSortModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||
{
|
||||
return matchStatusFilter(sourceRow, sourceParent)
|
||||
&& matchLabelFilter(sourceRow, sourceParent)
|
||||
&& matchTrackerFilter(sourceRow, sourceParent)
|
||||
&& QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent);
|
||||
}
|
||||
|
||||
bool TransferListSortModel::matchStatusFilter(int sourceRow, const QModelIndex &sourceParent) const {
|
||||
bool TransferListSortModel::matchStatusFilter(int sourceRow, const QModelIndex &sourceParent) const
|
||||
{
|
||||
if (filter0 == TorrentFilter::ALL)
|
||||
return true;
|
||||
QAbstractItemModel *model = sourceModel();
|
||||
@ -271,7 +283,8 @@ bool TransferListSortModel::matchStatusFilter(int sourceRow, const QModelIndex &
|
||||
}
|
||||
}
|
||||
|
||||
bool TransferListSortModel::matchLabelFilter(int sourceRow, const QModelIndex &sourceParent) const {
|
||||
bool TransferListSortModel::matchLabelFilter(int sourceRow, const QModelIndex &sourceParent) const
|
||||
{
|
||||
if (!labelFilterEnabled)
|
||||
return true;
|
||||
|
||||
@ -282,7 +295,8 @@ 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 {
|
||||
bool TransferListSortModel::matchTrackerFilter(int sourceRow, const QModelIndex &sourceParent) const
|
||||
{
|
||||
if (!trackerFilterEnabled)
|
||||
return true;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user