mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Update naturalSorting in the Peers tab.
This commit is contained in:
parent
d09b0d5f72
commit
6e9ed4ead7
@ -43,25 +43,19 @@ public:
|
||||
|
||||
protected:
|
||||
bool lessThan(const QModelIndex &left, const QModelIndex &right) const {
|
||||
if (sortColumn() == PeerListDelegate::IP) {
|
||||
const QStringList ipLeft = sourceModel()->data(left).toString().split('.');
|
||||
const QStringList ipRight = sourceModel()->data(right).toString().split('.');
|
||||
if ((ipRight.size() & ipLeft.size()) != 4) // One row in model
|
||||
return false;
|
||||
Q_ASSERT(ipLeft.size() == 4);
|
||||
Q_ASSERT(ipRight.size() == 4);
|
||||
if (sortColumn() == PeerListDelegate::IP || sortColumn() == PeerListDelegate::CLIENT) {
|
||||
QVariant vL = sourceModel()->data(left);
|
||||
QVariant vR = sourceModel()->data(right);
|
||||
if (!(vL.isValid() && vR.isValid()))
|
||||
return QSortFilterProxyModel::lessThan(left, right);
|
||||
Q_ASSERT(vL.isValid());
|
||||
Q_ASSERT(vR.isValid());
|
||||
|
||||
int i = 0;
|
||||
while (i < 4) {
|
||||
int l = ipLeft.at(i).toInt();
|
||||
int r = ipRight.at(i).toInt();
|
||||
if (l < r)
|
||||
return true;
|
||||
else if (l > r)
|
||||
return false;
|
||||
++i;
|
||||
}
|
||||
return false;
|
||||
bool res = false;
|
||||
if (misc::naturalSort(vL.toString(), vR.toString(), res))
|
||||
return res;
|
||||
|
||||
return QSortFilterProxyModel::lessThan(left, right);
|
||||
}
|
||||
return QSortFilterProxyModel::lessThan(left, right);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user