On `queue_column_sort` and `seed_peer_column_sort`, sorting is now made on a separate function, `queue_peer_seed_sort_function` so that code can be re-used and only the necessary treemodel lookups are made.

This commit is contained in:
Pedro Algarvio 2010-03-08 03:08:13 +00:00
parent 238e183851
commit 739636cc0b
1 changed files with 9 additions and 10 deletions

View File

@ -120,9 +120,7 @@ def cell_data_queue(column, cell, model, row, data):
else: else:
cell.set_property("text", value + 1) cell.set_property("text", value + 1)
def queue_column_sort(model, iter1, iter2, data): def queue_peer_seed_sort_function(v1, v2):
v1 = model[iter1][data]
v2 = model[iter2][data]
if v1 == v2: if v1 == v2:
return 0 return 0
if v2 < 0: if v2 < 0:
@ -134,6 +132,12 @@ def queue_column_sort(model, iter1, iter2, data):
if v2 > v1: if v2 > v1:
return -1 return -1
def queue_column_sort(model, iter1, iter2, data):
v1 = model[iter1][data]
v2 = model[iter2][data]
return queue_peer_seed_sort_function(v1, v2)
def eta_column_sort(model, iter1, iter2, data): def eta_column_sort(model, iter1, iter2, data):
v1 = model[iter1][data] v1 = model[iter1][data]
v2 = model[iter2][data] v2 = model[iter2][data]
@ -154,13 +158,8 @@ def seed_peer_column_sort(model, iter1, iter2, data):
if v1 == v3: if v1 == v3:
v2 = model[iter1][data+1] # total seeds/peers v2 = model[iter1][data+1] # total seeds/peers
v4 = model[iter2][data+1] # total seeds/peers v4 = model[iter2][data+1] # total seeds/peers
if v2 == v4: return queue_peer_seed_sort_function(v2, v4)
return 0 return queue_peer_seed_sort_function(v1, v3)
if v2 > v4:
return 1
if v2 < v4:
return -1
return queue_column_sort(model, iter1, iter2, data)
class TorrentView(listview.ListView, component.Component): class TorrentView(listview.ListView, component.Component):
"""TorrentView handles the listing of torrents.""" """TorrentView handles the listing of torrents."""