mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 21:14:33 +00:00
Merge pull request #14540 from jagannatharjun/remember
Remember sub sort column of transfer list
This commit is contained in:
commit
f6ab1d63e8
@ -61,10 +61,17 @@ namespace
|
|||||||
return 0;
|
return 0;
|
||||||
return isLeftValid ? -1 : 1;
|
return isLeftValid ? -1 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int adjustSubSortColumn(const int column)
|
||||||
|
{
|
||||||
|
return ((column >= 0) && (column < TransferListModel::NB_COLUMNS))
|
||||||
|
? column : TransferListModel::TR_NAME;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TransferListSortModel::TransferListSortModel(QObject *parent)
|
TransferListSortModel::TransferListSortModel(QObject *parent)
|
||||||
: QSortFilterProxyModel {parent}
|
: QSortFilterProxyModel {parent}
|
||||||
|
, m_subSortColumn {"TransferList/SubSortColumn", TransferListModel::TR_NAME, adjustSubSortColumn}
|
||||||
{
|
{
|
||||||
setSortRole(TransferListModel::UnderlyingDataRole);
|
setSortRole(TransferListModel::UnderlyingDataRole);
|
||||||
}
|
}
|
||||||
@ -186,14 +193,15 @@ bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex
|
|||||||
{
|
{
|
||||||
Q_ASSERT(left.column() == right.column());
|
Q_ASSERT(left.column() == right.column());
|
||||||
|
|
||||||
if (m_sortColumn != left.column())
|
if (m_lastSortColumn != left.column())
|
||||||
{
|
{
|
||||||
m_subSortColumn = m_sortColumn;
|
if (m_lastSortColumn != -1)
|
||||||
m_sortColumn = left.column();
|
m_subSortColumn = m_lastSortColumn;
|
||||||
|
m_lastSortColumn = left.column();
|
||||||
}
|
}
|
||||||
|
|
||||||
const int result = compare(left, right);
|
const int result = compare(left, right);
|
||||||
if ((result == 0) && (m_subSortColumn != -1))
|
if (result == 0)
|
||||||
return compare(left.sibling(left.row(), m_subSortColumn), right.sibling(right.row(), m_subSortColumn)) < 0;
|
return compare(left.sibling(left.row(), m_subSortColumn), right.sibling(right.row(), m_subSortColumn)) < 0;
|
||||||
|
|
||||||
return result < 0;
|
return result < 0;
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
|
#include "base/settingvalue.h"
|
||||||
#include "base/torrentfilter.h"
|
#include "base/torrentfilter.h"
|
||||||
|
|
||||||
namespace BitTorrent
|
namespace BitTorrent
|
||||||
@ -61,6 +62,6 @@ private:
|
|||||||
bool matchFilter(int sourceRow, const QModelIndex &sourceParent) const;
|
bool matchFilter(int sourceRow, const QModelIndex &sourceParent) const;
|
||||||
|
|
||||||
TorrentFilter m_filter;
|
TorrentFilter m_filter;
|
||||||
mutable int m_subSortColumn = -1;
|
mutable CachedSettingValue<int> m_subSortColumn;
|
||||||
mutable int m_sortColumn = -1;
|
mutable int m_lastSortColumn = -1;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user