[#2754] [GTKUI] Fix Deluge isn't sorting torrents properly
This commit is contained in:
parent
6032c25813
commit
bfb202086d
|
@ -429,8 +429,6 @@ class ListView:
|
||||||
if self.liststore is not None:
|
if self.liststore is not None:
|
||||||
self.liststore.foreach(copy_row, (new_list, self.columns))
|
self.liststore.foreach(copy_row, (new_list, self.columns))
|
||||||
self.liststore = new_list
|
self.liststore = new_list
|
||||||
self.create_model_filter()
|
|
||||||
return
|
|
||||||
|
|
||||||
def update_treeview_column(self, header, add=True):
|
def update_treeview_column(self, header, add=True):
|
||||||
"""Update TreeViewColumn based on ListView column mappings"""
|
"""Update TreeViewColumn based on ListView column mappings"""
|
||||||
|
@ -503,6 +501,8 @@ class ListView:
|
||||||
del self.liststore_columns[index]
|
del self.liststore_columns[index]
|
||||||
# Create a new liststore
|
# Create a new liststore
|
||||||
self.create_new_liststore()
|
self.create_new_liststore()
|
||||||
|
# Create new model for the treeview
|
||||||
|
self.create_model_filter()
|
||||||
|
|
||||||
# Re-create the menu
|
# Re-create the menu
|
||||||
self.create_checklist_menu()
|
self.create_checklist_menu()
|
||||||
|
@ -547,7 +547,11 @@ class ListView:
|
||||||
# Create a new list with the added column
|
# Create a new list with the added column
|
||||||
self.create_new_liststore()
|
self.create_new_liststore()
|
||||||
|
|
||||||
if column_type == None:
|
# Happens only on columns added after the torrent list has been loaded
|
||||||
|
if self.model_filter:
|
||||||
|
self.create_model_filter()
|
||||||
|
|
||||||
|
if column_type is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
self.update_treeview_column(header)
|
self.update_treeview_column(header)
|
||||||
|
@ -630,15 +634,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",
|
||||||
default=True):
|
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,
|
||||||
default=default)
|
sort_func=sort_func, default=default)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def add_texticon_column(self, header, col_types=[str, str], sortid=1,
|
def add_texticon_column(self, header, col_types=[str, str], sortid=1,
|
||||||
|
|
|
@ -210,6 +210,17 @@ def seed_peer_column_sort(model, iter1, iter2, data):
|
||||||
return queue_peer_seed_sort_function(v2, v4)
|
return queue_peer_seed_sort_function(v2, v4)
|
||||||
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 TorrentView(listview.ListView, component.Component):
|
class TorrentView(listview.ListView, component.Component):
|
||||||
"""TorrentView handles the listing of torrents."""
|
"""TorrentView handles the listing of torrents."""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -256,7 +267,8 @@ class TorrentView(listview.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=cell_data_progress)
|
function=cell_data_progress,
|
||||||
|
sort_func=progress_sort)
|
||||||
self.add_func_column(_("Seeders"), listview.cell_data_peer, [int, int],
|
self.add_func_column(_("Seeders"), listview.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…
Reference in New Issue