mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-02 22:48:40 +00:00
[#2754] [GTKUI] Fix Deluge isn't sorting torrents properly
This commit is contained in:
parent
8485fd591b
commit
1557bf8882
2 changed files with 15 additions and 3 deletions
|
@ -597,14 +597,14 @@ class ListView:
|
||||||
def add_progress_column(self, header, col_types=[float, str], sortid=0,
|
def add_progress_column(self, header, col_types=[float, str], sortid=0,
|
||||||
hidden=False, position=None, status_field=None,
|
hidden=False, position=None, status_field=None,
|
||||||
function=None, column_type="progress",
|
function=None, column_type="progress",
|
||||||
tooltip=None, default=True):
|
tooltip=None, sort_func=None, default=True):
|
||||||
"""Add a progress column to the listview."""
|
"""Add a progress column to the listview."""
|
||||||
|
|
||||||
render = gtk.CellRendererProgress()
|
render = gtk.CellRendererProgress()
|
||||||
self.add_column(header, render, col_types, hidden, position,
|
self.add_column(header, render, col_types, hidden, position,
|
||||||
status_field, sortid, function=function,
|
status_field, sortid, function=function,
|
||||||
column_type=column_type, value=0, text=1,
|
column_type=column_type, value=0, text=1,
|
||||||
tooltip=tooltip, default=default)
|
tooltip=tooltip, sort_func=sort_func, default=default)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,17 @@ def seed_peer_column_sort(model, iter1, iter2, data):
|
||||||
return queue_peer_seed_sort_function(v1, v3)
|
return queue_peer_seed_sort_function(v1, v3)
|
||||||
|
|
||||||
|
|
||||||
|
def progress_sort(model, iter1, iter2, sort_column_id):
|
||||||
|
progress1 = model[iter1][sort_column_id]
|
||||||
|
progress2 = model[iter2][sort_column_id]
|
||||||
|
# Progress value is equal, so sort on state
|
||||||
|
if progress1 == progress2:
|
||||||
|
state1 = model[iter1][sort_column_id + 1]
|
||||||
|
state2 = model[iter2][sort_column_id + 1]
|
||||||
|
return cmp(state1, state2)
|
||||||
|
return cmp(progress1, progress2)
|
||||||
|
|
||||||
|
|
||||||
class SearchBox(object):
|
class SearchBox(object):
|
||||||
def __init__(self, torrentview):
|
def __init__(self, torrentview):
|
||||||
self.torrentview = torrentview
|
self.torrentview = torrentview
|
||||||
|
@ -244,7 +255,8 @@ class TorrentView(ListView, component.Component):
|
||||||
self.add_progress_column(_("Progress"),
|
self.add_progress_column(_("Progress"),
|
||||||
status_field=["progress", "state"],
|
status_field=["progress", "state"],
|
||||||
col_types=[float, str],
|
col_types=[float, str],
|
||||||
function=funcs.cell_data_progress)
|
function=funcs.cell_data_progress,
|
||||||
|
sort_func=progress_sort)
|
||||||
self.add_func_column(_("Seeds"), funcs.cell_data_peer, [int, int],
|
self.add_func_column(_("Seeds"), funcs.cell_data_peer, [int, int],
|
||||||
status_field=["num_seeds", "total_seeds"],
|
status_field=["num_seeds", "total_seeds"],
|
||||||
sort_func=seed_peer_column_sort, default=False)
|
sort_func=seed_peer_column_sort, default=False)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue