From 5156399c681d6a47ceb47d99fed7130ac4b9f507 Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Thu, 21 Dec 2017 02:49:29 +0200 Subject: [PATCH 1/2] Fix sorting of country flags column in Peers tab. --- src/gui/properties/peerlistsortmodel.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/gui/properties/peerlistsortmodel.h b/src/gui/properties/peerlistsortmodel.h index 451749b2c..83c4f715e 100644 --- a/src/gui/properties/peerlistsortmodel.h +++ b/src/gui/properties/peerlistsortmodel.h @@ -53,17 +53,11 @@ protected: const QString strL = left.data().toString(); const QString strR = right.data().toString(); const int result = Utils::String::naturalCompare(strL, strR, Qt::CaseInsensitive); - if (result != 0) - return (result < 0); - - return (left < right); - } + return (result < 0); + } break; default: - if (left.data() != right.data()) - return QSortFilterProxyModel::lessThan(left, right); - - return (left < right); + return QSortFilterProxyModel::lessThan(left, right); }; } }; From 99abc21dab6f99e99a4b3dd47cf838593557221c Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Thu, 21 Dec 2017 15:26:28 +0200 Subject: [PATCH 2/2] Simplify sorting code. --- src/gui/categoryfilterproxymodel.cpp | 4 +--- src/gui/search/searchsortmodel.cpp | 12 +++--------- src/gui/tagfilterproxymodel.cpp | 5 +---- src/gui/transferlistsortmodel.cpp | 5 +---- 4 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/gui/categoryfilterproxymodel.cpp b/src/gui/categoryfilterproxymodel.cpp index 9c7a724b7..d9ba958ca 100644 --- a/src/gui/categoryfilterproxymodel.cpp +++ b/src/gui/categoryfilterproxymodel.cpp @@ -54,8 +54,6 @@ bool CategoryFilterProxyModel::lessThan(const QModelIndex &left, const QModelInd int result = Utils::String::naturalCompare(left.data().toString(), right.data().toString() , Qt::CaseInsensitive); - if (result != 0) - return (result < 0); - return (left < right); + return (result < 0); } diff --git a/src/gui/search/searchsortmodel.cpp b/src/gui/search/searchsortmodel.cpp index 8e5a54cd4..a41be4a68 100644 --- a/src/gui/search/searchsortmodel.cpp +++ b/src/gui/search/searchsortmodel.cpp @@ -113,17 +113,11 @@ bool SearchSortModel::lessThan(const QModelIndex &left, const QModelIndex &right const QString strL = left.data().toString(); const QString strR = right.data().toString(); const int result = Utils::String::naturalCompare(strL, strR, Qt::CaseInsensitive); - if (result != 0) - return (result < 0); - - return (left < right); - } + return (result < 0); + } break; default: - if (left.data() != right.data()) - return base::lessThan(left, right); - - return (left < right); + return base::lessThan(left, right); }; } diff --git a/src/gui/tagfilterproxymodel.cpp b/src/gui/tagfilterproxymodel.cpp index c80d9cfbb..c73d2e7ec 100644 --- a/src/gui/tagfilterproxymodel.cpp +++ b/src/gui/tagfilterproxymodel.cpp @@ -54,8 +54,5 @@ bool TagFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &r int result = Utils::String::naturalCompare(left.data().toString(), right.data().toString() , Qt::CaseInsensitive); - if (result != 0) - return (result < 0); - - return (left < right); + return (result < 0); } diff --git a/src/gui/transferlistsortmodel.cpp b/src/gui/transferlistsortmodel.cpp index 513db5b9d..e57b35baf 100644 --- a/src/gui/transferlistsortmodel.cpp +++ b/src/gui/transferlistsortmodel.cpp @@ -95,10 +95,7 @@ bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex return lowerPositionThan(left, right); const int result = Utils::String::naturalCompare(vL.toString(), vR.toString(), Qt::CaseInsensitive); - if (result != 0) - return (result < 0); - - return (left < right); + return (result < 0); } case TorrentModel::TR_ADD_DATE: