[#2754] [GTKUI] Fix Deluge isn't sorting torrents properly

This commit is contained in:
bendikro 2015-09-17 19:36:36 +02:00 committed by Calum Lind
parent 8485fd591b
commit 1557bf8882
2 changed files with 15 additions and 3 deletions

View File

@ -597,14 +597,14 @@ class ListView:
def add_progress_column(self, header, col_types=[float, str], sortid=0,
hidden=False, position=None, status_field=None,
function=None, column_type="progress",
tooltip=None, default=True):
tooltip=None, sort_func=None, default=True):
"""Add a progress column to the listview."""
render = gtk.CellRendererProgress()
self.add_column(header, render, col_types, hidden, position,
status_field, sortid, function=function,
column_type=column_type, value=0, text=1,
tooltip=tooltip, default=default)
tooltip=tooltip, sort_func=sort_func, default=default)
return True

View File

@ -71,6 +71,17 @@ def seed_peer_column_sort(model, iter1, iter2, data):
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):
def __init__(self, torrentview):
self.torrentview = torrentview
@ -244,7 +255,8 @@ class TorrentView(ListView, component.Component):
self.add_progress_column(_("Progress"),
status_field=["progress", "state"],
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],
status_field=["num_seeds", "total_seeds"],
sort_func=seed_peer_column_sort, default=False)