Module: deluge
Branch: master
Commit: 739636cc0beca34b74414efe97ddcefd08fb9b28

Author: Pedro Algarvio <[email protected]>
Date:   Mon Mar  8 03:08:13 2010 +0000

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.

---

 deluge/ui/gtkui/torrentview.py |   19 +++++++++----------
 1 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/deluge/ui/gtkui/torrentview.py b/deluge/ui/gtkui/torrentview.py
index e36dc1c..33fa1ba 100644
--- a/deluge/ui/gtkui/torrentview.py
+++ b/deluge/ui/gtkui/torrentview.py
@@ -120,9 +120,7 @@ def cell_data_queue(column, cell, model, row, data):
     else:
         cell.set_property("text", value + 1)
 
-def queue_column_sort(model, iter1, iter2, data):
-    v1 = model[iter1][data]
-    v2 = model[iter2][data]
+def queue_peer_seed_sort_function(v1, v2):
     if v1 == v2:
         return 0
     if v2 < 0:
@@ -134,6 +132,12 @@ def queue_column_sort(model, iter1, iter2, data):
     if v2 > v1:
         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):
     v1 = model[iter1][data]
     v2 = model[iter2][data]
@@ -154,13 +158,8 @@ def seed_peer_column_sort(model, iter1, iter2, data):
     if v1 == v3:
         v2 = model[iter1][data+1]   # total seeds/peers
         v4 = model[iter2][data+1]   # total seeds/peers
-        if v2 == v4:
-            return 0
-        if v2 > v4:
-            return 1
-        if v2 < v4:
-            return -1
-    return queue_column_sort(model, iter1, iter2, data)
+        return queue_peer_seed_sort_function(v2, v4)
+    return queue_peer_seed_sort_function(v1, v3)
 
 class TorrentView(listview.ListView, component.Component):
     """TorrentView handles the listing of torrents."""

-- 
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en.

Reply via email to