|
|
@ -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); |
|
|
|
} |
|
|
|
} |
|
|
|