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