Skip to content

Commit

Permalink
Fix incorrect sorting by "private" column
Browse files Browse the repository at this point in the history
  • Loading branch information
glassez committed Jul 15, 2024
1 parent 96607ce commit 558799f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/gui/transferlistsortmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ namespace
int customCompare(const TagSet &left, const TagSet &right, const Utils::Compare::NaturalCompare<Qt::CaseInsensitive> &compare)
{
for (auto leftIter = left.cbegin(), rightIter = right.cbegin();
(leftIter != left.cend()) && (rightIter != right.cend());
++leftIter, ++rightIter)
(leftIter != left.cend()) && (rightIter != right.cend());
++leftIter, ++rightIter)
{
const int result = compare(leftIter->toString(), rightIter->toString());
if (result != 0)
Expand All @@ -84,6 +84,17 @@ namespace
return isLeftValid ? -1 : 1;
}

int compareAsBool(const QVariant &left, const QVariant &right)
{
const bool leftValid = left.isValid();
const bool rightValid = right.isValid();
if (leftValid && rightValid)
return threeWayCompare(left.toBool(), right.toBool());
if (!leftValid && !rightValid)
return 0;
return leftValid ? -1 : 1;
}

int adjustSubSortColumn(const int column)
{
return ((column >= 0) && (column < TransferListModel::NB_COLUMNS))
Expand Down Expand Up @@ -214,6 +225,9 @@ int TransferListSortModel::compare(const QModelIndex &left, const QModelIndex &r
case TransferListModel::TR_UPSPEED:
return customCompare(leftValue.toInt(), rightValue.toInt());

case TransferListModel::TR_PRIVATE:
return compareAsBool(leftValue, rightValue);

case TransferListModel::TR_PEERS:
case TransferListModel::TR_SEEDS:
{
Expand Down
1 change: 1 addition & 0 deletions src/webui/api/synccontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ namespace
case QMetaType::UInt:
case QMetaType::QDateTime:
case QMetaType::Nullptr:
case QMetaType::UnknownType:
if (prevData[key] != value)
syncData[key] = value;
break;
Expand Down

0 comments on commit 558799f

Please sign in to comment.