Skip to content

Commit

Permalink
Merge pull request #1136 from vktr/feature/sort-by-status
Browse files Browse the repository at this point in the history
Sort by status
  • Loading branch information
vktr committed Feb 19, 2021
2 parents 7c4cef0 + 01accd4 commit 2649978
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/picotorrent/ui/models/torrentlistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ int TorrentListModel::Compare(const wxDataViewItem& item1, const wxDataViewItem&
if (lhs.totalWantedRemaining == rhs.totalWantedRemaining) { return hashSort(ascending, lhs, rhs); }
break;
}
case Columns::Status:
{
if (lhs.state < rhs.state) { return ascending ? -1 : 1; }
if (lhs.state > rhs.state) { return ascending ? 1 : -1; }
if (lhs.state == rhs.state) { return hashSort(ascending, lhs, rhs); }
break;
}
case Columns::Progress:
{
if (lhs.progress < rhs.progress) { return ascending ? -1 : 1; }
Expand Down
2 changes: 1 addition & 1 deletion src/picotorrent/ui/torrentlistview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ TorrentListView::TorrentListView(wxWindow* parent, wxWindowID id, Models::Torren
TorrentListModel::Columns::Status,
FromDIP(120),
wxALIGN_NOT,
wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_RESIZABLE)));
defaultFlags)));

m_columns.push_back(
ColumnMetadata(
Expand Down

0 comments on commit 2649978

Please sign in to comment.