Merge pull request #14717 from Chocobo1/ncmp

Simplify natural sort classes interface
This commit is contained in:
Chocobo1
2021-04-13 14:22:25 +08:00
committed by GitHub
24 changed files with 235 additions and 177 deletions

View File

@@ -28,7 +28,6 @@
#include "peerlistsortmodel.h"
#include "base/utils/string.h"
#include "peerlistwidget.h"
PeerListSortModel::PeerListSortModel(QObject *parent)
@@ -43,11 +42,10 @@ bool PeerListSortModel::lessThan(const QModelIndex &left, const QModelIndex &rig
{
case PeerListWidget::IP:
case PeerListWidget::CLIENT:
{
{
const QString strL = left.data(UnderlyingDataRole).toString();
const QString strR = right.data(UnderlyingDataRole).toString();
const int result = Utils::String::naturalCompare(strL, strR, Qt::CaseInsensitive);
return (result < 0);
return m_naturalLessThan(strL, strR);
}
break;
default:

View File

@@ -30,6 +30,8 @@
#include <QSortFilterProxyModel>
#include "base/utils/compare.h"
class PeerListSortModel final : public QSortFilterProxyModel
{
Q_OBJECT
@@ -45,4 +47,6 @@ public:
private:
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
Utils::Compare::NaturalLessThan<Qt::CaseInsensitive> m_naturalLessThan;
};